diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-05-12 02:48:41 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-05-12 02:48:41 +0400 |
commit | 8925ed1420ea2557abc7867cf12f89730ef77718 (patch) | |
tree | 67a95fd12253de438e1bdb30bf6c90af2ff12d7f /source/blender/editors | |
parent | bf2fac79d407a1d8c0e5727cc644d98eef60a965 (diff) | |
parent | 1c0c2f4d0bd6556a3dd7293ddbd419a066e745f4 (diff) |
Merged changes in the trunk up to revision 46557.
Conflicts resolved:
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/makesrna/intern/rna_scene.c
Additional changes:
* Fix for recent changes of BKE_* function renaming.
* Fix for an "attempt to free NULL pointer" in BlenderStrokeRenderer::RenderStrokeRepBasic().
Diffstat (limited to 'source/blender/editors')
212 files changed, 18914 insertions, 17252 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index d63d5ae2082..6ba61830cd9 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -80,10 +80,10 @@ // XXX constant defines to be moved elsewhere? /* extra padding for lengths (to go under scrollers) */ -#define EXTRA_SCROLL_PAD 100.0f +#define EXTRA_SCROLL_PAD 100.0f /* size of indent steps */ -#define INDENT_STEP_SIZE 7 +#define INDENT_STEP_SIZE 7 #define ANIM_CHAN_NAME_SIZE 256 @@ -108,10 +108,10 @@ static void acf_generic_root_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUS /* backdrop for top-level widgets (Scene and Object only) */ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -120,7 +120,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } @@ -134,9 +134,9 @@ static void acf_generic_dataexpand_color(bAnimContext *UNUSED(ac), bAnimListElem /* backdrop for data expanders under top-level Scene/Object */ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -144,24 +144,24 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale glColor3fv(color); /* no rounded corner - just rectangular box */ - glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } /* get backdrop color for generic channels */ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3]) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); SpaceAction *saction = NULL; bActionGroup *grp = NULL; - short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; /* get context info needed... */ if ((ac->sl) && (ac->spacetype == SPACE_ACTION)) - saction= (SpaceAction *)ac->sl; + saction = (SpaceAction *)ac->sl; if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; - grp= fcu->grp; + FCurve *fcu = (FCurve *)ale->data; + grp = fcu->grp; } /* set color for normal channels @@ -169,7 +169,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - only use group colors if allowed to, and if actually feasible */ if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && - ((grp) && (grp->customCol)) ) + ((grp) && (grp->customCol)) ) { unsigned char cp[3]; @@ -188,7 +188,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa } else { // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? - int colOfs= 20 - 20*indent; + int colOfs = 20 - 20 * indent; UI_GetThemeColorShade3fv(TH_HEADER, colOfs, r_color); } } @@ -196,9 +196,9 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa /* backdrop for generic channels */ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -206,7 +206,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f glColor3fv(color); /* no rounded corners - just rectangular box */ - glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } /* Indention + Offset ------------------------------------------- */ @@ -230,11 +230,11 @@ static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) /* indention which varies with the grouping status */ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - short indent= 0; + short indent = 0; /* grouped F-Curves need extra level of indention */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: we need some way of specifying that the indention color should be one less... if (fcu->grp) @@ -248,7 +248,7 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE /* basic offset for channels derived from indention */ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); if (acf && acf->get_indent_level) return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; @@ -273,7 +273,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) case NTREE_TEXTURE: /* 2 additional levels */ - return INDENT_STEP_SIZE*2; + return INDENT_STEP_SIZE * 2; } } @@ -284,7 +284,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) /* offset for groups + grouped entities */ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) { - short offset= acf_generic_basic_offset(ac, ale); + short offset = acf_generic_basic_offset(ac, ale); if (ale->id) { /* texture animdata */ @@ -301,7 +301,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) /* nodetree animdata */ if (GS(ale->id->name) == ID_NT) { - offset += acf_nodetree_rootType_offset((bNodeTree*)ale->id); + offset += acf_nodetree_rootType_offset((bNodeTree *)ale->id); } } @@ -314,11 +314,11 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) /* name for ID block entries */ static void acf_generic_idblock_name(bAnimListElem *ale, char *name) { - ID *id= (ID *)ale->data; /* data pointed to should be an ID block */ + ID *id = (ID *)ale->data; /* data pointed to should be an ID block */ /* just copy the name... */ if (id && name) - BLI_strncpy(name, id->name+2, ANIM_CHAN_NAME_SIZE); + BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE); } /* name property for ID block entries */ @@ -378,7 +378,7 @@ static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListEle static void acf_summary_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3]) { // FIXME: hardcoded color - same as the 'action' line in NLA - // reddish color + // reddish color r_color[0] = 0.8f; r_color[1] = 0.2f; r_color[2] = 0.0f; @@ -387,8 +387,8 @@ static void acf_summary_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al /* backdrop for summary widget */ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; float color[3]; /* set backdrop drawing color */ @@ -400,7 +400,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi * - special hack: make the top a bit higher, since we are first... */ uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); - uiDrawBox(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for summary entries */ @@ -428,12 +428,12 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short { if (setting == ACHANNEL_SETTING_EXPAND) { /* expanded */ - *neg= 1; + *neg = 1; return ADS_FLAG_SUMMARY_COLLAPSED; } else { /* unsupported */ - *neg= 0; + *neg = 0; return 0; } } @@ -441,21 +441,21 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bAnimContext *ac= (bAnimContext *)ale->data; + bAnimContext *ac = (bAnimContext *)ale->data; /* if data is valid, return pointer to active dopesheet's relevant flag * - this is restricted to DopeSheet/Action Editor only */ if ((ac->sl) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) { - SpaceAction *saction= (SpaceAction *)ac->sl; - bDopeSheet *ads= &saction->ads; + SpaceAction *saction = (SpaceAction *)ac->sl; + bDopeSheet *ads = &saction->ads; /* return pointer to DopeSheet's flag */ return GET_ACF_FLAG_PTR(ads->flag, type); } else { /* can't return anything useful - unsupported */ - *type= 0; + *type = 0; return NULL; } } @@ -463,20 +463,20 @@ static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *typ /* all animation summary (DopeSheet only) type define */ static bAnimChannelType ACF_SUMMARY = { - "Summary", /* type name */ + "Summary", /* type name */ - acf_summary_color, /* backdrop color */ - acf_summary_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ - - acf_summary_name, /* name */ - NULL, /* name prop */ - acf_summary_icon, /* icon */ - - acf_summary_setting_valid, /* has setting */ - acf_summary_setting_flag, /* flag for setting */ - acf_summary_setting_ptr /* pointer for setting */ + acf_summary_color, /* backdrop color */ + acf_summary_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_summary_name, /* name */ + NULL, /* name prop */ + acf_summary_icon, /* icon */ + + acf_summary_setting_valid, /* has setting */ + acf_summary_setting_flag, /* flag for setting */ + acf_summary_setting_ptr /* pointer for setting */ }; /* Scene ------------------------------------------- */ @@ -513,21 +513,21 @@ static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SCE_DS_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return SCE_DS_COLLAPSED; case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -538,10 +538,10 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Scene *scene= (Scene *)ale->data; + Scene *scene = (Scene *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -565,28 +565,28 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) /* scene type define */ static bAnimChannelType ACF_SCENE = { - "Scene", /* type name */ + "Scene", /* type name */ - acf_generic_root_color, /* backdrop color */ - acf_generic_root_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_scene_icon, /* icon */ - - acf_scene_setting_valid, /* has setting */ - acf_scene_setting_flag, /* flag for setting */ - acf_scene_setting_ptr /* pointer for setting */ + acf_generic_root_color, /* backdrop color */ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_scene_icon, /* icon */ + + acf_scene_setting_valid, /* has setting */ + acf_scene_setting_flag, /* flag for setting */ + acf_scene_setting_ptr /* pointer for setting */ }; /* Object ------------------------------------------- */ static int acf_object_icon(bAnimListElem *ale) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* icon depends on object-type */ @@ -622,19 +622,19 @@ static int acf_object_icon(bAnimListElem *ale) /* name for object */ static void acf_object_name(bAnimListElem *ale, char *name) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* just copy the name... */ if (ob && name) - BLI_strncpy(name, ob->id.name+2, ANIM_CHAN_NAME_SIZE); + BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE); } /* check if some setting exists for this channel */ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; switch (setting) { /* muted only in NLA */ @@ -659,21 +659,21 @@ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SELECT; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return OB_ADS_COLLAPSED; case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -684,11 +684,11 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -712,20 +712,20 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type /* object type define */ static bAnimChannelType ACF_OBJECT = { - "Object", /* type name */ - - acf_generic_root_color, /* backdrop color */ - acf_generic_root_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ + "Object", /* type name */ - acf_object_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_object_icon, /* icon */ - - acf_object_setting_valid, /* has setting */ - acf_object_setting_flag, /* flag for setting */ - acf_object_setting_ptr /* pointer for setting */ + acf_generic_root_color, /* backdrop color */ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_object_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_object_icon, /* icon */ + + acf_object_setting_valid, /* has setting */ + acf_object_setting_flag, /* flag for setting */ + acf_object_setting_ptr /* pointer for setting */ }; /* Group ------------------------------------------- */ @@ -743,10 +743,10 @@ static void acf_group_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float /* backdrop for group widget */ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -755,13 +755,13 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for group entries */ static void acf_group_name(bAnimListElem *ale, char *name) { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* just copy the name... */ if (agrp && name) @@ -783,7 +783,7 @@ static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale /* for now, all settings are supported, though some are only conditionally */ switch (setting) { case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ - return (ac->spacetype==SPACE_IPO); + return (ac->spacetype == SPACE_IPO); default: /* always supported */ return 1; @@ -794,7 +794,7 @@ static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -807,8 +807,8 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) * proved to be a hazard for workflows... */ return (ac->spacetype == SPACE_IPO) ? - AGRP_EXPANDED_G : /* Graph Editor case */ - AGRP_EXPANDED; /* DopeSheet and elsewhere */ + AGRP_EXPANDED_G : /* Graph Editor case */ + AGRP_EXPANDED; /* DopeSheet and elsewhere */ } case ACHANNEL_SETTING_MUTE: /* muted */ @@ -819,7 +819,7 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) return AGRP_PROTECTED; case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ - *neg= 1; + *neg = 1; return AGRP_NOTVISIBLE; } @@ -830,7 +830,7 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) /* get pointer to the setting */ static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(agrp->flag, type); @@ -839,20 +839,20 @@ static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), shor /* group type define */ static bAnimChannelType ACF_GROUP = { - "Group", /* type name */ - - acf_group_color, /* backdrop color */ - acf_group_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_group_offset, /* offset */ + "Group", /* type name */ - acf_group_name, /* name */ - acf_group_name_prop, /* name prop */ - NULL, /* icon */ - - acf_group_setting_valid, /* has setting */ - acf_group_setting_flag, /* flag for setting */ - acf_group_setting_ptr /* pointer for setting */ + acf_group_color, /* backdrop color */ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_group_name, /* name */ + acf_group_name_prop, /* name prop */ + NULL, /* icon */ + + acf_group_setting_valid, /* has setting */ + acf_group_setting_flag, /* flag for setting */ + acf_group_setting_ptr /* pointer for setting */ }; /* F-Curve ------------------------------------------- */ @@ -866,7 +866,7 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name) /* check if some setting exists for this channel */ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; switch (setting) { /* unsupported */ @@ -878,10 +878,10 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int if (fcu->bezt) return 1; else - return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ - return (ac->spacetype==SPACE_IPO); + return (ac->spacetype == SPACE_IPO); /* always available */ default: @@ -893,7 +893,7 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -917,7 +917,7 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(fcu->flag, type); @@ -926,20 +926,20 @@ static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sho /* fcurve type define */ static bAnimChannelType ACF_FCURVE = { - "F-Curve", /* type name */ - - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? - acf_generic_group_offset, /* offset */ + "F-Curve", /* type name */ - acf_fcurve_name, /* name */ - NULL, /* name prop */ - NULL, /* icon */ - - acf_fcurve_setting_valid, /* has setting */ - acf_fcurve_setting_flag, /* flag for setting */ - acf_fcurve_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + NULL, /* name prop */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ }; /* Object Action Expander ------------------------------------------- */ @@ -968,14 +968,14 @@ static short acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return ACT_COLLAPSED; default: /* unsupported */ @@ -986,11 +986,11 @@ static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, shor /* get pointer to the setting */ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bAction *act= (bAction *)ale->data; - AnimData *adt= ale->adt; + bAction *act = (bAction *)ale->data; + AnimData *adt = ale->adt; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1011,20 +1011,20 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *ty /* object action expander type define */ static bAnimChannelType ACF_FILLACTD = { - "Ob-Action Filler", /* type name */ + "Ob-Action Filler", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_fillactd_icon, /* icon */ - - acf_fillactd_setting_valid, /* has setting */ - acf_fillactd_setting_flag, /* flag for setting */ - acf_fillactd_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_fillactd_icon, /* icon */ + + acf_fillactd_setting_valid, /* has setting */ + acf_fillactd_setting_flag, /* flag for setting */ + acf_fillactd_setting_ptr /* pointer for setting */ }; /* Drivers Expander ------------------------------------------- */ @@ -1058,11 +1058,11 @@ static short acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEl static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return ADT_DRIVERS_COLLAPSED; default: /* unsupported */ @@ -1073,10 +1073,10 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, s /* get pointer to the setting */ static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type) { - AnimData *adt= (AnimData *)ale->data; + AnimData *adt = (AnimData *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1090,20 +1090,20 @@ static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short /* drivers expander type define */ static bAnimChannelType ACF_FILLDRIVERS = { - "Drivers Filler", /* type name */ + "Drivers Filler", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_filldrivers_name, /* name */ - NULL, /* name prop */ - acf_filldrivers_icon, /* icon */ - - acf_filldrivers_setting_valid, /* has setting */ - acf_filldrivers_setting_flag, /* flag for setting */ - acf_filldrivers_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_filldrivers_name, /* name */ + NULL, /* name prop */ + acf_filldrivers_icon, /* icon */ + + acf_filldrivers_setting_valid, /* has setting */ + acf_filldrivers_setting_flag, /* flag for setting */ + acf_filldrivers_setting_ptr /* pointer for setting */ }; @@ -1119,7 +1119,7 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1129,7 +1129,7 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1143,10 +1143,10 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Material *ma= (Material *)ale->data; + Material *ma = (Material *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1166,22 +1166,22 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* material expander type define */ -static bAnimChannelType ACF_DSMAT= +static bAnimChannelType ACF_DSMAT = { - "Material Data Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ + "Material Data Expander", /* type name */ - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmat_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmat_setting_flag, /* flag for setting */ - acf_dsmat_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmat_setting_flag, /* flag for setting */ + acf_dsmat_setting_ptr /* pointer for setting */ }; /* Lamp Expander ------------------------------------------- */ @@ -1196,7 +1196,7 @@ static int acf_dslam_icon(bAnimListElem *UNUSED(ale)) static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1206,7 +1206,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1220,10 +1220,10 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Lamp *la= (Lamp *)ale->data; + Lamp *la = (Lamp *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1243,22 +1243,22 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* lamp expander type define */ -static bAnimChannelType ACF_DSLAM= +static bAnimChannelType ACF_DSLAM = { - "Lamp Expander", /* type name */ + "Lamp Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dslam_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dslam_setting_flag, /* flag for setting */ - acf_dslam_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dslam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslam_setting_flag, /* flag for setting */ + acf_dslam_setting_ptr /* pointer for setting */ }; /* Texture Expander ------------------------------------------- */ @@ -1280,7 +1280,7 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1290,7 +1290,7 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1304,10 +1304,10 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Tex *tex= (Tex *)ale->data; + Tex *tex = (Tex *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1327,22 +1327,22 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* texture expander type define */ -static bAnimChannelType ACF_DSTEX= +static bAnimChannelType ACF_DSTEX = { - "Texture Data Expander", /* type name */ + "Texture Data Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_dstex_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dstex_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dstex_setting_flag, /* flag for setting */ - acf_dstex_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_dstex_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dstex_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dstex_setting_flag, /* flag for setting */ + acf_dstex_setting_ptr /* pointer for setting */ }; /* Camera Expander ------------------------------------------- */ @@ -1357,7 +1357,7 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale)) static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1367,7 +1367,7 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1381,10 +1381,10 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Camera *ca= (Camera *)ale->data; + Camera *ca = (Camera *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1404,22 +1404,22 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* camera expander type define */ -static bAnimChannelType ACF_DSCAM= +static bAnimChannelType ACF_DSCAM = { - "Camera Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dscam_icon, /* icon */ + "Camera Expander", /* type name */ - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dscam_setting_flag, /* flag for setting */ - acf_dscam_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dscam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscam_setting_flag, /* flag for setting */ + acf_dscam_setting_ptr /* pointer for setting */ }; /* Curve Expander ------------------------------------------- */ @@ -1427,8 +1427,8 @@ static bAnimChannelType ACF_DSCAM= // TODO: just get this from RNA? static int acf_dscur_icon(bAnimListElem *ale) { - Curve *cu= (Curve *)ale->data; - short obtype= BKE_curve_type_get(cu); + Curve *cu = (Curve *)ale->data; + short obtype = BKE_curve_type_get(cu); switch (obtype) { case OB_FONT: @@ -1444,7 +1444,7 @@ static int acf_dscur_icon(bAnimListElem *ale) static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1454,7 +1454,7 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1468,10 +1468,10 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Curve *cu= (Curve *)ale->data; + Curve *cu = (Curve *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1491,22 +1491,22 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* curve expander type define */ -static bAnimChannelType ACF_DSCUR= +static bAnimChannelType ACF_DSCUR = { - "Curve Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dscur_icon, /* icon */ + "Curve Expander", /* type name */ - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dscur_setting_flag, /* flag for setting */ - acf_dscur_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dscur_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscur_setting_flag, /* flag for setting */ + acf_dscur_setting_ptr /* pointer for setting */ }; /* Shape Key Expander ------------------------------------------- */ @@ -1521,7 +1521,7 @@ static int acf_dsskey_icon(bAnimListElem *UNUSED(ale)) static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1531,7 +1531,7 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1545,10 +1545,10 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Key *key= (Key *)ale->data; + Key *key = (Key *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1568,22 +1568,22 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type } /* shapekey expander type define */ -static bAnimChannelType ACF_DSSKEY= +static bAnimChannelType ACF_DSSKEY = { - "Shape Key Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ + "Shape Key Expander", /* type name */ - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsskey_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsskey_setting_flag, /* flag for setting */ - acf_dsskey_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsskey_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsskey_setting_flag, /* flag for setting */ + acf_dsskey_setting_ptr /* pointer for setting */ }; /* World Expander ------------------------------------------- */ @@ -1598,7 +1598,7 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale)) static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1608,7 +1608,7 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1622,10 +1622,10 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) { - World *wo= (World *)ale->data; + World *wo = (World *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1645,22 +1645,22 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* world expander type define */ -static bAnimChannelType ACF_DSWOR= +static bAnimChannelType ACF_DSWOR = { - "World Expander", /* type name */ + "World Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dswor_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dswor_setting_flag, /* flag for setting */ - acf_dswor_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dswor_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dswor_setting_flag, /* flag for setting */ + acf_dswor_setting_ptr /* pointer for setting */ }; /* Particle Expander ------------------------------------------- */ @@ -1675,7 +1675,7 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale)) static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1685,7 +1685,7 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1699,10 +1699,10 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type) { - ParticleSettings *part= (ParticleSettings *)ale->data; + ParticleSettings *part = (ParticleSettings *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1722,22 +1722,22 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type } /* particle expander type define */ -static bAnimChannelType ACF_DSPART= +static bAnimChannelType ACF_DSPART = { - "Particle Data Expander", /* type name */ + "Particle Data Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dspart_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dspart_setting_flag, /* flag for setting */ - acf_dspart_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dspart_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dspart_setting_flag, /* flag for setting */ + acf_dspart_setting_ptr /* pointer for setting */ }; /* MetaBall Expander ------------------------------------------- */ @@ -1752,7 +1752,7 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1762,7 +1762,7 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1776,10 +1776,10 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type) { - MetaBall *mb= (MetaBall *)ale->data; + MetaBall *mb = (MetaBall *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1799,22 +1799,22 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *typ } /* metaball expander type define */ -static bAnimChannelType ACF_DSMBALL= +static bAnimChannelType ACF_DSMBALL = { - "Metaball Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmball_icon, /* icon */ + "Metaball Expander", /* type name */ - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmball_setting_flag, /* flag for setting */ - acf_dsmball_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmball_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmball_setting_flag, /* flag for setting */ + acf_dsmball_setting_ptr /* pointer for setting */ }; /* Armature Expander ------------------------------------------- */ @@ -1829,7 +1829,7 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale)) static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1839,7 +1839,7 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1853,10 +1853,10 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bArmature *arm= (bArmature *)ale->data; + bArmature *arm = (bArmature *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1876,22 +1876,22 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* metaball expander type define */ -static bAnimChannelType ACF_DSARM= +static bAnimChannelType ACF_DSARM = { - "Armature Expander", /* type name */ + "Armature Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsarm_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsarm_setting_flag, /* flag for setting */ - acf_dsarm_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsarm_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsarm_setting_flag, /* flag for setting */ + acf_dsarm_setting_ptr /* pointer for setting */ }; /* NodeTree Expander ------------------------------------------- */ @@ -1906,7 +1906,7 @@ static int acf_dsntree_icon(bAnimListElem *UNUSED(ale)) static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) { bNodeTree *ntree = (bNodeTree *)ale->data; - short offset= acf_generic_basic_offset(ac, ale); + short offset = acf_generic_basic_offset(ac, ale); offset += acf_nodetree_rootType_offset(ntree); @@ -1917,7 +1917,7 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1927,7 +1927,7 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1941,10 +1941,10 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bNodeTree *ntree= (bNodeTree *)ale->data; + bNodeTree *ntree = (bNodeTree *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1955,8 +1955,8 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *typ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (ntree->adt) return GET_ACF_FLAG_PTR(ntree->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -1964,22 +1964,22 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *typ } /* node tree expander type define */ -static bAnimChannelType ACF_DSNTREE= +static bAnimChannelType ACF_DSNTREE = { - "Node Tree Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_dsntree_offset, /* offset */ + "Node Tree Expander", /* type name */ - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsntree_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsntree_setting_flag, /* flag for setting */ - acf_dsntree_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_dsntree_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsntree_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsntree_setting_flag, /* flag for setting */ + acf_dsntree_setting_ptr /* pointer for setting */ }; /* LineStyle Expander ------------------------------------------- */ @@ -2071,7 +2071,7 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2081,7 +2081,7 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2095,10 +2095,10 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Mesh *me= (Mesh *)ale->data; + Mesh *me = (Mesh *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2109,8 +2109,8 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (me->adt) return GET_ACF_FLAG_PTR(me->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -2118,22 +2118,22 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type } /* node tree expander type define */ -static bAnimChannelType ACF_DSMESH= +static bAnimChannelType ACF_DSMESH = { - "Mesh Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ // XXX this only works for compositing - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmesh_icon, /* icon */ + "Mesh Expander", /* type name */ - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmesh_setting_flag, /* flag for setting */ - acf_dsmesh_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ // XXX this only works for compositing + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmesh_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmesh_setting_flag, /* flag for setting */ + acf_dsmesh_setting_ptr /* pointer for setting */ }; /* Lattice Expander ------------------------------------------- */ @@ -2148,7 +2148,7 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale)) static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2158,7 +2158,7 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2172,10 +2172,10 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Lattice *lt= (Lattice *)ale->data; + Lattice *lt = (Lattice *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2186,8 +2186,8 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (lt->adt) return GET_ACF_FLAG_PTR(lt->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -2195,22 +2195,22 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* node tree expander type define */ -static bAnimChannelType ACF_DSLAT= +static bAnimChannelType ACF_DSLAT = { - "Lattice Expander", /* type name */ + "Lattice Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ // XXX this only works for compositing - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dslat_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dslat_setting_flag, /* flag for setting */ - acf_dslat_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ // XXX this only works for compositing + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dslat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslat_setting_flag, /* flag for setting */ + acf_dslat_setting_ptr /* pointer for setting */ }; /* Speaker Expander ------------------------------------------- */ @@ -2225,7 +2225,7 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale)) static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2235,7 +2235,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2249,10 +2249,10 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Speaker *spk= (Speaker *)ale->data; + Speaker *spk = (Speaker *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2272,22 +2272,22 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* speaker expander type define */ -static bAnimChannelType ACF_DSSPK= +static bAnimChannelType ACF_DSSPK = { - "Speaker Expander", /* type name */ - - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsspk_icon, /* icon */ + "Speaker Expander", /* type name */ - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsspk_setting_flag, /* flag for setting */ - acf_dsspk_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsspk_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsspk_setting_flag, /* flag for setting */ + acf_dsspk_setting_ptr /* pointer for setting */ }; /* ShapeKey Entry ------------------------------------------- */ @@ -2295,7 +2295,7 @@ static bAnimChannelType ACF_DSSPK= /* name for ShapeKey */ static void acf_shapekey_name(bAnimListElem *ale, char *name) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* just copy the name... */ if (kb && name) { @@ -2310,7 +2310,7 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name) /* name property for ShapeKey entries */ static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* if the KeyBlock had a name, use it, otherwise use the index */ if (kb && kb->name[0]) { @@ -2342,7 +2342,7 @@ static short acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_MUTE: /* mute */ @@ -2362,10 +2362,10 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, shor /* get pointer to the setting */ static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *type) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2379,22 +2379,22 @@ static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *ty } /* shapekey expander type define */ -static bAnimChannelType ACF_SHAPEKEY= +static bAnimChannelType ACF_SHAPEKEY = { - "Shape Key", /* type name */ - - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_basic_offset, /* offset */ + "Shape Key", /* type name */ - acf_shapekey_name, /* name */ - acf_shapekey_nameprop, /* name prop */ - NULL, /* icon */ - - acf_shapekey_setting_valid, /* has setting */ - acf_shapekey_setting_flag, /* flag for setting */ - acf_shapekey_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_shapekey_name, /* name */ + acf_shapekey_nameprop, /* name prop */ + NULL, /* icon */ + + acf_shapekey_setting_valid, /* has setting */ + acf_shapekey_setting_flag, /* flag for setting */ + acf_shapekey_setting_ptr /* pointer for setting */ }; /* GPencil Datablock ------------------------------------------- */ @@ -2430,7 +2430,7 @@ static short acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2447,7 +2447,7 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne /* get pointer to the setting */ static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bGPdata *gpd= (bGPdata *)ale->data; + bGPdata *gpd = (bGPdata *)ale->data; /* all flags are just in gpd->flag for now... */ return GET_ACF_FLAG_PTR(gpd->flag, type); @@ -2456,20 +2456,20 @@ static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short /* gpencil datablock type define */ static bAnimChannelType ACF_GPD = { - "GPencil Datablock", /* type name */ - - acf_gpd_color, /* backdrop color */ - acf_group_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_group_offset, /* offset */ + "GPencil Datablock", /* type name */ - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_gpd_icon, /* icon */ - - acf_gpd_setting_valid, /* has setting */ - acf_gpd_setting_flag, /* flag for setting */ - acf_gpd_setting_ptr /* pointer for setting */ + acf_gpd_color, /* backdrop color */ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_gpd_icon, /* icon */ + + acf_gpd_setting_valid, /* has setting */ + acf_gpd_setting_flag, /* flag for setting */ + acf_gpd_setting_ptr /* pointer for setting */ }; /* GPencil Layer ------------------------------------------- */ @@ -2515,7 +2515,7 @@ static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2536,7 +2536,7 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne /* get pointer to the setting */ static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(gpl->flag, type); @@ -2545,20 +2545,20 @@ static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short /* grease pencil layer type define */ static bAnimChannelType ACF_GPL = { - "GPencil Layer", /* type name */ - - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_flexible, /* indent level */ - acf_generic_group_offset, /* offset */ + "GPencil Layer", /* type name */ - acf_gpl_name, /* name */ - acf_gpl_name_prop, /* name prop */ - NULL, /* icon */ - - acf_gpl_setting_valid, /* has setting */ - acf_gpl_setting_flag, /* flag for setting */ - acf_gpl_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_gpl_name, /* name */ + acf_gpl_name_prop, /* name prop */ + NULL, /* icon */ + + acf_gpl_setting_valid, /* has setting */ + acf_gpl_setting_flag, /* flag for setting */ + acf_gpl_setting_ptr /* pointer for setting */ }; /* *********************************************** */ @@ -2566,61 +2566,61 @@ static bAnimChannelType ACF_GPL = /* These globals only ever get directly accessed in this file */ static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES]; -static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */ +static short ACF_INIT = 1; /* when non-zero, the list needs to be updated */ /* Initialize type info definitions */ -static void ANIM_init_channel_typeinfo_data (void) +static void ANIM_init_channel_typeinfo_data(void) { - int type= 0; + int type = 0; /* start initializing if necessary... */ if (ACF_INIT) { - ACF_INIT= 0; - - animchannelTypeInfo[type++]= NULL; /* None */ - animchannelTypeInfo[type++]= NULL; /* AnimData */ - animchannelTypeInfo[type++]= NULL; /* Special */ - - animchannelTypeInfo[type++]= &ACF_SUMMARY; /* Motion Summary */ - - animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */ - animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */ - animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */ - animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */ - - animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */ - animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */ - - animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */ - animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */ - animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */ - animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */ - animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */ - animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */ - animchannelTypeInfo[type++]= &ACF_DSNTREE; /* NodeTree Channel */ - animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */ - animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */ - animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */ - animchannelTypeInfo[type++]= &ACF_DSMESH; /* Mesh Channel */ - animchannelTypeInfo[type++]= &ACF_DSTEX; /* Texture Channel */ - animchannelTypeInfo[type++]= &ACF_DSLAT; /* Lattice Channel */ - animchannelTypeInfo[type++]= &ACF_DSLINESTYLE; /* LineStyle Channel */ - animchannelTypeInfo[type++]= &ACF_DSSPK; /* Speaker Channel */ - - animchannelTypeInfo[type++]= &ACF_SHAPEKEY; /* ShapeKey */ - - animchannelTypeInfo[type++]= &ACF_GPD; /* Grease Pencil Datablock */ - animchannelTypeInfo[type++]= &ACF_GPL; /* Grease Pencil Layer */ - - // TODO: these types still need to be implemented!!! - // probably need a few extra flags for these special cases... - animchannelTypeInfo[type++]= NULL; /* NLA Track */ - animchannelTypeInfo[type++]= NULL; /* NLA Action */ + ACF_INIT = 0; + + animchannelTypeInfo[type++] = NULL; /* None */ + animchannelTypeInfo[type++] = NULL; /* AnimData */ + animchannelTypeInfo[type++] = NULL; /* Special */ + + animchannelTypeInfo[type++] = &ACF_SUMMARY; /* Motion Summary */ + + animchannelTypeInfo[type++] = &ACF_SCENE; /* Scene */ + animchannelTypeInfo[type++] = &ACF_OBJECT; /* Object */ + animchannelTypeInfo[type++] = &ACF_GROUP; /* Group */ + animchannelTypeInfo[type++] = &ACF_FCURVE; /* F-Curve */ + + animchannelTypeInfo[type++] = &ACF_FILLACTD; /* Object Action Expander */ + animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */ + + animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */ + animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */ + animchannelTypeInfo[type++] = &ACF_DSCUR; /* Curve Channel */ + animchannelTypeInfo[type++] = &ACF_DSSKEY; /* ShapeKey Channel */ + animchannelTypeInfo[type++] = &ACF_DSWOR; /* World Channel */ + animchannelTypeInfo[type++] = &ACF_DSNTREE; /* NodeTree Channel */ + animchannelTypeInfo[type++] = &ACF_DSPART; /* Particle Channel */ + animchannelTypeInfo[type++] = &ACF_DSMBALL; /* MetaBall Channel */ + animchannelTypeInfo[type++] = &ACF_DSARM; /* Armature Channel */ + animchannelTypeInfo[type++] = &ACF_DSMESH; /* Mesh Channel */ + animchannelTypeInfo[type++] = &ACF_DSTEX; /* Texture Channel */ + animchannelTypeInfo[type++] = &ACF_DSLAT; /* Lattice Channel */ + animchannelTypeInfo[type++] = &ACF_DSSPK; /* Speaker Channel */ + animchannelTypeInfo[type++] = &ACF_DSLINESTYLE; /* LineStyle Channel */ + + animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */ + + animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock */ + animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer */ + + // TODO: these types still need to be implemented!!! + // probably need a few extra flags for these special cases... + animchannelTypeInfo[type++] = NULL; /* NLA Track */ + animchannelTypeInfo[type++] = NULL; /* NLA Action */ } } /* Get type info from given channel type */ -bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) +bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale) { /* santiy checks */ if (ale == NULL) @@ -2641,7 +2641,7 @@ bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) /* Print debug info string for the given channel */ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* print indents */ for (; indent_level > 0; indent_level--) @@ -2673,7 +2673,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) */ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { @@ -2682,44 +2682,44 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting int flag; void *ptr; - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ { - int *val= (int *)ptr; + int *val = (int *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ { - short *val= (short *)ptr; + short *val = (short *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ { - char *val= (char *)ptr; + char *val = (char *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; } } } @@ -2731,17 +2731,17 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting /* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ #define ACF_SETTING_SET(sval, sflag, smode) \ - {\ - if (negflag) {\ - if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ + { \ + if (negflag) { \ + if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \ - else (sval) |= (sflag); \ + else (sval) |= (sflag); \ } \ - else {\ - if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ + else { \ + if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \ - else (sval) &= ~(sflag); \ - }\ + else (sval) &= ~(sflag); \ + } \ } /* Change value of some setting for a channel @@ -2750,7 +2750,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting */ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, short mode) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { @@ -2759,32 +2759,32 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, int flag; void *ptr; - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ { - int *val= (int *)ptr; + int *val = (int *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ { - short *val= (short *)ptr; + short *val = (short *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ { - char *val= (char *)ptr; + char *val = (char *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; } } } @@ -2793,9 +2793,9 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, /* --------------------------- */ // XXX hardcoded size of icons -#define ICON_WIDTH 17 +#define ICON_WIDTH 17 // XXX hardcoded width of sliders -#define SLIDER_WIDTH 80 +#define SLIDER_WIDTH 80 // XXX hardcoded width of rename textboxes #define RENAME_TEXT_WIDTH 100 @@ -2803,8 +2803,8 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, // TODO: make this use UI controls for the buttons void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; short selected, offset; float y, ymid, ytext; @@ -2814,23 +2814,23 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* get initial offset */ if (acf->get_offset) - offset= acf->get_offset(ac, ale); + offset = acf->get_offset(ac, ale); else - offset= 0; + offset = 0; /* calculate appropriate y-coordinates for icon buttons * 7 is hardcoded factor for half-height of icons */ - y= (ymaxc - yminc)/2 + yminc; - ymid= y - 7; + y = (ymaxc - yminc) / 2 + yminc; + ymid = y - 7; /* y-coordinates for text is only 4 down from middle */ - ytext= y - 4; + ytext = y - 4; /* check if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) - selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); else - selected= 0; + selected = 0; /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2863,7 +2863,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { /* for F-Curves, draw color-preview of curve behind checkbox */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever * color the curve has stored @@ -2871,10 +2871,10 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float glColor3fv(fcu->color); /* just a solid color rect - * hardcoded 17 pixels width is slightly wider than icon width, so that + * hardcoded 17 pixels width is slightly wider than icon width, so that * there's a slight border around it */ - glRectf(offset, yminc, offset+17, ymaxc); + glRectf(offset, yminc, offset + 17, ymaxc); } /* icon is drawn as widget now... */ @@ -2909,8 +2909,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float // FIXME: replace hardcoded color here, and check on extents! glColor3f(1.0f, 0.0f, 0.0f); glLineWidth(2.0); - fdrawline((float)(offset), yminc, - (float)(v2d->cur.xmax), yminc); + fdrawline((float)(offset), yminc, + (float)(v2d->cur.xmax), yminc); glLineWidth(1.0); } } @@ -2934,21 +2934,21 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)ac->sl; - draw_sliders= (saction->flag & SACTION_SLIDERS); + SpaceAction *saction = (SpaceAction *)ac->sl; + draw_sliders = (saction->flag & SACTION_SLIDERS); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - draw_sliders= (sipo->flag & SIPO_SLIDERS); + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + draw_sliders = (sipo->flag & SIPO_SLIDERS); } - break; + 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) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; @@ -2972,7 +2972,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float * - starts from the point where the first toggle/slider starts, * - ends past the space that might be reserved for a scroller */ - glRectf(v2d->cur.xmax-(float)offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(v2d->cur.xmax - (float)offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } } @@ -2981,13 +2981,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* callback for (normal) widget settings - send notifiers */ static void achannel_setting_widget_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } /* callback for widget settings that need flushing */ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void *setting_wrap) { - bAnimListElem *ale_setting= (bAnimListElem *)ale_npoin; + bAnimListElem *ale_setting = (bAnimListElem *)ale_npoin; bAnimContext ac; ListBase anim_data = {NULL, NULL}; int filter; @@ -2995,7 +2995,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void short on = 0; /* send notifiers before doing anything else... */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* verify animation context */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -3004,7 +3004,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void /* verify that we have a channel to operate on, and that it has all we need */ if (ale_setting) { /* check if the setting is on... */ - on= ANIM_channel_setting_get(&ac, ale_setting, setting); + on = ANIM_channel_setting_get(&ac, ale_setting, setting); /* on == -1 means setting not found... */ if (on == -1) @@ -3014,7 +3014,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void return; /* get all channels that can possibly be chosen - but ignore hierarchy */ - filter= ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* call API method to flush the setting */ @@ -3034,25 +3034,25 @@ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *U /* send notifiers */ // XXX: right notifier? - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_RENAME, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); } /* callback for widget sliders - insert keyframes */ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) { - ID *id= (ID *)id_poin; - FCurve *fcu= (FCurve *)fcu_poin; + ID *id = (ID *)id_poin; + FCurve *fcu = (FCurve *)fcu_poin; ReportList *reports = CTX_wm_reports(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; - short flag=0, done=0; + short flag = 0, done = 0; float cfra; /* get current frame */ // NOTE: this will do for now... - cfra= (float)CFRA; + cfra = (float)CFRA; /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); @@ -3067,30 +3067,30 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } } /* callback for shapekey widget sliders - insert keyframes */ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin) { - Key *key= (Key *)key_poin; - KeyBlock *kb= (KeyBlock *)kb_poin; - char *rna_path= key_get_curValue_rnaPath(key, kb); + Key *key = (Key *)key_poin; + KeyBlock *kb = (KeyBlock *)kb_poin; + char *rna_path = key_get_curValue_rnaPath(key, kb); ReportList *reports = CTX_wm_reports(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; - short flag=0, done=0; + short flag = 0, done = 0; float cfra; /* get current frame */ // NOTE: this will do for now... - cfra= (float)CFRA; + cfra = (float)CFRA; /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); @@ -3102,18 +3102,18 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi if (RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop)) { /* find or create new F-Curve */ // XXX is the group name for this ok? - bAction *act= verify_adt_action((ID *)key, 1); - FCurve *fcu= verify_fcurve(act, NULL, rna_path, 0, 1); + bAction *act = verify_adt_action((ID *)key, 1); + FCurve *fcu = verify_fcurve(act, NULL, rna_path, 0, 1); /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } /* free the path */ @@ -3132,32 +3132,32 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann uiBut *but = NULL; /* get the flag and the pointer to that flag */ - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* enabled= ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */ /* get the base icon for the setting */ switch (setting) { - case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ + case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ //icon= ((enabled)? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); - icon= ICON_VISIBLE_IPO_OFF; + icon = ICON_VISIBLE_IPO_OFF; if (ale->type == ANIMTYPE_FCURVE) - tooltip= "Channel is visible in Graph Editor for editing"; + tooltip = "Channel is visible in Graph Editor for editing"; else - tooltip= "Channel(s) are visible in Graph Editor for editing"; + tooltip = "Channel(s) are visible in Graph Editor for editing"; break; case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); - icon= ICON_TRIA_RIGHT; - tooltip= "Make channels grouped under this channel visible"; + icon = ICON_TRIA_RIGHT; + tooltip = "Make channels grouped under this channel visible"; break; case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); - icon= ICON_LAYER_USED; - tooltip= "NLA Track is the only one evaluated for the AnimData block it belongs to"; + icon = ICON_LAYER_USED; + tooltip = "NLA Track is the only one evaluated for the AnimData block it belongs to"; break; /* --- */ @@ -3165,48 +3165,48 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann case ACHANNEL_SETTING_PROTECT: /* protected lock */ // TODO: what about when there's no protect needed? //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); - icon= ICON_UNLOCKED; - tooltip= "Editability of keyframes for this channel"; + icon = ICON_UNLOCKED; + tooltip = "Editability of keyframes for this channel"; break; case ACHANNEL_SETTING_MUTE: /* muted speaker */ //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); - icon= ICON_MUTE_IPO_OFF; + icon = ICON_MUTE_IPO_OFF; if (ale->type == ALE_FCURVE) - tooltip= "Does F-Curve contribute to result"; + tooltip = "Does F-Curve contribute to result"; else - tooltip= "Do channels contribute to result"; + tooltip = "Do channels contribute to result"; break; default: - tooltip= NULL; - icon= 0; + tooltip = NULL; + icon = 0; break; } /* type of button */ if (negflag) - butType= ICONTOGN; + butType = ICONTOGN; else - butType= ICONTOG; + butType = ICONTOG; /* draw button for setting */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ but = uiDefIconButBitI(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ but = uiDefIconButBitS(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ but = uiDefIconButBitC(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; } @@ -3232,9 +3232,9 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann /* Draw UI widgets the given channel */ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc, size_t channel_index) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - float y, ymid/*, ytext*/; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + float y, ymid /*, ytext*/; short offset; /* sanity checks - don't draw anything */ @@ -3243,15 +3243,15 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale /* get initial offset */ if (acf->get_offset) - offset= acf->get_offset(ac, ale); + offset = acf->get_offset(ac, ale); else - offset= 0; + offset = 0; /* calculate appropriate y-coordinates for icon buttons * 7 is hardcoded factor for half-height of icons */ - y= (ymaxc - yminc)/2 + yminc; - ymid= y - 7; + y = (ymaxc - yminc) / 2 + yminc; + ymid = y - 7; /* y-coordinates for text is only 4 down from middle */ /* ytext= y - 4; */ @@ -3292,7 +3292,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale float channel_height = ymaxc - yminc; /* if rename index matches, add widget for this */ - if (ac->ads->renameIndex == channel_index+1) { + if (ac->ads->renameIndex == channel_index + 1) { PointerRNA ptr; PropertyRNA *prop; @@ -3302,7 +3302,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale uiBlockSetEmboss(block, UI_EMBOSS); - but = uiDefButR(block, TEX, 1, "", offset+3, yminc, RENAME_TEXT_WIDTH, channel_height, + but = uiDefButR(block, TEX, 1, "", offset + 3, yminc, RENAME_TEXT_WIDTH, channel_height, &ptr, RNA_property_identifier(prop), -1, 0, 0, -1, -1, NULL); uiButSetFunc(but, achannel_setting_rename_done_cb, ac->ads, NULL); uiButActiveOnly(C, block, but); @@ -3326,30 +3326,30 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)ac->sl; - draw_sliders= (saction->flag & SACTION_SLIDERS); + SpaceAction *saction = (SpaceAction *)ac->sl; + draw_sliders = (saction->flag & SACTION_SLIDERS); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - draw_sliders= (sipo->flag & SIPO_SLIDERS); + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + draw_sliders = (sipo->flag & SIPO_SLIDERS); } - break; + 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) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; - draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT); + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PROTECT); } /* mute... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { offset += ICON_WIDTH; - draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE); + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MUTE); } } @@ -3378,17 +3378,17 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale /* get destination info */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; - rna_path= fcu->rna_path; - array_index= fcu->array_index; + rna_path = fcu->rna_path; + array_index = fcu->array_index; } else if (ale->type == ANIMTYPE_SHAPEKEY) { - KeyBlock *kb= (KeyBlock *)ale->data; - Key *key= (Key *)ale->id; + KeyBlock *kb = (KeyBlock *)ale->data; + Key *key = (Key *)ale->id; - rna_path= key_get_curValue_rnaPath(key, kb); - free_path= 1; + rna_path = key_get_curValue_rnaPath(key, kb); + free_path = 1; } /* only if RNA-Path found */ @@ -3401,7 +3401,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale uiBut *but; /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ - but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax-offset, ymid, SLIDER_WIDTH, (int)ymaxc-yminc); + but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc); /* assign keyframing function according to slider type */ if (ale->type == ANIMTYPE_SHAPEKEY) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index a1878de7523..e200972dd56 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -80,7 +80,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f return; /* only clear the 'active' flag for the channels of the same type */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* skip if types don't match */ if (channel_type != ale->type) continue; @@ -89,28 +89,28 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f switch (ale->type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE); } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE); } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -130,7 +130,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f ACHANNEL_SET_FLAG(ale->adt, ACHANNEL_SETFLAG_CLEAR, ADT_UI_ACTIVE); } } - break; + break; } } @@ -139,25 +139,25 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f switch (channel_type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)channel_data; + bActionGroup *agrp = (bActionGroup *)channel_data; agrp->flag |= AGRP_ACTIVE; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)channel_data; + FCurve *fcu = (FCurve *)channel_data; fcu->flag |= FCURVE_ACTIVE; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)channel_data; + NlaTrack *nlt = (NlaTrack *)channel_data; nlt->flag |= NLATRACK_ACTIVE; } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -176,7 +176,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f ale->adt->flag |= ADT_UI_ACTIVE; } } - break; + break; } } @@ -198,45 +198,45 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s /* filter data */ /* NOTE: no list visible, otherwise, we get dangling */ - filter= ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (sel == 0) break; switch (ale->type) { case ANIMTYPE_SCENE: if (ale->flag & SCE_DS_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_OBJECT: - #if 0 /* for now, do not take object selection into account, since it gets too annoying */ + #if 0 /* for now, do not take object selection into account, since it gets too annoying */ if (ale->flag & SELECT) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; #endif break; case ANIMTYPE_GROUP: if (ale->flag & AGRP_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_FCURVE: if (ale->flag & FCURVE_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_SHAPEKEY: if (ale->flag & KEYBLOCK_SEL) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_NLATRACK: if (ale->flag & NLATRACK_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -253,24 +253,24 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s case ANIMTYPE_DSSPK: { if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; } - break; + break; case ANIMTYPE_GPLAYER: if (ale->flag & GP_LAYER_SELECT) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; } } } /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *scene= (Scene *)ale->data; + Scene *scene = (Scene *)ale->data; ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED); @@ -278,56 +278,56 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED); } } - break; + break; case ANIMTYPE_OBJECT: - #if 0 /* for now, do not take object selection into account, since it gets too annoying */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; + #if 0 /* for now, do not take object selection into account, since it gets too annoying */ + { + Base *base = (Base *)ale->data; + Object *ob = base->object; - ACHANNEL_SET_FLAG(base, sel, SELECT); - ACHANNEL_SET_FLAG(ob, sel, SELECT); + ACHANNEL_SET_FLAG(base, sel, SELECT); + ACHANNEL_SET_FLAG(ob, sel, SELECT); - if (ob->adt) { - ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); + if (ob->adt) { + ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); + } } - } #endif break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED); agrp->flag &= ~AGRP_ACTIVE; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED); fcu->flag &= ~FCURVE_ACTIVE; } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED); nlt->flag &= ~NLATRACK_ACTIVE; } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -349,7 +349,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ale->adt->flag &= ~ADT_UI_ACTIVE; } } - break; + break; case ANIMTYPE_GPLAYER: { @@ -357,7 +357,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT); } - break; + break; } } @@ -378,21 +378,21 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s */ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on) { - bAnimListElem *ale, *match=NULL; - int prevLevel=0, matchLevel=0; + bAnimListElem *ale, *match = NULL; + int prevLevel = 0, matchLevel = 0; /* sanity check */ if (ELEM(NULL, anim_data, anim_data->first)) return; /* find the channel that got changed */ - for (ale= anim_data->first; ale; ale= ale->next) { + for (ale = anim_data->first; ale; ale = ale->next) { /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { /* we also have to check the ID, this is assigned to, since a block may have multiple users */ // TODO: is the owner-data more revealing? if (ale->id == ale_setting->id) { - match= ale; + match = ale; break; } } @@ -402,7 +402,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn return; } else { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale_setting); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting); if (acf == NULL) { printf("ERROR: no channel info for the changed channel\n"); @@ -410,10 +410,10 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn } /* get the level of the channel that was affected - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - matchLevel= (acf->get_offset)? acf->get_offset(ac, ale_setting) : 0; - prevLevel= matchLevel; + matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; + prevLevel = matchLevel; } /* flush up? @@ -427,11 +427,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn * (otherwise, it's too much work to force the parents to be active too) */ if ( ((setting == ACHANNEL_SETTING_VISIBLE) && on) || - ((setting != ACHANNEL_SETTING_VISIBLE) && on==0) ) + ((setting != ACHANNEL_SETTING_VISIBLE) && on == 0) ) { /* go backwards in the list, until the highest-ranking element (by indention has been covered) */ - for (ale= match->prev; ale; ale= ale->prev) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + for (ale = match->prev; ale; ale = ale->prev) { + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; /* if no channel info was found, skip, since this type might not have any useful info */ @@ -439,9 +439,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn continue; /* get the level of the current channel traversed - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - level= (acf->get_offset)? acf->get_offset(ac, ale) : 0; + level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; /* if the level is 'less than' (i.e. more important) the level we're matching * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, @@ -453,7 +453,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn ANIM_channel_setting_set(ac, ale, setting, on); /* store this level as the 'old' level now */ - prevLevel= level; + prevLevel = level; } /* if the level is 'greater than' (i.e. less important) than the previous level... */ else if (level > prevLevel) { @@ -474,8 +474,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* flush down (always) */ { /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */ - for (ale= match->next; ale; ale= ale->next) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + for (ale = match->next; ale; ale = ale->next) { + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; /* if no channel info was found, skip, since this type might not have any useful info */ @@ -483,9 +483,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn continue; /* get the level of the current channel traversed - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - level= (acf->get_offset)? acf->get_offset(ac, ale) : 0; + level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; /* if the level is 'greater than' (i.e. less important) the channel that was changed, * flush the new status... @@ -541,11 +541,11 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f * channel list that are empty, and linger around long after the data they * are for has disappeared (and probably won't come back). */ - // XXX: does everybody always want this? - /* XXX: there's a problem where many actions could build up in the file if multiple - * full add/delete cycles are performed on the same objects, but assume that this is rare - */ - if ((adt->action->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON)==0) { + // XXX: does everybody always want this? + /* XXX: there's a problem where many actions could build up in the file if multiple + * full add/delete cycles are performed on the same objects, but assume that this is rare + */ + if ((adt->action->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { id_us_min(&adt->action->id); adt->action = NULL; } @@ -561,9 +561,9 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f /* ****************** Operator Utilities ********************************** */ /* poll callback for being in an Animation Editor channels list region */ -static int animedit_poll_channels_active (bContext *C) +static int animedit_poll_channels_active(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); /* channels region test */ // TODO: could enhance with actually testing if channels region? @@ -577,9 +577,9 @@ static int animedit_poll_channels_active (bContext *C) } /* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */ -static int animedit_poll_channels_nla_tweakmode_off (bContext *C) +static int animedit_poll_channels_nla_tweakmode_off(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); /* channels region test */ @@ -604,10 +604,10 @@ static int animedit_poll_channels_nla_tweakmode_off (bContext *C) /* constants for channel rearranging */ /* WARNING: don't change exising ones without modifying rearrange func accordingly */ enum { - REARRANGE_ANIMCHAN_TOP= -2, - REARRANGE_ANIMCHAN_UP= -1, - REARRANGE_ANIMCHAN_DOWN= 1, - REARRANGE_ANIMCHAN_BOTTOM= 2 + REARRANGE_ANIMCHAN_TOP = -2, + REARRANGE_ANIMCHAN_UP = -1, + REARRANGE_ANIMCHAN_DOWN = 1, + REARRANGE_ANIMCHAN_BOTTOM = 2 }; /* defines for rearranging channels */ @@ -625,21 +625,21 @@ static EnumPropertyItem prop_animchannel_rearrange_types[] = { typedef struct tReorderChannelIsland { struct tReorderChannelIsland *next, *prev; - ListBase channels; /* channels within this region with the same state */ - int flag; /* eReorderIslandFlag */ + ListBase channels; /* channels within this region with the same state */ + int flag; /* eReorderIslandFlag */ } tReorderChannelIsland; /* flags for channel reordering islands */ typedef enum eReorderIslandFlag { - REORDER_ISLAND_SELECTED = (1<<0), /* island is selected */ - REORDER_ISLAND_UNTOUCHABLE = (1<<1), /* island should be ignored */ - REORDER_ISLAND_MOVED = (1<<2) /* island has already been moved */ + REORDER_ISLAND_SELECTED = (1 << 0), /* island is selected */ + REORDER_ISLAND_UNTOUCHABLE = (1 << 1), /* island should be ignored */ + REORDER_ISLAND_MOVED = (1 << 2) /* island has already been moved */ } eReorderIslandFlag; /* Rearrange Methods --------------------------------------------- */ -static short rearrange_island_ok (tReorderChannelIsland *island) +static short rearrange_island_ok(tReorderChannelIsland *island) { /* island must not be untouchable */ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) @@ -651,7 +651,7 @@ static short rearrange_island_ok (tReorderChannelIsland *island) /* ............................. */ -static short rearrange_island_top (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_top(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* remove from current position */ @@ -666,11 +666,11 @@ static short rearrange_island_top (ListBase *list, tReorderChannelIsland *island return 0; } -static short rearrange_island_up (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_up(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* moving up = moving before the previous island, otherwise we're in the same place */ - tReorderChannelIsland *prev= island->prev; + tReorderChannelIsland *prev = island->prev; if (prev) { /* remove from current position */ @@ -686,7 +686,7 @@ static short rearrange_island_up (ListBase *list, tReorderChannelIsland *island) return 0; } -static short rearrange_island_down (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_down(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* moving down = moving after the next island, otherwise we're in the same place */ @@ -694,7 +694,7 @@ static short rearrange_island_down (ListBase *list, tReorderChannelIsland *islan if (next) { /* can only move past if next is not untouchable (i.e. nothing can go after it) */ - if ((next->flag & REORDER_ISLAND_UNTOUCHABLE)==0) { + if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* remove from current position */ BLI_remlink(list, island); @@ -710,7 +710,7 @@ static short rearrange_island_down (ListBase *list, tReorderChannelIsland *islan return 0; } -static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_bottom(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { tReorderChannelIsland *last = list->last; @@ -719,7 +719,7 @@ static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *isl BLI_remlink(list, island); /* add before or after the last channel? */ - if ((last->flag & REORDER_ISLAND_UNTOUCHABLE)==0) { + if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* can add after it */ BLI_addtail(list, island); } @@ -745,7 +745,7 @@ static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *isl typedef short (*AnimChanRearrangeFp)(ListBase *list, tReorderChannelIsland *island); /* get rearranging function, given 'rearrange' mode */ -static AnimChanRearrangeFp rearrange_get_mode_func (short mode) +static AnimChanRearrangeFp rearrange_get_mode_func(short mode) { switch (mode) { case REARRANGE_ANIMCHAN_TOP: @@ -764,35 +764,35 @@ static AnimChanRearrangeFp rearrange_get_mode_func (short mode) /* Rearrange Islands Generics ------------------------------------- */ /* add channel into list of islands */ -static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *srcList, Link *channel, short type) +static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *srcList, Link *channel, short type) { - tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ - short is_sel=0, is_untouchable=0; + tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ + short is_sel = 0, is_untouchable = 0; /* get flags - selected and untouchable from the channel */ switch (type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)channel; + bActionGroup *agrp = (bActionGroup *)channel; - is_sel= SEL_AGRP(agrp); - is_untouchable= (agrp->flag & AGRP_TEMP) != 0; + is_sel = SEL_AGRP(agrp); + is_untouchable = (agrp->flag & AGRP_TEMP) != 0; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)channel; + FCurve *fcu = (FCurve *)channel; - is_sel= SEL_FCU(fcu); + is_sel = SEL_FCU(fcu); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)channel; + NlaTrack *nlt = (NlaTrack *)channel; - is_sel= SEL_NLT(nlt); + is_sel = SEL_NLT(nlt); } - break; + break; default: printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %d\n", type); @@ -801,8 +801,8 @@ static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *s /* do we need to add to a new island? */ if ((island == NULL) || /* 1) no islands yet */ - ((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 2) unselected islands have single channels only - to allow up/down movement */ - (is_sel == 0)) /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */ + ((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 2) unselected islands have single channels only - to allow up/down movement */ + (is_sel == 0)) /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */ { /* create a new island now */ island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); @@ -820,9 +820,9 @@ static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *s } /* flatten islands out into a single list again */ -static void rearrange_animchannel_flatten_islands (ListBase *islands, ListBase *srcList) +static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList) { - tReorderChannelIsland *island, *isn=NULL; + tReorderChannelIsland *island, *isn = NULL; /* make sure srcList is empty now */ BLI_assert(srcList->first == NULL); @@ -840,10 +840,10 @@ static void rearrange_animchannel_flatten_islands (ListBase *islands, ListBase * /* ............................. */ /* performing rearranging of channels using islands */ -static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp rearrange_func, short mode, short type) +static short rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp rearrange_func, short mode, short type) { ListBase islands = {NULL, NULL}; - Link *channel, *chanNext=NULL; + Link *channel, *chanNext = NULL; short done = 0; /* don't waste effort on an empty list */ @@ -862,7 +862,7 @@ static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp */ if (islands.first != islands.last) { tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first; - tReorderChannelIsland *island, *isn=NULL; + tReorderChannelIsland *island, *isn = NULL; for (island = first; island; island = isn) { isn = (mode > 0) ? island->prev : island->next; @@ -888,7 +888,7 @@ static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp * ! NLA tracks are displayed in opposite order, so directions need care * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_nla_channels (bAnimContext *UNUSED(ac), AnimData *adt, short mode) +static void rearrange_nla_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode) { AnimChanRearrangeFp rearrange_func; @@ -913,7 +913,7 @@ static void rearrange_nla_channels (bAnimContext *UNUSED(ac), AnimData *adt, sho /* Change the order drivers within AnimData block * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_driver_channels (bAnimContext *UNUSED(ac), AnimData *adt, short mode) +static void rearrange_driver_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode) { /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); @@ -932,7 +932,7 @@ static void rearrange_driver_channels (bAnimContext *UNUSED(ac), AnimData *adt, /* Action Specific Stuff ------------------------------------------------- */ /* make sure all action-channels belong to a group (and clear action's list) */ -static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) +static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) { bActionGroup *agrp; FCurve *fcu; @@ -941,37 +941,37 @@ static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) return; /* Separate F-Curves into lists per group */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->channels.first) { - fcu= agrp->channels.last; - act->curves.first= fcu->next; + fcu = agrp->channels.last; + act->curves.first = fcu->next; - fcu= agrp->channels.first; - fcu->prev= NULL; + fcu = agrp->channels.first; + fcu->prev = NULL; - fcu= agrp->channels.last; - fcu->next= NULL; + fcu = agrp->channels.last; + fcu->next = NULL; } } /* Initialize memory for temp-group */ memset(tgrp, 0, sizeof(bActionGroup)); - tgrp->flag |= (AGRP_EXPANDED|AGRP_TEMP); + tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP); BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name)); /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { /* start of list */ - fcu= act->curves.first; - fcu->prev= NULL; - tgrp->channels.first= fcu; - act->curves.first= NULL; + fcu = act->curves.first; + fcu->prev = NULL; + tgrp->channels.first = fcu; + act->curves.first = NULL; /* end of list */ - fcu= act->curves.last; - fcu->next= NULL; - tgrp->channels.last= fcu; - act->curves.last= NULL; + fcu = act->curves.last; + fcu->next = NULL; + tgrp->channels.last = fcu; + act->curves.last = NULL; } /* Add temp-group to list */ @@ -979,17 +979,17 @@ static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) } /* link lists of channels that groups have */ -static void join_groups_action_temp (bAction *act) +static void join_groups_action_temp(bAction *act) { bActionGroup *agrp; - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { ListBase tempGroup; /* add list of channels to action's channels */ - tempGroup= agrp->channels; + tempGroup = agrp->channels; BLI_movelisttolist(&act->curves, &agrp->channels); - agrp->channels= tempGroup; + agrp->channels = tempGroup; /* clear moved flag */ agrp->flag &= ~AGRP_MOVED; @@ -1005,7 +1005,7 @@ static void join_groups_action_temp (bAction *act) /* Change the order of anim-channels within action * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mode) +static void rearrange_action_channels(bAnimContext *ac, bAction *act, short mode) { bActionGroup tgrp; short do_channels; @@ -1028,7 +1028,7 @@ static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mod if (do_channels) { bActionGroup *agrp; - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ if (EXPANDED_AGRP(ac, agrp)) { rearrange_animchannel_islands(&agrp->channels, rearrange_func, mode, ANIMTYPE_FCURVE); @@ -1052,7 +1052,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get mode */ - mode= RNA_enum_get(op->ptr, "direction"); + mode = RNA_enum_get(op->ptr, "direction"); /* method to move channels depends on the editor */ if (ac.datatype == ANIMCONT_GPENCIL) { @@ -1069,11 +1069,11 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) int filter; /* get animdata blocks */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); for (ale = anim_data.first; ale; ale = ale->next) { - AnimData *adt= ale->data; + AnimData *adt = ale->data; switch (ac.datatype) { case ANIMCONT_NLA: /* NLA-tracks only */ @@ -1100,12 +1100,12 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_move (wmOperatorType *ot) +static void ANIM_OT_channels_move(wmOperatorType *ot) { /* identifiers */ ot->name = "Move Channels"; @@ -1117,7 +1117,7 @@ static void ANIM_OT_channels_move (wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", ""); @@ -1144,15 +1144,15 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* do groups only first (unless in Drivers mode, where there are none) */ if (ac.datatype != ANIMCONT_DRIVERS) { /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete selected groups and their associated channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* only groups - don't check other types yet, since they may no-longer exist */ if (ale->type == ANIMTYPE_GROUP) { - bActionGroup *agrp= (bActionGroup *)ale->data; - AnimData *adt= ale->adt; + bActionGroup *agrp = (bActionGroup *)ale->data; + AnimData *adt = ale->adt; FCurve *fcu, *fcn; /* skip this group if no AnimData available, as we can't safely remove the F-Curves */ @@ -1160,8 +1160,8 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) continue; /* delete all of the Group's F-Curves, but no others */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcn) { - fcn= fcu->next; + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) { + fcn = fcu->next; /* remove from group and action, then free */ action_groups_remove_channel(adt->action, fcu); @@ -1181,34 +1181,34 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete selected data channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_FCURVE: { /* F-Curves if we can identify its parent */ - AnimData *adt= ale->adt; - FCurve *fcu= (FCurve *)ale->data; + AnimData *adt = ale->adt; + FCurve *fcu = (FCurve *)ale->data; /* try to free F-Curve */ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu); } - break; + break; case ANIMTYPE_GPLAYER: { /* Grease Pencil layer */ - bGPdata *gpd= (bGPdata *)ale->id; - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPdata *gpd = (bGPdata *)ale->id; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* try to delete the layer's data and the layer itself */ free_gpencil_frames(gpl); BLI_freelinkN(&gpd->layers, gpl); } - break; + break; } } @@ -1216,12 +1216,12 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_delete (wmOperatorType *ot) +static void ANIM_OT_channels_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Channels"; @@ -1233,7 +1233,7 @@ static void ANIM_OT_channels_delete (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Set Channel Visibility Operator *********************** */ @@ -1254,7 +1254,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* get list of all channels that selection may need to be flushed to * - hierarchy mustn't affect what we have access to here... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); /* hide all channels not selected @@ -1266,15 +1266,15 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) */ if ((ac.spacetype == SPACE_IPO) && (ac.regiontype != RGN_TYPE_CHANNELS)) { /* graph editor (case 2) */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); } else { /* standard case */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS); } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* clear setting first */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); @@ -1287,10 +1287,10 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* make all the selected channels visible */ - filter= (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ // TODO: find out why this is the case, and fix that if (ale->type == ANIMTYPE_OBJECT) @@ -1308,12 +1308,12 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_visibility_set (wmOperatorType *ot) +static void ANIM_OT_channels_visibility_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Visibility"; @@ -1325,7 +1325,7 @@ static void ANIM_OT_channels_visibility_set (wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1339,7 +1339,7 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o ListBase all_data = {NULL, NULL}; bAnimListElem *ale; int filter; - short vis= ACHANNEL_SETFLAG_ADD; + short vis = ACHANNEL_SETFLAG_ADD; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1348,26 +1348,26 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o /* get list of all channels that selection may need to be flushed to * - hierarchy mustn't affect what we have access to here... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); /* filter data * - restrict this to only applying on settings we can get to in the list */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* See if we should be making showing all selected or hiding */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE)) { - vis= ACHANNEL_SETFLAG_CLEAR; + vis = ACHANNEL_SETFLAG_CLEAR; break; } } /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ // TODO: find out why this is the case, and fix that if (ale->type == ANIMTYPE_OBJECT) @@ -1385,12 +1385,12 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o BLI_freelistN(&all_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_visibility_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Visibility"; @@ -1402,7 +1402,7 @@ static void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************** Set Flags Operator *********************** */ @@ -1433,7 +1433,7 @@ static EnumPropertyItem prop_animchannel_settings_types[] = { * onlysel: only selected channels get the flag set */ // TODO: enable a setting which turns flushing on/off? -static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, short onlysel, short flush) +static void setflag_anim_channels(bAnimContext *ac, short setting, short mode, short onlysel, short flush) { ListBase anim_data = {NULL, NULL}; ListBase all_data = {NULL, NULL}; @@ -1446,7 +1446,7 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, * - hierarchy visibility needs to be ignored so that settings can get flushed * "down" inside closed containers */ - filter= ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype); } @@ -1459,11 +1459,11 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, */ if ((ac->spacetype == SPACE_IPO) && (ac->regiontype != RGN_TYPE_CHANNELS)) { /* graph editor (case 2) */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); } else { /* standard case */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); } if (onlysel) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -1471,20 +1471,20 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, /* if toggling, check if disable or enable */ if (mode == ACHANNEL_SETFLAG_TOGGLE) { /* default to turn all on, unless we encounter one that's on... */ - mode= ACHANNEL_SETFLAG_ADD; + mode = ACHANNEL_SETFLAG_ADD; /* see if we should turn off instead... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ if (ANIM_channel_setting_get(ac, ale, setting) > 0) { - mode= ACHANNEL_SETFLAG_CLEAR; + mode = ACHANNEL_SETFLAG_CLEAR; break; } } } /* apply the setting */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* skip channel if setting is not available */ if (ANIM_channel_setting_get(ac, ale, setting) == -1) continue; @@ -1507,19 +1507,19 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode, setting; - short flush=1; + short flush = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */ - mode= RNA_enum_get(op->ptr, "mode"); - setting= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "mode"); + setting = RNA_enum_get(op->ptr, "type"); /* check if setting is flushable */ if (setting == ACHANNEL_SETTING_EXPAND) - flush= 0; + flush = 0; /* modify setting * - only selected channels are affected @@ -1527,13 +1527,13 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) setflag_anim_channels(&ac, setting, mode, 1, flush); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ -static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) +static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) { /* identifiers */ ot->name = "Enable Channel Setting"; @@ -1546,16 +1546,16 @@ static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ -static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) +static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) { /* identifiers */ ot->name = "Disable Channel Setting"; @@ -1568,16 +1568,16 @@ static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } -static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Channel Setting"; @@ -1590,16 +1590,16 @@ static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } -static void ANIM_OT_channels_editable_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Channel Editability"; @@ -1611,21 +1611,21 @@ static void ANIM_OT_channels_editable_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); - /* setting to set */ + /* setting to set */ RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); } /* ********************** Expand Channels Operator *********************** */ -static int animchannels_expand_exec (bContext *C, wmOperator *op) +static int animchannels_expand_exec(bContext *C, wmOperator *op) { bAnimContext ac; - short onlysel= 1; + short onlysel = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1633,18 +1633,18 @@ static int animchannels_expand_exec (bContext *C, wmOperator *op) /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) - onlysel= 0; + onlysel = 0; /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, 0); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_expand (wmOperatorType *ot) +static void ANIM_OT_channels_expand(wmOperatorType *ot) { /* identifiers */ ot->name = "Expand Channels"; @@ -1656,7 +1656,7 @@ static void ANIM_OT_channels_expand (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); @@ -1664,10 +1664,10 @@ static void ANIM_OT_channels_expand (wmOperatorType *ot) /* ********************** Collapse Channels Operator *********************** */ -static int animchannels_collapse_exec (bContext *C, wmOperator *op) +static int animchannels_collapse_exec(bContext *C, wmOperator *op) { bAnimContext ac; - short onlysel= 1; + short onlysel = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1675,18 +1675,18 @@ static int animchannels_collapse_exec (bContext *C, wmOperator *op) /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) - onlysel= 0; + onlysel = 0; /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, 0); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_collapse (wmOperatorType *ot) +static void ANIM_OT_channels_collapse(wmOperatorType *ot) { /* identifiers */ ot->name = "Collapse Channels"; @@ -1698,7 +1698,7 @@ static void ANIM_OT_channels_collapse (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)"); @@ -1706,9 +1706,9 @@ static void ANIM_OT_channels_collapse (wmOperatorType *ot) /* ******************* Reenable Disabled Operator ******************* */ -static int animchannels_enable_poll (bContext *C) +static int animchannels_enable_poll(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); /* channels region test */ // TODO: could enhance with actually testing if channels region? @@ -1722,7 +1722,7 @@ static int animchannels_enable_poll (bContext *C) return 1; } -static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) +static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1735,11 +1735,11 @@ static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; /* remove disabled flags from F-Curves */ @@ -1757,12 +1757,12 @@ static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_fcurves_enable (wmOperatorType *ot) +static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) { /* identifiers */ ot->name = "Revive Disabled F-Curves"; @@ -1774,12 +1774,12 @@ static void ANIM_OT_channels_fcurves_enable (wmOperatorType *ot) ot->poll = animchannels_enable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************** Select All Operator *********************** */ -static int animchannels_deselectall_exec (bContext *C, wmOperator *op) +static int animchannels_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1794,12 +1794,12 @@ static int animchannels_deselectall_exec (bContext *C, wmOperator *op) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_ADD); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; @@ -1811,7 +1811,7 @@ static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -1819,14 +1819,14 @@ static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) /* ******************** Borderselect Operator *********************** */ -static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short selectmode) +static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin, ymax; @@ -1841,19 +1841,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele } /* convert border-region to view coordinates */ - UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ac->datatype == ANIMCONT_NLA) - ymin= ymax - NLACHANNEL_STEP(snla); + ymin = ymax - NLACHANNEL_STEP(snla); else - ymin= ymax - ACHANNEL_STEP; + ymin = ymax - ACHANNEL_STEP; /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { @@ -1864,27 +1864,27 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele switch (ale->type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* for now, it's easier just to do this here manually, as defining a new type * currently adds complications when doing other stuff */ ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); } - break; + break; } } /* set minimum extent to be the maximum of the next channel */ - ymax= ymin; + ymax = ymin; } /* cleanup */ @@ -1897,7 +1897,7 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short selectmode=0; + short selectmode = 0; int gesture_mode, extend; /* get editor data */ @@ -1910,8 +1910,8 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - extend= RNA_boolean_get(op->ptr, "extend"); + gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_CLEAR); @@ -1925,7 +1925,7 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) borderselect_anim_channels(&ac, &rect, selectmode); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -1946,7 +1946,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -1955,7 +1955,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) /* ******************* Rename Operator ***************************** */ /* Allow renaming some channels by clicking on them */ -static void rename_anim_channels (bAnimContext *ac, int channel_index) +static void rename_anim_channels(bAnimContext *ac, int channel_index) { ListBase anim_data = {NULL, NULL}; bAnimChannelType *acf; @@ -1963,12 +1963,12 @@ static void rename_anim_channels (bAnimContext *ac, int channel_index) int filter; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -2004,7 +2004,7 @@ static void rename_anim_channels (bAnimContext *ac, int channel_index) ED_region_tag_redraw(ac->ar); } -static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *evt) +static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *evt) { bAnimContext ac; ARegion *ar; @@ -2017,8 +2017,8 @@ static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEv return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; /* figure out which channel user clicked in * Note: although channels technically start at y= ACHANNEL_FIRST, we need to adjust by half a channel's height @@ -2041,7 +2041,7 @@ static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEv return OPERATOR_FINISHED; } -static void ANIM_OT_channels_rename (wmOperatorType *ot) +static void ANIM_OT_channels_rename(wmOperatorType *ot) { /* identifiers */ ot->name = "Rename Channels"; @@ -2056,7 +2056,7 @@ static void ANIM_OT_channels_rename (wmOperatorType *ot) /* ******************** Mouse-Click Operator *********************** */ /* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ -static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_index, short selectmode) +static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_index, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -2064,12 +2064,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i int notifierFlags = 0; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -2092,8 +2092,8 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)ale->data; - AnimData *adt= sce->adt; + Scene *sce = (Scene *)ale->data; + AnimData *adt = sce->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { @@ -2106,22 +2106,22 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (adt) adt->flag |= ADT_UI_SELECTED; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_OBJECT: { - bDopeSheet *ads= (bDopeSheet *)ac->data; - Scene *sce= (Scene *)ads->source; - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ob->adt; + bDopeSheet *ads = (bDopeSheet *)ac->data; + Scene *sce = (Scene *)ads->source; + Base *base = (Base *)ale->data; + Object *ob = base->object; + AnimData *adt = ob->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ base->flag ^= SELECT; - ob->flag= base->flag; + ob->flag = base->flag; if (adt) adt->flag ^= ADT_UI_SELECTED; } @@ -2130,10 +2130,10 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i /* deselect all */ // TODO: should this deselect all other types of channels too? - for (b= sce->base.first; b; b= b->next) { + for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; - b->object->flag= b->flag; - if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED|ADT_UI_ACTIVE); + b->object->flag = b->flag; + if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } /* select object now */ @@ -2145,12 +2145,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if ((adt) && (adt->flag & ADT_UI_SELECTED)) adt->flag |= ADT_UI_ACTIVE; - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -2184,13 +2184,13 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i ale->adt->flag |= ADT_UI_ACTIVE; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* select/deselect group */ if (selectmode == SELECT_INVERT) { @@ -2205,7 +2205,7 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* only select channels in group and group itself */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) fcu->flag |= FCURVE_SELECTED; agrp->flag |= AGRP_SELECTED; } @@ -2219,12 +2219,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (agrp->flag & AGRP_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2241,12 +2241,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (fcu->flag & FCURVE_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2259,24 +2259,24 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i kb->flag |= KEYBLOCK_SEL; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_GPDATABLOCK: { - bGPdata *gpd= (bGPdata *)ale->data; + bGPdata *gpd = (bGPdata *)ale->data; /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ gpd->flag ^= GP_DATA_EXPAND; - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - break; + break; case ANIMTYPE_GPLAYER: { - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2289,9 +2289,9 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i gpl->flag |= GP_LAYER_SELECT; } - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - break; + break; default: if (G.debug & G_DEBUG) printf("Error: Invalid channel type in mouse_anim_channels()\n"); @@ -2323,16 +2323,16 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent * return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else if (RNA_boolean_get(op->ptr, "children_only")) - selectmode= -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ + selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out which channel user clicked in * Note: although channels technically start at y= ACHANNEL_FIRST, we need to adjust by half a channel's height @@ -2343,15 +2343,15 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent * UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); /* handle mouse-click in the relevant channel then */ - notifierFlags= mouse_anim_channels(&ac, x, channel_index, selectmode); + notifierFlags = mouse_anim_channels(&ac, x, channel_index, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|notifierFlags, NULL); + WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_click (wmOperatorType *ot) +static void ANIM_OT_channels_click(wmOperatorType *ot) { /* identifiers */ ot->name = "Mouse Click on Channels"; @@ -2363,7 +2363,7 @@ static void ANIM_OT_channels_click (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY @@ -2387,7 +2387,7 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_delete); - // XXX does this need to be a separate operator? + // XXX does this need to be a separate operator? WM_operatortype_append(ANIM_OT_channels_editable_toggle); WM_operatortype_append(ANIM_OT_channels_move); @@ -2408,20 +2408,20 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* selection */ - /* click-select */ - // XXX for now, only leftmouse.... + /* click-select */ + // XXX for now, only leftmouse.... WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "children_only", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "children_only", TRUE); - /* rename */ + /* rename */ WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - /* deselect all */ + /* deselect all */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); @@ -2431,7 +2431,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* settings */ WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0); /* settings - specialized hotkeys */ diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index b449c11ff7b..32cbbc79496 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -67,17 +67,17 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) FCurve *fcu; AnimData *adt; - id= ale->id; + id = ale->id; if (!id) return; /* tag AnimData for refresh so that other views will update in realtime with these changes */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if (adt) adt->recalc |= ADT_RECALC_ANIM; /* update data */ - fcu= (ale->datatype == ALE_FCURVE)? ale->key_data: NULL; + fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; if (fcu && fcu->rna_path) { /* if we have an fcurve, call the update for the property we @@ -94,7 +94,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) else { /* in other case we do standard depsgaph update, ideally * we'd be calling property update functions here too ... */ - DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX or do we want something more restrictive? + DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive? } } @@ -103,14 +103,14 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) void ANIM_id_update(Scene *UNUSED(scene), ID *id) { if (id) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* tag AnimData for refresh so that other views will update in realtime with these changes */ if (adt) adt->recalc |= ADT_RECALC_ANIM; /* set recalc flags */ - DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX or do we want something more restrictive? + DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive? } } @@ -125,10 +125,10 @@ void ANIM_id_update(Scene *UNUSED(scene), ID *id) */ /* perform syncing updates for Action Groups */ -static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_group(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - bActionGroup *agrp= (bActionGroup *)ale->data; - ID *owner_id= ale->id; + bActionGroup *agrp = (bActionGroup *)ale->data; + ID *owner_id = ale->id; /* major priority is selection status * so we need both a group and an owner @@ -138,13 +138,13 @@ static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) /* for standard Objects, check if group is the name of some bone */ if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* check if there are bones, and whether the name matches any * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone */ if (ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, agrp->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); /* if one matches, sync the selection status */ if (pchan) { @@ -158,10 +158,10 @@ static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) } /* perform syncing updates for F-Curves */ -static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - FCurve *fcu= (FCurve *)ale->data; - ID *owner_id= ale->id; + FCurve *fcu = (FCurve *)ale->data; + ID *owner_id = ale->id; /* major priority is selection status, so refer to the checks done in anim_filter.c * skip_fcurve_selected_data() for reference about what's going on here... @@ -170,7 +170,7 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) return; if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* only affect if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { @@ -178,8 +178,8 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* F-Curve selection depends on whether the bone is selected */ @@ -196,12 +196,12 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) /* only affect if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); @@ -223,7 +223,7 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) char *node_name; /* get strip name, and check if this strip is selected */ - node_name= BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); @@ -254,12 +254,12 @@ void ANIM_sync_animchannels_to_data(const bContext *C) return; /* filter data */ - /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed */ - filter= ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_CHANNELS; + /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed */ + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* flush settings as appropriate depending on the types of the channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_GROUP: animchan_sync_group(&ac, ale); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 236b8d18b78..0514700e120 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -55,7 +55,7 @@ /* TIME CODE FORMATTING */ /* Generate timecode/frame number string and store in the supplied string - * - buffer: must be at least 13 chars long + * - buffer: must be at least 13 chars long * - power: special setting for View2D grid drawing, * used to specify how detailed we need to be * - timecodes: boolean specifying whether timecodes or @@ -66,41 +66,41 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short timecodes, float cfra) { if (timecodes) { - int hours=0, minutes=0, seconds=0, frames=0; - float raw_seconds= cfra; - char neg[2]= {'\0'}; + int hours = 0, minutes = 0, seconds = 0, frames = 0; + float raw_seconds = cfra; + char neg[2] = {'\0'}; /* get cframes */ if (cfra < 0) { /* correction for negative cfraues */ - neg[0]= '-'; + neg[0] = '-'; cfra = -cfra; } if (cfra >= 3600) { /* hours */ /* XXX should we only display a single digit for hours since clips are - * VERY UNLIKELY to be more than 1-2 hours max? However, that would + * VERY UNLIKELY to be more than 1-2 hours max? However, that would * go against conventions... */ - hours= (int)cfra / 3600; - cfra= (float)fmod(cfra, 3600); + hours = (int)cfra / 3600; + cfra = (float)fmod(cfra, 3600); } if (cfra >= 60) { /* minutes */ - minutes= (int)cfra / 60; - cfra= (float)fmod(cfra, 60); + minutes = (int)cfra / 60; + cfra = (float)fmod(cfra, 60); } if (power <= 0) { /* seconds + frames * Frames are derived from 'fraction' of second. We need to perform some additional rounding * to cope with 'half' frames, etc., which should be fine in most cases */ - seconds= (int)cfra; - frames= (int)floor( (((double)cfra - (double)seconds) * FPS) + 0.5 ); + seconds = (int)cfra; + frames = (int)floor( (((double)cfra - (double)seconds) * FPS) + 0.5); } else { /* seconds (with pixel offset rounding) */ - seconds= (int)floor(cfra + 0.375f); + seconds = (int)floor(cfra + 0.375f); } switch (U.timecode_style) { @@ -124,7 +124,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t else sprintf(str, "%s%02d:%02d", neg, minutes, seconds); } } - break; + break; case USER_TIMECODE_SMPTE_MSF: { @@ -132,27 +132,27 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t if (hours) sprintf(str, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames); else sprintf(str, "%s%02d:%02d:%02d", neg, minutes, seconds, frames); } - break; + break; case USER_TIMECODE_MILLISECONDS: { /* reduced SMPTE. Instead of frames, milliseconds are shown */ - int ms_dp= (power <= 0) ? (1 - power) : 1; /* precision of decimal part */ - int s_pad= ms_dp+3; /* to get 2 digit whole-number part for seconds display (i.e. 3 is for 2 digits + radix, on top of full length) */ + int ms_dp = (power <= 0) ? (1 - power) : 1; /* precision of decimal part */ + int s_pad = ms_dp + 3; /* to get 2 digit whole-number part for seconds display (i.e. 3 is for 2 digits + radix, on top of full length) */ if (hours) sprintf(str, "%s%02d:%02d:%0*.*f", neg, hours, minutes, s_pad, ms_dp, cfra); else sprintf(str, "%s%02d:%0*.*f", neg, minutes, s_pad, ms_dp, cfra); } - break; + break; case USER_TIMECODE_SECONDS_ONLY: { /* only show the original seconds display */ /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ - if (power <= 0) sprintf(str, "%.*f", 1-power, raw_seconds); + if (power <= 0) sprintf(str, "%.*f", 1 - power, raw_seconds); else sprintf(str, "%d", (int)floor(raw_seconds + 0.375f)); } - break; + break; case USER_TIMECODE_SMPTE_FULL: default: @@ -160,12 +160,12 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t /* full SMPTE format */ sprintf(str, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames); } - break; + break; } } else { /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ - if (power <= 0) sprintf(str, "%.*f", 1-power, cfra); + if (power <= 0) sprintf(str, "%.*f", 1 - power, cfra); else sprintf(str, "%d", (int)floor(cfra + 0.375f)); } } @@ -174,15 +174,15 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t /* CURRENT FRAME DRAWING */ /* Draw current frame number in a little green box beside the current frame indicator */ -static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) +static void draw_cfra_number(Scene *scene, View2D *v2d, float cfra, short time) { float xscale, yscale, x, y; - char numstr[32] = " t"; /* t is the character to start replacing from */ + char numstr[32] = " t"; /* t is the character to start replacing from */ short slen; /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); /* get timecode string * - padding on str-buf passed so that it doesn't sit on the frame indicator @@ -193,19 +193,19 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) ANIM_timecode_string_from_frame(&numstr[4], scene, 0, time, FRA2TIME(cfra)); else ANIM_timecode_string_from_frame(&numstr[4], scene, 1, time, cfra); - slen= (short)UI_GetStringWidth(numstr) - 1; + slen = (short)UI_GetStringWidth(numstr) - 1; /* get starting coordinates for drawing */ - x= cfra * xscale; - y= 18; + x = cfra * xscale; + y = 18; /* draw green box around/behind text */ UI_ThemeColorShade(TH_CFRAME, 0); - glRectf(x, y, x+slen, y+15); + glRectf(x, y, x + slen, y + 15); /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - UI_DrawString(x-5, y+3, numstr); + UI_DrawString(x - 5, y + 3, numstr); /* restore view transform */ glScalef(xscale, 1.0, 1.0); @@ -214,11 +214,11 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) /* General call for drawing current frame indicator in animation editor */ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); float vec[2]; /* Draw a light green line to indicate current frame */ - vec[0]= (float)(scene->r.cfra * scene->r.framelen); + vec[0] = (float)(scene->r.cfra * scene->r.framelen); UI_ThemeColor(TH_CFRAME); if (flag & DRAWCFRA_WIDE) @@ -227,11 +227,11 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) glLineWidth(2.0); glBegin(GL_LINE_STRIP); - vec[1]= v2d->cur.ymin-500.0f; /* XXX arbitrary... want it go to bottom */ - glVertex2fv(vec); + vec[1] = v2d->cur.ymin - 500.0f; /* XXX arbitrary... want it go to bottom */ + glVertex2fv(vec); - vec[1]= v2d->cur.ymax; - glVertex2fv(vec); + vec[1] = v2d->cur.ymax; + glVertex2fv(vec); glEnd(); glLineWidth(1.0); @@ -250,7 +250,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) /* Draw preview range 'curtains' for highlighting where the animation data is */ void ANIM_draw_previewrange(const bContext *C, View2D *v2d) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* only draw this if preview range is set */ if (PRVRANGEON) { @@ -298,16 +298,16 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData *)ked->data; - short only_keys= (short)ked->i1; + AnimData *adt = (AnimData *)ked->data; + short only_keys = (short)ked->i1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); - bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); + bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); + bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); } - bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); return 0; } @@ -316,16 +316,16 @@ static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt) static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData*)ked->data; - short only_keys= (short)ked->i1; + AnimData *adt = (AnimData *)ked->data; + short only_keys = (short)ked->i1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP); - bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP); + bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP); + bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP); } - bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP); + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP); return 0; } @@ -333,25 +333,25 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve * - restore = whether to map points back to non-mapped time - * - only_keys = whether to only adjust the location of the center point of beztriples + * - only_keys = whether to only adjust the location of the center point of beztriples */ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, short restore, short only_keys) { - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc map_cb; /* init edit data * - AnimData is stored in 'data' * - only_keys is stored in 'i1' */ - ked.data= (void *)adt; - ked.i1= (int)only_keys; + ked.data = (void *)adt; + ked.i1 = (int)only_keys; /* get editing callback */ if (restore) - map_cb= bezt_nlamapping_restore; + map_cb = bezt_nlamapping_restore; else - map_cb= bezt_nlamapping_apply; + map_cb = bezt_nlamapping_apply; /* apply to F-Curve */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL); @@ -376,9 +376,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest /* if the radians flag is not set, default to using degrees which need conversions */ if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { if (restore) - return DEG2RADF(1.0f); /* degrees to radians */ + return DEG2RADF(1.0f); /* degrees to radians */ else - return RAD2DEGF(1.0f); /* radians to degrees */ + return RAD2DEGF(1.0f); /* radians to degrees */ } } @@ -393,18 +393,18 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest /* ----------------------- */ /* helper function for ANIM_unit_mapping_apply_fcurve -> mapping callback for unit mapping */ -static short bezt_unit_mapping_apply (KeyframeEditData *ked, BezTriple *bezt) +static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt) { /* mapping factor is stored in f1, flags are stored in i1 */ - short only_keys= (ked->i1 & ANIM_UNITCONV_ONLYKEYS); - short sel_vs= (ked->i1 & ANIM_UNITCONV_SELVERTS); - float fac= ked->f1; + short only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS); + short sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS); + float fac = ked->f1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - if ((sel_vs==0) || (bezt->f1 & SELECT)) + if ((sel_vs == 0) || (bezt->f1 & SELECT)) bezt->vec[0][1] *= fac; - if ((sel_vs==0) || (bezt->f3 & SELECT)) + if ((sel_vs == 0) || (bezt->f3 & SELECT)) bezt->vec[2][1] *= fac; } @@ -425,7 +425,7 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla if (G.rendering) return; /* calculate mapping factor, and abort if nothing to change */ - fac= ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE)); + fac = ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE)); if (fac == 1.0f) return; @@ -434,14 +434,14 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla * - flags are stored in 'i1' */ memset(&ked, 0, sizeof(KeyframeEditData)); - ked.f1= (float)fac; - ked.i1= (int)flag; + ked.f1 = (float)fac; + ked.i1 = (int)flag; /* only selected? */ if (flag & ANIM_UNITCONV_ONLYSEL) - sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); else - sel_cb= NULL; + sel_cb = NULL; /* apply to F-Curve */ ANIM_fcurve_keyframes_loop(&ked, fcu, sel_cb, bezt_unit_mapping_apply, NULL); @@ -452,7 +452,7 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla FPoint *fpt; unsigned int i; - for (i=0, fpt=fcu->fpt; i < fcu->totvert; i++, fpt++) { + for (i = 0, fpt = fcu->fpt; i < fcu->totvert; i++, fpt++) { /* apply unit mapping */ fpt->vec[1] *= fac; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 809b4c8d65e..3ee3d9c6198 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -100,9 +100,9 @@ /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ /* Note: there's a similar function in key.c (ob_get_key) */ -static Key *actedit_get_shapekeys (bAnimContext *ac) +static Key *actedit_get_shapekeys(bAnimContext *ac) { - Scene *scene= ac->scene; + Scene *scene = ac->scene; Object *ob; Key *key; @@ -114,7 +114,7 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) //if (saction->pin) return NULL; /* shapekey data is stored with geometry data */ - key= ob_get_key(ob); + key = ob_get_key(ob); if (key) { if (key->type == KEY_RELATIVE) @@ -125,7 +125,7 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) } /* Get data being edited in Action Editor (depending on current 'mode') */ -static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) +static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) { /* get dopesheet */ ac->ads = &saction->ads; @@ -134,51 +134,61 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) switch (saction->mode) { case SACTCONT_ACTION: /* 'Action Editor' */ /* if not pinned, sync with active object */ - if (/*saction->pin == 0*/1) { + if (/*saction->pin == 0*/ 1) { if (ac->obact && ac->obact->adt) saction->action = ac->obact->adt->action; else - saction->action= NULL; + saction->action = NULL; } - ac->datatype= ANIMCONT_ACTION; - ac->data= saction->action; + ac->datatype = ANIMCONT_ACTION; + ac->data = saction->action; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */ - ac->datatype= ANIMCONT_SHAPEKEY; - ac->data= actedit_get_shapekeys(ac); + ac->datatype = ANIMCONT_SHAPEKEY; + ac->data = actedit_get_shapekeys(ac); - ac->mode= saction->mode; + /* if not pinned, sync with active object */ + if (/*saction->pin == 0*/ 1) { + Key *key = (Key *)ac->data; + + if (key && key->adt) + saction->action = key->adt->action; + else + saction->action = NULL; + } + + ac->mode = saction->mode; return 1; case SACTCONT_GPENCIL: /* Grease Pencil */ // XXX review how this mode is handled... /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - saction->ads.source= (ID *)ac->scene; + saction->ads.source = (ID *)ac->scene; - ac->datatype= ANIMCONT_GPENCIL; - ac->data= &saction->ads; + ac->datatype = ANIMCONT_GPENCIL; + ac->data = &saction->ads; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; case SACTCONT_DOPESHEET: /* DopeSheet */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - saction->ads.source= (ID *)ac->scene; + saction->ads.source = (ID *)ac->scene; - ac->datatype= ANIMCONT_DOPESHEET; - ac->data= &saction->ads; + ac->datatype = ANIMCONT_DOPESHEET; + ac->data = &saction->ads; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; default: /* unhandled yet */ - ac->datatype= ANIMCONT_NONE; - ac->data= NULL; + ac->datatype = ANIMCONT_NONE; + ac->data = NULL; - ac->mode= -1; + ac->mode = -1; return 0; } } @@ -186,12 +196,12 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) /* ----------- Private Stuff - Graph Editor ------------- */ /* Get data being edited in Graph Editor (depending on current 'mode') */ -static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) +static short graphedit_get_context(bAnimContext *ac, SpaceIpo *sipo) { /* init dopesheet data if non-existant (i.e. for old files) */ if (sipo->ads == NULL) { - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)ac->scene; + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)ac->scene; } ac->ads = sipo->ads; @@ -203,33 +213,33 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) /* sync settings with current view status, then return appropriate data */ switch (sipo->mode) { - case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */ + case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - sipo->ads->source= (ID *)ac->scene; + sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag &= ~ADS_FILTER_ONLYDRIVERS; - ac->datatype= ANIMCONT_FCURVES; - ac->data= sipo->ads; + ac->datatype = ANIMCONT_FCURVES; + ac->data = sipo->ads; - ac->mode= sipo->mode; + ac->mode = sipo->mode; return 1; - case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */ + case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - sipo->ads->source= (ID *)ac->scene; + sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag |= ADS_FILTER_ONLYDRIVERS; - ac->datatype= ANIMCONT_DRIVERS; - ac->data= sipo->ads; + ac->datatype = ANIMCONT_DRIVERS; + ac->data = sipo->ads; - ac->mode= sipo->mode; + ac->mode = sipo->mode; return 1; default: /* unhandled yet */ - ac->datatype= ANIMCONT_NONE; - ac->data= NULL; + ac->datatype = ANIMCONT_NONE; + ac->data = NULL; - ac->mode= -1; + ac->mode = -1; return 0; } } @@ -237,20 +247,20 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) /* ----------- Private Stuff - NLA Editor ------------- */ /* Get data being edited in Graph Editor (depending on current 'mode') */ -static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla) +static short nlaedit_get_context(bAnimContext *ac, SpaceNla *snla) { /* init dopesheet data if non-existant (i.e. for old files) */ if (snla->ads == NULL) - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); ac->ads = snla->ads; /* sync settings with current view status, then return appropriate data */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - snla->ads->source= (ID *)ac->scene; + snla->ads->source = (ID *)ac->scene; snla->ads->filterflag |= ADS_FILTER_ONLYNLA; - ac->datatype= ANIMCONT_NLA; - ac->data= snla->ads; + ac->datatype = ANIMCONT_NLA; + ac->data = snla->ads; return 1; } @@ -264,31 +274,31 @@ static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla) short ANIM_animdata_context_getdata(bAnimContext *ac) { SpaceLink *sl = ac->sl; - short ok= 0; + short ok = 0; /* context depends on editor we are currently in */ if (sl) { switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)sl; - ok= actedit_get_context(ac, saction); + SpaceAction *saction = (SpaceAction *)sl; + ok = actedit_get_context(ac, saction); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)sl; - ok= graphedit_get_context(ac, sipo); + SpaceIpo *sipo = (SpaceIpo *)sl; + ok = graphedit_get_context(ac, sipo); } - break; + break; case SPACE_NLA: { - SpaceNla *snla= (SpaceNla *)sl; - ok= nlaedit_get_context(ac, snla); + SpaceNla *snla = (SpaceNla *)sl; + ok = nlaedit_get_context(ac, snla); } - break; + break; } } @@ -306,26 +316,26 @@ short ANIM_animdata_context_getdata(bAnimContext *ac) */ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - SpaceLink *sl= CTX_wm_space_data(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + SpaceLink *sl = CTX_wm_space_data(C); + Scene *scene = CTX_data_scene(C); /* clear old context info */ if (ac == NULL) return 0; memset(ac, 0, sizeof(bAnimContext)); /* get useful default context settings from context */ - ac->scene= scene; + ac->scene = scene; if (scene) { - ac->markers= ED_context_get_markers(C); - ac->obact= (scene->basact)? scene->basact->object : NULL; + ac->markers = ED_context_get_markers(C); + ac->obact = (scene->basact) ? scene->basact->object : NULL; } - ac->sa= sa; - ac->ar= ar; - ac->sl= sl; - ac->spacetype= (sa) ? sa->spacetype : 0; - ac->regiontype= (ar) ? ar->regiontype : 0; + ac->sa = sa; + ac->ar = ar; + ac->sl = sl; + ac->spacetype = (sa) ? sa->spacetype : 0; + ac->regiontype = (ar) ? ar->regiontype : 0; /* get data context info */ return ANIM_animdata_context_getdata(ac); @@ -346,28 +356,28 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * dealt with by the recursive detection idiom in place. * * Implementation Note: - * YES the _doSubChannels variable is NOT read anywhere. BUT, this is NOT an excuse - * to go steamrolling the logic into a single-line expression as from experience, - * those are notoriously difficult to read + debug when extending later on. The code - * below is purposefully laid out so that each case noted above corresponds clearly to - * one case below. + * YES the _doSubChannels variable is NOT read anywhere. BUT, this is NOT an excuse + * to go steamrolling the logic into a single-line expression as from experience, + * those are notoriously difficult to read + debug when extending later on. The code + * below is purposefully laid out so that each case noted above corresponds clearly to + * one case below. */ #define BEGIN_ANIMFILTER_SUBCHANNELS(expanded_check) \ { \ int _filter = filter_mode; \ short _doSubChannels = 0; \ if (!(filter_mode & ANIMFILTER_LIST_VISIBLE) || (expanded_check)) \ - _doSubChannels=1; \ + _doSubChannels = 1; \ else if (!(filter_mode & ANIMFILTER_LIST_CHANNELS)) \ - _doSubChannels=2; \ - else {\ + _doSubChannels = 2; \ + else { \ filter_mode |= ANIMFILTER_TMP_PEEK; \ } \ - \ + \ { \ (void) _doSubChannels; \ } - /* ... standard sub-channel filtering can go on here now ... */ +/* ... standard sub-channel filtering can go on here now ... */ #define END_ANIMFILTER_SUBCHANNELS \ filter_mode = _filter; \ } @@ -393,9 +403,9 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * - ListBase anim_data; * - bDopeSheet *ads; * - bAnimListElem *ale; - * - size_t items; + * - size_t items; * - * - id: ID block which should have an AnimData pointer following it immediately, to use + * - id: ID block which should have an AnimData pointer following it immediately, to use * - adtOk: line or block of code to execute for AnimData-blocks case (usually ANIMDATA_ADD_ANIMDATA) * - nlaOk: line or block of code to execute for NLA tracks+strips case * - driversOk: line or block of code to execute for Drivers case @@ -412,32 +422,32 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * 4) normal keyframes: only when there is an active action */ #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \ - {\ - if ((id)->adt) {\ - if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\ - if (filter_mode & ANIMFILTER_ANIMDATA) {\ - adtOk\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ - if (ANIMDATA_HAS_NLA(id)) {\ - nlaOk\ - }\ - else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ - nlaOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ - if (ANIMDATA_HAS_DRIVERS(id)) {\ - driversOk\ - }\ - }\ - else {\ - if (ANIMDATA_HAS_KEYS(id)) {\ - keysOk\ - }\ - }\ - }\ - }\ + { \ + if ((id)->adt) { \ + if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) { \ + if (filter_mode & ANIMFILTER_ANIMDATA) { \ + adtOk \ + } \ + else if (ads->filterflag & ADS_FILTER_ONLYNLA) { \ + if (ANIMDATA_HAS_NLA(id)) { \ + nlaOk \ + } \ + else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) { \ + nlaOk \ + } \ + } \ + else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) { \ + if (ANIMDATA_HAS_DRIVERS(id)) { \ + driversOk \ + } \ + } \ + else { \ + if (ANIMDATA_HAS_KEYS(id)) { \ + keysOk \ + } \ + } \ + } \ + } \ } /* ............................... */ @@ -452,10 +462,10 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) if (filter_mode & ANIMFILTER_TMP_PEEK) \ return 1; \ else { \ - bAnimListElem *ale= make_new_animlistelem(channel_data, channel_type, (ID *)owner_id); \ - if (ale) {\ + bAnimListElem *ale = make_new_animlistelem(channel_data, channel_type, (ID *)owner_id); \ + if (ale) { \ BLI_addtail(anim_data, ale); \ - items++; \ + items ++; \ ale_statement \ } \ } @@ -467,13 +477,13 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* quick macro to test if an anim-channel representing an AnimData block is suitably active */ #define ANIMCHANNEL_ACTIVEOK(ale) \ - ( !(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) ) + (!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) ) /* quick macro to test if an anim-channel (F-Curve, Group, etc.) is selected in an acceptable way */ #define ANIMCHANNEL_SELOK(test_func) \ - ( !(filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) || \ - ((filter_mode & ANIMFILTER_SEL) && test_func) || \ - ((filter_mode & ANIMFILTER_UNSEL) && test_func==0) ) + (!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \ + ((filter_mode & ANIMFILTER_SEL) && test_func) || \ + ((filter_mode & ANIMFILTER_UNSEL) && test_func == 0) ) /* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes * - _SELEDIT means that only selected curves will have visible+editable keyframes @@ -484,29 +494,29 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * 3) test_func (i.e. selection test) - only if selected, this test will pass */ #define ANIMCHANNEL_SELEDITOK(test_func) \ - ( !(filter_mode & ANIMFILTER_SELEDIT) || \ - !(filter_mode & ANIMFILTER_FOREDIT) || \ - (test_func) ) + (!(filter_mode & ANIMFILTER_SELEDIT) || \ + !(filter_mode & ANIMFILTER_FOREDIT) || \ + (test_func) ) /* ----------- 'Private' Stuff --------------- */ /* this function allocates memory for a new bAnimListElem struct for the * provided animation channel-data. */ -static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *owner_id) +static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owner_id) { - bAnimListElem *ale= NULL; + bAnimListElem *ale = NULL; /* only allocate memory if there is data to convert */ if (data) { /* allocate and set generic data */ - ale= MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); + ale = MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); - ale->data= data; - ale->type= datatype; + ale->data = data; + ale->type = datatype; - ale->id= owner_id; - ale->adt= BKE_animdata_from_id(owner_id); + ale->id = owner_id; + ale->adt = BKE_animdata_from_id(owner_id); /* do specifics */ switch (datatype) { @@ -515,201 +525,201 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own /* nothing to include for now... this is just a dummy wrappy around all the other channels * in the DopeSheet, and gets included at the start of the list */ - ale->key_data= NULL; - ale->datatype= ALE_ALL; + ale->key_data = NULL; + ale->datatype = ALE_ALL; } - break; + break; case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)data; + Scene *sce = (Scene *)data; - ale->flag= sce->flag; + ale->flag = sce->flag; - ale->key_data= sce; - ale->datatype= ALE_SCE; + ale->key_data = sce; + ale->datatype = ALE_SCE; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_OBJECT: { - Base *base= (Base *)data; - Object *ob= base->object; + Base *base = (Base *)data; + Object *ob = base->object; - ale->flag= ob->flag; + ale->flag = ob->flag; - ale->key_data= ob; - ale->datatype= ALE_OB; + ale->key_data = ob; + ale->datatype = ALE_OB; - ale->adt= BKE_animdata_from_id(&ob->id); + ale->adt = BKE_animdata_from_id(&ob->id); } - break; + break; case ANIMTYPE_FILLACTD: { - bAction *act= (bAction *)data; + bAction *act = (bAction *)data; - ale->flag= act->flag; + ale->flag = act->flag; - ale->key_data= act; - ale->datatype= ALE_ACT; + ale->key_data = act; + ale->datatype = ALE_ACT; } - break; + break; case ANIMTYPE_FILLDRIVERS: { - AnimData *adt= (AnimData *)data; + AnimData *adt = (AnimData *)data; - ale->flag= adt->flag; + ale->flag = adt->flag; - // XXX... drivers don't show summary for now - ale->key_data= NULL; - ale->datatype= ALE_NONE; + // XXX... drivers don't show summary for now + ale->key_data = NULL; + ale->datatype = ALE_NONE; } - break; + break; case ANIMTYPE_DSMAT: { - Material *ma= (Material *)data; - AnimData *adt= ma->adt; + Material *ma = (Material *)data; + AnimData *adt = ma->adt; - ale->flag= FILTER_MAT_OBJD(ma); + ale->flag = FILTER_MAT_OBJD(ma); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLAM: { - Lamp *la= (Lamp *)data; - AnimData *adt= la->adt; + Lamp *la = (Lamp *)data; + AnimData *adt = la->adt; - ale->flag= FILTER_LAM_OBJD(la); + ale->flag = FILTER_LAM_OBJD(la); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSCAM: { - Camera *ca= (Camera *)data; - AnimData *adt= ca->adt; + Camera *ca = (Camera *)data; + AnimData *adt = ca->adt; - ale->flag= FILTER_CAM_OBJD(ca); + ale->flag = FILTER_CAM_OBJD(ca); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSCUR: { - Curve *cu= (Curve *)data; - AnimData *adt= cu->adt; + Curve *cu = (Curve *)data; + AnimData *adt = cu->adt; - ale->flag= FILTER_CUR_OBJD(cu); + ale->flag = FILTER_CUR_OBJD(cu); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSARM: { - bArmature *arm= (bArmature *)data; - AnimData *adt= arm->adt; + bArmature *arm = (bArmature *)data; + AnimData *adt = arm->adt; - ale->flag= FILTER_ARM_OBJD(arm); + ale->flag = FILTER_ARM_OBJD(arm); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSMESH: { - Mesh *me= (Mesh *)data; - AnimData *adt= me->adt; + Mesh *me = (Mesh *)data; + AnimData *adt = me->adt; - ale->flag= FILTER_MESH_OBJD(me); + ale->flag = FILTER_MESH_OBJD(me); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLAT: { - Lattice *lt= (Lattice *)data; - AnimData *adt= lt->adt; + Lattice *lt = (Lattice *)data; + AnimData *adt = lt->adt; - ale->flag= FILTER_LATTICE_OBJD(lt); + ale->flag = FILTER_LATTICE_OBJD(lt); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSSPK: { - Speaker *spk= (Speaker *)data; - AnimData *adt= spk->adt; + Speaker *spk = (Speaker *)data; + AnimData *adt = spk->adt; - ale->flag= FILTER_SPK_OBJD(spk); + ale->flag = FILTER_SPK_OBJD(spk); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSSKEY: { - Key *key= (Key *)data; - AnimData *adt= key->adt; + Key *key = (Key *)data; + AnimData *adt = key->adt; - ale->flag= FILTER_SKE_OBJD(key); + ale->flag = FILTER_SKE_OBJD(key); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSWOR: { - World *wo= (World *)data; - AnimData *adt= wo->adt; + World *wo = (World *)data; + AnimData *adt = wo->adt; - ale->flag= FILTER_WOR_SCED(wo); + ale->flag = FILTER_WOR_SCED(wo); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSNTREE: { - bNodeTree *ntree= (bNodeTree *)data; - AnimData *adt= ntree->adt; + bNodeTree *ntree = (bNodeTree *)data; + AnimData *adt = ntree->adt; - ale->flag= FILTER_NTREE_DATA(ntree); + ale->flag = FILTER_NTREE_DATA(ntree); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLINESTYLE: { FreestyleLineStyle *linestyle= (FreestyleLineStyle *)data; @@ -725,110 +735,110 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own break; case ANIMTYPE_DSPART: { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= part->adt; + ParticleSettings *part = (ParticleSettings *)ale->data; + AnimData *adt = part->adt; - ale->flag= FILTER_PART_OBJD(part); + ale->flag = FILTER_PART_OBJD(part); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSTEX: { - Tex *tex= (Tex *)data; - AnimData *adt= tex->adt; + Tex *tex = (Tex *)data; + AnimData *adt = tex->adt; - ale->flag= FILTER_TEX_DATA(tex); + ale->flag = FILTER_TEX_DATA(tex); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)data; + bActionGroup *agrp = (bActionGroup *)data; - ale->flag= agrp->flag; + ale->flag = agrp->flag; - ale->key_data= NULL; - ale->datatype= ALE_GROUP; + ale->key_data = NULL; + ale->datatype = ALE_GROUP; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)data; + FCurve *fcu = (FCurve *)data; - ale->flag= fcu->flag; + ale->flag = fcu->flag; - ale->key_data= fcu; - ale->datatype= ALE_FCURVE; + ale->key_data = fcu; + ale->datatype = ALE_FCURVE; } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)data; - Key *key= (Key *)ale->id; + KeyBlock *kb = (KeyBlock *)data; + Key *key = (Key *)ale->id; - ale->flag= kb->flag; + ale->flag = kb->flag; /* whether we have keyframes depends on whether there is a Key block to find it from */ if (key) { /* index of shapekey is defined by place in key's list */ - ale->index= BLI_findindex(&key->block, kb); + ale->index = BLI_findindex(&key->block, kb); /* the corresponding keyframes are from the animdata */ if (ale->adt && ale->adt->action) { - bAction *act= ale->adt->action; + bAction *act = ale->adt->action; char *rna_path = key_get_curValue_rnaPath(key, kb); /* try to find the F-Curve which corresponds to this exactly, * then free the MEM_alloc'd string */ if (rna_path) { - ale->key_data= (void *)list_find_fcurve(&act->curves, rna_path, 0); + ale->key_data = (void *)list_find_fcurve(&act->curves, rna_path, 0); MEM_freeN(rna_path); } } - ale->datatype= (ale->key_data)? ALE_FCURVE : ALE_NONE; + ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE; } } - break; + break; case ANIMTYPE_GPLAYER: { - bGPDlayer *gpl= (bGPDlayer *)data; + bGPDlayer *gpl = (bGPDlayer *)data; - ale->flag= gpl->flag; + ale->flag = gpl->flag; - ale->key_data= NULL; - ale->datatype= ALE_GPFRAME; + ale->key_data = NULL; + ale->datatype = ALE_GPFRAME; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)data; + NlaTrack *nlt = (NlaTrack *)data; - ale->flag= nlt->flag; + ale->flag = nlt->flag; - ale->key_data= &nlt->strips; - ale->datatype= ALE_NLASTRIP; + ale->key_data = &nlt->strips; + ale->datatype = ALE_NLASTRIP; } - break; + break; case ANIMTYPE_NLAACTION: { /* nothing to include for now... nothing editable from NLA-perspective here */ - ale->key_data= NULL; - ale->datatype= ALE_NONE; + ale->key_data = NULL; + ale->datatype = ALE_NONE; } - break; + break; } } @@ -841,13 +851,13 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own /* 'Only Selected' selected data and/or 'Include Hidden' filtering * NOTE: when this function returns true, the F-Curve is to be skipped */ -static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) +static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) { /* hidden items should be skipped if we only care about visible data, but we aren't interested in hidden stuff */ short skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN); if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* only consider if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { @@ -855,15 +865,15 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* check whether to continue or skip */ if ((pchan) && (pchan->bone)) { /* if only visible channels, skip if bone not visible unless user wants channels from hidden data too */ if (skip_hidden) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; /* skipping - not visible on currently visible layers */ if ((arm->layer & pchan->bone->layer) == 0) @@ -886,18 +896,18 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ /* only consider if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { - if ((seq == NULL) || (seq->flag & SELECT)==0) + if ((seq == NULL) || (seq->flag & SELECT) == 0) return 1; } } @@ -911,13 +921,13 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ char *node_name; /* get strip name, and check if this strip is selected */ - node_name= BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { - if ((node) && (node->flag & NODE_SELECT)==0) + if ((node) && (node->flag & NODE_SELECT) == 0) return 1; } } @@ -928,7 +938,7 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ /* (Display-)Name-based F-Curve filtering * NOTE: when this function returns true, the F-Curve is to be skipped */ -static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) +static short skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, ID *owner_id) { bAnimListElem ale_dummy = {NULL}; bAnimChannelType *acf; @@ -957,14 +967,14 @@ static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) } /* find the next F-Curve that is usable for inclusion */ -static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) +static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) { FCurve *fcu = NULL; /* loop over F-Curves - assume that the caller of this has already checked that these should be included * NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too... */ - for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) { + for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) { /* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves: * - the 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data which * can be independently selected/hidden, such as Pose-Channels, Sequence Strips, and Nodes. @@ -974,7 +984,7 @@ static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGr * - this will also affect things like Drivers, and also works for Bone Constraints */ if (ads && owner_id) { - if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN)==0) { + if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) { if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) continue; } @@ -1006,7 +1016,7 @@ static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGr return NULL; } -static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) +static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) { FCurve *fcu; size_t items = 0; @@ -1028,7 +1038,7 @@ static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve * return items; } -static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *UNUSED(act), bActionGroup *agrp, int filter_mode, ID *owner_id) +static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *UNUSED(act), bActionGroup *agrp, int filter_mode, ID *owner_id) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1037,12 +1047,12 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope /* if we care about the selection status of the channels, * but the group isn't expanded (1)... - * (1) this only matters if we actually care about the hierarchy though. + * (1) this only matters if we actually care about the hierarchy though. * - Hierarchy matters: this hack should be applied * - Hierarchy ignored: cases like [#21276] won't work properly, unless we skip this hack */ - if ( ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp)==0) && /* care about hierarchy but group isn't expanded */ - (filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) ) /* care about selection status */ + if ( ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp) == 0) && /* care about hierarchy but group isn't expanded */ + (filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) ) /* care about selection status */ { /* if the group itself isn't selected appropriately, we shouldn't consider it's children either */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) @@ -1056,7 +1066,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope * - pasting keyframes * - creating ghost curves in Graph Editor */ - filter_mode &= ~(ANIMFILTER_SEL|ANIMFILTER_UNSEL|ANIMFILTER_LIST_VISIBLE); + filter_mode &= ~(ANIMFILTER_SEL | ANIMFILTER_UNSEL | ANIMFILTER_LIST_VISIBLE); } /* add grouped F-Curves */ @@ -1090,7 +1100,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope //filter_mode = ofilter; /* filter selection of channel specially here again, since may be open and not subject to previous test */ - if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) { + if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) { ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id); } } @@ -1105,7 +1115,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope return items; } -static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id) +static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id) { bActionGroup *agrp; FCurve *lastchan = NULL; @@ -1123,7 +1133,7 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* store reference to last channel of group */ if (agrp->channels.last) - lastchan= agrp->channels.last; + lastchan = agrp->channels.last; /* action group's channels */ items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id); @@ -1131,7 +1141,7 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe /* un-grouped F-Curves (only if we're not only considering those channels in the active group) */ if (!(filter_mode & ANIMFILTER_ACTGROUPED)) { - FCurve *firstfcu = (lastchan)? (lastchan->next) : (act->curves.first); + FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first); items += animfilter_fcurves(anim_data, ads, firstfcu, NULL, filter_mode, owner_id); } @@ -1147,10 +1157,10 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe * - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation * order, i.e. first to last. Otherwise, some tools may get screwed up. */ -static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) +static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) { NlaTrack *nlt; - NlaTrack *first=NULL, *next=NULL; + NlaTrack *first = NULL, *next = NULL; size_t items = 0; /* if showing channels, include active action */ @@ -1167,26 +1177,26 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo */ ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, { - ale->data= adt->action ? adt->action : NULL; + ale->data = adt->action ? adt->action : NULL; }); } } /* first track to include will be the last one if we're filtering by channels */ - first= adt->nla_tracks.last; + first = adt->nla_tracks.last; } else { /* first track to include will the the first one (as per normal) */ - first= adt->nla_tracks.first; + first = adt->nla_tracks.first; } /* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */ - for (nlt= first; nlt; nlt= next) { + for (nlt = first; nlt; nlt = next) { /* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) - next= nlt->prev; + next = nlt->prev; else - next= nlt->next; + next = nlt->next; /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now * - active track should still get shown though (even though it has disabled flag set) @@ -1212,14 +1222,14 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo } /* determine what animation data from AnimData block should get displayed */ -static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) +static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) { AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; /* image object datablocks have no anim-data so check for NULL */ if (adt) { - IdAdtTemplate *iat = (IdAdtTemplate*)id; + IdAdtTemplate *iat = (IdAdtTemplate *)id; /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed * in a few places in he rest of the code still - notably for the few cases where special mode-based @@ -1248,7 +1258,7 @@ static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDop /* Include ShapeKey Data for ShapeKey Editor */ -static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode) +static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode) { size_t items = 0; @@ -1257,7 +1267,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K KeyBlock *kb; /* loop through the channels adding ShapeKeys as appropriate */ - for (kb= key->block.first; kb; kb= kb->next) { + for (kb = key->block.first; kb; kb = kb->next) { /* skip the first one, since that's the non-animatable basis */ // XXX maybe in future this may become handy? if (kb == key->block.first) continue; @@ -1265,7 +1275,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) { /* only include this track if selected in a way consistent with the filtering requirements */ - if ( ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) { + if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) { // TODO: consider 'active' too? /* owner-id here must be key so that the F-Curve can be resolved... */ @@ -1282,7 +1292,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, key); } else if (key->adt->action) { - items= animfilter_action(ac, anim_data, NULL, key->adt->action, filter_mode, (ID *)key); + items = animfilter_action(ac, anim_data, NULL, key->adt->action, filter_mode, (ID *)key); } } } @@ -1291,15 +1301,15 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K return items; } -static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, int filter_mode) +static size_t animdata_filter_gpencil_data(ListBase *anim_data, bGPdata *gpd, int filter_mode) { bGPDlayer *gpl; size_t items = 0; /* loop over layers as the conditions are acceptable */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only if selected */ - if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) { + if (ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) { /* only if editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) { /* active... */ @@ -1316,7 +1326,7 @@ static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, i /* Grab all Grease Pencil datablocks in file */ // TODO: should this be amalgamated with the dopesheet filtering code? -static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode) +static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), int filter_mode) { bGPdata *gpd; size_t items = 0; @@ -1359,7 +1369,7 @@ static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), /* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */ // TODO: how to handle group nodes is still unclear... -static size_t animdata_filter_ds_nodetree (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) +static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1442,11 +1452,11 @@ static size_t animdata_filter_ds_linestyle (bAnimContext *ac, ListBase *anim_dat } /* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */ -static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) +static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) { MTex **mtex = NULL; - size_t items=0; - int a=0; + size_t items = 0; + int a = 0; /* get datatype specific data first */ if (owner_id == NULL) @@ -1455,22 +1465,22 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data switch (GS(owner_id->name)) { case ID_MA: { - Material *ma= (Material *)owner_id; - mtex= (MTex**)(&ma->mtex); + Material *ma = (Material *)owner_id; + mtex = (MTex **)(&ma->mtex); } - break; + break; case ID_LA: { - Lamp *la= (Lamp *)owner_id; - mtex= (MTex**)(&la->mtex); + Lamp *la = (Lamp *)owner_id; + mtex = (MTex **)(&la->mtex); } - break; + break; case ID_WO: { - World *wo= (World *)owner_id; - mtex= (MTex**)(&wo->mtex); + World *wo = (World *)owner_id; + mtex = (MTex **)(&wo->mtex); } - break; + break; default: { /* invalid/unsupported option */ @@ -1481,8 +1491,8 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data } /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */ - for (a=0; a < MAX_MTEX; a++) { - Tex *tex= (mtex[a]) ? mtex[a]->tex : NULL; + for (a = 0; a < MAX_MTEX; a++) { + Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1527,51 +1537,83 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data return items; } -static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) + +static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Material *ma, int filter_mode) { - size_t items=0; - int a=0; + ListBase tmp_data = {NULL, NULL}; + size_t tmp_items = 0; + size_t items = 0; - /* firstly check that we actuallly have some materials, by gathering all materials in a temp list */ - for (a=1; a <= ob->totcol; a++) { - Material *ma= give_current_material(ob, a); - ListBase tmp_data = {NULL, NULL}; - size_t tmp_items = 0; + /* add material's animation data to temp collection */ + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) + { + /* material's animation data */ + tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* textures */ + if (!(ads->filterflag & ADS_FILTER_NOTEX)) + tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* nodes */ + if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); + } + END_ANIMFILTER_SUBCHANNELS; + + /* did we find anything? */ + if (tmp_items) { + /* include material-expand widget first */ + // hmm... do we need to store the index of this material in the array anywhere? + if (filter_mode & ANIMFILTER_LIST_CHANNELS) { + /* check if filtering by active status */ + if (ANIMCHANNEL_ACTIVEOK(ma)) { + ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); + } + } - /* if no material returned, skip - so that we don't get weird blank entries... */ - if (ma == NULL) continue; + /* now add the list of collected channels */ + BLI_movelisttolist(anim_data, &tmp_data); + BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + items += tmp_items; + } + + return items; +} + +static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +{ + short has_nested = 0; + size_t items = 0; + int a = 0; + + /* first pass: take the materials referenced via the Material slots of the object */ + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); - /* add material's animation data to temp collection */ - BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) - { - /* material's animation data */ - tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* textures */ - if (!(ads->filterflag & ADS_FILTER_NOTEX)) - tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* nodes */ - if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) - tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); + /* if material is valid, try to add relevant contents from here */ + if (ma) { + /* add channels */ + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); + + /* for optimising second pass - check if there's a nested material here to come back for */ + if (has_nested == 0) + has_nested = give_node_material(ma) != NULL; } - END_ANIMFILTER_SUBCHANNELS; - - /* did we find anything? */ - if (tmp_items) { - /* include material-expand widget first */ - // hmm... do we need to store the index of this material in the array anywhere? - if (filter_mode & ANIMFILTER_LIST_CHANNELS) { - /* check if filtering by active status */ - if (ANIMCHANNEL_ACTIVEOK(ma)) { - ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); - } - } + } + + /* second pass: go through a second time looking for "nested" materials (material.material references) + * + * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are + * disappearing/not available, since the relationships between these is not that clear + */ + if (has_nested) { + for (a = 1; a <= ob->totcol; a++) { + Material *base = give_current_material(ob, a); + Material *ma = give_node_material(base); - /* now add the list of collected channels */ - BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); - items += tmp_items; + /* add channels from the nested material if it exists */ + if (ma) + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); } } @@ -1579,12 +1621,12 @@ static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_particles (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ParticleSystem *psys; - size_t items= 0; + size_t items = 0; - for (psys = ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1621,85 +1663,85 @@ static size_t animdata_filter_ds_particles (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - size_t items= 0; + size_t items = 0; - IdAdtTemplate *iat= ob->data; - short type=0, expanded=0; + IdAdtTemplate *iat = ob->data; + short type = 0, expanded = 0; /* get settings based on data type */ switch (ob->type) { case OB_CAMERA: /* ------- Camera ------------ */ { - Camera *ca= (Camera *)ob->data; + Camera *ca = (Camera *)ob->data; if (ads->filterflag & ADS_FILTER_NOCAM) return 0; - type= ANIMTYPE_DSCAM; - expanded= FILTER_CAM_OBJD(ca); + type = ANIMTYPE_DSCAM; + expanded = FILTER_CAM_OBJD(ca); } - break; + break; case OB_LAMP: /* ---------- Lamp ----------- */ { - Lamp *la= (Lamp *)ob->data; + Lamp *la = (Lamp *)ob->data; if (ads->filterflag & ADS_FILTER_NOLAM) return 0; - type= ANIMTYPE_DSLAM; - expanded= FILTER_LAM_OBJD(la); + type = ANIMTYPE_DSLAM; + expanded = FILTER_LAM_OBJD(la); } - break; + break; case OB_CURVE: /* ------- Curve ---------- */ case OB_SURF: /* ------- Nurbs Surface ---------- */ case OB_FONT: /* ------- Text Curve ---------- */ { - Curve *cu= (Curve *)ob->data; + Curve *cu = (Curve *)ob->data; if (ads->filterflag & ADS_FILTER_NOCUR) return 0; - type= ANIMTYPE_DSCUR; - expanded= FILTER_CUR_OBJD(cu); + type = ANIMTYPE_DSCUR; + expanded = FILTER_CUR_OBJD(cu); } - break; + break; case OB_MBALL: /* ------- MetaBall ---------- */ { - MetaBall *mb= (MetaBall *)ob->data; + MetaBall *mb = (MetaBall *)ob->data; if (ads->filterflag & ADS_FILTER_NOMBA) return 0; - type= ANIMTYPE_DSMBALL; - expanded= FILTER_MBALL_OBJD(mb); + type = ANIMTYPE_DSMBALL; + expanded = FILTER_MBALL_OBJD(mb); } - break; + break; case OB_ARMATURE: /* ------- Armature ---------- */ { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; if (ads->filterflag & ADS_FILTER_NOARM) return 0; - type= ANIMTYPE_DSARM; - expanded= FILTER_ARM_OBJD(arm); + type = ANIMTYPE_DSARM; + expanded = FILTER_ARM_OBJD(arm); } - break; + break; case OB_MESH: /* ------- Mesh ---------- */ { - Mesh *me= (Mesh *)ob->data; + Mesh *me = (Mesh *)ob->data; if (ads->filterflag & ADS_FILTER_NOMESH) return 0; - type= ANIMTYPE_DSMESH; - expanded= FILTER_MESH_OBJD(me); + type = ANIMTYPE_DSMESH; + expanded = FILTER_MESH_OBJD(me); } - break; + break; case OB_LATTICE: /* ---- Lattice ---- */ { Lattice *lt = (Lattice *)ob->data; @@ -1707,18 +1749,18 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, if (ads->filterflag & ADS_FILTER_NOLAT) return 0; - type= ANIMTYPE_DSLAT; - expanded= FILTER_LATTICE_OBJD(lt); + type = ANIMTYPE_DSLAT; + expanded = FILTER_LATTICE_OBJD(lt); } - break; + break; case OB_SPEAKER: /* ---------- Speaker ----------- */ { - Speaker *spk= (Speaker *)ob->data; + Speaker *spk = (Speaker *)ob->data; - type= ANIMTYPE_DSSPK; - expanded= FILTER_SPK_OBJD(spk); + type = ANIMTYPE_DSSPK; + expanded = FILTER_SPK_OBJD(spk); } - break; + break; } /* add object data animation channels */ @@ -1729,13 +1771,13 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, /* sub-data filtering... */ switch (ob->type) { - case OB_LAMP: /* lamp - textures */ + case OB_LAMP: /* lamp - textures */ { /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, ob->data, filter_mode); } - break; + break; } } END_ANIMFILTER_SUBCHANNELS; @@ -1761,7 +1803,7 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, } /* shapekey-level animation */ -static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode) +static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1795,27 +1837,27 @@ static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, } /* object-level animation */ -static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; AnimData *adt = ob->adt; - short type=0, expanded=1; + short type = 0, expanded = 1; void *cdata = NULL; /* determine the type of expander channels to use */ // this is the best way to do this for now... ANIMDATA_FILTER_CASES(ob, - {/* AnimData - no channel, but consider data */}, - {/* NLA - no channel, but consider data */}, - {/* Drivers */ + { /* AnimData - no channel, but consider data */ }, + { /* NLA - no channel, but consider data */ }, + { /* Drivers */ type = ANIMTYPE_FILLDRIVERS; cdata = adt; expanded = EXPANDED_DRVD(adt); }, - {/* Keyframes */ + { /* Keyframes */ type = ANIMTYPE_FILLACTD; cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); @@ -1850,17 +1892,17 @@ static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, } /* get animation channels from object2 */ -static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode) +static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode) { ListBase tmp_data = {NULL, NULL}; - Object *ob= base->object; + Object *ob = base->object; size_t tmp_items = 0; size_t items = 0; /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob)) { - Key *key= ob_get_key(ob); + Key *key = ob_get_key(ob); /* object-level animation */ if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { @@ -1914,7 +1956,7 @@ static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode) +static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1956,27 +1998,27 @@ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, b return items; } -static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) +static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; AnimData *adt = sce->adt; - short type=0, expanded=1; + short type = 0, expanded = 1; void *cdata = NULL; /* determine the type of expander channels to use */ // this is the best way to do this for now... ANIMDATA_FILTER_CASES(sce, - {/* AnimData - no channel, but consider data */}, - {/* NLA - no channel, but consider data */}, - {/* Drivers */ + { /* AnimData - no channel, but consider data */}, + { /* NLA - no channel, but consider data */}, + { /* Drivers */ type = ANIMTYPE_FILLDRIVERS; cdata = adt; expanded = EXPANDED_DRVD(adt); }, - {/* Keyframes */ + { /* Keyframes */ type = ANIMTYPE_FILLACTD; cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); @@ -2010,7 +2052,7 @@ static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, b return items; } -static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) +static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -2019,8 +2061,8 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce)) { - bNodeTree *ntree= sce->nodetree; - World *wo= sce->world; + bNodeTree *ntree = sce->nodetree; + World *wo = sce->world; /* Action, Drivers, or NLA for Scene */ if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) { @@ -2068,17 +2110,17 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ } // TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted) -static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) +static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) { - Scene *sce= (Scene *)ads->source; + Scene *sce = (Scene *)ads->source; Base *base; size_t items = 0; /* check that we do indeed have a scene */ - if ((ads->source == NULL) || (GS(ads->source->name)!=ID_SCE)) { + if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) { printf("DopeSheet Error: Not scene!\n"); if (G.debug & G_DEBUG) - printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source)?ads->source->name:NULL); + printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL); return 0; } @@ -2094,10 +2136,10 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, items += animdata_filter_dopesheet_scene(ac, anim_data, ads, sce, filter_mode); /* loop over all bases (i.e.objects) in the scene */ - for (base= sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { /* check if there's an object (all the relevant checks are done in the ob-function) */ if (base->object) { - Object *ob= base->object; + Object *ob = base->object; /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility @@ -2110,7 +2152,7 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((sce->lay & (ob->lay|base->lay))==0) continue; + if ((sce->lay & (ob->lay | base->lay)) == 0) continue; /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) continue; @@ -2149,9 +2191,9 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, } /* Summary track for DopeSheet/Action Editor - * - return code is whether the summary lets the other channels get drawn + * - return code is whether the summary lets the other channels get drawn */ -static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items) +static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items) { bDopeSheet *ads = NULL; @@ -2161,8 +2203,8 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim * being applicable. */ if ((ac && ac->sl) && (ac->spacetype == SPACE_ACTION)) { - SpaceAction *saction= (SpaceAction *)ac->sl; - ads= &saction->ads; + SpaceAction *saction = (SpaceAction *)ac->sl; + ads = &saction->ads; } else { /* invalid space type - skip this summary channels */ @@ -2174,7 +2216,7 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim * - only useful for DopeSheet/Action/etc. editors where it is actually useful */ if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) { - bAnimListElem *ale= make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL); + bAnimListElem *ale = make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL); if (ale) { BLI_addtail(anim_data, ale); (*items)++; @@ -2194,7 +2236,7 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim /* ......................... */ /* filter data associated with a channel - usually for handling summary-channels in DopeSheet */ -static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) +static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) { size_t items = 0; @@ -2220,14 +2262,14 @@ static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, b /* ----------- Cleanup API --------------- */ /* Remove entries with invalid types in animation channel list */ -static size_t animdata_filter_remove_invalid (ListBase *anim_data) +static size_t animdata_filter_remove_invalid(ListBase *anim_data) { bAnimListElem *ale, *next; size_t items = 0; /* only keep entries with valid types */ - for (ale= anim_data->first; ale; ale= next) { - next= ale->next; + for (ale = anim_data->first; ale; ale = next) { + next = ale->next; if (ale->type == ANIMTYPE_NONE) BLI_freelinkN(anim_data, ale); @@ -2239,7 +2281,7 @@ static size_t animdata_filter_remove_invalid (ListBase *anim_data) } /* Remove duplicate entries in animation channel list */ -static size_t animdata_filter_remove_duplis (ListBase *anim_data) +static size_t animdata_filter_remove_duplis(ListBase *anim_data) { bAnimListElem *ale, *next; GHash *gh; @@ -2248,7 +2290,7 @@ static size_t animdata_filter_remove_duplis (ListBase *anim_data) /* build new hashtable to efficiently store and retrieve which entries have been * encountered already while searching */ - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh"); /* loop through items, removing them from the list if a similar item occurs already */ for (ale = anim_data->first; ale; ale = next) { @@ -2281,7 +2323,7 @@ static size_t animdata_filter_remove_duplis (ListBase *anim_data) /* This function filters the active data source to leave only animation channels suitable for * usage by the caller. It will return the length of the list * - * *anim_data: is a pointer to a ListBase, to which the filtered animation channels + * *anim_data: is a pointer to a ListBase, to which the filtered animation channels * will be placed for use. * filter_mode: how should the data be filtered - bitmapping accessed flags */ @@ -2294,31 +2336,31 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* firstly filter the data */ switch (datatype) { - case ANIMCONT_ACTION: /* 'Action Editor' */ + case ANIMCONT_ACTION: /* 'Action Editor' */ { - Object *obact= ac->obact; + Object *obact = ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; - bDopeSheet *ads = (saction)? &saction->ads : NULL; + bDopeSheet *ads = (saction) ? &saction->ads : NULL; /* the check for the DopeSheet summary is included here since the summary works here too */ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); } - break; + break; case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ { /* the check for the DopeSheet summary is included here since the summary works here too */ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) - items= animdata_filter_shapekey(ac, anim_data, data, filter_mode); + items = animdata_filter_shapekey(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_GPENCIL: { - items= animdata_filter_gpencil(anim_data, data, filter_mode); + items = animdata_filter_gpencil(anim_data, data, filter_mode); } - break; + break; case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ { @@ -2326,7 +2368,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_FCURVES: /* Graph Editor -> FCurves/Animation Editing */ case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */ @@ -2335,7 +2377,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* all of these editors use the basic DopeSheet data for filtering options, but don't have all the same features */ items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_CHANNEL: /* animation channel */ { @@ -2344,7 +2386,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* based on the channel type, filter relevant data for this */ items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode); } - break; + break; } /* remove any 'weedy' entries */ diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index bfc70c79404..7d1209a3033 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -40,14 +40,14 @@ extern ListBase builtin_keyingsets; /* Main Keyframe Management operators: * These handle keyframes management from various spaces. They only make use of - * Keying Sets. + * Keying Sets. */ void ANIM_OT_keyframe_insert(struct wmOperatorType *ot); void ANIM_OT_keyframe_delete(struct wmOperatorType *ot); /* Main Keyframe Management operators: * These handle keyframes management from various spaces. They will handle the menus - * required for each space. + * required for each space. */ void ANIM_OT_keyframe_insert_menu(struct wmOperatorType *ot); void ANIM_OT_keyframe_delete_v3d(struct wmOperatorType *ot); diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 4be3f79060e..593010fae09 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -78,9 +78,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* try to resolve the path */ if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { - const char *structname=NULL, *propname=NULL; + const char *structname = NULL, *propname = NULL; char arrayindbuf[16]; - const char *arrayname=NULL; + const char *arrayname = NULL; short free_structname = 0; /* For now, name will consist of 3 parts: struct-name, property name, array index @@ -104,44 +104,44 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) */ if (strstr(fcu->rna_path, "bones") && strstr(fcu->rna_path, "constraints")) { /* perform string 'chopping' to get "Bone Name : Constraint Name" */ - char *pchanName= BLI_getQuotedStr(fcu->rna_path, "bones["); - char *constName= BLI_getQuotedStr(fcu->rna_path, "constraints["); + char *pchanName = BLI_getQuotedStr(fcu->rna_path, "bones["); + char *constName = BLI_getQuotedStr(fcu->rna_path, "constraints["); /* assemble the string to display in the UI... */ - structname= BLI_sprintfN("%s : %s", pchanName, constName); - free_structname= 1; + structname = BLI_sprintfN("%s : %s", pchanName, constName); + free_structname = 1; /* free the temp names */ if (pchanName) MEM_freeN(pchanName); if (constName) MEM_freeN(constName); } else if (ptr.data != ptr.id.data) { - PropertyRNA *nameprop= RNA_struct_name_property(ptr.type); + PropertyRNA *nameprop = RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ - structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); - free_structname= 1; + structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); + free_structname = 1; } else - structname= RNA_struct_ui_name(ptr.type); + structname = RNA_struct_ui_name(ptr.type); } /* Property Name is straightforward */ - propname= RNA_property_ui_name(prop); + propname = RNA_property_ui_name(prop); /* Array Index - only if applicable */ if (RNA_property_array_length(&ptr, prop)) { - char c= RNA_property_array_item_char(prop, fcu->array_index); + char c = RNA_property_array_item_char(prop, fcu->array_index); /* we need to write the index to a temp buffer (in py syntax) */ if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c); else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index); - arrayname= &arrayindbuf[0]; + arrayname = &arrayindbuf[0]; } else { /* no array index */ - arrayname= ""; + arrayname = ""; } /* putting this all together into the buffer */ @@ -160,7 +160,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* Icon for this property's owner: * use the struct's icon if it is set */ - icon= RNA_struct_ui_icon(ptr.type); + icon = RNA_struct_ui_icon(ptr.type); /* valid path - remove the invalid tag since we now know how to use it saving * users manual effort to reenable using "Revive Disabled FCurves" [#29629] @@ -173,7 +173,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* icon for this should be the icon for the base ID */ // TODO: or should we just use the error icon? - icon= RNA_struct_ui_icon(id_ptr.type); + icon = RNA_struct_ui_icon(id_ptr.type); /* tag F-Curve as disabled - as not usable path */ fcu->flag |= FCURVE_DISABLED; @@ -187,7 +187,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* ------------------------------- Color Codes for F-Curve Channels ---------------------------- */ /* step between the major distinguishable color bands of the primary colors */ -#define HSV_BANDWIDTH 0.3f +#define HSV_BANDWIDTH 0.3f /* used to determine the color of F-Curves with FCURVE_COLOR_AUTO_RAINBOW set */ //void fcurve_rainbow (unsigned int cur, unsigned int tot, float *out) @@ -202,8 +202,8 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out) * 4 - for 'even' numbers of curves - there should be a majority of quartets of curves * so the base color is simply one of the three primary colors */ - grouping= (4 - (tot % 2)); - hue= HSV_BANDWIDTH * (float)(cur % grouping); + grouping = (4 - (tot % 2)); + hue = HSV_BANDWIDTH * (float)(cur % grouping); /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be * 'darker' (i.e. smaller value), so that they don't look that similar to previous ones. @@ -214,15 +214,15 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out) /* the base color can get offset a bit so that the colors aren't so identical */ hue += fac * HSV_BANDWIDTH; - if (hue > 1.0f) hue= fmod(hue, 1.0f); + if (hue > 1.0f) hue = fmod(hue, 1.0f); /* saturation adjustments for more visible range */ - if ((hue > 0.5f) && (hue < 0.8f)) sat= 0.5f; - else sat= 0.6f; + if ((hue > 0.5f) && (hue < 0.8f)) sat = 0.5f; + else sat = 0.6f; /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ - val= 1.0f; + val = 1.0f; /* finally, conver this to RGB colors */ - hsv_to_rgb(hue, sat, val, out, out+1, out+2); + hsv_to_rgb(hue, sat, val, out, out + 1, out + 2); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2527cb7eb40..ea344e7e332 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -81,7 +81,7 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa) SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* local markers can only be shown when there's only a single active action to grab them from - * - flag only takes effect when there's an action, otherwise it can get too confusing? + * - flag only takes effect when there's an action, otherwise it can get too confusing? */ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) { if (saction->flag & SACTION_POSEMARKERS_SHOW) { @@ -139,23 +139,23 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f case TFM_TIME_EXTEND: { /* apply delta if marker is on the right side of the current frame */ - if ((side=='B') || - (side=='L' && marker->frame < cfra) || - (side=='R' && marker->frame >= cfra)) + if ((side == 'B') || + (side == 'L' && marker->frame < cfra) || + (side == 'R' && marker->frame >= cfra)) { marker->frame += (int)floorf(value + 0.5f); changed++; } } - break; + break; case TFM_TIME_SCALE: { /* rescale the distance between the marker and the current frame */ - marker->frame= cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); + marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); changed++; } - break; + break; } } } @@ -167,18 +167,18 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f /* Get the marker that is closest to this point */ /* XXX for select, the min_dist should be small */ -TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) +TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x) { - TimeMarker *marker, *nearest=NULL; - float dist, min_dist= 1000000; + TimeMarker *marker, *nearest = NULL; + float dist, min_dist = 1000000; if (markers) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { dist = ABS((float)marker->frame - x); if (dist < min_dist) { - min_dist= dist; - nearest= marker; + min_dist = dist; + nearest = marker; } } } @@ -189,7 +189,7 @@ TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) /* Return the time of the marker that occurs on a frame closest to the given time */ int ED_markers_find_nearest_marker_time(ListBase *markers, float x) { - TimeMarker *nearest= ED_markers_find_nearest_marker(markers, x); + TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x); return (nearest) ? (nearest->frame) : (int)floor(x + 0.5f); } @@ -209,11 +209,11 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la } if (markers->first && markers->last) { - TimeMarker *fm= markers->first; - TimeMarker *lm= markers->last; + TimeMarker *fm = markers->first; + TimeMarker *lm = markers->last; - min= (float)fm->frame; - max= (float)lm->frame; + min = (float)fm->frame; + max = (float)lm->frame; } else { *first = 0.0f; @@ -223,39 +223,39 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la /* count how many markers are usable - see later */ if (sel) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) selcount++; } } else - selcount= BLI_countlist(markers); + selcount = BLI_countlist(markers); /* if only selected are to be considered, only consider the selected ones * (optimization for not searching list) */ if (selcount > 1) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (sel) { if (marker->flag & SELECT) { if (marker->frame < min) - min= (float)marker->frame; + min = (float)marker->frame; if (marker->frame > max) - max= (float)marker->frame; + max = (float)marker->frame; } } else { if (marker->frame < min) - min= (float)marker->frame; + min = (float)marker->frame; if (marker->frame > max) - max= (float)marker->frame; + max = (float)marker->frame; } } } /* set the min/max values */ - *first= min; - *last= max; + *first = min; + *last = max; } /* --------------------------------- */ @@ -266,26 +266,26 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only CfraElem *ce, *cen; /* should this one only be considered if it is selected? */ - if ((only_sel) && ((marker->flag & SELECT)==0)) + if ((only_sel) && ((marker->flag & SELECT) == 0)) return; /* insertion sort - try to find a previous cfra elem */ - for (ce= lb->first; ce; ce= ce->next) { + for (ce = lb->first; ce; ce = ce->next) { if (ce->cfra == marker->frame) { /* do because of double keys */ if (marker->flag & SELECT) - ce->sel= marker->flag; + ce->sel = marker->flag; return; } else if (ce->cfra > marker->frame) break; } - cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); + cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); else BLI_addtail(lb, cen); - cen->cfra= marker->frame; - cen->sel= marker->flag; + cen->cfra = marker->frame; + cen->sel = marker->flag; } /* This function makes a list of all the markers. The only_sel @@ -299,7 +299,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) if (markers == NULL) return; - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) add_marker_to_cfra_elem(lb, marker, only_sel); } @@ -349,15 +349,15 @@ void debug_markers_print_list(ListBase *markers) static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) { float xpos, ypixels, xscale, yscale; - int icon_id= 0; + int icon_id = 0; xpos = marker->frame; /* no time correction for framelen! space is drawn with old values */ - ypixels= v2d->mask.ymax-v2d->mask.ymin; + ypixels = v2d->mask.ymax - v2d->mask.ymin; UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -377,8 +377,8 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) glColor4ub(0, 0, 0, 96); glBegin(GL_LINES); - glVertex2f((xpos*xscale)+0.5f, 12.0f); - glVertex2f((xpos*xscale)+0.5f, (v2d->cur.ymax+12.0f)*yscale); + glVertex2f((xpos * xscale) + 0.5f, 12.0f); + glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); glEnd(); setlinestyle(0); @@ -386,16 +386,16 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* 5 px to offset icon to align properly, space / pixels corrects for zoom */ if (flag & DRAW_MARKERS_LOCAL) { - icon_id= (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : - (marker->flag & SELECT) ? ICON_PMARKER_SEL : - ICON_PMARKER; + icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : + (marker->flag & SELECT) ? ICON_PMARKER_SEL : + ICON_PMARKER; } else { - icon_id= (marker->flag & SELECT) ? ICON_MARKER_HLT : - ICON_MARKER; + icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : + ICON_MARKER; } - UI_icon_draw(xpos*xscale-5.0f, 16.0f, icon_id); + UI_icon_draw(xpos * xscale - 5.0f, 16.0f, icon_id); glDisable(GL_BLEND); @@ -405,18 +405,18 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) if (marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); - x= xpos*xscale + 4.0f; - y= (ypixels <= 39.0f)? (ypixels-10.0f) : 29.0f; + x = xpos * xscale + 4.0f; + y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f; } else { UI_ThemeColor(TH_TEXT); - if ((marker->frame <= cfra) && (marker->frame+5 > cfra)) { - x= xpos*xscale + 4.0f; - y= (ypixels <= 39.0f)? (ypixels - 10.0f) : 29.0f; + if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { + x = xpos * xscale + 4.0f; + y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f; } else { - x= xpos*xscale + 4.0f; - y= 17.0f; + x = xpos * xscale + 4.0f; + y = 17.0f; } } @@ -424,7 +424,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { float col[4]; glGetFloatv(GL_CURRENT_COLOR, col); - col[3]= 0.4; + col[3] = 0.4; glColor4fv(col); } #endif @@ -438,7 +438,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* Draw Scene-Markers in time window */ void draw_markers_time(const bContext *C, int flag) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); View2D *v2d; TimeMarker *marker; Scene *scene; @@ -450,14 +450,14 @@ void draw_markers_time(const bContext *C, int flag) v2d = UI_view2d_fromcontext(C); /* unselected markers are drawn at the first time */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if ((marker->flag & SELECT) == 0) { draw_marker(v2d, marker, scene->r.cfra, flag); } } /* selected markers are drawn later */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { draw_marker(v2d, marker, scene->r.cfra, flag); } @@ -549,32 +549,32 @@ static int ed_markers_opwrap_invoke(bContext *C, wmOperator *op, wmEvent *evt) /* add TimeMarker at curent frame */ static int ed_marker_add(bContext *C, wmOperator *UNUSED(op)) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; - int frame= CTX_data_scene(C)->r.cfra; + int frame = CTX_data_scene(C)->r.cfra; if (markers == NULL) return OPERATOR_CANCELLED; /* prefer not having 2 markers at the same place, * though the user can move them to overlap once added */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->frame == frame) return OPERATOR_CANCELLED; } /* deselect all */ - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) marker->flag &= ~SELECT; marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); - marker->flag= SELECT; - marker->frame= frame; + marker->flag = SELECT; + marker->frame = frame; BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only BLI_addtail(markers, marker); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -592,7 +592,7 @@ static void MARKER_OT_add(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** transform markers *************************** */ @@ -623,7 +623,7 @@ static void MARKER_OT_add(wmOperatorType *ot) typedef struct MarkerMove { SpaceLink *slink; ListBase *markers; - int event_type; /* store invoke-event, to verify */ + int event_type; /* store invoke-event, to verify */ int *oldframe, evtx, firstx; NumInput num; } MarkerMove; @@ -632,32 +632,32 @@ typedef struct MarkerMove { /* return 0 if not OK */ static int ed_marker_move_init(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); MarkerMove *mm; TimeMarker *marker; - int totmark=0; + int totmark = 0; int a; if (markers == NULL) return 0; - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) if (marker->flag & SELECT) totmark++; - if (totmark==0) return 0; + if (totmark == 0) return 0; - op->customdata= mm= MEM_callocN(sizeof(MarkerMove), "Markermove"); - mm->slink= CTX_wm_space_data(C); - mm->markers= markers; - mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe"); + op->customdata = mm = MEM_callocN(sizeof(MarkerMove), "Markermove"); + mm->slink = CTX_wm_space_data(C); + mm->markers = markers; + mm->oldframe = MEM_callocN(totmark * sizeof(int), "MarkerMove oldframe"); initNumInput(&mm->num); mm->num.idx_max = 0; /* one axis */ mm->num.flag |= NUM_NO_FRACTION; mm->num.increment = 1.0f; - for (a=0, marker= markers->first; marker; marker= marker->next) { + for (a = 0, marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - mm->oldframe[a]= marker->frame; + mm->oldframe[a] = marker->frame; a++; } } @@ -668,12 +668,12 @@ static int ed_marker_move_init(bContext *C, wmOperator *op) /* free stuff */ static void ed_marker_move_exit(bContext *C, wmOperator *op) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; /* free data */ MEM_freeN(mm->oldframe); MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; /* clear custom header prints */ ED_area_headerprint(CTX_wm_area(C), NULL); @@ -682,11 +682,11 @@ static void ed_marker_move_exit(bContext *C, wmOperator *op) static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) { if (ed_marker_move_init(C, op)) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; - mm->evtx= evt->x; - mm->firstx= evt->x; - mm->event_type= evt->type; + mm->evtx = evt->x; + mm->firstx = evt->x; + mm->event_type = evt->type; /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -708,14 +708,14 @@ static int ed_marker_move_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *e /* note, init has to be called succesfully */ static void ed_marker_move_apply(wmOperator *op) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; TimeMarker *marker; int a, offs; - offs= RNA_int_get(op->ptr, "frames"); - for (a=0, marker= mm->markers->first; marker; marker= marker->next) { + offs = RNA_int_get(op->ptr, "frames"); + for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - marker->frame= mm->oldframe[a] + offs; + marker->frame = mm->oldframe[a] + offs; a++; } } @@ -728,8 +728,8 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op) ed_marker_move_apply(op); ed_marker_move_exit(C, op); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_CANCELLED; } @@ -738,10 +738,10 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op) static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) { - Scene *scene= CTX_data_scene(C); - MarkerMove *mm= op->customdata; - View2D *v2d= UI_view2d_fromcontext(C); - TimeMarker *marker, *selmarker=NULL; + Scene *scene = CTX_data_scene(C); + MarkerMove *mm = op->customdata; + View2D *v2d = UI_view2d_fromcontext(C); + TimeMarker *marker, *selmarker = NULL; float dx, fac; char str[256]; @@ -756,7 +756,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) ed_marker_move_cancel(C, op); return OPERATOR_CANCELLED; } - /* else continue; <--- see if release event should be caught for tweak-end */ + /* else continue; <--- see if release event should be caught for tweak-end */ case RETKEY: case PADENTER: @@ -764,8 +764,8 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) case MIDDLEMOUSE: if (WM_modal_tweak_exit(evt, mm->event_type)) { ed_marker_move_exit(C, op); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } break; @@ -773,44 +773,44 @@ 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 = v2d->mask.xmax - v2d->mask.xmin; + dx = (v2d->cur.xmax - v2d->cur.xmin) / dx; - if (evt->x != mm->evtx) { /* XXX maybe init for firsttime */ - int a, offs, totmark=0; + if (evt->x != mm->evtx) { /* XXX maybe init for first time */ + int a, offs, totmark = 0; - mm->evtx= evt->x; + mm->evtx = evt->x; - fac= ((float)(evt->x - mm->firstx)*dx); + fac = ((float)(evt->x - mm->firstx) * dx); if (mm->slink->spacetype == SPACE_TIME) - apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, FPS, 0.1*FPS, 0); + apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0); else apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/); - offs= (int)fac; + offs = (int)fac; RNA_int_set(op->ptr, "frames", offs); ed_marker_move_apply(op); /* cruft below is for header print */ - for (a=0, marker= mm->markers->first; marker; marker= marker->next) { + for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - selmarker= marker; + selmarker = marker; a++; totmark++; } } - if (totmark==1) { + if (totmark == 1) { /* we print current marker value */ if (mm->slink->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)mm->slink; + SpaceTime *stime = (SpaceTime *)mm->slink; if (stime->flag & TIME_DRAWFRAMES) BLI_snprintf(str, sizeof(str), "Marker %d offset %d", selmarker->frame, offs); else BLI_snprintf(str, sizeof(str), "Marker %.2f offset %.2f", FRA2TIME(selmarker->frame), FRA2TIME(offs)); } else if (mm->slink->spacetype == SPACE_ACTION) { - SpaceAction *saction= (SpaceAction *)mm->slink; + SpaceAction *saction = (SpaceAction *)mm->slink; if (saction->flag & SACTION_DRAWTIME) BLI_snprintf(str, sizeof(str), "Marker %.2f offset %.2f", FRA2TIME(selmarker->frame), FRA2TIME(offs)); else @@ -823,14 +823,14 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) else { /* we only print the offset */ if (mm->slink->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)mm->slink; + SpaceTime *stime = (SpaceTime *)mm->slink; if (stime->flag & TIME_DRAWFRAMES) BLI_snprintf(str, sizeof(str), "Marker offset %d ", offs); else BLI_snprintf(str, sizeof(str), "Marker offset %.2f ", FRA2TIME(offs)); } else if (mm->slink->spacetype == SPACE_ACTION) { - SpaceAction *saction= (SpaceAction *)mm->slink; + SpaceAction *saction = (SpaceAction *)mm->slink; if (saction->flag & SACTION_DRAWTIME) BLI_snprintf(str, sizeof(str), "Marker offset %.2f ", FRA2TIME(offs)); else @@ -841,13 +841,13 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); ED_area_headerprint(CTX_wm_area(C), str); } } - if (evt->val==KM_PRESS) { + if (evt->val == KM_PRESS) { float vec[3]; char str_tx[256]; @@ -862,8 +862,8 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) BLI_snprintf(str, sizeof(str), "Marker offset %s", str_tx); ED_area_headerprint(CTX_wm_area(C), str); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } } @@ -895,7 +895,7 @@ static void MARKER_OT_move(wmOperatorType *ot) ot->cancel = ed_marker_move_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); @@ -922,7 +922,7 @@ static void MARKER_OT_move(wmOperatorType *ot) /* duplicate selected TimeMarkers */ static void ed_marker_duplicate_apply(bContext *C) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *newmarker; if (markers == NULL) @@ -931,19 +931,19 @@ static void ed_marker_duplicate_apply(bContext *C) /* go through the list of markers, duplicate selected markers and add duplicated copies * to the beginning of the list (unselect original markers) */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; /* create and set up new marker */ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); - newmarker->flag= SELECT; - newmarker->frame= marker->frame; + newmarker->flag = SELECT; + newmarker->frame = marker->frame; BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); #ifdef DURIAN_CAMERA_SWITCH - newmarker->camera= marker->camera; + newmarker->camera = marker->camera; #endif /* new marker is added to the beginning of list */ @@ -956,7 +956,7 @@ static void ed_marker_duplicate_apply(bContext *C) static int ed_marker_duplicate_exec(bContext *C, wmOperator *op) { ed_marker_duplicate_apply(C); - ed_marker_move_exec(C, op); /* assumes frs delta set */ + ed_marker_move_exec(C, op); /* assumes frs delta set */ return OPERATOR_FINISHED; @@ -988,7 +988,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) ot->cancel = ed_marker_move_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); @@ -1000,9 +1000,9 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift) { TimeMarker *marker; - int select=0; + int select = 0; - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { /* if Shift is not set, then deselect Markers */ if (!shift) marker->flag &= ~SELECT; @@ -1019,20 +1019,20 @@ static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) { - ListBase *markers= ED_context_get_markers(C); - View2D *v2d= UI_view2d_fromcontext(C); + ListBase *markers = ED_context_get_markers(C); + View2D *v2d = UI_view2d_fromcontext(C); float viewx; int x, y, cfra; if (markers == NULL) return OPERATOR_PASS_THROUGH; - x= evt->x - CTX_wm_region(C)->winrct.xmin; - y= evt->y - CTX_wm_region(C)->winrct.ymin; + x = evt->x - CTX_wm_region(C)->winrct.xmin; + y = evt->y - CTX_wm_region(C)->winrct.ymin; UI_view2d_region_to_view(v2d, x, y, &viewx, NULL); - cfra= ED_markers_find_nearest_marker_time(markers, viewx); + cfra = ED_markers_find_nearest_marker_time(markers, viewx); if (extend) select_timeline_marker_frame(markers, cfra, 1); @@ -1042,25 +1042,25 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) #ifdef DURIAN_CAMERA_SWITCH if (camera) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Base *base; TimeMarker *marker; - int sel= 0; + int sel = 0; if (!extend) - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); - for (marker= markers->first; marker; marker= marker->next) { - if (marker->frame==cfra) { - sel= (marker->flag & SELECT); + for (marker = markers->first; marker; marker = marker->next) { + if (marker->frame == cfra) { + sel = (marker->flag & SELECT); break; } } - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->camera) { - if (marker->frame==cfra) { - base= object_in_scene(marker->camera, scene); + if (marker->frame == cfra) { + base = BKE_scene_base_find(scene, marker->camera); if (base) { ED_base_object_select(base, sel); if (sel) @@ -1070,25 +1070,25 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } #else (void)camera; #endif - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); /* allowing tweaks, but needs OPERATOR_FINISHED, otherwise renaming fails... [#25987] */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } static int ed_marker_select_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - short extend= RNA_boolean_get(op->ptr, "extend"); - short camera= 0; + short extend = RNA_boolean_get(op->ptr, "extend"); + short camera = 0; #ifdef DURIAN_CAMERA_SWITCH - camera= RNA_boolean_get(op->ptr, "camera"); + camera = RNA_boolean_get(op->ptr, "camera"); #endif return ed_marker_select(C, evt, extend, camera); } @@ -1110,7 +1110,7 @@ static void MARKER_OT_select(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); #ifdef DURIAN_CAMERA_SWITCH @@ -1128,29 +1128,29 @@ static void MARKER_OT_select(wmOperatorType *ot) * * callbacks: * - * exec() has to be filled in by user + * exec() has to be filled in by user * - * invoke() default WM function - * adds modal handler + * invoke() default WM function + * adds modal handler * - * modal() default WM function - * accept modal events while doing it, calls exec(), handles ESC and border drawing + * modal() default WM function + * accept modal events while doing it, calls exec(), handles ESC and border drawing * - * poll() has to be filled in by user for context + * poll() has to be filled in by user for context */ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) { - View2D *v2d= UI_view2d_fromcontext(C); - ListBase *markers= ED_context_get_markers(C); + View2D *v2d = UI_view2d_fromcontext(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; float xminf, xmaxf, yminf, ymaxf; - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - int xmin= RNA_int_get(op->ptr, "xmin"); - int xmax= RNA_int_get(op->ptr, "xmax"); - int ymin= RNA_int_get(op->ptr, "ymin"); - int ymax= RNA_int_get(op->ptr, "ymax"); - int extend= RNA_boolean_get(op->ptr, "extend"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + int xmin = RNA_int_get(op->ptr, "xmin"); + int xmax = RNA_int_get(op->ptr, "xmax"); + int ymin = RNA_int_get(op->ptr, "ymin"); + int ymax = RNA_int_get(op->ptr, "ymax"); + int extend = RNA_boolean_get(op->ptr, "extend"); UI_view2d_region_to_view(v2d, xmin, ymin, &xminf, &yminf); UI_view2d_region_to_view(v2d, xmax, ymax, &xmaxf, &ymaxf); @@ -1159,7 +1159,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) return 0; /* XXX marker context */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if ((marker->frame > xminf) && (marker->frame <= xmaxf)) { switch (gesture_mode) { case GESTURE_MODAL_SELECT: @@ -1175,8 +1175,8 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return 1; } @@ -1202,7 +1202,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -1212,7 +1212,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) static int ed_marker_select_all_exec(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; int action = RNA_enum_get(op->ptr, "action"); @@ -1223,22 +1223,22 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT; } - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { switch (action) { - case SEL_SELECT: - marker->flag |= SELECT; - break; - case SEL_DESELECT: - marker->flag &= ~SELECT; - break; - case SEL_INVERT: - marker->flag ^= SELECT; - break; + case SEL_SELECT: + marker->flag |= SELECT; + break; + case SEL_DESELECT: + marker->flag &= ~SELECT; + break; + case SEL_INVERT: + marker->flag ^= SELECT; + break; } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -1256,7 +1256,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_select_all(ot); @@ -1267,24 +1267,24 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /* remove selected TimeMarkers */ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *nmarker; - short changed= 0; + short changed = 0; if (markers == NULL) return OPERATOR_CANCELLED; - for (marker= markers->first; marker; marker= nmarker) { - nmarker= marker->next; + for (marker = markers->first; marker; marker = nmarker) { + nmarker = marker->next; if (marker->flag & SELECT) { BLI_freelinkN(markers, marker); - changed= 1; + changed = 1; } } if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } return OPERATOR_FINISHED; @@ -1309,7 +1309,7 @@ static void MARKER_OT_delete(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1318,13 +1318,13 @@ static void MARKER_OT_delete(wmOperatorType *ot) /* rename first selected TimeMarker */ static int ed_marker_rename_exec(bContext *C, wmOperator *op) { - TimeMarker *marker= ED_markers_get_first_selected(ED_context_get_markers(C)); + TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C)); if (marker) { RNA_string_get(op->ptr, "name", marker->name); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -1357,7 +1357,7 @@ static void MARKER_OT_rename(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker"); @@ -1368,11 +1368,11 @@ static void MARKER_OT_rename(wmOperatorType *ot) static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); - Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); + ListBase *markers = ED_context_get_markers(C); + Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); TimeMarker *marker, *marker_new; - if (scene_to==NULL) { + if (scene_to == NULL) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } @@ -1383,10 +1383,10 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) } /* copy markers */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - marker_new= MEM_dupallocN(marker); - marker_new->prev= marker_new->next = NULL; + marker_new = MEM_dupallocN(marker); + marker_new->prev = marker_new->next = NULL; BLI_addtail(&scene_to->markers, marker_new); } @@ -1410,10 +1410,10 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); + prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_itemf); ot->prop = prop; @@ -1424,25 +1424,25 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc= CTX_wm_screen(C); - Scene *scene= CTX_data_scene(C); + bScreen *sc = CTX_wm_screen(C); + Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; - marker= ED_markers_get_first_selected(markers); + marker = ED_markers_get_first_selected(markers); if (marker == NULL) return OPERATOR_CANCELLED; - marker->camera= ob; + marker->camera = ob; /* camera may have changes */ - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); BKE_screen_view3d_scene_sync(sc); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_SCENE|NA_EDITED, scene); /* so we get view3d redraws */ + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); /* so we get view3d redraws */ return OPERATOR_FINISHED; } @@ -1460,7 +1460,7 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } #endif @@ -1501,7 +1501,7 @@ void ED_marker_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "camera", TRUE); - kmi = WM_keymap_add_item(keymap, "MARKER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "MARKER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "camera", TRUE); #else diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 8286e81b792..119df33dd91 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -62,7 +62,7 @@ /* Check if the operator can be run from the current context */ static int change_frame_poll(bContext *C) { - ScrArea *curarea= CTX_wm_area(C); + ScrArea *curarea = CTX_wm_area(C); /* XXX temp? prevent changes during render */ if (G.rendering) return 0; @@ -77,17 +77,17 @@ static int change_frame_poll(bContext *C) /* Set the new frame number */ static void change_frame_apply(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); /* set the new frame number */ - CFRA= RNA_int_get(op->ptr, "frame"); + CFRA = RNA_int_get(op->ptr, "frame"); FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.f; /* do updates */ sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* ---- */ @@ -105,14 +105,14 @@ static int change_frame_exec(bContext *C, wmOperator *op) /* Get frame from mouse coordinates */ static int frame_from_event(bContext *C, wmEvent *event) { - ARegion *region= CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float viewx; /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL); /* round result to nearest int (frames are ints!) */ - return (int)floor(viewx+0.5f); + return (int)floor(viewx + 0.5f); } /* Modal Operator init */ @@ -150,7 +150,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event) /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ - if (event->val==KM_RELEASE) + if (event->val == KM_RELEASE) return OPERATOR_FINISHED; break; } @@ -172,7 +172,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -182,14 +182,14 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) static int previewrange_define_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); float sfra, efra; int xmin, xmax; /* get min/max values from border select rect (already in region coordinates, not screen) */ - xmin= RNA_int_get(op->ptr, "xmin"); - xmax= RNA_int_get(op->ptr, "xmax"); + xmin = RNA_int_get(op->ptr, "xmin"); + xmax = RNA_int_get(op->ptr, "xmax"); /* convert min/max values to frames (i.e. region to 'tot' rect) */ UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL); @@ -201,14 +201,14 @@ static int previewrange_define_exec(bContext *C, wmOperator *op) */ FRAMENUMBER_MIN_CLAMP(sfra); FRAMENUMBER_MIN_CLAMP(efra); - if (efra < sfra) efra= sfra; + if (efra < sfra) efra = sfra; scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(sfra + 0.5f); - scene->r.pefra= (int)floor(efra + 0.5f); + scene->r.psfra = (int)floor(sfra + 0.5f); + scene->r.pefra = (int)floor(efra + 0.5f); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -229,13 +229,13 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - /* used to define frame range */ + /* used to define frame range */ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX); - /* these are not used, but are needed by borderselect gesture operator stuff */ + /* these are not used, but are needed by borderselect gesture operator stuff */ RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); } @@ -244,8 +244,8 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - ScrArea *curarea= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *curarea = CTX_wm_area(C); /* sanity checks */ if (ELEM(NULL, scene, curarea)) @@ -253,8 +253,8 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* simply clear values */ scene->r.flag &= ~SCER_PRV_RANGE; - scene->r.psfra= 0; - scene->r.pefra= 0; + scene->r.psfra = 0; + scene->r.pefra = 0; ED_area_tag_redraw(curarea); @@ -274,7 +274,7 @@ static void ANIM_OT_previewrange_clear(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** registration **********************************/ @@ -319,7 +319,7 @@ void ED_keymap_anim(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* frame management */ - /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ + /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ WM_keymap_add_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index a4bc0cc854c..0cc92394a40 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -78,7 +78,7 @@ void free_anim_drivers_copybuf(void); * 1 - add new Driver FCurve, * -1 - add new Driver FCurve without driver stuff (for pasting) */ -FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_index, short add) +FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add) { AnimData *adt; FCurve *fcu; @@ -88,9 +88,9 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind return NULL; /* init animdata if none available yet */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) - adt= BKE_id_add_animdata(id); + adt = BKE_id_add_animdata(id); if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ return NULL; @@ -100,22 +100,22 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ - fcu= list_find_fcurve(&adt->drivers, rna_path, array_index); + fcu = list_find_fcurve(&adt->drivers, rna_path, array_index); if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); /* store path - make copy, and store that */ - fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); - fcu->array_index= array_index; + fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); + fcu->array_index = array_index; /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */ if (add > 0) { /* add some new driver data */ - fcu->driver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); + fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); /* add simple generator modifier for driver so that there is some visible representation */ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); @@ -133,7 +133,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind /* Driver Management API */ /* Main Driver Management API calls: - * Add a new driver for the specified property on the given ID block + * Add a new driver for the specified property on the given ID block */ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type) { @@ -147,18 +147,18 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* key entire array convenience method */ if (array_index == -1) { - array_index_max= RNA_property_array_length(&ptr, prop); - array_index= 0; + array_index_max = RNA_property_array_length(&ptr, prop); + array_index = 0; } else - array_index_max= array_index; + array_index_max = array_index; /* maximum index should be greater than the start index */ if (array_index == array_index_max) @@ -167,40 +167,40 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { /* create F-Curve with Driver */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 1); + fcu = verify_driver_fcurve(id, rna_path, array_index, 1); if (fcu && fcu->driver) { - ChannelDriver *driver= fcu->driver; + ChannelDriver *driver = fcu->driver; /* set the type of the driver */ - driver->type= type; + driver->type = type; /* creating drivers for buttons will create the driver(s) with type * "scripted expression" so that their values won't be lost immediately, * so here we copy those values over to the driver's expression */ if (type == DRIVER_TYPE_PYTHON) { - PropertyType proptype= RNA_property_type(prop); - int array= RNA_property_array_length(&ptr, prop); - char *expression= driver->expression; - int val, maxlen= sizeof(driver->expression); + PropertyType proptype = RNA_property_type(prop); + int array = RNA_property_array_length(&ptr, prop); + char *expression = driver->expression; + int val, maxlen = sizeof(driver->expression); float fval; if (proptype == PROP_BOOLEAN) { - if (!array) val= RNA_property_boolean_get(&ptr, prop); - else val= RNA_property_boolean_get_index(&ptr, prop, array_index); + if (!array) val = RNA_property_boolean_get(&ptr, prop); + else val = RNA_property_boolean_get_index(&ptr, prop, array_index); - BLI_strncpy(expression, (val)? "True": "False", maxlen); + BLI_strncpy(expression, (val) ? "True" : "False", maxlen); } else if (proptype == PROP_INT) { - if (!array) val= RNA_property_int_get(&ptr, prop); - else val= RNA_property_int_get_index(&ptr, prop, array_index); + if (!array) val = RNA_property_int_get(&ptr, prop); + else val = RNA_property_int_get_index(&ptr, prop, array_index); BLI_snprintf(expression, maxlen, "%d", val); } else if (proptype == PROP_FLOAT) { - if (!array) fval= RNA_property_float_get(&ptr, prop); - else fval= RNA_property_float_get_index(&ptr, prop, array_index); + if (!array) fval = RNA_property_float_get(&ptr, prop); + else fval = RNA_property_float_get_index(&ptr, prop, array_index); BLI_snprintf(expression, maxlen, "%.3f", fval); } @@ -227,25 +227,25 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar } /* Main Driver Management API calls: - * Remove the driver for the specified property on the given ID block (if available) + * Remove the driver for the specified property on the given ID block (if available) */ short ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag)) { AnimData *adt; FCurve *fcu; - int success= 0; + int success = 0; /* we don't check the validity of the path here yet, but it should be ok... */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if (adt) { if (array_index == -1) { /* step through all drivers, removing all of those with the same base path */ - FCurve *fcu_iter= adt->drivers.first; + FCurve *fcu_iter = adt->drivers.first; while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) { /* store the next fcurve for looping */ - fcu_iter= fcu->next; + fcu_iter = fcu->next; /* remove F-Curve from driver stack, then free it */ BLI_remlink(&adt->drivers, fcu); @@ -258,9 +258,9 @@ short ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_pat else { /* find the matching driver and remove it only * Note: here is one of the places where we don't want new F-Curve + Driver added! - * so 'add' var must be 0 + * so 'add' var must be 0 */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 0); + fcu = verify_driver_fcurve(id, rna_path, array_index, 0); if (fcu) { BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); @@ -286,7 +286,7 @@ void free_anim_drivers_copybuf(void) /* free the buffer F-Curve if it exists, as if it were just another F-Curve */ if (channeldriver_copypaste_buf) free_fcurve(channeldriver_copypaste_buf); - channeldriver_copypaste_buf= NULL; + channeldriver_copypaste_buf = NULL; } /* Checks if there is a driver in the copy/paste buffer */ @@ -298,7 +298,7 @@ short ANIM_driver_can_paste(void) /* ------------------- */ /* Main Driver Management API calls: - * Make a copy of the driver for the specified property on the given ID block + * Make a copy of the driver for the specified property on the given ID block */ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) { @@ -310,13 +310,13 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* try to get F-Curve with Driver */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 0); + fcu = verify_driver_fcurve(id, rna_path, array_index, 0); /* clear copy/paste buffer first (for consistency with other copy/paste buffers) */ free_anim_drivers_copybuf(); @@ -327,13 +327,13 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a * so that we don't end up wasting memory storing the path which won't get used ever... */ char *tmp_path = fcu->rna_path; - fcu->rna_path= NULL; + fcu->rna_path = NULL; /* make a copy of the F-Curve with */ - channeldriver_copypaste_buf= copy_fcurve(fcu); + channeldriver_copypaste_buf = copy_fcurve(fcu); /* restore the path */ - fcu->rna_path= tmp_path; + fcu->rna_path = tmp_path; /* copied... */ return 1; @@ -344,7 +344,7 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a } /* Main Driver Management API calls: - * Add a new driver for the specified property on the given ID block or replace an existing one + * Add a new driver for the specified property on the given ID block or replace an existing one * with the driver + driver-curve data from the buffer */ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) @@ -357,8 +357,8 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } @@ -369,25 +369,25 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int } /* create Driver F-Curve, but without data which will be copied across... */ - fcu= verify_driver_fcurve(id, rna_path, array_index, -1); + fcu = verify_driver_fcurve(id, rna_path, array_index, -1); if (fcu) { /* copy across the curve data from the buffer curve * NOTE: this step needs care to not miss new settings */ - /* keyframes/samples */ - fcu->bezt= MEM_dupallocN(channeldriver_copypaste_buf->bezt); - fcu->fpt= MEM_dupallocN(channeldriver_copypaste_buf->fpt); - fcu->totvert= channeldriver_copypaste_buf->totvert; + /* keyframes/samples */ + fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt); + fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt); + fcu->totvert = channeldriver_copypaste_buf->totvert; - /* modifiers */ + /* modifiers */ copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); - /* extrapolation mode */ - fcu->extend= channeldriver_copypaste_buf->extend; + /* extrapolation mode */ + fcu->extend = channeldriver_copypaste_buf->extend; - /* the 'juicy' stuff - the driver */ - fcu->driver= fcurve_copy_driver(channeldriver_copypaste_buf->driver); + /* the 'juicy' stuff - the driver */ + fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver); } /* done */ @@ -407,7 +407,7 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int * * > returns: MEM_alloc'd string representing the path to the property from the given PointerRNA */ -static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *prop) +static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { ID *id = (ID *)ptr->id.data; ScrArea *sa = CTX_wm_area(C); @@ -431,17 +431,17 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr Material *ma = give_current_material(ob, ob->actcol); /* assumes: material will only be shown if it is active objects's active material it's ok */ - if ((ID*)ma == id) { + if ((ID *)ma == id) { /* create new path */ // TODO: use RNA path functions to construct instead? path = BLI_sprintfN("material_slots[\"%s\"].material.%s", - ma->id.name+2, basepath); + ma->id.name + 2, basepath); /* free old one */ MEM_freeN(basepath); } } - break; + break; case ID_TE: /* textures */ { @@ -449,17 +449,17 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr Tex *tex = give_current_material_texture(ma); /* assumes: texture will only be shown if it is active material's active texture it's ok */ - if ((ID*)tex == id) { + if ((ID *)tex == id) { /* create new path */ // TODO: use RNA path functions to construct step by step instead? path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", - ma->id.name+2, tex->id.name+2, basepath); + ma->id.name + 2, tex->id.name + 2, basepath); /* free old one */ MEM_freeN(basepath); } } - break; + break; } /* fix RNA pointer, as we've now changed the ID root by changing the paths */ @@ -476,25 +476,25 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr /* Add Driver Button Operator ------------------------ */ -static int add_driver_button_exec (bContext *C, wmOperator *op) +static int add_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; - int index, all= RNA_boolean_get(op->ptr, "all"); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; + int index, all = RNA_boolean_get(op->ptr, "all"); /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (all) - index= -1; + index = -1; if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; if (path) { - success+= ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); + success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } @@ -506,10 +506,10 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_driver_button_add(wmOperatorType *ot) @@ -524,7 +524,7 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some animatable property to do this /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Create drivers for all elements of the array"); @@ -532,23 +532,23 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) /* Remove Driver Button Operator ------------------------ */ -static int remove_driver_button_exec (bContext *C, wmOperator *op) +static int remove_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; - int index, all= RNA_boolean_get(op->ptr, "all"); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; + int index, all = RNA_boolean_get(op->ptr, "all"); /* try to find driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (all) - index= -1; + index = -1; if (ptr.id.data && ptr.data && prop) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); - success= ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); MEM_freeN(path); } @@ -558,10 +558,10 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_driver_button_remove(wmOperatorType *ot) @@ -576,7 +576,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array"); @@ -584,22 +584,22 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) /* Copy Driver Button Operator ------------------------ */ -static int copy_driver_button_exec (bContext *C, wmOperator *op) +static int copy_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; int index; /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ - success= ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); uiContextAnimUpdate(C); @@ -608,7 +608,7 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op) } /* since we're just copying, we don't really need to do anything else...*/ - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_copy_driver_button(wmOperatorType *ot) @@ -623,27 +623,27 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Paste Driver Button Operator ------------------------ */ -static int paste_driver_button_exec (bContext *C, wmOperator *op) +static int paste_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; int index; /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ - success= ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); uiContextAnimUpdate(C); @@ -652,7 +652,7 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op) } /* since we're just copying, we don't really need to do anything else...*/ - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_paste_driver_button(wmOperatorType *ot) @@ -667,7 +667,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************** */ diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 9b46729b489..24cae5d8652 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -69,23 +69,23 @@ // XXX! -------------------------------- /* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */ -#define UI_FLT_MAX 10000.0f +#define UI_FLT_MAX 10000.0f -#define B_REDR 1 -#define B_FMODIFIER_REDRAW 20 +#define B_REDR 1 +#define B_FMODIFIER_REDRAW 20 /* macro for use here to draw background box and set height */ // XXX for now, roundbox has it's callback func set to NULL to not intercept events #define DRAW_BACKDROP(height) \ { \ - uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco-height, width+3, height-1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \ + uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco - height, width + 3, height - 1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \ } /* callback to verify modifier data */ -static void validate_fmodifier_cb (bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg)) +static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg)) { - FModifier *fcm= (FModifier *)fcm_v; - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifier *fcm = (FModifier *)fcm_v; + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* call the verify callback on the modifier if applicable */ if (fmi && fmi->verify_data) @@ -93,10 +93,10 @@ static void validate_fmodifier_cb (bContext *UNUSED(C), void *fcm_v, void *UNUSE } /* callback to remove the given modifier */ -static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) +static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v) { ListBase *modifiers = (ListBase *)fmods_v; - FModifier *fcm= (FModifier *)fcm_v; + FModifier *fcm = (FModifier *)fcm_v; /* remove the given F-Modifier from the active modifier-stack */ remove_fmodifier(modifiers, fcm); @@ -105,7 +105,7 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) /* send notifiers */ // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* --------------- */ @@ -113,7 +113,7 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) /* draw settings for generator modifier */ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; uiLayout /* *col, */ /* UNUSED */ *row; uiBlock *block; uiBut *but; @@ -124,12 +124,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* basic settings (backdrop + mode selector + some padding) */ /* col= uiLayoutColumn(layout, 1); */ /* UNUSED */ - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockBeginAlign(block); - but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); - uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL); + uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL); uiBlockEndAlign(block); /* now add settings for individual modes */ @@ -141,20 +141,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); - but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width-30, 19, - &data->poly_order, 1, 100, 0, 0, - TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); + but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19, + &data->poly_order, 1, 100, 0, 0, + TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); /* draw controls for each coefficient and a + sign at end of row */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); - cp= data->coefficients; - for (i=0; (i < data->arraysize) && (cp); i++, cp++) { + cp = data->coefficients; + for (i = 0; (i < data->arraysize) && (cp); i++, cp++) { /* To align with first line */ if (i) uiDefBut(block, LABEL, 1, " ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -173,12 +173,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s sprintf(xval, "x^%u", i); uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x")); - if ( (i != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) ) { + if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) { uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* next coefficient on a new row */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); } else { /* For alignement in UI! */ @@ -194,20 +194,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); - but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width-30, 19, - &data->poly_order, 1, 100, 0, 0, - TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); + but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 30, 19, + &data->poly_order, 1, 100, 0, 0, + TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); /* draw controls for each pair of coefficients */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); - cp= data->coefficients; - for (i=0; (i < data->poly_order) && (cp); i++, cp+=2) { + cp = data->coefficients; + for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) { /* To align with first line */ if (i) uiDefBut(block, LABEL, 1, " ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -222,22 +222,22 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "x +", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp + 1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Second coefficient")); /* closing bracket and '+' sign */ - if ( (i != (data->poly_order - 1)) || ((i==0) && data->poly_order==2) ) { + if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) { uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients*/ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); } else uiDefBut(block, LABEL, 1, ")", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, ""); } } - break; + break; } } @@ -253,15 +253,15 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* add the settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); - uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - - col= uiLayoutColumn(layout, 0); // no grouping for now - uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "value_offset", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); + uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + + col = uiLayoutColumn(layout, 0); // no grouping for now + uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "value_offset", 0, NULL, ICON_NONE); } /* --------------- */ @@ -278,19 +278,19 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* before range */ - col= uiLayoutColumn(split, 1); - uiItemL(col, IFACE_("Before:"), ICON_NONE); - uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); - uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemL(col, IFACE_("Before:"), ICON_NONE); + uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); + uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); /* after range */ - col= uiLayoutColumn(split, 1); - uiItemL(col, IFACE_("After:"), ICON_NONE); - uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); - uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemL(col, IFACE_("After:"), ICON_NONE); + uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); + uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); } /* --------------- */ @@ -308,33 +308,33 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* col 1 */ - col= uiLayoutColumn(split, 0); - uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 0); + uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); /* col 2 */ - col= uiLayoutColumn(split, 0); - uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 0); + uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } /* --------------- */ -#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f +#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f /* Binary search algorithm for finding where to insert Envelope Data Point. * Returns the index to insert at (data already at that index will be offset if replace is 0) */ -static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float frame, int arraylen, short *exists) +static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float frame, int arraylen, short *exists) { - int start=0, end=arraylen; - int loopbreaker= 0, maxloop= arraylen * 2; + int start = 0, end = arraylen; + int loopbreaker = 0, maxloop = arraylen * 2; /* initialize exists-flag first */ - *exists= 0; + *exists = 0; /* sneaky optimisations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds @@ -349,7 +349,7 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float float framenum; /* 'First' Point (when only one point, this case is used) */ - framenum= array[0].time; + framenum = array[0].time; if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { *exists = 1; return 0; @@ -358,9 +358,9 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float return 0; /* 'Last' Point */ - framenum= array[(arraylen-1)].time; + framenum = array[(arraylen - 1)].time; if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { - *exists= 1; + *exists = 1; return (arraylen - 1); } else if (frame > framenum) @@ -369,12 +369,12 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* most of the time, this loop is just to find where to put it - * - 'loopbreaker' is just here to prevent infinite loops + * - 'loopbreaker' is just here to prevent infinite loops */ - for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { + for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ - float midfra= array[mid].time; + int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ + float midfra = array[mid].time; /* check if exactly equal to midpoint */ if (IS_EQT(frame, midfra, BINARYSEARCH_FRAMEEQ_THRESH)) { @@ -384,13 +384,13 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* repeat in upper/lower half */ if (frame > midfra) - start= mid + 1; + start = mid + 1; else if (frame < midfra) - end= mid - 1; + end = mid - 1; } /* print error if loop-limit exceeded */ - if (loopbreaker == (maxloop-1)) { + if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_fcm_envelopedata_index() was taking too long\n"); // include debug info @@ -403,91 +403,91 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* callback to add new envelope data point */ // TODO: should we have a separate file for things like this? -static void fmod_envelope_addpoint_cb (bContext *C, void *fcm_dv, void *UNUSED(arg)) +static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(arg)) { - Scene *scene= CTX_data_scene(C); - FMod_Envelope *env= (FMod_Envelope *)fcm_dv; + Scene *scene = CTX_data_scene(C); + FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; FCM_EnvelopeData fed; /* init template data */ - fed.min= -1.0f; - fed.max= 1.0f; - fed.time= (float)scene->r.cfra; // XXX make this int for ease of use? - fed.f1= fed.f2= 0; + fed.min = -1.0f; + fed.max = 1.0f; + fed.time = (float)scene->r.cfra; // XXX make this int for ease of use? + fed.f1 = fed.f2 = 0; /* check that no data exists for the current frame... */ if (env->data) { short exists = -1; - int i= binarysearch_fcm_envelopedata_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); + int i = binarysearch_fcm_envelopedata_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); /* binarysearch_...() will set exists by default to 0, so if it is non-zero, that means that the point exists already */ if (exists) return; /* add new */ - fedn= MEM_callocN((env->totvert+1)*sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); /* add the points that should occur before the point to be pasted */ if (i > 0) - memcpy(fedn, env->data, i*sizeof(FCM_EnvelopeData)); + memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData)); /* add point to paste at index i */ - *(fedn + i)= fed; + *(fedn + i) = fed; /* add the points that occur after the point to be pasted */ if (i < env->totvert) - memcpy(fedn+i+1, env->data+i, (env->totvert-i)*sizeof(FCM_EnvelopeData)); + memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData)); /* replace (+ free) old with new */ MEM_freeN(env->data); - env->data= fedn; + env->data = fedn; env->totvert++; } else { - env->data= MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); - *(env->data)= fed; + env->data = MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + *(env->data) = fed; - env->totvert= 1; + env->totvert = 1; } } /* callback to remove envelope data point */ // TODO: should we have a separate file for things like this? -static void fmod_envelope_deletepoint_cb (bContext *UNUSED(C), void *fcm_dv, void *ind_v) +static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void *ind_v) { - FMod_Envelope *env= (FMod_Envelope *)fcm_dv; + FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; - int index= GET_INT_FROM_POINTER(ind_v); + int index = GET_INT_FROM_POINTER(ind_v); /* check that no data exists for the current frame... */ if (env->totvert > 1) { /* allocate a new smaller array */ - fedn= MEM_callocN(sizeof(FCM_EnvelopeData)*(env->totvert-1), "FCM_EnvelopeData"); + fedn = MEM_callocN(sizeof(FCM_EnvelopeData) * (env->totvert - 1), "FCM_EnvelopeData"); - memcpy(fedn, env->data, sizeof(FCM_EnvelopeData)*(index)); - memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData)*((env->totvert - index)-1)); + memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index)); + memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1)); /* free old array, and set the new */ MEM_freeN(env->data); - env->data= fedn; + env->data = fedn; env->totvert--; } else { /* just free array, since the only vert was deleted */ if (env->data) { MEM_freeN(env->data); - env->data= NULL; + env->data = NULL; } - env->totvert= 0; + env->totvert = 0; } } /* draw settings for envelope modifier */ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, short UNUSED(width)) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; uiLayout *col, *row; uiBlock *block; @@ -499,45 +499,45 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ - col= uiLayoutColumn(layout, 1); - uiItemL(col, IFACE_("Envelope:"), ICON_NONE); - uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); - - row= uiLayoutRow(col, 1); - uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); - uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemL(col, IFACE_("Envelope:"), ICON_NONE); + uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); + + row = uiLayoutRow(col, 1); + uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); + uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists // the current way is far too cramped - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); - uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); - but = uiDefBut(block, BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 150, 19, - NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); - uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL); + but = uiDefBut(block, BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 150, 19, + NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); + uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL); /* control points list */ - for (i=0, fed=env->data; i < env->totvert; i++, fed++) { + for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); uiBlockBeginAlign(block); - but=uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 90, 20, - &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); - - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 100, 20, - &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point")); - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 100, 20, - &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Maximum bound of envelope at this point")); + but = uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 90, 20, + &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); - but = uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 18, 20, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete envelope control point")); - uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i)); + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 100, 20, + &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point")); + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 100, 20, + &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Maximum bound of envelope at this point")); + + but = uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 18, 20, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete envelope control point")); + uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i)); uiBlockBeginAlign(block); } } @@ -558,17 +558,17 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* x-minimum */ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } /* row 2: maximum */ @@ -576,17 +576,17 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* x-minimum */ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); } } @@ -602,36 +602,36 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); /* block 1: "stepping" settings */ - col= uiLayoutColumn(layout, 0); - uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 0); + uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); /* block 2: start range settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); - uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); + uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); - uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); + uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } /* --------------- */ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); uiLayout *box, *row, *sub, *col; uiBlock *block; uiBut *but; - short width= 314; + short width = 314; PointerRNA ptr; /* init the RNA-pointer */ @@ -640,13 +640,13 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* draw header */ { /* get layout-row + UI-block for this */ - box= uiLayoutBox(layout); + box = uiLayoutBox(layout); - row= uiLayoutRow(box, 0); - block= uiLayoutGetBlock(row); // err... + row = uiLayoutRow(box, 0); + block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -664,7 +664,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiItemL(sub, "<Unknown Modifier>", ICON_NONE); /* right-align ------------------------------------------- */ - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); @@ -675,7 +675,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* delete button */ but = uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm); uiBlockSetEmboss(block, UI_EMBOSS); @@ -684,7 +684,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* when modifier is expanded, draw settings */ if (fcm->flag & FMODIFIER_FLAG_EXPANDED) { /* set up the flexible-box layout which acts as the backdrop for the modifier settings */ - box= uiLayoutBox(layout); + box = uiLayoutBox(layout); /* draw settings for individual modifiers */ switch (fcm->type) { @@ -729,7 +729,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier col = uiLayoutColumn(box, 1); /* top row: use restricted range */ - row= uiLayoutRow(col, 1); + row = uiLayoutRow(col, 1); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { @@ -822,7 +822,7 @@ short ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, short replace) free_fmodifiers(modifiers); /* now copy over all the modifiers in the buffer to the end of the list */ - for (fcm= fmodifier_copypaste_buf.first; fcm; fcm= fcm->next) { + for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) { /* make a copy of it */ FModifier *fcmN = copy_fmodifier(fcm); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index cc5cb42a783..cb7dc7ac206 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -63,7 +63,7 @@ #include "BKE_key.h" #include "BKE_material.h" -#include "BKE_global.h" // XXX remove me! +#include "BKE_global.h" // XXX remove me! #include "BIF_gl.h" @@ -82,8 +82,8 @@ /* NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes */ short compare_ak_cfraPtr(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - float *cframe= data; + ActKeyColumn *ak = (ActKeyColumn *)node; + float *cframe = data; if (*cframe < ak->cfra) return -1; @@ -96,10 +96,10 @@ short compare_ak_cfraPtr(void *node, void *data) /* --------------- */ /* Comparator callback used for ActKeyColumns and BezTriple */ -static short compare_ak_bezt (void *node, void *data) +static short compare_ak_bezt(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + BezTriple *bezt = (BezTriple *)data; if (bezt->vec[1][0] < ak->cfra) return -1; @@ -110,15 +110,15 @@ static short compare_ak_bezt (void *node, void *data) } /* New node callback used for building ActKeyColumns from BezTriples */ -static DLRBT_Node *nalloc_ak_bezt (void *data) +static DLRBT_Node *nalloc_ak_bezt(void *data) { - ActKeyColumn *ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); + BezTriple *bezt = (BezTriple *)data; /* store settings based on state of BezTriple */ - ak->cfra= bezt->vec[1][0]; - ak->sel= BEZSELECTED(bezt) ? SELECT : 0; - ak->key_type= BEZKEYTYPE(bezt); + ak->cfra = bezt->vec[1][0]; + ak->sel = BEZSELECTED(bezt) ? SELECT : 0; + ak->key_type = BEZKEYTYPE(bezt); /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; @@ -127,10 +127,10 @@ static DLRBT_Node *nalloc_ak_bezt (void *data) } /* Node updater callback used for building ActKeyColumns from BezTriples */ -static void nupdate_ak_bezt (void *node, void *data) +static void nupdate_ak_bezt(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + BezTriple *bezt = (BezTriple *)data; /* set selection status and 'touched' status */ if (BEZSELECTED(bezt)) ak->sel = SELECT; @@ -138,16 +138,16 @@ static void nupdate_ak_bezt (void *node, void *data) /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) - ak->key_type= BEZT_KEYTYPE_KEYFRAME; + ak->key_type = BEZT_KEYTYPE_KEYFRAME; } /* ......... */ /* Comparator callback used for ActKeyColumns and GPencil frame */ -static short compare_ak_gpframe (void *node, void *data) +static short compare_ak_gpframe(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + bGPDframe *gpf = (bGPDframe *)data; if (gpf->framenum < ak->cfra) return -1; @@ -158,14 +158,14 @@ static short compare_ak_gpframe (void *node, void *data) } /* New node callback used for building ActKeyColumns from GPencil frames */ -static DLRBT_Node *nalloc_ak_gpframe (void *data) +static DLRBT_Node *nalloc_ak_gpframe(void *data) { - ActKeyColumn *ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); + bGPDframe *gpf = (bGPDframe *)data; /* store settings based on state of BezTriple */ - ak->cfra= gpf->framenum; - ak->sel= (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; + ak->cfra = gpf->framenum; + ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; @@ -174,10 +174,10 @@ static DLRBT_Node *nalloc_ak_gpframe (void *data) } /* Node updater callback used for building ActKeyColumns from GPencil frames */ -static void nupdate_ak_gpframe (void *node, void *data) +static void nupdate_ak_gpframe(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + bGPDframe *gpf = (bGPDframe *)data; /* set selection status and 'touched' status */ if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT; @@ -207,36 +207,36 @@ static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf) /* ActBeztColumns (Helpers for Long Keyframes) ------------------------------ */ /* maximum size of default buffer for BezTriple columns */ -#define MAX_ABK_BUFSIZE 4 +#define MAX_ABK_BUFSIZE 4 /* BezTriple Container Node */ // NOTE: only used internally while building Long Keyframes for now, but may be useful externally? typedef struct ActBeztColumn { /* Tree Node interface ---------------- */ - /* ListBase linkage */ + /* ListBase linkage */ struct ActBeztColumn *next, *prev; - /* sorting-tree linkage */ - struct ActBeztColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ - struct ActBeztColumn *parent; /* parent of this node in the tree */ - char tree_col; /* DLRB_BLACK or DLRB_RED */ + /* sorting-tree linkage */ + struct ActBeztColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ + struct ActBeztColumn *parent; /* parent of this node in the tree */ + char tree_col; /* DLRB_BLACK or DLRB_RED */ char pad; /* BezTriple Store -------------------- */ - short numBezts; /* number of BezTriples on this frame */ - float cfra; /* frame that the BezTriples occur on */ + short numBezts; /* number of BezTriples on this frame */ + float cfra; /* frame that the BezTriples occur on */ - BezTriple *bezts[MAX_ABK_BUFSIZE]; /* buffer of pointers to BezTriples on the same frame */ + BezTriple *bezts[MAX_ABK_BUFSIZE]; /* buffer of pointers to BezTriples on the same frame */ //BezTriple **bezts_extra; /* secondary buffer of pointers if need be */ } ActBeztColumn; /* --------------- */ /* Comparator callback used for ActBeztColumns and BezTriple */ -static short compare_abk_bezt (void *node, void *data) +static short compare_abk_bezt(void *node, void *data) { - ActBeztColumn *abk= (ActBeztColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = (ActBeztColumn *)node; + BezTriple *bezt = (BezTriple *)data; if (bezt->vec[1][0] < abk->cfra) return -1; @@ -247,23 +247,23 @@ static short compare_abk_bezt (void *node, void *data) } /* New node callback used for building ActBeztColumns from BezTriples */ -static DLRBT_Node *nalloc_abk_bezt (void *data) +static DLRBT_Node *nalloc_abk_bezt(void *data) { - ActBeztColumn *abk= MEM_callocN(sizeof(ActBeztColumn), "ActKeyColumn"); - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = MEM_callocN(sizeof(ActBeztColumn), "ActKeyColumn"); + BezTriple *bezt = (BezTriple *)data; /* store the BeztTriple in the buffer, and keep track of its frame number */ - abk->cfra= bezt->vec[1][0]; - abk->bezts[abk->numBezts++]= bezt; + abk->cfra = bezt->vec[1][0]; + abk->bezts[abk->numBezts++] = bezt; return (DLRBT_Node *)abk; } /* Node updater callback used for building ActBeztColumns from BezTriples */ -static void nupdate_abk_bezt (void *node, void *data) +static void nupdate_abk_bezt(void *node, void *data) { - ActBeztColumn *abk= (ActBeztColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = (ActBeztColumn *)node; + BezTriple *bezt = (BezTriple *)data; /* just add the BezTriple to the buffer if there's space, or allocate a new one */ if (abk->numBezts >= MAX_ABK_BUFSIZE) { @@ -274,14 +274,14 @@ static void nupdate_abk_bezt (void *node, void *data) } else { /* just store an extra one */ - abk->bezts[abk->numBezts++]= bezt; + abk->bezts[abk->numBezts++] = bezt; } } /* --------------- */ /* Return the BezTriple in the given ActBeztColumn that matches the requested value */ -static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) +static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value) { BezTriple *bezt; int i; @@ -293,12 +293,12 @@ static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) /* look over each BezTriple in this container */ for (i = 0; i < abk->numBezts; i++) { /* only do exact match for now... */ - if (/*i >= MAX_ABK_BUFSIZE*/0) { + if (/*i >= MAX_ABK_BUFSIZE*/ 0) { // TODO: this case needs special handling } else { /* just use the default buffer */ - bezt= abk->bezts[i]; + bezt = abk->bezts[i]; if (bezt->vec[1][1] == value) return bezt; @@ -314,8 +314,8 @@ static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) /* NOTE: this is exported to other modules that use the ActKeyBlocks for finding long-keyframes */ short compare_ab_cfraPtr(void *node, void *data) { - ActKeyBlock *ab= (ActKeyBlock *)node; - float *cframe= data; + ActKeyBlock *ab = (ActKeyBlock *)node; + float *cframe = data; if (*cframe < ab->start) return -1; @@ -330,13 +330,13 @@ short compare_ab_cfraPtr(void *node, void *data) /* Create a ActKeyColumn for a pair of BezTriples */ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) { - ActKeyBlock *ab= MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock"); + ActKeyBlock *ab = MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock"); - ab->start= prev->vec[1][0]; - ab->end= beztn->vec[1][0]; - ab->val= beztn->vec[1][1]; + ab->start = prev->vec[1][0]; + ab->end = beztn->vec[1][0]; + ab->val = beztn->vec[1][1]; - ab->sel= (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0; + ab->sel = (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0; ab->modified = 1; return ab; @@ -344,44 +344,44 @@ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, BezTriple *beztn) { - ActKeyBlock *new_ab= NULL; + ActKeyBlock *new_ab = NULL; ActBeztColumn *abk; BezTriple *prev; /* get the BezTriple immediately before the given one which has the same value */ - /* the keyframes immediately before the ones containing the specified keyframe */ - abk= (ActBeztColumn *)BLI_dlrbTree_search_prev(beztTree, compare_abk_bezt, beztn); - /* if applicable, the BezTriple with the same value */ - prev= (abk) ? abk_get_bezt_with_value(abk, beztn->vec[1][1]) : NULL; + /* the keyframes immediately before the ones containing the specified keyframe */ + abk = (ActBeztColumn *)BLI_dlrbTree_search_prev(beztTree, compare_abk_bezt, beztn); + /* if applicable, the BezTriple with the same value */ + prev = (abk) ? abk_get_bezt_with_value(abk, beztn->vec[1][1]) : NULL; /* check if block needed - same value(s)? * -> firstly, handles must have same central value as each other * -> secondly, handles which control that section of the curve must be constant */ if ((!prev) || (!beztn)) return; - if (IS_EQF(beztn->vec[1][1], prev->vec[1][1])==0) return; - if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1])==0) return; - if (IS_EQF(prev->vec[1][1], prev->vec[2][1])==0) return; + if (IS_EQF(beztn->vec[1][1], prev->vec[1][1]) == 0) return; + if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) == 0) return; + if (IS_EQF(prev->vec[1][1], prev->vec[2][1]) == 0) return; /* if there are no blocks already, just add as root */ if (blocks->root == NULL) { /* just add this as the root, then call the tree-balancing functions to validate */ - new_ab= bezts_to_new_actkeyblock(prev, beztn); - blocks->root= (DLRBT_Node *)new_ab; + new_ab = bezts_to_new_actkeyblock(prev, beztn); + blocks->root = (DLRBT_Node *)new_ab; } else { - ActKeyBlock *ab, *abn=NULL; + ActKeyBlock *ab, *abn = NULL; /* try to find a keyblock that starts on the previous beztriple, and add a new one if none start there * Note: we can't search from end to try to optimize this as it causes errors there's - * an A ___ B |---| B situation + * an A ___ B |---| B situation */ // FIXME: here there is a bug where we are trying to get the summary for the following channels // A|--------------|A ______________ B|--------------|B // A|------------------------------------------------|A // A|----|A|---|A|-----------------------------------|A - for (ab= blocks->root; ab; ab= abn) { + for (ab = blocks->root; ab; ab = abn) { /* check if this is a match, or whether we go left or right */ if (ab->start == prev->vec[1][0]) { /* set selection status and 'touched' status */ @@ -392,24 +392,24 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, return; } else { - ActKeyBlock **abnp= NULL; + ActKeyBlock **abnp = NULL; /* check if go left or right, but if not available, add new node */ if (ab->start < prev->vec[1][0]) - abnp= &ab->right; + abnp = &ab->right; else - abnp= &ab->left; + abnp = &ab->left; /* if this does not exist, add a new node, otherwise continue... */ if (*abnp == NULL) { /* add a new node representing this, and attach it to the relevant place */ - new_ab= bezts_to_new_actkeyblock(prev, beztn); - new_ab->parent= ab; - *abnp= new_ab; + new_ab = bezts_to_new_actkeyblock(prev, beztn); + new_ab->parent = ab; + *abnp = new_ab; break; } else - abn= *abnp; + abn = *abnp; } } } @@ -421,7 +421,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, /* --------- */ /* Handle the 'touched' status of ActKeyColumn tree nodes */ -static void set_touched_actkeycolumn (ActKeyColumn *ak) +static void set_touched_actkeycolumn(ActKeyColumn *ak) { /* sanity check */ if (ak == NULL) @@ -429,7 +429,7 @@ static void set_touched_actkeycolumn (ActKeyColumn *ak) /* deal with self first */ if (ak->modified) { - ak->modified= 0; + ak->modified = 0; ak->totcurve++; } @@ -439,7 +439,7 @@ static void set_touched_actkeycolumn (ActKeyColumn *ak) } /* Handle the 'touched' status of ActKeyBlock tree nodes */ -static void set_touched_actkeyblock (ActKeyBlock *ab) +static void set_touched_actkeyblock(ActKeyBlock *ab) { /* sanity check */ if (ab == NULL) @@ -447,7 +447,7 @@ static void set_touched_actkeyblock (ActKeyBlock *ab) /* deal with self first */ if (ab->modified) { - ab->modified= 0; + ab->modified = 0; ab->totcurve++; } @@ -469,17 +469,17 @@ short actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys) return 0; /* find out how many curves occur at each keyframe */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); - startCurves = (ak)? ak->totcurve: 0; + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); + startCurves = (ak) ? ak->totcurve : 0; - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); - endCurves = (ak)? ak->totcurve: 0; + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); + endCurves = (ak) ? ak->totcurve : 0; /* only draw keyblock if it appears in at all of the keyframes at lowest end */ if (!startCurves && !endCurves) return 0; - totCurves = (startCurves>endCurves)? endCurves: startCurves; + totCurves = (startCurves > endCurves) ? endCurves : startCurves; return (ab->totcurve >= totCurves); } @@ -487,52 +487,54 @@ short actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys) /* coordinates for diamond shape */ static const float _unit_diamond_shape[4][2] = { - {0.0f, 1.0f}, /* top vert */ - {1.0f, 0.0f}, /* mid-right */ - {0.0f, -1.0f}, /* bottom vert */ - {-1.0f, 0.0f} /* mid-left */ + {0.0f, 1.0f}, /* top vert */ + {1.0f, 0.0f}, /* mid-right */ + {0.0f, -1.0f}, /* bottom vert */ + {-1.0f, 0.0f} /* mid-left */ }; /* draw a simple diamond shape with OpenGL */ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha) { - static GLuint displist1=0; - static GLuint displist2=0; + static GLuint displist1 = 0; + static GLuint displist2 = 0; /* initialize 2 display lists for diamond shape - one empty, one filled */ if (displist1 == 0) { - displist1= glGenLists(1); - glNewList(displist1, GL_COMPILE); + displist1 = glGenLists(1); + glNewList(displist1, GL_COMPILE); - glBegin(GL_LINE_LOOP); - glVertex2fv(_unit_diamond_shape[0]); - glVertex2fv(_unit_diamond_shape[1]); - glVertex2fv(_unit_diamond_shape[2]); - glVertex2fv(_unit_diamond_shape[3]); - glEnd(); + glBegin(GL_LINE_LOOP); + glVertex2fv(_unit_diamond_shape[0]); + glVertex2fv(_unit_diamond_shape[1]); + glVertex2fv(_unit_diamond_shape[2]); + glVertex2fv(_unit_diamond_shape[3]); + glEnd(); + glEndList(); } if (displist2 == 0) { - displist2= glGenLists(1); - glNewList(displist2, GL_COMPILE); + displist2 = glGenLists(1); + glNewList(displist2, GL_COMPILE); - glBegin(GL_QUADS); - glVertex2fv(_unit_diamond_shape[0]); - glVertex2fv(_unit_diamond_shape[1]); - glVertex2fv(_unit_diamond_shape[2]); - glVertex2fv(_unit_diamond_shape[3]); - glEnd(); + glBegin(GL_QUADS); + glVertex2fv(_unit_diamond_shape[0]); + glVertex2fv(_unit_diamond_shape[1]); + glVertex2fv(_unit_diamond_shape[2]); + glVertex2fv(_unit_diamond_shape[3]); + glEnd(); + glEndList(); } /* tweak size of keyframe shape according to type of keyframe - * - 'proper' keyframes have key_type=0, so get drawn at full size + * - 'proper' keyframes have key_type=0, so get drawn at full size */ - hsize -= 0.5f*key_type; + hsize -= 0.5f * key_type; /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, hsize, 1.0f); + glScalef(1.0f / xscale * hsize, hsize, 1.0f); /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); @@ -546,29 +548,29 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, if (sel) glColor4f(0.33f, 0.75f, 0.93f, alpha); else glColor4f(0.70f, 0.86f, 0.91f, alpha); } - break; + break; case BEZT_KEYTYPE_EXTREME: /* redish frames for now */ { if (sel) glColor4f(0.95f, 0.5f, 0.5f, alpha); else glColor4f(0.91f, 0.70f, 0.80f, alpha); } - break; + break; case BEZT_KEYTYPE_JITTER: /* greenish frames for now? */ { if (sel) glColor4f(0.38f, 0.75f, 0.26f, alpha); else glColor4f(0.58f, 0.90f, 0.46f, alpha); } - break; + break; case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames for now */ default: { - if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha)); + if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); else glColor4f(0.91f, 0.91f, 0.91f, alpha); } - break; + break; } glCallList(displist2); @@ -584,7 +586,7 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, glDisable(GL_LINE_SMOOTH); /* restore view transform */ - glScalef(xscale/hsize, 1.0f/hsize, 1.0); + glScalef(xscale / hsize, 1.0f / hsize, 1.0f); glTranslatef(-x, -y, 0.0f); } @@ -601,7 +603,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keyblocks */ if (blocks) { - for (ab= blocks->first; ab; ab= ab->next) { + for (ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { /* draw block */ if (ab->sel) @@ -609,7 +611,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa else UI_ThemeColor4(TH_STRIP); - glRectf(ab->start, ypos-5, ab->end, ypos+5); + glRectf(ab->start, ypos - 5, ab->end, ypos + 5); } } } @@ -618,9 +620,9 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (keys) { /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ // TODO: allow this opacity factor to be themed? - float kalpha = (channelLocked)? 0.35f : 1.0f; + float kalpha = (channelLocked) ? 0.35f : 1.0f; - for (ak= keys->first; ak; ak= ak->next) { + for (ak = keys->first; ak; ak = ak->next) { /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices */ @@ -646,12 +648,12 @@ void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - summary_to_keylist(ac, &keys, &blocks); + summary_to_keylist(ac, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -664,12 +666,12 @@ void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - scene_to_keylist(ads, sce, &keys, &blocks); + scene_to_keylist(ads, sce, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -682,12 +684,12 @@ void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - ob_to_keylist(ads, ob, &keys, &blocks); + ob_to_keylist(ads, ob, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -700,12 +702,12 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - fcurve_to_keylist(adt, fcu, &keys, &blocks); + fcurve_to_keylist(adt, fcu, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, (fcu->flag & FCURVE_PROTECTED)); + draw_keylist(v2d, &keys, &blocks, ypos, (fcu->flag & FCURVE_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -718,12 +720,12 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - agroup_to_keylist(adt, agrp, &keys, &blocks); + agroup_to_keylist(adt, agrp, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, (agrp->flag & AGRP_PROTECTED)); + draw_keylist(v2d, &keys, &blocks, ypos, (agrp->flag & AGRP_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -736,12 +738,12 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - action_to_keylist(adt, act, &keys, &blocks); + action_to_keylist(adt, act, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -753,11 +755,11 @@ void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos) BLI_dlrbTree_init(&keys); - gpl_to_keylist(ads, gpl, &keys); + gpl_to_keylist(ads, gpl, &keys); BLI_dlrbTree_linkedlist_sync(&keys); - draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED)); + draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED)); BLI_dlrbTree_free(&keys); } @@ -772,11 +774,11 @@ 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; // curves only 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) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -806,11 +808,11 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only 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) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -842,11 +844,11 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only 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) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -868,10 +870,10 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree */ if (blocks) { /* init new tree */ - beztTree= BLI_dlrbTree_new(); + beztTree = BLI_dlrbTree_new(); /* populate tree with the BezTriples */ - for (v=0, bezt=fcu->bezt; v < fcu->totvert; v++, bezt++) + for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) BLI_dlrbTree_add(beztTree, compare_abk_bezt, nalloc_abk_bezt, nupdate_abk_bezt, bezt); /* make sure that it is suitable for linked-list searching too */ @@ -879,7 +881,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree } /* loop through beztriples, making ActKeysColumns and ActKeyBlocks */ - for (v=0, bezt=fcu->bezt; v < fcu->totvert; v++, bezt++) { + for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) { add_bezt_to_keycolumns_list(keys, bezt); if (blocks) add_bezt_to_keyblocks_list(blocks, beztTree, bezt); } @@ -908,7 +910,7 @@ void agroup_to_keylist(AnimData *adt, bActionGroup *agrp, DLRBT_Tree *keys, DLRB if (agrp) { /* loop through F-Curves */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) { + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { fcurve_to_keylist(adt, fcu, keys, blocks); } } @@ -920,7 +922,7 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree if (act) { /* loop through F-Curves */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { fcurve_to_keylist(adt, fcu, keys, blocks); } } @@ -933,7 +935,7 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys) if (gpl && keys) { /* although the frames should already be in an ordered list, they are not suitable for displaying yet */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) add_gpframe_to_keycolumns_list(keys, gpf); } } diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 4e59216a39c..b92d0fb345a 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -102,9 +102,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* set the F-Curve into the editdata so that it can be accessed */ if (ked) { - ked->fcu= fcu; - ked->curIndex= 0; - ked->curflags= ok; + ked->fcu = fcu; + ked->curIndex = 0; + ked->curflags = ok; } /* if function to apply to bezier curves is set, then loop through executing it on beztriples */ @@ -113,16 +113,16 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi * (this is should be more efficient than checking for it in every loop) */ if (key_ok) { - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if (ked) { /* advance the index, and reset the ok flags (to not influence the result) */ - ked->curIndex= i; - ked->curflags= 0; + ked->curIndex = i; + ked->curflags = 0; } /* Only operate on this BezTriple if it fullfills the criteria of the validation func */ if ( (ok = key_ok(ked, bezt)) ) { - if (ked) ked->curflags= ok; + if (ked) ked->curflags = ok; /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. @@ -132,8 +132,8 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi } } else { - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { - if (ked) ked->curIndex= i; + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { + if (ked) ked->curIndex = i; /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. @@ -145,9 +145,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* unset the F-Curve from the editdata now that it's done */ if (ked) { - ked->fcu= NULL; - ked->curIndex= 0; - ked->curflags= 0; + ked->fcu = NULL; + ked->curIndex = 0; + ked->curflags = 0; } /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */ @@ -170,7 +170,7 @@ static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, Keyf return 0; /* only iterate over the F-Curves that are in this group */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) { + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } @@ -188,7 +188,7 @@ static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEdi return 0; /* just loop through all F-Curves */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } @@ -203,7 +203,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ret=0; + int ret = 0; bAnimListElem dummychan = {NULL}; Base dummybase = {NULL}; @@ -224,12 +224,12 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ - for (ale= anim_data.first; ale; ale= ale->next) { - if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) { + for (ale = anim_data.first; ale; ale = ale->next) { + if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; break; } @@ -248,7 +248,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ret=0; + int ret = 0; bAnimListElem dummychan = {NULL}; @@ -266,12 +266,12 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ - for (ale= anim_data.first; ale; ale= ale->next) { - if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) { + for (ale = anim_data.first; ale; ale = ale->next) { + if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; break; } @@ -288,19 +288,19 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ret_code=0; + int filter, ret_code = 0; /* sanity check */ if (ac == NULL) return 0; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; + filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, working on the keyframes until the first curve aborts */ - for (ale= anim_data.first; ale; ale= ale->next) { - ret_code= ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); + for (ale = anim_data.first; ale; ale = ale->next) { + ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); if (ret_code) break; @@ -388,16 +388,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) bAnimListElem *ale; int filter; /* when not in graph view, don't use handles */ - SpaceIpo *sipo= (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; + SpaceIpo *sipo = (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; const short use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : FALSE; /* filter animation data */ - filter= ANIMFILTER_DATA_VISIBLE; + filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop over F-Curves that are likely to have been edited, and check them */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = ale->key_data; /* make sure keyframes in F-Curve are all in order, and handles are in valid positions */ sort_time_fcurve(fcu); @@ -439,7 +439,7 @@ static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt) /* frame is stored in f1 property (this float accuracy check may need to be dropped?) */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -452,7 +452,7 @@ static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt) /* frame range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][0] > ked->f1) && (bezt->vec[_index][0] < ked->f2)) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -462,7 +462,7 @@ static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt) static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { /* this macro checks all beztriple handles for selection... - * only one of the verts has to be selected for this to be ok... + * only one of the verts has to be selected for this to be ok... */ if (BEZSELECTED(bezt)) return KEYFRAME_OK_ALL; @@ -479,7 +479,7 @@ static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt) * - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too? */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -492,7 +492,7 @@ static short ok_bezier_valuerange(KeyframeEditData *ked, BezTriple *bezt) /* value range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][1] > ked->f1) && (bezt->vec[_index][1] < ked->f2)) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -506,7 +506,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) short ok = 0; #define KEY_CHECK_OK(_index) BLI_in_rctf(ked->data, bezt->vec[_index][0], bezt->vec[_index][1]) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -525,7 +525,7 @@ KeyframeEditFunc ANIM_editkeyframes_ok(short mode) return ok_bezier_frame; case BEZT_OK_FRAMERANGE: /* only if bezt falls within the specified frame range (floats) */ return ok_bezier_framerange; - case BEZT_OK_SELECTED: /* only if bezt is selected (self) */ + case BEZT_OK_SELECTED: /* only if bezt is selected (self) */ return ok_bezier_selected; case BEZT_OK_VALUE: /* only if bezt value matches (float) */ return ok_bezier_value; @@ -566,10 +566,10 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt) { /* only if selected */ if (bezt->f2 & SELECT) { - CfraElem *ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + CfraElem *ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked->list, ce); - ce->cfra= bezt->vec[1][0]; + ce->cfra = bezt->vec[1][0]; } return 0; @@ -580,15 +580,15 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt) */ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) { - KeyframeEditCD_Remap *rmap= (KeyframeEditCD_Remap*)ked->data; + KeyframeEditCD_Remap *rmap = (KeyframeEditCD_Remap *)ked->data; const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin); /* perform transform on all three handles unless indicated otherwise */ // TODO: need to include some checks for that - bezt->vec[0][0]= scale*(bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; - bezt->vec[1][0]= scale*(bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; - bezt->vec[2][0]= scale*(bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[2][0] = scale * (bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; } /* ******************************************* */ @@ -598,27 +598,27 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)(floorf(bezt->vec[1][0]+0.5f)); + bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f)); return 0; } /* snaps the keyframe to the neares second */ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; const float secf = (float)FPS; if (bezt->f2 & SELECT) - bezt->vec[1][0]= ((float)floor(bezt->vec[1][0]/secf + 0.5f) * secf); + bezt->vec[1][0] = ((float)floor(bezt->vec[1][0] / secf + 0.5f) * secf); return 0; } /* snaps the keyframe to the current frame */ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)CFRA; + bezt->vec[1][0] = (float)CFRA; return 0; } @@ -626,7 +626,7 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]); + bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]); return 0; } @@ -634,10 +634,10 @@ static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) { - bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; - if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1= HD_ALIGN; - if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2= HD_ALIGN; + if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN; + if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN; } return 0; } @@ -646,7 +646,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][1]= ked->f1; + bezt->vec[1][1] = ked->f1; return 0; } @@ -675,12 +675,12 @@ KeyframeEditFunc ANIM_editkeyframes_snap(short type) static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; float diff; if (bezt->f2 & SELECT) { - diff= ((float)CFRA - bezt->vec[1][0]); - bezt->vec[1][0]= ((float)CFRA + diff); + diff = ((float)CFRA - bezt->vec[1][0]); + bezt->vec[1][0] = ((float)CFRA + diff); } return 0; @@ -691,8 +691,8 @@ static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) float diff; if (bezt->f2 & SELECT) { - diff= (0.0f - bezt->vec[1][0]); - bezt->vec[1][0]= (0.0f + diff); + diff = (0.0f - bezt->vec[1][0]); + bezt->vec[1][0] = (0.0f + diff); } return 0; @@ -703,8 +703,8 @@ static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) float diff; if (bezt->f2 & SELECT) { - diff= (0.0f - bezt->vec[1][1]); - bezt->vec[1][1]= (0.0f + diff); + diff = (0.0f - bezt->vec[1][1]); + bezt->vec[1][1] = (0.0f + diff); } return 0; @@ -714,8 +714,8 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt) { /* mirroring time stored in f1 */ if (bezt->f2 & SELECT) { - const float diff= (ked->f1 - bezt->vec[1][0]); - bezt->vec[1][0]= (ked->f1 + diff); + const float diff = (ked->f1 - bezt->vec[1][0]); + bezt->vec[1][0] = (ked->f1 + diff); } return 0; @@ -727,8 +727,8 @@ static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt) /* value to mirror over is stored in the custom data -> first float value slot */ if (bezt->f2 & SELECT) { - diff= (ked->f1 - bezt->vec[1][1]); - bezt->vec[1][1]= (ked->f1 + diff); + diff = (ked->f1 - bezt->vec[1][1]); + bezt->vec[1][1] = (ked->f1 + diff); } return 0; @@ -763,17 +763,17 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) #define ENSURE_HANDLES_MATCH(bezt) \ if (bezt->h1 != bezt->h2) { \ if (ELEM3(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ - bezt->h1= HD_FREE; \ + bezt->h1 = HD_FREE; \ if (ELEM3(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ - bezt->h2= HD_FREE; \ + bezt->h2 = HD_FREE; \ } /* Sets the selected bezier handles to type 'auto' */ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_AUTO; - if (bezt->f3 & SELECT) bezt->h2= HD_AUTO; + if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO; + if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO; ENSURE_HANDLES_MATCH(bezt); } @@ -786,8 +786,8 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_AUTO_ANIM; - if (bezt->f3 & SELECT) bezt->h2= HD_AUTO_ANIM; + if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO_ANIM; + if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO_ANIM; ENSURE_HANDLES_MATCH(bezt); } @@ -797,8 +797,8 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b /* Sets the selected bezier handles to type 'vector' */ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_VECT; - if (bezt->f3 & SELECT) bezt->h2= HD_VECT; + if (bezt->f1 & SELECT) bezt->h1 = HD_VECT; + if (bezt->f3 & SELECT) bezt->h2 = HD_VECT; return 0; } @@ -815,16 +815,16 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Sets selected bezier handles to type 'align' */ static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_ALIGN; - if (bezt->f3 & SELECT) bezt->h2= HD_ALIGN; + if (bezt->f1 & SELECT) bezt->h1 = HD_ALIGN; + if (bezt->f3 & SELECT) bezt->h2 = HD_ALIGN; return 0; } /* Sets selected bezier handles to type 'free' */ static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_FREE; - if (bezt->f3 & SELECT) bezt->h2= HD_FREE; + if (bezt->f1 & SELECT) bezt->h1 = HD_FREE; + if (bezt->f3 & SELECT) bezt->h2 = HD_FREE; return 0; } @@ -855,21 +855,21 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code) static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_CONST; + bezt->ipo = BEZT_IPO_CONST; return 0; } static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_LIN; + bezt->ipo = BEZT_IPO_LIN; return 0; } static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_BEZ; + bezt->ipo = BEZT_IPO_BEZ; return 0; } @@ -892,28 +892,28 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_KEYFRAME; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME; return 0; } static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_BREAKDOWN; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN; return 0; } static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_EXTREME; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME; return 0; } static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_JITTER; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER; return 0; } @@ -1017,32 +1017,32 @@ KeyframeEditFunc ANIM_editkeyframes_select(short selectmode) static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt) { - FCurve *fcu= ked->fcu; - char *map= ked->data; - int i= ked->curIndex; + FCurve *fcu = ked->fcu; + char *map = ked->data; + int i = ked->curIndex; /* if current is selected, just make sure it stays this way */ if (BEZSELECTED(bezt)) { - map[i]= 1; + map[i] = 1; return 0; } /* if previous is selected, that means that selection should extend across */ if (i > 0) { - BezTriple *prev= bezt - 1; + BezTriple *prev = bezt - 1; if (BEZSELECTED(prev)) { - map[i]= 1; + map[i] = 1; return 0; } } /* if next is selected, that means that selection should extend across */ - if (i < (fcu->totvert-1)) { - BezTriple *next= bezt + 1; + if (i < (fcu->totvert - 1)) { + BezTriple *next = bezt + 1; if (BEZSELECTED(next)) { - map[i]= 1; + map[i] = 1; return 0; } } @@ -1052,9 +1052,9 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt) static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) { - FCurve *fcu= ked->fcu; - char *map= ked->data; - int i= ked->curIndex; + FCurve *fcu = ked->fcu; + char *map = ked->data; + int i = ked->curIndex; /* if current is selected, check the left/right keyframes * since it might need to be deselected (but otherwise no) @@ -1062,7 +1062,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) if (BEZSELECTED(bezt)) { /* if previous is not selected, we're on the tip of an iceberg */ if (i > 0) { - BezTriple *prev= bezt - 1; + BezTriple *prev = bezt - 1; if (BEZSELECTED(prev) == 0) return 0; @@ -1073,19 +1073,19 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) } /* if next is not selected, we're on the tip of an iceberg */ - if (i < (fcu->totvert-1)) { - BezTriple *next= bezt + 1; + if (i < (fcu->totvert - 1)) { + BezTriple *next = bezt + 1; if (BEZSELECTED(next) == 0) return 0; } - else if (i == (fcu->totvert-1)) { + else if (i == (fcu->totvert - 1)) { /* current keyframe is selected at an endpoint, so should get deselected */ return 0; } /* if we're still here, that means that keyframe should remain untouched */ - map[i]= 1; + map[i] = 1; } return 0; @@ -1109,8 +1109,8 @@ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode) /* flush selection map values to the given beztriple */ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt) { - char *map= ked->data; - short on= map[ked->curIndex]; + char *map = ked->data; + short on = map[ked->curIndex]; /* select or deselect based on whether the map allows it or not */ if (on) { diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index c54f8c5bd25..05c87e98f9b 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -90,13 +90,13 @@ void delete_fcurve_key(FCurve *fcu, int index, short do_recalc) index += fcu->totvert; /* Delete this keyframe */ - memmove(&fcu->bezt[index], &fcu->bezt[index+1], sizeof(BezTriple)*(fcu->totvert-index-1)); + memmove(&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1)); fcu->totvert--; if (fcu->totvert == 0) { if (fcu->bezt) MEM_freeN(fcu->bezt); - fcu->bezt= NULL; + fcu->bezt = NULL; } /* recalc handles - only if it won't cause problems */ @@ -109,13 +109,13 @@ void delete_fcurve_keys(FCurve *fcu) { int i; - if (fcu->bezt==NULL) /* ignore baked curves */ + if (fcu->bezt == NULL) /* ignore baked curves */ return; /* Delete selected BezTriples */ - for (i=0; i < fcu->totvert; i++) { + for (i = 0; i < fcu->totvert; i++) { if (fcu->bezt[i].f2 & SELECT) { - memmove(&fcu->bezt[i], &fcu->bezt[i+1], sizeof(BezTriple)*(fcu->totvert-i-1)); + memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1)); fcu->totvert--; i--; } @@ -131,9 +131,9 @@ void clear_fcurve_keys(FCurve *fcu) { if (fcu->bezt) MEM_freeN(fcu->bezt); - fcu->bezt= NULL; + fcu->bezt = NULL; - fcu->totvert= 0; + fcu->totvert = 0; } /* ---------------- */ @@ -148,20 +148,20 @@ void duplicate_fcurve_keys(FCurve *fcu) if (ELEM(NULL, fcu, fcu->bezt)) return; - for (i=0; i < fcu->totvert; i++) { + for (i = 0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { /* Expand the list */ - newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert+1), "beztriple"); + newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); - memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i+1)); - memcpy(newbezt+i+1, fcu->bezt+i, sizeof(BezTriple)); - memcpy(newbezt+i+2, fcu->bezt+i+1, sizeof (BezTriple) *(fcu->totvert-(i+1))); + memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); + memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); + memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof (BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; /* reassign pointers... (free old, and add new) */ MEM_freeN(fcu->bezt); - fcu->bezt=newbezt; + fcu->bezt = newbezt; /* Unselect the current key */ BEZ_DESEL(&fcu->bezt[i]); @@ -200,20 +200,20 @@ void clean_fcurve(FCurve *fcu, float thresh) /* Loop through BezTriples, comparing them. Skip any that do * not fit the criteria for "ok" points. */ - for (i=1; i<totCount; i++) { + for (i = 1; i < totCount; i++) { float prev[2], cur[2], next[2]; /* get BezTriples and their values */ if (i < (totCount - 1)) { - beztn = (old_bezts + (i+1)); - next[0]= beztn->vec[1][0]; next[1]= beztn->vec[1][1]; + beztn = (old_bezts + (i + 1)); + next[0] = beztn->vec[1][0]; next[1] = beztn->vec[1][1]; } else { beztn = NULL; next[0] = next[1] = 0.0f; } - lastb= (fcu->bezt + (fcu->totvert - 1)); - bezt= (old_bezts + i); + lastb = (fcu->bezt + (fcu->totvert - 1)); + bezt = (old_bezts + i); /* get references for quicker access */ prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1]; @@ -226,7 +226,7 @@ void clean_fcurve(FCurve *fcu, float thresh) * current is further away than the next one is to the previous. */ if (beztn && (IS_EQT(cur[0], next[0], thresh)) && - (IS_EQT(next[1], prev[1], thresh)==0)) + (IS_EQT(next[1], prev[1], thresh) == 0)) { /* only add if current is further away from previous */ if (cur[1] > next[1]) { @@ -276,8 +276,8 @@ void clean_fcurve(FCurve *fcu, float thresh) /* temp struct used for smooth_fcurve */ typedef struct tSmooth_Bezt { - float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */ - float y1, y2, y3; /* averaged before/new/after y-values */ + float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */ + float y1, y2, y3; /* averaged before/new/after y-values */ } tSmooth_Bezt; /* Use a weighted moving-means method to reduce intensity of fluctuations */ @@ -288,8 +288,8 @@ void smooth_fcurve(FCurve *fcu) int i, x, totSel = 0; /* first loop through - count how many verts are selected */ - bezt= fcu->bezt; - for (i=0; i < fcu->totvert; i++, bezt++) { + bezt = fcu->bezt; + for (i = 0; i < fcu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) totSel++; } @@ -299,11 +299,11 @@ void smooth_fcurve(FCurve *fcu) tSmooth_Bezt *tarray, *tsb; /* allocate memory in one go */ - tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); /* populate tarray with data of selected points */ - bezt= fcu->bezt; - for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + bezt = fcu->bezt; + for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { if (BEZSELECTED(bezt)) { /* tsb simply needs pointer to vec, and index */ tsb->h1 = &bezt->vec[0][1]; @@ -311,7 +311,7 @@ void smooth_fcurve(FCurve *fcu) tsb->h3 = &bezt->vec[2][1]; /* advance to the next tsb to populate */ - if (x < totSel-1) + if (x < totSel - 1) tsb++; else break; @@ -321,19 +321,19 @@ void smooth_fcurve(FCurve *fcu) /* calculate the new smoothed F-Curve's with weighted averages: * - this is done with two passes to avoid progressive corruption errors * - uses 5 points for each operation (which stores in the relevant handles) - * - previous: w/a ratio = 3:5:2:1:1 - * - next: w/a ratio = 1:1:2:5:3 + * - previous: w/a ratio = 3:5:2:1:1 + * - next: w/a ratio = 1:1:2:5:3 */ /* round 1: calculate smoothing deltas and new values */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { + tsb = tarray; + for (i = 0; i < totSel; i++, tsb++) { /* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */ - if (ELEM(i, 0, (totSel-1)) == 0) { + if (ELEM(i, 0, (totSel - 1)) == 0) { const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL); const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); + const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL); const float p1 = *tP1->h2; const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); @@ -342,18 +342,18 @@ void smooth_fcurve(FCurve *fcu) const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); /* calculate previous and next, then new position by averaging these */ - tsb->y1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; - tsb->y3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + tsb->y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12; + tsb->y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12; tsb->y2 = (tsb->y1 + tsb->y3) / 2; } } /* round 2: apply new values */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { + tsb = tarray; + for (i = 0; i < totSel; i++, tsb++) { /* don't touch end points, as their values were't touched above */ - if (ELEM(i, 0, (totSel-1)) == 0) { + if (ELEM(i, 0, (totSel - 1)) == 0) { /* y2 takes the average of the 2 points */ *tsb->h2 = tsb->y2; @@ -382,42 +382,42 @@ typedef struct tempFrameValCache { /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ void sample_fcurve(FCurve *fcu) { - BezTriple *bezt, *start=NULL, *end=NULL; + BezTriple *bezt, *start = NULL, *end = NULL; tempFrameValCache *value_cache, *fp; int sfra, range; int i, n, nIndex; - if (fcu->bezt==NULL) /* ignore baked */ + if (fcu->bezt == NULL) /* ignore baked */ return; /* find selected keyframes... once pair has been found, add keyframes */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if selected, and which end this is */ if (BEZSELECTED(bezt)) { if (start) { /* set end */ - end= bezt; + end = bezt; /* cache values then add keyframes using these values, as adding * keyframes while sampling will affect the outcome... * - only start sampling+adding from index=1, so that we don't overwrite original keyframe */ - range= (int)( ceil(end->vec[1][0] - start->vec[1][0]) ); - sfra= (int)( floor(start->vec[1][0]) ); + range = (int)(ceil(end->vec[1][0] - start->vec[1][0]) ); + sfra = (int)(floor(start->vec[1][0]) ); if (range) { - value_cache= MEM_callocN(sizeof(tempFrameValCache)*range, "IcuFrameValCache"); + value_cache = MEM_callocN(sizeof(tempFrameValCache) * range, "IcuFrameValCache"); - /* sample values */ - for (n=1, fp=value_cache; n<range && fp; n++, fp++) { - fp->frame= (float)(sfra + n); - fp->val= evaluate_fcurve(fcu, fp->frame); + /* sample values */ + for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { + fp->frame = (float)(sfra + n); + fp->val = evaluate_fcurve(fcu, fp->frame); } - /* add keyframes with these, tagging as 'breakdowns' */ - for (n=1, fp=value_cache; n<range && fp; n++, fp++) { - nIndex= insert_vert_fcurve(fcu, fp->frame, fp->val, 1); - BEZKEYTYPE(fcu->bezt + nIndex)= BEZT_KEYTYPE_BREAKDOWN; + /* add keyframes with these, tagging as 'breakdowns' */ + for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { + nIndex = insert_vert_fcurve(fcu, fp->frame, fp->val, 1); + BEZKEYTYPE(fcu->bezt + nIndex) = BEZT_KEYTYPE_BREAKDOWN; } /* free temp cache */ @@ -429,13 +429,13 @@ void sample_fcurve(FCurve *fcu) } /* bezt was selected, so it now marks the start of a whole new chain to search */ - start= bezt; - end= NULL; + start = bezt; + end = NULL; } else { /* just set start keyframe */ - start= bezt; - end= NULL; + start = bezt; + end = NULL; } } } @@ -455,23 +455,23 @@ void sample_fcurve(FCurve *fcu) /* globals for copy/paste data (like for other copy/paste buffers) */ static ListBase animcopybuf = {NULL, NULL}; -static float animcopy_firstframe= 999999999.0f; -static float animcopy_lastframe= -999999999.0f; -static float animcopy_cfra= 0.0; +static float animcopy_firstframe = 999999999.0f; +static float animcopy_lastframe = -999999999.0f; +static float animcopy_cfra = 0.0; /* datatype for use in copy/paste buffer */ typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; - ID *id; /* ID which owns the curve */ - bActionGroup *grp; /* Action Group */ - char *rna_path; /* RNA-Path */ - int array_index; /* array index */ + ID *id; /* ID which owns the curve */ + bActionGroup *grp; /* Action Group */ + char *rna_path; /* RNA-Path */ + int array_index; /* array index */ - int totvert; /* number of keyframes stored for this channel */ - BezTriple *bezt; /* keyframes in buffer */ + int totvert; /* number of keyframes stored for this channel */ + BezTriple *bezt; /* keyframes in buffer */ - short id_type; /* Result of GS(id->name)*/ + short id_type; /* Result of GS(id->name)*/ } tAnimCopybufItem; @@ -482,8 +482,8 @@ void free_anim_copybuf(void) tAnimCopybufItem *aci, *acn; /* free each buffer element */ - for (aci= animcopybuf.first; aci; aci= acn) { - acn= aci->next; + for (aci = animcopybuf.first; aci; aci = acn) { + acn = aci->next; /* free keyframes */ if (aci->bezt) @@ -498,9 +498,9 @@ void free_anim_copybuf(void) } /* restore initial state */ - animcopybuf.first= animcopybuf.last= NULL; - animcopy_firstframe= 999999999.0f; - animcopy_lastframe= -999999999.0f; + animcopybuf.first = animcopybuf.last = NULL; + animcopy_firstframe = 999999999.0f; + animcopy_lastframe = -999999999.0f; } /* ------------------- */ @@ -509,14 +509,14 @@ void free_anim_copybuf(void) short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) { bAnimListElem *ale; - Scene *scene= ac->scene; + Scene *scene = ac->scene; /* clear buffer first */ free_anim_copybuf(); /* assume that each of these is an F-Curve */ - for (ale= anim_data->first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data->first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; tAnimCopybufItem *aci; BezTriple *bezt, *nbezt, *newbuf; int i; @@ -529,42 +529,42 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) continue; /* init copybuf item info */ - aci= MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); - aci->id= ale->id; - aci->id_type= GS(ale->id->name); - aci->grp= fcu->grp; - aci->rna_path= MEM_dupallocN(fcu->rna_path); - aci->array_index= fcu->array_index; + aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); + aci->id = ale->id; + aci->id_type = GS(ale->id->name); + aci->grp = fcu->grp; + aci->rna_path = MEM_dupallocN(fcu->rna_path); + aci->array_index = fcu->array_index; BLI_addtail(&animcopybuf, aci); /* add selected keyframes to buffer */ // TODO: currently, we resize array everytime we add a new vert - this works ok as long as it is assumed only a few keys are copied - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) { /* add to buffer */ - newbuf= MEM_callocN(sizeof(BezTriple)*(aci->totvert+1), "copybuf beztriple"); + newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple"); /* assume that since we are just re-sizing the array, just copy all existing data across */ if (aci->bezt) - memcpy(newbuf, aci->bezt, sizeof(BezTriple)*(aci->totvert)); + memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert)); /* copy current beztriple across too */ - nbezt= &newbuf[aci->totvert]; - *nbezt= *bezt; + nbezt = &newbuf[aci->totvert]; + *nbezt = *bezt; /* ensure copy buffer is selected so pasted keys are selected */ BEZ_SEL(nbezt); /* free old array and set the new */ if (aci->bezt) MEM_freeN(aci->bezt); - aci->bezt= newbuf; + aci->bezt = newbuf; aci->totvert++; /* check if this is the earliest frame encountered so far */ if (bezt->vec[1][0] < animcopy_firstframe) - animcopy_firstframe= bezt->vec[1][0]; + animcopy_firstframe = bezt->vec[1][0]; if (bezt->vec[1][0] > animcopy_lastframe) - animcopy_lastframe= bezt->vec[1][0]; + animcopy_lastframe = bezt->vec[1][0]; } } @@ -575,7 +575,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) return -1; /* in case 'relative' paste method is used */ - animcopy_cfra= CFRA; + animcopy_cfra = CFRA; /* everything went fine */ return 0; @@ -588,7 +588,7 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, const short from_ { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if (to_simple || (aci->rna_path && fcu->rna_path)) { if (to_simple || (strcmp(aci->rna_path, fcu->rna_path) == 0)) { @@ -606,7 +606,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if (aci->rna_path && fcu->rna_path) { /* find the property of the fcurve and compare against the end of the tAnimCopybufItem @@ -627,12 +627,12 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f RNA_path_resolve(&id_ptr, aci->rna_path, &rptr, &prop); if (prop) { - const char *identifier= RNA_property_identifier(prop); + const char *identifier = RNA_property_identifier(prop); int len_id = strlen(identifier); int len_path = strlen(fcu->rna_path); if (len_id <= len_path) { /* note, paths which end with "] will fail with this test - Animated ID Props */ - if (strcmp(identifier, fcu->rna_path + (len_path-len_id))==0) { + if (strcmp(identifier, fcu->rna_path + (len_path - len_id)) == 0) { if ((from_single) || (aci->array_index == fcu->array_index)) break; } @@ -653,7 +653,7 @@ static tAnimCopybufItem *pastebuf_match_index_only(FCurve *fcu, const short from { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if ((from_single) || (aci->array_index == fcu->array_index)) { break; @@ -672,7 +672,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float int i; /* First de-select existing FCuvre */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { bezt->f2 &= ~SELECT; } @@ -693,19 +693,19 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float float f_min; float f_max; - if (merge_mode==KEYFRAME_PASTE_MERGE_OVER_RANGE) { - f_min= aci->bezt[0].vec[1][0] + offset; - f_max= aci->bezt[aci->totvert-1].vec[1][0] + offset; + if (merge_mode == KEYFRAME_PASTE_MERGE_OVER_RANGE) { + f_min = aci->bezt[0].vec[1][0] + offset; + f_max = aci->bezt[aci->totvert - 1].vec[1][0] + offset; } else { /* Entire Range */ - f_min= animcopy_firstframe + offset; - f_max= animcopy_lastframe + offset; + f_min = animcopy_firstframe + offset; + f_max = animcopy_lastframe + offset; } /* remove keys in range */ if (f_min < f_max) { /* select verts in range for removal */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if ((f_min < bezt[0].vec[1][0]) && (bezt[0].vec[1][0] < f_max)) { bezt->f2 |= SELECT; } @@ -719,7 +719,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float } /* just start pasting, with the the first keyframe on the current frame, and so on */ - for (i=0, bezt=aci->bezt; i < aci->totvert; i++, bezt++) { + for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) { /* temporarily apply offset to src beztriple while copying */ bezt->vec[0][0] += offset; bezt->vec[1][0] += offset; @@ -765,10 +765,10 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, { bAnimListElem *ale; - const Scene *scene= (ac->scene); + const Scene *scene = (ac->scene); - const short from_single= (animcopybuf.first == animcopybuf.last); - const short to_simple= (anim_data->first == anim_data->last); + const short from_single = (animcopybuf.first == animcopybuf.last); + const short to_simple = (anim_data->first == anim_data->last); float offset = 0.0f; int pass; @@ -787,16 +787,16 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, /* mathods of offset */ switch (offset_mode) { case KEYFRAME_PASTE_OFFSET_CFRA_START: - offset= (float)(CFRA - animcopy_firstframe); + offset = (float)(CFRA - animcopy_firstframe); break; case KEYFRAME_PASTE_OFFSET_CFRA_END: - offset= (float)(CFRA - animcopy_lastframe); + offset = (float)(CFRA - animcopy_lastframe); break; case KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE: - offset= (float)(CFRA - animcopy_cfra); + offset = (float)(CFRA - animcopy_cfra); break; case KEYFRAME_PASTE_OFFSET_NONE: - offset= 0.0f; + offset = 0.0f; break; } @@ -805,44 +805,44 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, FCurve *fcu; tAnimCopybufItem *aci; - ale= anim_data->first; - fcu= (FCurve *)ale->data; /* destination F-Curve */ - aci= animcopybuf.first; + ale = anim_data->first; + fcu = (FCurve *)ale->data; /* destination F-Curve */ + aci = animcopybuf.first; paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode); } else { /* from selected channels - * This "passes" system aims to try to find "matching" channels to paste keyframes - * into with increasingly loose matching heuristics. The process finishes when at least - * one F-Curve has been pasted into. + * This "passes" system aims to try to find "matching" channels to paste keyframes + * into with increasingly loose matching heuristics. The process finishes when at least + * one F-Curve has been pasted into. */ - for (pass= 0; pass < 3; pass++) { - unsigned int totmatch= 0; + for (pass = 0; pass < 3; pass++) { + unsigned int totmatch = 0; - for (ale= anim_data->first; ale; ale= ale->next) { + for (ale = anim_data->first; ale; ale = ale->next) { /* find buffer item to paste from * - if names don't matter (i.e. only 1 channel in buffer), don't check id/group * - if names do matter, only check if id-type is ok for now (group check is not that important) * - most importantly, rna-paths should match (array indices are unimportant for now) */ - FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ - tAnimCopybufItem *aci= NULL; + FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ + tAnimCopybufItem *aci = NULL; switch (pass) { case 0: /* most strict, must be exact path match data_path & index */ - aci= pastebuf_match_path_full(fcu, from_single, to_simple); + aci = pastebuf_match_path_full(fcu, from_single, to_simple); break; case 1: /* less strict, just compare property names */ - aci= pastebuf_match_path_property(fcu, from_single, to_simple); + aci = pastebuf_match_path_property(fcu, from_single, to_simple); break; case 2: /* Comparing properties gave no results, so just do index comparisons */ - aci= pastebuf_match_index_only(fcu, from_single, to_simple); + aci = pastebuf_match_index_only(fcu, from_single, to_simple); break; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 9d51b42f1a2..2a68d32557a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -121,14 +121,14 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode) /* Get (or add relevant data to be able to do so) the Active Action for the given * Animation Data block, given an ID block where the Animation Data should reside. */ -bAction *verify_adt_action (ID *id, short add) +bAction *verify_adt_action(ID *id, short add) { AnimData *adt; /* init animdata if none available yet */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) - adt= BKE_id_add_animdata(id); + adt = BKE_id_add_animdata(id); if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>"); @@ -138,9 +138,9 @@ bAction *verify_adt_action (ID *id, short add) /* init action if none available yet */ // TODO: need some wizardry to handle NLA stuff correct if ((adt->action == NULL) && (add)) { - char actname[sizeof(id->name)-2]; - BLI_snprintf(actname, sizeof(actname), "%sAction", id->name+2); - adt->action= add_empty_action(actname); + char actname[sizeof(id->name) - 2]; + BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); + adt->action = add_empty_action(actname); } /* return the action */ @@ -150,7 +150,7 @@ bAction *verify_adt_action (ID *id, short add) /* Get (or add relevant data to be able to do so) F-Curve from the Active Action, * for the given Animation Data block. This assumes that all the destinations are valid. */ -FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], const int array_index, short add) +FCurve *verify_fcurve(bAction *act, const char group[], const char rna_path[], const int array_index, short add) { bActionGroup *grp; FCurve *fcu; @@ -164,30 +164,30 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], * TODO: add auto-grouping support? how this works will need to be resolved */ if (act) - fcu= list_find_fcurve(&act->curves, rna_path, array_index); + fcu = list_find_fcurve(&act->curves, rna_path, array_index); else - fcu= NULL; + fcu = NULL; if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); - if (act->curves.first==NULL) - fcu->flag |= FCURVE_ACTIVE; /* first one added active */ + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); + if (act->curves.first == NULL) + fcu->flag |= FCURVE_ACTIVE; /* first one added active */ /* store path - make copy, and store that */ - fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); - fcu->array_index= array_index; + fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); + fcu->array_index = array_index; /* if a group name has been provided, try to add or find a group, then add F-Curve to it */ if (group) { /* try to find group */ - grp= action_groups_find_named(act, group); + grp = BKE_action_group_find_name(act, group); /* no matching groups, so add one */ if (grp == NULL) - grp= action_groups_add_new(act, group); + grp = action_groups_add_new(act, group); /* add F-Curve to group */ action_groups_add_channel(act, grp, fcu); @@ -212,11 +212,11 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], * suitable place in chronological order. * * NOTE: any recalculate of the F-Curve that needs to be done will need to - * be done by the caller. + * be done by the caller. */ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) { - int i= 0; + int i = 0; /* are there already keyframes? */ if (fcu->bezt) { @@ -228,17 +228,17 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) /* sanity check: 'i' may in rare cases exceed arraylen */ if ((i >= 0) && (i < fcu->totvert)) { /* just change the values when replacing, so as to not overwrite handles */ - BezTriple *dst= (fcu->bezt + i); - float dy= bezt->vec[1][1] - dst->vec[1][1]; + BezTriple *dst = (fcu->bezt + i); + float dy = bezt->vec[1][1] - dst->vec[1][1]; /* just apply delta value change to the handle values */ dst->vec[0][1] += dy; dst->vec[1][1] += dy; dst->vec[2][1] += dy; - dst->f1= bezt->f1; - dst->f2= bezt->f2; - dst->f3= bezt->f3; + dst->f1 = bezt->f1; + dst->f2 = bezt->f2; + dst->f3 = bezt->f3; // TODO: perform some other operations? } @@ -246,22 +246,22 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) /* keyframing modes allow to not replace keyframe */ else if ((flag & INSERTKEY_REPLACE) == 0) { /* insert new - if we're not restricted to replacing keyframes only */ - BezTriple *newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple"); + BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple"); /* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */ if (i > 0) - memcpy(newb, fcu->bezt, i*sizeof(BezTriple)); + memcpy(newb, fcu->bezt, i * sizeof(BezTriple)); /* add beztriple to paste at index i */ - *(newb + i)= *bezt; + *(newb + i) = *bezt; /* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */ if (i < fcu->totvert) - memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple)); + memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple)); /* replace (+ free) old with new, only if necessary to do so */ MEM_freeN(fcu->bezt); - fcu->bezt= newb; + fcu->bezt = newb; fcu->totvert++; } @@ -272,11 +272,11 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, * // but for now, having both is asking for trouble */ - else if ((flag & INSERTKEY_REPLACE)==0 && (fcu->fpt==NULL)) { + else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) { /* create new keyframes array */ - fcu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple"); - *(fcu->bezt)= *bezt; - fcu->totvert= 1; + fcu->bezt = MEM_callocN(sizeof(BezTriple), "beztriple"); + *(fcu->bezt) = *bezt; + fcu->totvert = 1; } /* cannot add anything */ else { @@ -297,25 +297,25 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) */ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) { - BezTriple beztr= {{{0}}}; + BezTriple beztr = {{{0}}}; unsigned int oldTot = fcu->totvert; int a; /* set all three points, for nicer start position * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... */ - beztr.vec[0][0]= x-1.0f; - beztr.vec[0][1]= y; - beztr.vec[1][0]= x; - beztr.vec[1][1]= y; - beztr.vec[2][0]= x+1.0f; - beztr.vec[2][1]= y; - beztr.f1= beztr.f2= beztr.f3= SELECT; - beztr.h1= beztr.h2= U.keyhandles_new; /* use default handle type here */ + beztr.vec[0][0] = x - 1.0f; + beztr.vec[0][1] = y; + beztr.vec[1][0] = x; + beztr.vec[1][1] = y; + beztr.vec[2][0] = x + 1.0f; + beztr.vec[2][1] = y; + beztr.f1 = beztr.f2 = beztr.f3 = SELECT; + beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */ //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */ /* use default interpolation mode, with exceptions for int/discrete values */ - beztr.ipo= U.ipo_new; + beztr.ipo = U.ipo_new; if (fcu->flag & FCURVE_DISCRETE_VALUES) beztr.ipo = BEZT_IPO_CONST; @@ -323,7 +323,7 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) beztr.ipo = BEZT_IPO_LIN; /* add temp beztriple to keyframes */ - a= insert_bezt_fcurve(fcu, &beztr, flag); + a = insert_bezt_fcurve(fcu, &beztr, flag); /* what if 'a' is a negative index? * for now, just exit to prevent any segfaults @@ -338,18 +338,18 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) calchandles_fcurve(fcu); /* set handletype and interpolation */ - if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE)==0) { - BezTriple *bezt= (fcu->bezt + a); + if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) { + BezTriple *bezt = (fcu->bezt + a); /* set interpolation from previous (if available), but only if we didn't just replace some keyframe - * - replacement is indicated by no-change in number of verts + * - replacement is indicated by no-change in number of verts * - when replacing, the user may have specified some interpolation that should be kept */ if (fcu->totvert > oldTot) { if (a > 0) - bezt->ipo= (bezt-1)->ipo; - else if (a < fcu->totvert-1) - bezt->ipo= (bezt+1)->ipo; + bezt->ipo = (bezt - 1)->ipo; + else if (a < fcu->totvert - 1) + bezt->ipo = (bezt + 1)->ipo; } /* don't recalculate handles if fast is set @@ -379,33 +379,33 @@ enum { * 2. Keyframe to be added on frame where two keyframes are already situated * 3. Keyframe lies at point that intersects the linear line between two keyframes */ -static short new_key_needed (FCurve *fcu, float cFrame, float nValue) +static short new_key_needed(FCurve *fcu, float cFrame, float nValue) { - BezTriple *bezt=NULL, *prev=NULL; + BezTriple *bezt = NULL, *prev = NULL; int totCount, i; float valA = 0.0f, valB = 0.0f; /* safety checking */ if (fcu == NULL) return KEYNEEDED_JUSTADD; - totCount= fcu->totvert; + totCount = fcu->totvert; if (totCount == 0) return KEYNEEDED_JUSTADD; /* loop through checking if any are the same */ - bezt= fcu->bezt; - for (i=0; i<totCount; i++) { - float prevPosi=0.0f, prevVal=0.0f; - float beztPosi=0.0f, beztVal=0.0f; + bezt = fcu->bezt; + for (i = 0; i < totCount; i++) { + float prevPosi = 0.0f, prevVal = 0.0f; + float beztPosi = 0.0f, beztVal = 0.0f; /* get current time+value */ - beztPosi= bezt->vec[1][0]; - beztVal= bezt->vec[1][1]; + beztPosi = bezt->vec[1][0]; + beztVal = bezt->vec[1][1]; if (prev) { /* there is a keyframe before the one currently being examined */ /* get previous time+value */ - prevPosi= prev->vec[1][0]; - prevVal= prev->vec[1][1]; + prevPosi = prev->vec[1][0]; + prevVal = prev->vec[1][1]; /* keyframe to be added at point where there are already two similar points? */ if (IS_EQF(prevPosi, cFrame) && IS_EQF(beztPosi, cFrame) && IS_EQF(beztPosi, prevPosi)) { @@ -422,7 +422,7 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) float realVal; /* get real value of curve at that point */ - realVal= evaluate_fcurve(fcu, cFrame); + realVal = evaluate_fcurve(fcu, cFrame); /* compare whether it's the same as proposed */ if (IS_EQF(realVal, nValue)) @@ -448,13 +448,13 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) /* just add a keyframe if there's only one keyframe * and the new one occurs before the existing one does. */ - if ((cFrame < beztPosi) && (totCount==1)) + if ((cFrame < beztPosi) && (totCount == 1)) return KEYNEEDED_JUSTADD; } /* continue. frame to do not yet passed (or other conditions not met) */ - if (i < (totCount-1)) { - prev= bezt; + if (i < (totCount - 1)) { + prev = bezt; bezt++; } else @@ -468,13 +468,13 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) * -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last * keyframe is not equal to last keyframe. */ - bezt= (fcu->bezt + (fcu->totvert - 1)); - valA= bezt->vec[1][1]; + bezt = (fcu->bezt + (fcu->totvert - 1)); + valA = bezt->vec[1][1]; if (prev) - valB= prev->vec[1][1]; + valB = prev->vec[1][1]; else - valB= bezt->vec[1][1] + 1.0f; + valB = bezt->vec[1][1] + 1.0f; if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) return KEYNEEDED_DELPREV; @@ -485,31 +485,31 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) /* ------------------ RNA Data-Access Functions ------------------ */ /* Try to read value using RNA-properties obtained already */ -static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int index) +static float setting_get_rna_value(PointerRNA *ptr, PropertyRNA *prop, int index) { - float value= 0.0f; + float value = 0.0f; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_length(ptr, prop)) - value= (float)RNA_property_boolean_get_index(ptr, prop, index); + value = (float)RNA_property_boolean_get_index(ptr, prop, index); else - value= (float)RNA_property_boolean_get(ptr, prop); + value = (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: if (RNA_property_array_length(ptr, prop)) - value= (float)RNA_property_int_get_index(ptr, prop, index); + value = (float)RNA_property_int_get_index(ptr, prop, index); else - value= (float)RNA_property_int_get(ptr, prop); + value = (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: if (RNA_property_array_length(ptr, prop)) - value= RNA_property_float_get_index(ptr, prop, index); + value = RNA_property_float_get_index(ptr, prop, index); else - value= RNA_property_float_get(ptr, prop); + value = RNA_property_float_get(ptr, prop); break; case PROP_ENUM: - value= (float)RNA_property_enum_get(ptr, prop); + value = (float)RNA_property_enum_get(ptr, prop); break; default: break; @@ -534,12 +534,12 @@ enum { * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying * settings is on. */ -static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) +static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) { - bConstraint *con= NULL; - short searchtype= VISUALKEY_NONE; + bConstraint *con = NULL; + short searchtype = VISUALKEY_NONE; short has_parent = FALSE; - const char *identifier= NULL; + const char *identifier = NULL; /* validate data */ // TODO: this check is probably not needed, but it won't hurt @@ -547,25 +547,25 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 0; /* get first constraint and determine type of keyframe constraints to check for - * - constraints can be on either Objects or PoseChannels, so we only check if the + * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for * those structs, allowing us to identify the owner of the data */ if (ptr->type == &RNA_Object) { /* Object */ - Object *ob= (Object *)ptr->data; + Object *ob = (Object *)ptr->data; - con= ob->constraints.first; - identifier= RNA_property_identifier(prop); - has_parent= (ob->parent != NULL); + con = ob->constraints.first; + identifier = RNA_property_identifier(prop); + has_parent = (ob->parent != NULL); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ - bPoseChannel *pchan= (bPoseChannel *)ptr->data; + bPoseChannel *pchan = (bPoseChannel *)ptr->data; - con= pchan->constraints.first; - identifier= RNA_property_identifier(prop); - has_parent= (pchan->parent != NULL); + con = pchan->constraints.first; + identifier = RNA_property_identifier(prop); + has_parent = (pchan->parent != NULL); } /* check if any data to search using */ @@ -578,10 +578,10 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 0; } else if (strstr(identifier, "location")) { - searchtype= VISUALKEY_LOC; + searchtype = VISUALKEY_LOC; } else if (strstr(identifier, "rotation")) { - searchtype= VISUALKEY_ROT; + searchtype = VISUALKEY_ROT; } else { printf("%s failed: identifier - '%s'\n", __func__, identifier); @@ -596,7 +596,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 1; /* constraints */ - for (; con; con= con->next) { + for (; con; con = con->next) { /* only consider constraint if it is not disabled, and has influence */ if (con->flag & CONSTRAINT_DISABLE) continue; if (con->enforce == 0.0f) continue; @@ -616,28 +616,28 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) /* single-transform constraits */ case CONSTRAINT_TYPE_TRACKTO: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_ROTLIMIT: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_LOCLIMIT: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_ROTLIKE: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_DISTLIMIT: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_LOCLIKE: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_LOCKTRACK: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_MINMAX: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; default: @@ -654,18 +654,18 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ -static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index) +static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_index) { - const char *identifier= RNA_property_identifier(prop); + const char *identifier = RNA_property_identifier(prop); /* handle for Objects or PoseChannels only - * - constraints can be on either Objects or PoseChannels, so we only check if the + * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for - * those structs, allowing us to identify the owner of the data + * those structs, allowing us to identify the owner of the data * - assume that array_index will be sane */ if (ptr->type == &RNA_Object) { - Object *ob= (Object *)ptr->data; + Object *ob = (Object *)ptr->data; /* only Location or Rotation keyframes are supported now */ if (strstr(identifier, "location")) { @@ -699,7 +699,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ } else if (ptr->type == &RNA_PoseBone) { Object *ob = (Object *)ptr->id.data; /* we assume that this is always set, and is an object */ - bPoseChannel *pchan= (bPoseChannel *)ptr->data; + bPoseChannel *pchan = (bPoseChannel *)ptr->data; float tmat[4][4]; /* Although it is not strictly required for this particular space conversion, @@ -752,7 +752,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ /* ------------------------- Insert Key API ------------------------- */ /* Secondary Keyframing API call: - * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary + * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary * data being keyframed, and a pointer to the F-Curve to use have both been provided. * * The flag argument is used for special settings that alter the behavior of @@ -761,7 +761,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ */ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, short flag) { - float curval= 0.0f; + float curval = 0.0f; /* no F-Curve to add keyframe to? */ if (fcu == NULL) { @@ -771,13 +771,13 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* F-Curve not editable? */ if (fcurve_is_keyframable(fcu) == 0) { BKE_reportf(reports, RPT_ERROR, - "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers", - fcu->rna_path, fcu->array_index); + "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers", + fcu->rna_path, fcu->array_index); return 0; } /* if no property given yet, try to validate from F-Curve info */ - if ((ptr.id.data == NULL) && (ptr.data==NULL)) { + if ((ptr.id.data == NULL) && (ptr.data == NULL)) { BKE_report(reports, RPT_ERROR, "No RNA-pointer available to retrieve values for keyframing from"); return 0; } @@ -787,21 +787,21 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* try to get property we should be affecting */ if ((RNA_path_resolve(&ptr, fcu->rna_path, &tmp_ptr, &prop) == 0) || (prop == NULL)) { /* property not found... */ - const char *idname= (ptr.id.data) ? ((ID *)ptr.id.data)->name : "<No ID-Pointer>"; + const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : "<No ID-Pointer>"; BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - idname, fcu->rna_path); + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + idname, fcu->rna_path); return 0; } else { /* property found, so overwrite 'ptr' to make later code easier */ - ptr= tmp_ptr; + ptr = tmp_ptr; } } /* set additional flags for the F-Curve (i.e. only integer values) */ - fcu->flag &= ~(FCURVE_INT_VALUES|FCURVE_DISCRETE_VALUES); + fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); switch (RNA_property_type(prop)) { case PROP_FLOAT: /* do nothing */ @@ -815,23 +815,23 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p * values at all) interpolation between all points * - however, we must also ensure that evaluated values are only integers still */ - fcu->flag |= (FCURVE_DISCRETE_VALUES|FCURVE_INT_VALUES); + fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES); break; } /* obtain value to give keyframe */ if ( (flag & INSERTKEY_MATRIX) && - (visualkey_can_use(&ptr, prop)) ) + (visualkey_can_use(&ptr, prop)) ) { /* visual-keying is only available for object and pchan datablocks, as * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - curval= visualkey_get_value(&ptr, prop, fcu->array_index); + curval = visualkey_get_value(&ptr, prop, fcu->array_index); } else { /* read value from system */ - curval= setting_get_rna_value(&ptr, prop, fcu->array_index); + curval = setting_get_rna_value(&ptr, prop, fcu->array_index); } /* only insert keyframes where they are needed */ @@ -839,7 +839,7 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p short insert_mode; /* check whether this curve really needs a new keyframe */ - insert_mode= new_key_needed(fcu, cfra, curval); + insert_mode = new_key_needed(fcu, cfra, curval); /* insert new keyframe at current frame */ if (insert_mode) @@ -848,7 +848,7 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* delete keyframe immediately before/after newly added */ switch (insert_mode) { case KEYNEEDED_DELPREV: - delete_fcurve_key(fcu, fcu->totvert-2, 1); + delete_fcurve_key(fcu, fcu->totvert - 2, 1); break; case KEYNEEDED_DELNEXT: delete_fcurve_key(fcu, 1, 1); @@ -885,8 +885,8 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; FCurve *fcu; - int array_index_max= array_index+1; - int ret= 0; + int array_index_max = array_index + 1; + int ret = 0; /* validate pointer first - exit if failure */ if (id == NULL) { @@ -897,33 +897,33 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - (id)? id->name : "<Missing ID-Block>", rna_path); + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + (id) ? id->name : "<Missing ID-Block>", rna_path); return 0; } /* if no action is provided, keyframe to the default one attached to this ID-block */ if (act == NULL) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* get action to add F-Curve+keyframe to */ - act= verify_adt_action(id, 1); + act = verify_adt_action(id, 1); if (act == NULL) { BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)", - id->name, rna_path); + "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* apply NLA-mapping to frame to use (if applicable) */ - cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } /* key entire array convenience method */ if (array_index == -1) { - array_index= 0; - array_index_max= RNA_property_array_length(&ptr, prop); + array_index = 0; + array_index_max = RNA_property_array_length(&ptr, prop); /* for single properties, increase max_index so that the property itself gets included, * but don't do this for standard arrays since that can cause corruption issues @@ -939,7 +939,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet * but still try to get the F-Curve if it exists... */ - fcu= verify_fcurve(act, group, rna_path, array_index, (flag & INSERTKEY_REPLACE)==0); + fcu = verify_fcurve(act, group, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0); /* we may not have a F-Curve when we're replacing only... */ if (fcu) { @@ -949,7 +949,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * is determined by the array index for the F-Curve */ if (ELEM5(RNA_property_subtype(prop), PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR, PROP_COORDS)) { - fcu->color_mode= FCURVE_COLOR_AUTO_RGB; + fcu->color_mode = FCURVE_COLOR_AUTO_RGB; } } @@ -973,11 +973,11 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou */ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag)) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); PointerRNA id_ptr, ptr; PropertyRNA *prop; - int array_index_max= array_index+1; - int ret= 0; + int array_index_max = array_index + 1; + int ret = 0; /* sanity checks */ if (ELEM(NULL, id, adt)) { @@ -994,17 +994,17 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* get F-Curve * Note: here is one of the places where we don't want new Action + F-Curve added! - * so 'add' var must be 0 + * so 'add' var must be 0 */ if (act == NULL) { /* if no action is provided, use the default one attached to this ID-block - * - if it doesn't exist, then we're out of options... + * - if it doesn't exist, then we're out of options... */ if (adt->action) { - act= adt->action; + act = adt->action; /* apply NLA-mapping to frame to use (if applicable) */ - cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } else { BKE_reportf(reports, RPT_ERROR, "No Action to delete keyframes from for ID = %s\n", id->name); @@ -1014,8 +1014,8 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* key entire array convenience method */ if (array_index == -1) { - array_index= 0; - array_index_max= RNA_property_array_length(&ptr, prop); + array_index = 0; + array_index_max = RNA_property_array_length(&ptr, prop); /* for single properties, increase max_index so that the property itself gets included, * but don't do this for standard arrays since that can cause corruption issues @@ -1027,7 +1027,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { - FCurve *fcu= verify_fcurve(act, group, rna_path, array_index, 0); + FCurve *fcu = verify_fcurve(act, group, rna_path, array_index, 0); short found = -1; int i; @@ -1075,9 +1075,9 @@ enum { */ static int modify_key_op_poll(bContext *C) { - ScrArea *sa= CTX_wm_area(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *so= CTX_wm_space_outliner(C); + ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *so = CTX_wm_space_outliner(C); /* if no area or active scene */ if (ELEM(NULL, sa, scene)) @@ -1099,13 +1099,13 @@ static int modify_key_op_poll(bContext *C) /* Insert Key Operator ------------------------ */ -static int insert_key_exec (bContext *C, wmOperator *op) +static int insert_key_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= NULL; - int type= RNA_enum_get(op->ptr, "type"); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = NULL; + int type = RNA_enum_get(op->ptr, "type"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; /* type is the Keying Set the user specified to use when calling the operator: @@ -1114,11 +1114,11 @@ static int insert_key_exec (bContext *C, wmOperator *op) * - type < 0: use a builtin Keying Set */ if (type == 0) - type= scene->active_keyingset; + type = scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, type-1); + ks = BLI_findlink(&scene->keyingsets, type - 1); else - ks= BLI_findlink(&builtin_keyingsets, -type-1); + ks = BLI_findlink(&builtin_keyingsets, -type - 1); /* report failures */ if (ks == NULL) { @@ -1127,7 +1127,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) } /* try to insert keyframes for the channels specified by KeyingSet */ - success= ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); + success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) BKE_reportf(op->reports, RPT_INFO, "KeyingSet '%s' - Successfully added %d Keyframes\n", ks->name, success); @@ -1142,7 +1142,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Successfully added %d Keyframes for KeyingSet '%s'", success, ks->name); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes"); @@ -1167,10 +1167,10 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) ot->poll = modify_key_op_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1178,8 +1178,8 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ - prop= RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", - "Show a popup when the keyframes get successfully added"); + prop = RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", + "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -1188,9 +1188,9 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) * then calls the menu if necessary before */ -static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int insert_key_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* if prompting or no active Keying Set, show the menu */ if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) { @@ -1229,10 +1229,10 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1241,27 +1241,27 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) * - by default, this is disabled so that if a menu is shown, this doesn't come up too */ // XXX should this just be always on? - prop= RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", - "Show a popup when the keyframes get successfully added"); + prop = RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", + "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); /* whether the menu should always be shown * - by default, the menu should only be shown when there is no active Keying Set (2.5 behavior), * although in some cases it might be useful to always shown (pre 2.5 behavior) */ - prop= RNA_def_boolean(ot->srna, "always_prompt", 0, "Always Show Menu", ""); + prop = RNA_def_boolean(ot->srna, "always_prompt", 0, "Always Show Menu", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } /* Delete Key Operator ------------------------ */ -static int delete_key_exec (bContext *C, wmOperator *op) +static int delete_key_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= NULL; - int type= RNA_enum_get(op->ptr, "type"); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = NULL; + int type = RNA_enum_get(op->ptr, "type"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; /* type is the Keying Set the user specified to use when calling the operator: @@ -1270,11 +1270,11 @@ static int delete_key_exec (bContext *C, wmOperator *op) * - type < 0: use a builtin Keying Set */ if (type == 0) - type= scene->active_keyingset; + type = scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, type-1); + ks = BLI_findlink(&scene->keyingsets, type - 1); else - ks= BLI_findlink(&builtin_keyingsets, -type-1); + ks = BLI_findlink(&builtin_keyingsets, -type - 1); /* report failure */ if (ks == NULL) { @@ -1283,7 +1283,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) } /* try to delete keyframes for the channels specified by KeyingSet */ - success= ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); + success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); if (G.debug & G_DEBUG) printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success); @@ -1298,7 +1298,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d Keyframes for KeyingSet '%s'", success, ks->name); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes"); @@ -1323,10 +1323,10 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) ot->poll = modify_key_op_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1346,31 +1346,31 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) * -- Joshua Leung, Jan 2009 */ -static int delete_key_v3d_exec (bContext *C, wmOperator *op) +static int delete_key_v3d_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap // XXX more comprehensive tests will be needed - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - ID *id= (ID *)ob; + ID *id = (ID *)ob; FCurve *fcu, *fcn; - short success= 0; + short success = 0; /* loop through all curves in animdata and delete keys on this frame */ if ((ob->adt) && (ob->adt->action)) { - AnimData *adt= ob->adt; - bAction *act= adt->action; + AnimData *adt = ob->adt; + bAction *act = adt->action; - for (fcu= act->curves.first; fcu; fcu= fcn) { - fcn= fcu->next; - success+= delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); + for (fcu = act->curves.first; fcu; fcu = fcn) { + fcn = fcu->next; + success += delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); } } - BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name+2, success); + BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name + 2, success); ob->recalc |= OB_RECALC_OB; } @@ -1379,7 +1379,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op) /* send updates */ DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); return OPERATOR_FINISHED; } @@ -1398,22 +1398,22 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Insert Key Button Operator ------------------------ */ -static int insert_key_button_exec (bContext *C, wmOperator *op) +static int insert_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; char *path; - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - short success= 0; - int a, index, length, all= RNA_boolean_get(op->ptr, "all"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + short success = 0; + int a, index, length, all = RNA_boolean_get(op->ptr, "all"); short flag = 0; /* flags for inserting keyframes */ @@ -1423,29 +1423,29 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) uiContextActiveProperty(C, &ptr, &prop, &index); if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length = RNA_property_array_length(&ptr, prop); - if (length) index= 0; - else length= 1; + if (length) index = 0; + else length = 1; } else - length= 1; + length = 1; - for (a=0; a<length; a++) - success+= insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index+a, cfra, flag); + for (a = 0; a < length; a++) + success += insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, flag); MEM_freeN(path); } else if (ptr.type == &RNA_NlaStrip) { /* handle special vars for NLA-strips */ - NlaStrip *strip= (NlaStrip *)ptr.data; - FCurve *fcu= list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag); + NlaStrip *strip = (NlaStrip *)ptr.data; + FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag); - success+= insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0); + success += insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0); } else { if (G.debug & G_DEBUG) @@ -1468,10 +1468,10 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) @@ -1479,7 +1479,7 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* identifiers */ ot->name = "Insert Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_insert_button"; - ot->description = "Insert a keyframe keyframe for current UI-active property"; + ot->description = "Insert a keyframe for current UI-active property"; /* callbacks */ ot->exec = insert_key_button_exec; @@ -1494,35 +1494,35 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* Delete Key Button Operator ------------------------ */ -static int delete_key_button_exec (bContext *C, wmOperator *op) +static int delete_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; char *path; - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - short success= 0; - int a, index, length, all= RNA_boolean_get(op->ptr, "all"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + short success = 0; + int a, index, length, all = RNA_boolean_get(op->ptr, "all"); /* try to insert keyframe using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length = RNA_property_array_length(&ptr, prop); - if (length) index= 0; - else length= 1; + if (length) index = 0; + else length = 1; } else - length= 1; + length = 1; - for (a=0; a<length; a++) - success+= delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index+a, cfra, 0); + for (a = 0; a < length; a++) + success += delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, 0); MEM_freeN(path); } @@ -1541,10 +1541,10 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) @@ -1570,7 +1570,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) int autokeyframe_cfra_can_key(Scene *scene, ID *id) { - float cfra= (float)CFRA; // XXX for now, this will do + float cfra = (float)CFRA; // XXX for now, this will do /* only filter if auto-key mode requires this */ if (IS_AUTOKEY_ON(scene) == 0) @@ -1580,7 +1580,7 @@ int autokeyframe_cfra_can_key(Scene *scene, ID *id) /* can insert anytime we like... */ return 1; } - else /* REPLACE */ { + else { /* REPLACE */ /* for whole block - only key if there's a keyframe on that frame already * this is a valid assumption when we're blocking + tweaking */ @@ -1601,12 +1601,12 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) return 0; /* we either include all regardless of muting, or only non-muted */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) { + if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) { short replace = -1; int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); /* binarysearch_bezt_index will set replace to be 0 or 1 - * - obviously, 1 represents a match + * - obviously, 1 represents a match */ if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ @@ -1621,7 +1621,7 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) /* Checks whether an Action has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ -static short action_frame_has_keyframe (bAction *act, float frame, short filter) +static short action_frame_has_keyframe(bAction *act, float frame, short filter) { FCurve *fcu; @@ -1636,7 +1636,7 @@ static short action_frame_has_keyframe (bAction *act, float frame, short filter) /* loop over F-Curves, using binary-search to try to find matches * - this assumes that keyframes are only beztriples */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { /* only check if there are keyframes (currently only of type BezTriple) */ if (fcu->bezt && fcu->totvert) { if (fcurve_frame_has_keyframe(fcu, frame, filter)) @@ -1649,7 +1649,7 @@ static short action_frame_has_keyframe (bAction *act, float frame, short filter) } /* Checks whether an Object has a keyframe for a given frame */ -static short object_frame_has_keyframe (Object *ob, float frame, short filter) +static short object_frame_has_keyframe(Object *ob, float frame, short filter) { /* error checking */ if (ob == NULL) @@ -1662,26 +1662,26 @@ static short object_frame_has_keyframe (Object *ob, float frame, short filter) } /* try shapekey keyframes (if available, and allowed by filter) */ - if ( !(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) { - Key *key= ob_get_key(ob); + if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) { + Key *key = ob_get_key(ob); /* shapekeys can have keyframes ('Relative Shape Keys') * or depend on time (old 'Absolute Shape Keys') */ - /* 1. test for relative (with keyframes) */ + /* 1. test for relative (with keyframes) */ if (id_frame_has_keyframe((ID *)key, frame, filter)) return 1; - /* 2. test for time */ + /* 2. test for time */ // TODO... yet to be implemented (this feature may evolve before then anyway) } /* try materials */ - if ( !(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { + if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { /* if only active, then we can skip a lot of looping */ if (filter & ANIMFILTER_KEYS_ACTIVE) { - Material *ma= give_current_material(ob, (ob->actcol + 1)); + Material *ma = give_current_material(ob, (ob->actcol + 1)); /* we only retrieve the active material... */ if (id_frame_has_keyframe((ID *)ma, frame, filter)) @@ -1691,8 +1691,8 @@ static short object_frame_has_keyframe (Object *ob, float frame, short filter) int a; /* loop over materials */ - for (a=0; a<ob->totcol; a++) { - Material *ma= give_current_material(ob, a+1); + for (a = 0; a < ob->totcol; a++) { + Material *ma = give_current_material(ob, a + 1); if (id_frame_has_keyframe((ID *)ma, frame, filter)) return 1; @@ -1723,15 +1723,15 @@ short id_frame_has_keyframe(ID *id, float frame, short filter) // XXX TODO... for now, just use 'normal' behavior // break; - default: /* 'normal type' */ + default: /* 'normal type' */ { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* only check keyframes in active action */ if (adt) return action_frame_has_keyframe(adt->action, frame, filter); } - break; + break; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 925cffca288..cd914f9ff9a 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -75,16 +75,16 @@ */ /* poll callback for adding default KeyingSet */ -static int keyingset_poll_default_add (bContext *C) +static int keyingset_poll_default_add(bContext *C) { /* as long as there's an active Scene, it's fine */ return (CTX_data_scene(C) != NULL); } /* poll callback for editing active KeyingSet */ -static int keyingset_poll_active_edit (bContext *C) +static int keyingset_poll_active_edit(bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); if (scene == NULL) return 0; @@ -94,9 +94,9 @@ static int keyingset_poll_active_edit (bContext *C) } /* poll callback for editing active KeyingSet Path */ -static int keyingset_poll_activePath_edit (bContext *C) +static int keyingset_poll_activePath_edit(bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; if (scene == NULL) @@ -104,7 +104,7 @@ static int keyingset_poll_activePath_edit (bContext *C) if (scene->active_keyingset <= 0) return 0; else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* there must be an active KeyingSet and an active path */ return ((ks) && (ks->paths.first) && (ks->active_path > 0)); @@ -113,10 +113,10 @@ static int keyingset_poll_activePath_edit (bContext *C) /* Add a Default (Empty) Keying Set ------------------------- */ -static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op)) +static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - short flag=0, keyingflag=0; + Scene *scene = CTX_data_scene(C); + short flag = 0, keyingflag = 0; /* validate flags * - absolute KeyingSets should be created by default @@ -129,10 +129,10 @@ static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op)) /* call the API func, and set the active keyingset index */ BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -151,9 +151,9 @@ void ANIM_OT_keying_set_add(wmOperatorType *ot) /* Remove 'Active' Keying Set ------------------------- */ -static int remove_active_keyingset_exec (bContext *C, wmOperator *op) +static int remove_active_keyingset_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; /* verify the Keying Set to use: @@ -169,7 +169,7 @@ static int remove_active_keyingset_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* free KeyingSet's data, then remove it from the scene */ BKE_keyingset_free(ks); @@ -179,7 +179,7 @@ static int remove_active_keyingset_exec (bContext *C, wmOperator *op) scene->active_keyingset--; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -198,9 +198,9 @@ void ANIM_OT_keying_set_remove(wmOperatorType *ot) /* Add Empty Keying Set Path ------------------------- */ -static int add_empty_ks_path_exec (bContext *C, wmOperator *op) +static int add_empty_ks_path_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; KS_Path *ksp; @@ -213,16 +213,16 @@ static int add_empty_ks_path_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* don't use the API method for this, since that checks on values... */ - ksp= MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); + ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); BLI_addtail(&ks->paths, ksp); - ks->active_path= BLI_countlist(&ks->paths); + ks->active_path = BLI_countlist(&ks->paths); - ksp->groupmode= KSP_GROUP_KSNAME; // XXX? - ksp->idtype= ID_OB; - ksp->flag= KSP_FLAG_WHOLE_ARRAY; + ksp->groupmode = KSP_GROUP_KSNAME; // XXX? + ksp->idtype = ID_OB; + ksp->flag = KSP_FLAG_WHOLE_ARRAY; return OPERATOR_FINISHED; } @@ -241,14 +241,14 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot) /* Remove Active Keying Set Path ------------------------- */ -static int remove_active_ks_path_exec (bContext *C, wmOperator *op) +static int remove_active_ks_path_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* if there is a KeyingSet, find the nominated path to remove */ if (ks) { - KS_Path *ksp= BLI_findlink(&ks->paths, ks->active_path-1); + KS_Path *ksp = BLI_findlink(&ks->paths, ks->active_path - 1); if (ksp) { /* remove the active path from the KeyingSet */ @@ -287,24 +287,24 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) /* Add to KeyingSet Button Operator ------------------------ */ -static int add_keyingset_button_exec (bContext *C, wmOperator *op) +static int add_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; - PropertyRNA *prop= NULL; - PointerRNA ptr= {{NULL}}; + PropertyRNA *prop = NULL; + PointerRNA ptr = {{NULL}}; char *path = NULL; - short success= 0; - int index=0, pflag=0; - int all= RNA_boolean_get(op->ptr, "all"); + short success = 0; + int index = 0, pflag = 0; + int all = RNA_boolean_get(op->ptr, "all"); /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) * - add a new one if it doesn't exist */ if (scene->active_keyingset == 0) { - short flag=0, keyingflag=0; + short flag = 0, keyingflag = 0; /* validate flags * - absolute KeyingSets should be created by default @@ -317,23 +317,23 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) keyingflag |= INSERTKEY_XYZ2RGB; /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); + ks = BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); } else if (scene->active_keyingset < 0) { BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in Keying Set"); return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* try to add to keyingset using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); /* check if property is able to be added */ if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* set flags */ @@ -344,13 +344,13 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) * necessary if we want the entire array for most cases to get included without the user * having to worry about where they clicked */ - index= 0; + index = 0; } /* add path to this setting */ BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME); - ks->active_path= BLI_countlist(&ks->paths); - success= 1; + ks->active_path = BLI_countlist(&ks->paths); + success = 1; /* free the temp path created */ MEM_freeN(path); @@ -362,10 +362,10 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyingset_button_add(wmOperatorType *ot) @@ -380,7 +380,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) //op->poll= ??? /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Add all elements of the array to a Keying Set"); @@ -388,16 +388,16 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) /* Remove from KeyingSet Button Operator ------------------------ */ -static int remove_keyingset_button_exec (bContext *C, wmOperator *op) +static int remove_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; - PropertyRNA *prop= NULL; - PointerRNA ptr= {{NULL}}; + PropertyRNA *prop = NULL; + PointerRNA ptr = {{NULL}}; char *path = NULL; - short success= 0; - int index=0; + short success = 0; + int index = 0; /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) @@ -412,23 +412,23 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* try to add to keyingset using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { KS_Path *ksp; /* try to find a path matching this description */ - ksp= BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); + ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); if (ksp) { BKE_keyingset_free_path(ks, ksp); - success= 1; + success = 1; } /* free temp path used */ @@ -442,10 +442,10 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) @@ -460,7 +460,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) //op->poll= ??? /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************************************* */ @@ -468,7 +468,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* Change Active KeyingSet Operator ------------------------ */ /* This operator checks if a menu should be shown for choosing the KeyingSet to make the active one */ -static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; @@ -482,7 +482,7 @@ static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *U return OPERATOR_CANCELLED; } -static int keyingset_active_menu_exec (bContext *C, wmOperator *op) +static int keyingset_active_menu_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); int type = RNA_enum_get(op->ptr, "type"); @@ -491,7 +491,7 @@ static int keyingset_active_menu_exec (bContext *C, wmOperator *op) scene->active_keyingset = type; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -511,10 +511,10 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); /* RNA_def_property_flag(prop, PROP_HIDDEN);*/ } @@ -531,7 +531,7 @@ ListBase builtin_keyingsets = {NULL, NULL}; /* --------------- */ /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) +KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]) { /* sanity checks */ if ((name == NULL) || (name[0] == 0)) @@ -542,9 +542,9 @@ KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) } /* Find builtin KeyingSet by name */ -KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[]) +KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]) { - KeyingSet *ks, *first=NULL; + KeyingSet *ks, *first = NULL; /* sanity checks any name to check? */ if (name[0] == 0) @@ -552,12 +552,12 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[ /* get first KeyingSet to use */ if (prevKS && prevKS->next) - first= prevKS->next; + first = prevKS->next; else - first= builtin_keyingsets.first; + first = builtin_keyingsets.first; /* loop over KeyingSets checking names */ - for (ks= first; ks; ks= ks->next) { + for (ks = first; ks; ks = ks->next) { if (strcmp(name, ks->idname) == 0) return ks; } @@ -601,7 +601,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) /* find relevant builtin KeyingSets which use this, and remove them */ // TODO: this isn't done now, since unregister is really only used atm when we // reload the scripts, which kindof defeats the purpose of "builtin"? - for (ks= builtin_keyingsets.first; ks; ks= ksn) { + for (ks = builtin_keyingsets.first; ks; ks = ksn) { ksn = ks->next; /* remove if matching typeinfo name */ @@ -610,7 +610,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) BKE_keyingset_free(ks); BLI_remlink(&builtin_keyingsets, ks); - for (scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene = bmain->scene.first; scene; scene = scene->id.next) BLI_remlink_safe(&scene->keyingsets, ks); MEM_freeN(ks); @@ -628,8 +628,8 @@ void ANIM_keyingset_infos_exit(void) KeyingSetInfo *ksi, *next; /* free type infos */ - for (ksi=keyingset_type_infos.first; ksi; ksi=next) { - next= ksi->next; + for (ksi = keyingset_type_infos.first; ksi; ksi = next) { + next = ksi->next; /* free extra RNA data, and remove from list */ if (ksi->ext.free) @@ -647,7 +647,7 @@ void ANIM_keyingset_infos_exit(void) /* Getters for Active/Indices ----------------------------- */ /* Get the active Keying Set for the Scene provided */ -KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene) +KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene) { /* if no scene, we've got no hope of finding the Keying Set */ if (scene == NULL) @@ -659,9 +659,9 @@ KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene) * - < 0: a builtin keying set */ if (scene->active_keyingset > 0) - return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); else - return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset)-1); + return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1); } /* Get the index of the Keying Set provided, for the given Scene */ @@ -699,7 +699,7 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK { /* get KeyingSet to use * - use the active KeyingSet if defined (and user wants to use it for all autokeying), - * or otherwise key transforms only + * or otherwise key transforms only */ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) return ANIM_scene_get_active_keyingset(scene); @@ -712,13 +712,13 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ /* Dynamically populate an enum of Keying Sets */ -EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; if (C == NULL) { return DummyRNA_DEFAULT_items; @@ -729,9 +729,9 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p */ if (scene->active_keyingset) { /* active Keying Set */ - item_tmp.identifier= "__ACTIVE__"; - item_tmp.name= "Active Keying Set"; - item_tmp.value= i; + item_tmp.identifier = "__ACTIVE__"; + item_tmp.name = "Active Keying Set"; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); /* separator */ @@ -744,12 +744,12 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { - for (ks= scene->keyingsets.first; ks; ks= ks->next, i++) { + for (ks = scene->keyingsets.first; ks; ks = ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; item_tmp.name = ks->name; item_tmp.description = ks->description; - item_tmp.value= i; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } @@ -759,20 +759,20 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p } /* builtin Keying Sets */ - i= -1; - for (ks= builtin_keyingsets.first; ks; ks= ks->next, i--) { + i = -1; + for (ks = builtin_keyingsets.first; ks; ks = ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; item_tmp.name = ks->name; item_tmp.description = ks->description; - item_tmp.value= i; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -786,7 +786,7 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) @@ -803,12 +803,12 @@ short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* Special 'Overrides' Iterator for Relative KeyingSets ------ */ /* 'Data Sources' for relative Keying Set 'overrides' - * - this is basically a wrapper for PointerRNA's in a linked list + * - this is basically a wrapper for PointerRNA's in a linked list * - do not allow this to be accessed from outside for now */ typedef struct tRKS_DSource { struct tRKS_DSource *next, *prev; - PointerRNA ptr; /* the whole point of this exercise! */ + PointerRNA ptr; /* the whole point of this exercise! */ } tRKS_DSource; @@ -816,7 +816,7 @@ typedef struct tRKS_DSource { * relative Keying Sets, with the main usage of this being operators * requiring Auto Keyframing. Internal Use Only! */ -static void RKS_ITER_overrides_list (KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources) +static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources) { tRKS_DSource *ds; @@ -868,7 +868,7 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* clear all existing paths * NOTE: BKE_keyingset_free() frees all of the paths for the KeyingSet, but not the set itself @@ -910,11 +910,11 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) */ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); KS_Path *ksp; - int kflag=0, success= 0; - char *groupname= NULL; + int kflag = 0, success = 0; + char *groupname = NULL; /* sanity checks */ if (ks == NULL) @@ -923,13 +923,13 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe /* get flags to use */ if (mode == MODIFYKEY_MODE_INSERT) { /* use KeyingSet's flags as base */ - kflag= ks->keyingflag; + kflag = ks->keyingflag; /* suppliment with info from the context */ kflag |= ANIM_get_keyframing_flags(scene, 1); } else if (mode == MODIFYKEY_MODE_DELETE) - kflag= 0; + kflag = 0; /* if relative Keying Sets, poll and build up the paths */ success = ANIM_validate_keyingset(C, dsources, ks); @@ -940,15 +940,15 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe } /* apply the paths as specified in the KeyingSet now */ - for (ksp= ks->paths.first; ksp; ksp= ksp->next) { + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { int arraylen, i; short kflag2; /* skip path if no ID pointer is specified */ if (ksp->id == NULL) { BKE_reportf(reports, RPT_WARNING, - "Skipping path in Keying Set, as it has no ID (KS = '%s', Path = '%s'[%d])", - ks->name, ksp->rna_path, ksp->array_index); + "Skipping path in Keying Set, as it has no ID (KS = '%s', Path = '%s'[%d])", + ks->name, ksp->rna_path, ksp->array_index); continue; } @@ -957,17 +957,17 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe /* get pointer to name of group to add channels to */ if (ksp->groupmode == KSP_GROUP_NONE) - groupname= NULL; + groupname = NULL; else if (ksp->groupmode == KSP_GROUP_KSNAME) - groupname= ks->name; + groupname = ks->name; else - groupname= ksp->group; + groupname = ksp->group; /* init arraylen and i - arraylen should be greater than i so that * normal non-array entries get keyframed correctly */ - i= ksp->array_index; - arraylen= i; + i = ksp->array_index; + arraylen = i; /* get length of array if whole array option is enabled */ if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { @@ -976,7 +976,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(&ptr, prop); + arraylen = RNA_property_array_length(&ptr, prop); } /* we should do at least one step */ @@ -998,15 +998,15 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe switch (GS(ksp->id->name)) { case ID_OB: /* Object (or Object-Related) Keyframes */ { - Object *ob= (Object *)ksp->id; + Object *ob = (Object *)ksp->id; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: only object transforms only? + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: only object transforms only? } - break; + break; } /* send notifiers for updates (this doesn't require context to work!) */ - WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* return the number of channels successfully affected */ diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h index 1d8ee8e2c62..583178dd2b7 100644 --- a/source/blender/editors/armature/BIF_generate.h +++ b/source/blender/editors/armature/BIF_generate.h @@ -32,7 +32,7 @@ struct BArcIterator; struct bArmature; struct ListBase; -typedef int(NextSubdivisionFunc)(struct ToolSettings*, struct BArcIterator*, int, int, float[3], float[3]); +typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]); float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]); @@ -40,7 +40,7 @@ int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator int nextLengthSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]); int nextAdaptativeSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]); -struct EditBone * subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion); +struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion); void setBoneRollFromNormal(struct EditBone *bone, float *no, float invmat[][4], float tmat[][3]); diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h index c878b0c36df..2ea0e0ab0d7 100644 --- a/source/blender/editors/armature/BIF_retarget.h +++ b/source/blender/editors/armature/BIF_retarget.h @@ -22,7 +22,6 @@ * \ingroup edarmature */ - #ifndef __BIF_RETARGET_H__ #define __BIF_RETARGET_H__ @@ -49,21 +48,21 @@ struct RigEdge; #define USE_THREADS typedef struct RigGraph { - ListBase arcs; - ListBase nodes; + ListBase arcs; + ListBase nodes; float length; - FreeArc free_arc; - FreeNode free_node; - RadialSymmetry radial_symmetry; - AxialSymmetry axial_symmetry; + FreeArc free_arc; + FreeNode free_node; + RadialSymmetry radial_symmetry; + AxialSymmetry axial_symmetry; /*********************************/ - int flag; + int flag; - ListBase controls; - ListBase* editbones; + ListBase controls; + ListBase *editbones; struct RigNode *head; ReebGraph *link_mesh; @@ -71,8 +70,8 @@ typedef struct RigGraph { struct ThreadedWorker *worker; - GHash *bones_map; /* map of editbones by name */ - GHash *controls_map; /* map of rigcontrols by bone pointer */ + GHash *bones_map; /* map of editbones by name */ + GHash *controls_map; /* map of rigcontrols by bone pointer */ struct Object *ob; } RigGraph; @@ -123,16 +122,16 @@ typedef struct RigEdge { } RigEdge; /* Graph flags */ -#define RIG_FREE_BONELIST 1 +#define RIG_FREE_BONELIST 1 /* Control flags */ -#define RIG_CTRL_HEAD_DONE 1 -#define RIG_CTRL_TAIL_DONE 2 -#define RIG_CTRL_PARENT_DEFORM 4 -#define RIG_CTRL_FIT_ROOT 8 -#define RIG_CTRL_FIT_BONE 16 +#define RIG_CTRL_HEAD_DONE 1 +#define RIG_CTRL_TAIL_DONE 2 +#define RIG_CTRL_PARENT_DEFORM 4 +#define RIG_CTRL_FIT_ROOT 8 +#define RIG_CTRL_FIT_BONE 16 -#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE|RIG_CTRL_TAIL_DONE) +#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE | RIG_CTRL_TAIL_DONE) /* Control tail flags */ typedef enum { @@ -147,10 +146,10 @@ typedef struct RigControl { struct EditBone *bone; struct EditBone *link; struct EditBone *link_tail; - float up_axis[3]; - float offset[3]; - float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */ - int flag; + float up_axis[3]; + float offset[3]; + float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */ + int flag; LinkTailMode tail_mode; } RigControl; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 72d261ec187..0760b384ecd 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -117,6 +117,7 @@ void POSE_OT_group_select(struct wmOperatorType *ot); void POSE_OT_group_deselect(struct wmOperatorType *ot); void POSE_OT_paths_calculate(struct wmOperatorType *ot); +void POSE_OT_paths_update(struct wmOperatorType *ot); void POSE_OT_paths_clear(struct wmOperatorType *ot); void POSE_OT_autoside_names(struct wmOperatorType *ot); @@ -149,19 +150,19 @@ void SKETCH_OT_select(struct wmOperatorType *ot); typedef struct tPChanFCurveLink { struct tPChanFCurveLink *next, *prev; - ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ - struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ + ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ + struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ - char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ + char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ - float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ + float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ float oldrot[3]; float oldscale[3]; float oldquat[4]; float oldangle; float oldaxis[3]; - struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ + struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ } tPChanFCurveLink; /* ----------- */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index aeecbc1fd28..f3461f71391 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -133,6 +133,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_group_deselect); WM_operatortype_append(POSE_OT_paths_calculate); + WM_operatortype_append(POSE_OT_paths_update); WM_operatortype_append(POSE_OT_paths_clear); WM_operatortype_append(POSE_OT_autoside_names); @@ -171,18 +172,20 @@ void ED_operatormacros_armature(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", + "Make copies of the selected bones within the same armature and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make copies of the selected bones within the same armature and move them"; WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); } - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; - otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", FALSE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -190,10 +193,11 @@ void ED_operatormacros_armature(void) // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? // that would require fixing a properties bug 19733 - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; - otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -233,7 +237,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "unselected", TRUE); WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0); @@ -244,23 +248,23 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", TRUE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", TRUE); WM_keymap_add_item(keymap, "ARMATURE_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -275,27 +279,27 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - /* set flags */ + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0); - /* armature/bone layers */ + /* armature/bone layers */ WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - /* special transforms: */ - /* 1) envelope/b-bone size */ - kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); - /* 2) set roll */ + /* special transforms: */ + /* 1) envelope/b-bone size */ + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); + /* 2) set roll */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL); + RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL); - /* menus */ + /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0); /* Pose ------------------------ */ @@ -330,60 +334,60 @@ void ED_keymap_armature(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "flipped", FALSE); - kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "flipped", TRUE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", TRUE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", TRUE); WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0); - /* set flags */ + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0); - /* armature/bone layers */ + /* armature/bone layers */ WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - /* special transforms: */ - /* 1) envelope/b-bone size */ - kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); + /* special transforms: */ + /* 1) envelope/b-bone size */ + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); - /* keyframes management */ + /* keyframes management */ WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0); + WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); /* Pose -> PoseLib ------------- */ /* only set in posemode, by space_view3d listener */ @@ -391,12 +395,15 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); /* Pose -> Pose Sliding ------------- */ /* only set in posemode, by space_view3d listener */ WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_relax", EKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_breakdown", EKEY, KM_PRESS, KM_SHIFT, 0); + + /* menus */ + WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a2e95622bcf..f698153eb7f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -102,7 +102,7 @@ void ED_armature_sync_selection(ListBase *edbo) { EditBone *ebo; - for (ebo=edbo->first; ebo; ebo= ebo->next) { + for (ebo = edbo->first; ebo; ebo = ebo->next) { /* if bone is not selectable, we shouldn't alter this setting... */ if ((ebo->flag & BONE_UNSELECTABLE) == 0) { if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) { @@ -122,18 +122,18 @@ void ED_armature_sync_selection(ListBase *edbo) void ED_armature_validate_active(struct bArmature *arm) { - EditBone *ebone= arm->act_edbone; + EditBone *ebone = arm->act_edbone; if (ebone) { if (ebone->flag & BONE_HIDDEN_A) - arm->act_edbone= NULL; + arm->act_edbone = NULL; } } static void bone_free(bArmature *arm, EditBone *bone) { - if (arm->act_edbone==bone) - arm->act_edbone= NULL; + if (arm->act_edbone == bone) + arm->act_edbone = NULL; if (bone->prop) { IDP_FreeProperty(bone->prop); @@ -148,9 +148,9 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) EditBone *curBone; /* Find any bones that refer to this bone */ - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { - if (curBone->parent==exBone) { - curBone->parent=exBone->parent; + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + if (curBone->parent == exBone) { + curBone->parent = exBone->parent; curBone->flag &= ~BONE_CONNECTED; } } @@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) /* context: editmode armature */ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) { - EditBone *eboflip= NULL; + EditBone *eboflip = NULL; char name[MAXBONENAME]; if (ebo == NULL) @@ -169,9 +169,9 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) flip_side_name(name, ebo->name, FALSE); - for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) { + for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) { if (ebo != eboflip) { - if (!strcmp (name, eboflip->name)) + if (!strcmp(name, eboflip->name)) break; } } @@ -187,10 +187,10 @@ static void armature_select_mirrored(bArmature *arm) if (arm->flag & ARM_MIRROR_EDIT) { EditBone *curBone, *ebone_mirr; - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { - ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); + ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); if (ebone_mirr) ebone_mirr->flag |= BONE_SELECTED; } @@ -205,16 +205,16 @@ static void armature_tag_select_mirrored(bArmature *arm) EditBone *curBone; /* always untag */ - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { curBone->flag &= ~BONE_DONE; } /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { - if (curBone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL)) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); + if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) { + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) { ebone_mirr->flag |= BONE_DONE; } @@ -222,10 +222,10 @@ static void armature_tag_select_mirrored(bArmature *arm) } } - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); - curBone->flag |= ebone_mirr->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); + curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); } } } @@ -237,9 +237,9 @@ static void armature_tag_unselect(bArmature *arm) { EditBone *curBone; - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { - curBone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_DONE); + curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE); } } } @@ -247,16 +247,16 @@ static void armature_tag_unselect(bArmature *arm) /* converts Bones to EditBone list, used for tools as well */ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone) { - EditBone *eBone; - EditBone *eBoneAct= NULL; - EditBone *eBoneTest= NULL; - Bone *curBone; + EditBone *eBone; + EditBone *eBoneAct = NULL; + EditBone *eBoneTest = NULL; + Bone *curBone; - for (curBone=bones->first; curBone; curBone=curBone->next) { - eBone= MEM_callocN(sizeof(EditBone), "make_editbone"); + for (curBone = bones->first; curBone; curBone = curBone->next) { + eBone = MEM_callocN(sizeof(EditBone), "make_editbone"); /* Copy relevant data from bone to eBone */ - eBone->parent= parent; + eBone->parent = parent; BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name)); eBone->flag = curBone->flag; @@ -295,32 +295,32 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->roll = curBone->arm_roll; /* rest of stuff copy */ - eBone->length= curBone->length; - eBone->dist= curBone->dist; - eBone->weight= curBone->weight; - eBone->xwidth= curBone->xwidth; - eBone->zwidth= curBone->zwidth; - eBone->ease1= curBone->ease1; - eBone->ease2= curBone->ease2; - eBone->rad_head= curBone->rad_head; - eBone->rad_tail= curBone->rad_tail; + eBone->length = curBone->length; + eBone->dist = curBone->dist; + eBone->weight = curBone->weight; + eBone->xwidth = curBone->xwidth; + eBone->zwidth = curBone->zwidth; + eBone->ease1 = curBone->ease1; + eBone->ease2 = curBone->ease2; + eBone->rad_head = curBone->rad_head; + eBone->rad_tail = curBone->rad_tail; eBone->segments = curBone->segments; eBone->layer = curBone->layer; if (curBone->prop) - eBone->prop= IDP_CopyProperty(curBone->prop); + eBone->prop = IDP_CopyProperty(curBone->prop); BLI_addtail(edbo, eBone); /* Add children if necessary */ if (curBone->childbase.first) { - eBoneTest= make_boneList(edbo, &curBone->childbase, eBone, actBone); + eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone); if (eBoneTest) - eBoneAct= eBoneTest; + eBoneAct = eBoneTest; } - if (curBone==actBone) - eBoneAct= eBone; + if (curBone == actBone) + eBoneAct = eBone; } return eBoneAct; @@ -328,7 +328,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone /* nasty stuff for converting roll in editbones into bones */ /* also sets restposition in armature (arm_mat) */ -static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) +static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist) { Bone *curBone; EditBone *ebone; @@ -338,13 +338,13 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) float imat[3][3]; float delta[3]; - for (curBone=bonelist->first; curBone; curBone=curBone->next) { + for (curBone = bonelist->first; curBone; curBone = curBone->next) { /* sets local matrix and arm_mat (restpos) */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); /* Find the associated editbone */ - for (ebone = editbonelist->first; ebone; ebone=ebone->next) - if ((Bone*)ebone->temp == curBone) + for (ebone = editbonelist->first; ebone; ebone = ebone->next) + if ((Bone *)ebone->temp == curBone) break; if (ebone) { @@ -358,16 +358,16 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) invert_m3_m3(imat, premat); mul_m3_m3m3(difmat, imat, postmat); #if 0 - printf ("Bone %s\n", curBone->name); + printf("Bone %s\n", curBone->name); print_m4("premat", premat); print_m4("postmat", postmat); print_m4("difmat", difmat); - printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); + printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); #endif curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); /* and set restposition again */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); } fix_bonelist_roll(&curBone->childbase, editbonelist); } @@ -376,25 +376,25 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) /* put EditMode back in Object */ void ED_armature_from_edit(Object *obedit) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *eBone, *neBone; - Bone *newBone; + Bone *newBone; Object *obt; /* armature bones */ - free_bonelist(&arm->bonebase); + BKE_armature_bonelist_free(&arm->bonebase); /* remove zero sized bones, this gives instable restposes */ - for (eBone=arm->edbo->first; eBone; eBone= neBone) { - float len= len_v3v3(eBone->head, eBone->tail); - neBone= eBone->next; - if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ + for (eBone = arm->edbo->first; eBone; eBone = neBone) { + float len = len_v3v3(eBone->head, eBone->tail); + neBone = eBone->next; + if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ EditBone *fBone; /* Find any bones that refer to this bone */ - for (fBone=arm->edbo->first; fBone; fBone= fBone->next) { - if (fBone->parent==eBone) - fBone->parent= eBone->parent; + for (fBone = arm->edbo->first; fBone; fBone = fBone->next) { + if (fBone->parent == eBone) + fBone->parent = eBone->parent; } if (G.debug & G_DEBUG) printf("Warning: removed zero sized bone: %s\n", eBone->name); @@ -403,23 +403,23 @@ void ED_armature_from_edit(Object *obedit) } /* Copy the bones from the editData into the armature */ - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { - newBone= MEM_callocN(sizeof(Bone), "bone"); - eBone->temp= newBone; /* Associate the real Bones with the EditBones */ + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + newBone = MEM_callocN(sizeof(Bone), "bone"); + eBone->temp = newBone; /* Associate the real Bones with the EditBones */ BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name)); copy_v3_v3(newBone->arm_head, eBone->head); copy_v3_v3(newBone->arm_tail, eBone->tail); newBone->arm_roll = eBone->roll; - newBone->flag= eBone->flag; + newBone->flag = eBone->flag; if (eBone == arm->act_edbone) { /* don't change active selection, this messes up separate which uses * editmode toggle and can separate active bone which is de-selected originally */ /* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */ - arm->act_edbone= NULL; - arm->act_bone= newBone; + arm->act_edbone = NULL; + arm->act_bone = newBone; } newBone->roll = 0.0f; @@ -428,29 +428,29 @@ void ED_armature_from_edit(Object *obedit) newBone->xwidth = eBone->xwidth; newBone->zwidth = eBone->zwidth; - newBone->ease1= eBone->ease1; - newBone->ease2= eBone->ease2; - newBone->rad_head= eBone->rad_head; - newBone->rad_tail= eBone->rad_tail; - newBone->segments= eBone->segments; + newBone->ease1 = eBone->ease1; + newBone->ease2 = eBone->ease2; + newBone->rad_head = eBone->rad_head; + newBone->rad_tail = eBone->rad_tail; + newBone->segments = eBone->segments; newBone->layer = eBone->layer; if (eBone->prop) - newBone->prop= IDP_CopyProperty(eBone->prop); + newBone->prop = IDP_CopyProperty(eBone->prop); } /* Fix parenting in a separate pass to ensure ebone->bone connections * are valid at this point */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { - newBone= (Bone *)eBone->temp; + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + newBone = (Bone *)eBone->temp; if (eBone->parent) { - newBone->parent= (Bone *)eBone->parent->temp; + newBone->parent = (Bone *)eBone->parent->temp; BLI_addtail(&newBone->parent->childbase, newBone); { float M_parentRest[3][3]; float iM_parentRest[3][3]; - float delta[3]; + float delta[3]; /* Get the parent's matrix (rotation only) */ sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); @@ -476,13 +476,13 @@ void ED_armature_from_edit(Object *obedit) } /* Make a pass through the new armature to fix rolling */ - /* also builds restposition again (like where_is_armature) */ + /* also builds restposition again (like BKE_armature_where_is) */ fix_bonelist_roll(&arm->bonebase, arm->edbo); /* so all users of this armature should get rebuilt */ - for (obt= G.main->object.first; obt; obt= obt->id.next) { - if (obt->data==arm) - armature_rebuild_pose(obt, arm); + for (obt = G.main->object.first; obt; obt = obt->id.next) { + if (obt->data == arm) + BKE_pose_rebuild(obt, arm); } DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -491,8 +491,8 @@ void ED_armature_from_edit(Object *obedit) void ED_armature_apply_transform(Object *ob, float mat[4][4]) { EditBone *ebone; - bArmature *arm= ob->data; - float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ + bArmature *arm = ob->data; + float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ float mat3[3][3]; copy_m3_m4(mat3, mat); @@ -502,8 +502,8 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) ED_armature_to_edit(ob); /* Do the rotations */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - float delta[3], tmat[3][3]; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + float delta[3], tmat[3][3]; /* find the current bone's roll matrix */ sub_v3_v3v3(delta, ebone->tail, ebone->head); @@ -519,13 +519,13 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* apply the transfiormed roll back */ mat3_to_vec_roll(tmat, NULL, &ebone->roll); - ebone->rad_head *= scale; - ebone->rad_tail *= scale; - ebone->dist *= scale; + ebone->rad_head *= scale; + ebone->rad_tail *= scale; + ebone->dist *= scale; /* we could be smarter and scale by the matrix along the x & z axis */ - ebone->xwidth *= scale; - ebone->zwidth *= scale; + ebone->xwidth *= scale; + ebone->zwidth *= scale; } /* Turn the list into an armature */ @@ -537,15 +537,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* 0 == do center, 1 == center new, 2 == center cursor */ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode, int around) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context EditBone *ebone; - bArmature *arm= ob->data; + bArmature *arm = ob->data; float cent[3]; /* Put the armature into editmode */ if (ob != obedit) { ED_armature_to_edit(ob); - obedit= NULL; /* we cant use this so behave as if there is no obedit */ + obedit = NULL; /* we cant use this so behave as if there is no obedit */ } /* Find the centerpoint */ @@ -555,20 +555,20 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode mul_m4_v3(ob->imat, cent); } else { - if (around==V3D_CENTROID) { - int total= 0; + if (around == V3D_CENTROID) { + int total = 0; zero_v3(cent); - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - total+=2; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + total += 2; add_v3_v3(cent, ebone->head); add_v3_v3(cent, ebone->tail); } - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); } else { float min[3], max[3]; INIT_MINMAX(min, max); - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { DO_MINMAX(ebone->head, min, max); DO_MINMAX(ebone->tail, min, max); } @@ -577,19 +577,19 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode } /* Do the adjustments */ - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { sub_v3_v3(ebone->head, cent); sub_v3_v3(ebone->tail, cent); } /* Turn the list into an armature */ - if (obedit==NULL) { + if (obedit == NULL) { ED_armature_from_edit(ob); ED_armature_edit_free(ob); } /* Adjust object location for new centerpoint */ - if (centermode && obedit==NULL) { + if (centermode && obedit == NULL) { mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ add_v3_v3(ob->loc, cent); } @@ -598,7 +598,7 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode /* ---------------------- */ /* checks if an EditBone with a matching name already, returning the matching bone if it exists */ -static EditBone *editbone_name_exists (ListBase *edbo, const char *name) +static EditBone *editbone_name_exists(ListBase *edbo, const char *name) { return BLI_findstring(edbo, name, offsetof(EditBone, name)); } @@ -606,54 +606,54 @@ static EditBone *editbone_name_exists (ListBase *edbo, const char *name) /* note: there's a unique_bone_name() too! */ static int editbone_unique_check(void *arg, const char *name) { - struct {ListBase *lb;void *bone;} *data= arg; - EditBone *dupli= editbone_name_exists(data->lb, name); + struct {ListBase *lb; void *bone; } *data = arg; + EditBone *dupli = editbone_name_exists(data->lb, name); return dupli && dupli != data->bone; } void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone) { - struct {ListBase *lb; void *bone;} data; - data.lb= edbo; - data.bone= bone; + struct {ListBase *lb; void *bone; } data; + data.lb = edbo; + data.bone = bone; BLI_uniquename_cb(editbone_unique_check, &data, "Bone", '.', name, sizeof(bone->name)); } /* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */ -static void applyarmature_fix_boneparents (Scene *scene, Object *armob) +static void applyarmature_fix_boneparents(Scene *scene, Object *armob) { Object workob, *ob; /* go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* if parent is bone in this armature, apply corrections */ if ((ob->parent == armob) && (ob->partype == PARBONE)) { /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } } /* set the current pose as the restpose */ -static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) +static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object - bArmature *arm= get_armature(ob); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + bArmature *arm = BKE_armature_from_object(ob); bPose *pose; bPoseChannel *pchan; EditBone *curbone; /* don't check if editmode (should be done by caller) */ - if (ob->type!=OB_ARMATURE) + if (ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata(); return OPERATOR_CANCELLED; } @@ -667,10 +667,10 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) ED_armature_to_edit(ob); /* get pose of active object and move it out of posemode */ - pose= ob->pose; + pose = ob->pose; - for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) { - curbone= editbone_name_exists(arm->edbo, pchan->name); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + curbone = editbone_name_exists(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); @@ -697,7 +697,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) mat3_to_eul(eul, tmat); /* just use this euler-y as new roll value */ - curbone->roll= eul[1]; + curbone->roll = eul[1]; } /* clear transform values for pchan */ @@ -705,7 +705,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f; + pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; /* set anim lock */ curbone->flag |= BONE_UNKEYED; @@ -716,13 +716,13 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) ED_armature_edit_free(ob); /* flush positions of posebones */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* fix parenting of objects which are bone-parented */ applyarmature_fix_boneparents(scene, ob); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -739,17 +739,17 @@ void POSE_OT_armature_apply(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* set the current pose as the restpose */ -static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object /* don't check if editmode (should be done by caller) */ - if (ob->type!=OB_ARMATURE) + if (ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; /* loop over all selected pchans @@ -766,14 +766,14 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op) * change, thus changing the result we may be trying to record. */ copy_m4_m4(delta_mat, pchan->chan_mat); - pchan_apply_mat4(pchan, delta_mat, TRUE); + BKE_pchan_apply_mat4(pchan, delta_mat, TRUE); } CTX_DATA_END; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -790,7 +790,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ---------------------- */ @@ -804,13 +804,13 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann bConstraint *con; /* let's go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { - pose= ob->pose; - for (pchant= pose->chanbase.first; pchant; pchant= pchant->next) { - for (con= pchant->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + pose = ob->pose; + for (pchant = pose->chanbase.first; pchant; pchant = pchant->next) { + for (con = pchant->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -818,12 +818,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == srcArm) { if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } - else if (strcmp(ct->subtarget, pchan->name)==0) { + else if (strcmp(ct->subtarget, pchan->name) == 0) { ct->tar = tarArm; BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget)); } @@ -836,15 +836,15 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* action constraint? */ if (con->type == CONSTRAINT_TYPE_ACTION) { - bActionConstraint *data= con->data; // XXX old animation system + bActionConstraint *data = con->data; // XXX old animation system bAction *act; bActionChannel *achan; if (data->act) { - act= data->act; + act = data->act; - for (achan= act->chanbase.first; achan; achan= achan->next) { - if (strcmp(achan->name, pchan->name)==0) + for (achan = act->chanbase.first; achan; achan = achan->next) { + if (strcmp(achan->name, pchan->name) == 0) BLI_strncpy(achan->name, curbone->name, sizeof(achan->name)); } } @@ -856,8 +856,8 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* fix object-level constraints */ if (ob != srcArm) { - for (con= ob->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -865,12 +865,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == srcArm) { if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } - else if (strcmp(ct->subtarget, pchan->name)==0) { + else if (strcmp(ct->subtarget, pchan->name) == 0) { ct->tar = tarArm; BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget)); } @@ -886,7 +886,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* See if an object is parented to this armature */ if (ob->parent && (ob->parent == srcArm)) { /* Is object parented to a bone of this src armature? */ - if (ob->partype==PARBONE) { + if (ob->partype == PARBONE) { /* bone name in object */ if (!strcmp(ob->parsubstr, pchan->name)) BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr)); @@ -901,17 +901,17 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* join armature exec is exported for use in object->join objects operator... */ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - bArmature *arm= (ob)? ob->data: NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + bArmature *arm = (ob) ? ob->data : NULL; bPose *pose, *opose; bPoseChannel *pchan, *pchann; EditBone *curbone; - float mat[4][4], oimat[4][4]; + float mat[4][4], oimat[4][4]; /* Ensure we're not in editmode and that the active object is an armature*/ - if (!ob || ob->type!=OB_ARMATURE) + if (!ob || ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; if (!arm || arm->edbo) return OPERATOR_CANCELLED; @@ -920,19 +920,19 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_to_edit(ob); /* get pose of active object and move it out of posemode */ - pose= ob->pose; + pose = ob->pose; ob->mode &= ~OB_MODE_POSE; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) { - bArmature *curarm= base->object->data; + if ((base->object->type == OB_ARMATURE) && (base->object != ob)) { + bArmature *curarm = base->object->data; /* Make a list of editbones in current armature */ ED_armature_to_edit(base->object); /* Get Pose of current armature */ - opose= base->object->pose; + opose = base->object->pose; base->object->mode &= ~OB_MODE_POSE; //BASACT->flag &= ~OB_MODE_POSE; @@ -941,9 +941,9 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) mult_m4_m4m4(mat, oimat, base->object->obmat); /* Copy bones and posechannels from the object to the edit armature */ - for (pchan=opose->chanbase.first; pchan; pchan=pchann) { - pchann= pchan->next; - curbone= editbone_name_exists(curarm->edbo, pchan->name); + for (pchan = opose->chanbase.first; pchan; pchan = pchann) { + pchann = pchan->next; + curbone = editbone_name_exists(curarm->edbo, pchan->name); /* Get new name */ unique_editbone_name(arm->edbo, curbone->name, NULL); @@ -991,8 +991,8 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(&opose->chanbase, pchan); BLI_addtail(&pose->chanbase, pchan); - free_pose_channels_hash(opose); - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(opose); + BKE_pose_channels_hash_free(pose); } ED_base_object_free_and_unlink(bmain, scene, base); @@ -1000,12 +1000,12 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); // because we removed object(s) + DAG_scene_sort(bmain, scene); /* because we removed object(s) */ ED_armature_from_edit(ob); ED_armature_edit_free(ob); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); return OPERATOR_FINISHED; } @@ -1021,16 +1021,16 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) ListBase *opchans, *npchans; /* get reference to list of bones in original and new armatures */ - opchans= &origArm->pose->chanbase; - npchans= &newArm->pose->chanbase; + opchans = &origArm->pose->chanbase; + npchans = &newArm->pose->chanbase; /* let's go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -1038,7 +1038,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm @@ -1046,12 +1046,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (ct->subtarget[0] != 0) { if (ct->tar == origArm) { if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= newArm; + ct->tar = newArm; } } else if (ct->tar == newArm) { if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= origArm; + ct->tar = origArm; } } } @@ -1067,8 +1067,8 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) /* fix object-level constraints */ if (ob != origArm) { - for (con= ob->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -1076,7 +1076,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm @@ -1084,12 +1084,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (ct->subtarget[0] != '\0') { if (ct->tar == origArm) { if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= newArm; + ct->tar = newArm; } } else if (ct->tar == newArm) { if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= origArm; + ct->tar = origArm; } } } @@ -1107,7 +1107,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) /* Is object parented to a bone of this src armature? */ if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) { if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) { - ob->parent= newArm; + ob->parent = newArm; } } } @@ -1120,7 +1120,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) */ static void separate_armature_bones(Object *ob, short sel) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; bPoseChannel *pchan, *pchann; EditBone *curbone; @@ -1128,35 +1128,35 @@ static void separate_armature_bones(Object *ob, short sel) ED_armature_to_edit(ob); /* go through pose-channels, checking if a bone should be removed */ - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchann) { - pchann= pchan->next; - curbone= editbone_name_exists(arm->edbo, pchan->name); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { + pchann = pchan->next; + curbone = editbone_name_exists(arm->edbo, pchan->name); /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || - (!sel && !(curbone->flag & BONE_SELECTED)) ) + (!sel && !(curbone->flag & BONE_SELECTED)) ) { EditBone *ebo; bPoseChannel *pchn; /* clear the bone->parent var of any bone that had this as its parent */ - for (ebo= arm->edbo->first; ebo; ebo= ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if (ebo->parent == curbone) { - ebo->parent= NULL; - ebo->temp= NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */ + ebo->parent = NULL; + ebo->temp = NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */ ebo->flag &= ~BONE_CONNECTED; } } /* clear the pchan->parent var of any pchan that had this as its parent */ - for (pchn= ob->pose->chanbase.first; pchn; pchn=pchn->next) { + for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) { if (pchn->parent == pchan) - pchn->parent= NULL; + pchn->parent = NULL; } /* free any of the extra-data this pchan might have */ - free_pose_channel(pchan); - free_pose_channels_hash(ob->pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(ob->pose); /* get rid of unneeded bone */ bone_free(arm, curbone); @@ -1170,11 +1170,11 @@ static void separate_armature_bones(Object *ob, short sel) } /* separate selected bones into their armature */ -static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) +static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); Object *oldob, *newob; Base *oldbase, *newbase; @@ -1197,14 +1197,14 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) // TODO: use context iterators for this? CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (base->object==obedit) base->flag |= 1; + if (base->object == obedit) base->flag |= 1; else base->flag &= ~1; } CTX_DATA_END; /* 1) store starting settings and exit editmode */ - oldob= obedit; - oldbase= BASACT; + oldob = obedit; + oldbase = BASACT; oldob->mode &= ~OB_MODE_POSE; //oldbase->flag &= ~OB_POSEMODE; @@ -1212,8 +1212,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) ED_armature_edit_free(obedit); /* 2) duplicate base */ - newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ - newob= newbase->object; + newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ + newob = newbase->object; newbase->flag &= ~SELECT; @@ -1225,17 +1225,17 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) /* 4) fix links before depsgraph flushes */ // err... or after? separated_armature_fix_links(oldob, newob); - DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ - DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ + DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ + DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ /* 5) restore original conditions */ - obedit= oldob; + obedit = oldob; ED_armature_to_edit(obedit); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); /* recalc/redraw + cleanup */ WM_cursor_wait(0); @@ -1256,20 +1256,20 @@ void ARMATURE_OT_separate(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** END tools on Editmode Armature **************** */ /* **************** PoseMode & EditMode *************************** */ /* only for opengl selection indices */ -Bone *get_indexed_bone (Object *ob, int index) +Bone *get_indexed_bone(Object *ob, int index) { bPoseChannel *pchan; - if (ob->pose==NULL) return NULL; - index>>=16; // bone selection codes use left 2 bytes + if (ob->pose == NULL) return NULL; + index >>= 16; // bone selection codes use left 2 bytes - pchan= BLI_findlink(&ob->pose->chanbase, index); + pchan = BLI_findlink(&ob->pose->chanbase, index); return pchan ? pchan->bone : NULL; } @@ -1277,22 +1277,22 @@ Bone *get_indexed_bone (Object *ob, int index) /* only bones from base are checked on */ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short findunsel) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context Bone *bone; EditBone *ebone; - void *firstunSel=NULL, *firstSel=NULL, *data; + void *firstunSel = NULL, *firstSel = NULL, *data; unsigned int hitresult; - short i, takeNext=0, sel; + short i, takeNext = 0, sel; - for (i=0; i< hits; i++) { - hitresult = buffer[3+(i*4)]; + for (i = 0; i < hits; i++) { + hitresult = buffer[3 + (i * 4)]; - if (!(hitresult & BONESEL_NOSEL)) { // -1 - if (hitresult & BONESEL_ANY) { // to avoid including objects in selection + if (!(hitresult & BONESEL_NOSEL)) { // -1 + if (hitresult & BONESEL_ANY) { // to avoid including objects in selection hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ - if (obedit==NULL || base->object!=obedit) { + if (obedit == NULL || base->object != obedit) { /* no singular posemode, so check for correct object */ if (base->selcol == (hitresult & 0xFFFF)) { bone = get_indexed_bone(base->object, hitresult); @@ -1305,12 +1305,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * data = bone; } else { - data= NULL; - sel= 0; + data = NULL; + sel = 0; } } else { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; ebone = BLI_findlink(arm->edbo, hitresult); if (findunsel) @@ -1323,12 +1323,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * if (data) { if (sel) { - if (!firstSel) firstSel= data; - takeNext=1; + if (!firstSel) firstSel = data; + takeNext = 1; } else { if (!firstunSel) - firstunSel=data; + firstunSel = data; if (takeNext) return data; } @@ -1348,7 +1348,7 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * /* used by posemode as well editmode */ /* only checks scene->basact! */ /* x and y are mouse coords (area space) */ -static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) +static void *get_nearest_bone(bContext *C, short findunsel, int x, int y) { ViewContext vc; rcti rect; @@ -1362,9 +1362,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) rect.ymin = rect.ymax = y; glInitNames(); - hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); - if (hits>0) + if (hits > 0) return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel); return NULL; @@ -1373,9 +1373,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) /* Get the first available child of an editbone */ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_visibility) { - EditBone *curbone, *chbone=NULL; + EditBone *curbone, *chbone = NULL; - for (curbone= arm->edbo->first; curbone; curbone= curbone->next) { + for (curbone = arm->edbo->first; curbone; curbone = curbone->next) { if (curbone->parent == pabone) { if (use_visibility) { if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) { @@ -1394,7 +1394,7 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_ /* **************** Posemode stuff ********************** */ -static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend) +static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) { Bone *curBone; @@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (extend) @@ -1410,7 +1410,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend else bone->flag |= BONE_SELECTED; - for (curBone=bone->childbase.first; curBone; curBone=curBone->next) + for (curBone = bone->childbase.first; curBone; curBone = curBone->next) selectconnected_posebonechildren(ob, curBone, extend); } @@ -1418,25 +1418,25 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend /* previously known as "selectconnected_posearmature" */ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *ob= CTX_data_edit_object(C); - Bone *bone, *curBone, *next= NULL; - int extend= RNA_boolean_get(op->ptr, "extend"); + Object *ob = CTX_data_edit_object(C); + Bone *bone, *curBone, *next = NULL; + int extend = RNA_boolean_get(op->ptr, "extend"); view3d_operator_needs_opengl(C); if (extend) - bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]); else - bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]); if (!bone) return OPERATOR_CANCELLED; /* Select parents */ - for (curBone=bone; curBone; curBone=next) { + for (curBone = bone; curBone; curBone = next) { /* ignore bone if cannot be selected */ if ((curBone->flag & BONE_UNSELECTABLE) == 0) { - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name (ob->action, curBone->name, !(shift)); if (extend) @@ -1445,26 +1445,26 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev curBone->flag |= BONE_SELECTED; if (curBone->flag & BONE_CONNECTED) - next=curBone->parent; + next = curBone->parent; else - next=NULL; + next = NULL; } else - next= NULL; + next = NULL; } /* Select children */ - for (curBone=bone->childbase.first; curBone; curBone=next) + for (curBone = bone->childbase.first; curBone; curBone = next) selectconnected_posebonechildren(ob, curBone, extend); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } static int pose_select_linked_poll(bContext *C) { - return ( ED_operator_view3d_active(C) && ED_operator_posemode(C) ); + return (ED_operator_view3d_active(C) && ED_operator_posemode(C) ); } void POSE_OT_select_linked(wmOperatorType *ot) @@ -1480,7 +1480,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) ot->poll = pose_select_linked_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -1495,70 +1495,70 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e { bArmature *arm; EditBone *bone, *curBone, *next; - int extend= RNA_boolean_get(op->ptr, "extend"); - Object *obedit= CTX_data_edit_object(C); - arm= obedit->data; + int extend = RNA_boolean_get(op->ptr, "extend"); + Object *obedit = CTX_data_edit_object(C); + arm = obedit->data; view3d_operator_needs_opengl(C); if (extend) - bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]); else - bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]); if (!bone) return OPERATOR_CANCELLED; /* Select parents */ - for (curBone=bone; curBone; curBone=next) { + for (curBone = bone; curBone; curBone = next) { if ((curBone->flag & BONE_UNSELECTABLE) == 0) { if (extend) { - curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } else { - curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } if (curBone->flag & BONE_CONNECTED) - next=curBone->parent; + next = curBone->parent; else - next=NULL; + next = NULL; } /* Select children */ while (bone) { - for (curBone=arm->edbo->first; curBone; curBone=next) { + for (curBone = arm->edbo->first; curBone; curBone = next) { next = curBone->next; - if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE)==0) { + if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE) == 0) { if (curBone->flag & BONE_CONNECTED) { if (extend) - curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); else - curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - bone=curBone; + curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + bone = curBone; break; } else { - bone=NULL; + bone = NULL; break; } } } if (!curBone) - bone=NULL; + bone = NULL; } ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } static int armature_select_linked_poll(bContext *C) { - return ( ED_operator_view3d_active(C) && ED_operator_editarmature(C) ); + return (ED_operator_view3d_active(C) && ED_operator_editarmature(C) ); } void ARMATURE_OT_select_linked(wmOperatorType *ot) @@ -1574,7 +1574,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) ot->poll = armature_select_linked_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties s*/ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -1582,71 +1582,71 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; unsigned int buffer[MAXPICKBUF]; - unsigned int hitresult, besthitresult=BONESEL_NOSEL; - int i, mindep= 4; + unsigned int hitresult, besthitresult = BONESEL_NOSEL; + int i, mindep = 4; short hits; glInitNames(); - rect.xmin = mval[0]-5; - rect.xmax = mval[0]+5; - rect.ymin = mval[1]-5; - rect.ymax = mval[1]+5; - - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); - if (hits==0) { - rect.xmin = mval[0]-12; - rect.xmax = mval[0]+12; - rect.ymin = mval[1]-12; - rect.ymax = mval[1]+12; - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); + rect.xmin = mval[0] - 5; + rect.xmax = mval[0] + 5; + rect.ymin = mval[1] - 5; + rect.ymax = mval[1] + 5; + + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); + if (hits == 0) { + rect.xmin = mval[0] - 12; + rect.xmax = mval[0] + 12; + rect.ymin = mval[1] - 12; + rect.ymax = mval[1] + 12; + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); } /* See if there are any selected bones in this group */ - if (hits>0) { + if (hits > 0) { - if (hits==1) { + if (hits == 1) { if (!(buffer[3] & BONESEL_NOSEL)) - besthitresult= buffer[3]; + besthitresult = buffer[3]; } else { - for (i=0; i< hits; i++) { - hitresult= buffer[3+(i*4)]; + for (i = 0; i < hits; i++) { + hitresult = buffer[3 + (i * 4)]; if (!(hitresult & BONESEL_NOSEL)) { int dep; ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY); /* clicks on bone points get advantage */ - if ( hitresult & (BONESEL_ROOT|BONESEL_TIP)) { + if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) { /* but also the unselected one */ if (findunsel) { - if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0) - dep= 1; - else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0) - dep= 1; + if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0) + dep = 1; + else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) + dep = 1; else - dep= 2; + dep = 2; } - else dep= 2; + else dep = 2; } else { /* bone found */ if (findunsel) { - if ((ebone->flag & BONE_SELECTED)==0) - dep= 2; + if ((ebone->flag & BONE_SELECTED) == 0) + dep = 2; else - dep= 3; + dep = 3; } - else dep= 3; + else dep = 3; } if (dep < mindep) { - mindep= dep; - besthitresult= hitresult; + mindep = dep; + besthitresult = hitresult; } } } @@ -1654,7 +1654,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], if (!(besthitresult & BONESEL_NOSEL)) { - ebone= BLI_findlink(edbo, besthitresult & ~BONESEL_ANY); + ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY); *selmask = 0; if (besthitresult & BONESEL_ROOT) @@ -1675,9 +1675,9 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; - EditBone *curBone, *ebone_next; + EditBone *curBone, *ebone_next; bConstraint *con; - Object *obedit= CTX_data_edit_object(C); // XXX get from context + Object *obedit = CTX_data_edit_object(C); // XXX get from context arm = obedit->data; /* cancel if nothing selected */ @@ -1689,31 +1689,31 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* First erase any associated pose channel */ if (obedit->pose) { bPoseChannel *pchan, *pchan_next; - for (pchan=obedit->pose->chanbase.first; pchan; pchan= pchan_next) { - pchan_next= pchan->next; + for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) { + pchan_next = pchan->next; curBone = editbone_name_exists(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { - free_pose_channel(pchan); - free_pose_channels_hash(obedit->pose); - BLI_freelinkN (&obedit->pose->chanbase, pchan); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(obedit->pose); + BLI_freelinkN(&obedit->pose->chanbase, pchan); } else { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == obedit) { if (ct->subtarget[0]) { curBone = editbone_name_exists(arm->edbo, ct->subtarget); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { con->flag |= CONSTRAINT_DISABLE; - ct->subtarget[0]= 0; + ct->subtarget[0] = 0; } } } @@ -1728,11 +1728,11 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) } - for (curBone=arm->edbo->first; curBone; curBone= ebone_next) { - ebone_next= curBone->next; + for (curBone = arm->edbo->first; curBone; curBone = ebone_next) { + ebone_next = curBone->next; if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { - if (curBone==arm->act_edbone) arm->act_edbone= NULL; + if (curBone == arm->act_edbone) arm->act_edbone = NULL; ED_armature_edit_bone_remove(arm, curBone); } } @@ -1741,7 +1741,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -1759,7 +1759,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* toggle==0: deselect @@ -1768,35 +1768,35 @@ void ARMATURE_OT_delete(wmOperatorType *ot) */ void ED_armature_deselect_all(Object *obedit, int toggle) { - bArmature *arm= obedit->data; - EditBone *eBone; - int sel=1; + bArmature *arm = obedit->data; + EditBone *eBone; + int sel = 1; - if (toggle==1) { + if (toggle == 1) { /* Determine if there are any selected bones * and therefore whether we are selecting or deselecting */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { // if (arm->layer & eBone->layer) { if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { - sel=0; + sel = 0; break; } // } } } - else sel= toggle; + else sel = toggle; /* Set the flags */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { - if (sel==2) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + if (sel == 2) { /* invert selection of bone */ if (EBONE_VISIBLE(arm, eBone)) { eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (arm->act_edbone==eBone) - arm->act_edbone= NULL; + if (arm->act_edbone == eBone) + arm->act_edbone = NULL; } } - else if (sel==1) { + else if (sel == 1) { /* select bone */ if (EBONE_VISIBLE(arm, eBone)) { eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); @@ -1807,8 +1807,8 @@ void ED_armature_deselect_all(Object *obedit, int toggle) else { /* deselect bone */ eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (arm->act_edbone==eBone) - arm->act_edbone= NULL; + if (arm->act_edbone == eBone) + arm->act_edbone = NULL; } } @@ -1817,12 +1817,12 @@ void ED_armature_deselect_all(Object *obedit, int toggle) void ED_armature_deselect_all_visible(Object *obedit) { - bArmature *arm= obedit->data; - EditBone *ebone; + bArmature *arm = obedit->data; + EditBone *ebone; - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ - if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) { + if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } @@ -1834,27 +1834,27 @@ void ED_armature_deselect_all_visible(Object *obedit) static int ebone_select_flag(EditBone *ebone) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { - return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL)); + return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED | BONE_TIPSEL)); } else { - return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); } } /* context: editmode armature in view3d */ int mouse_armature(bContext *C, const int mval[2], int extend) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; ViewContext vc; EditBone *nearBone = NULL; - int selmask; + int selmask; view3d_set_viewcontext(C, &vc); BIF_sk_selectStroke(C, mval, extend); - nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask); + nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask); if (nearBone) { if (!extend) @@ -1870,7 +1870,7 @@ int mouse_armature(bContext *C, const int mval[2], int extend) /* hold shift inverts this bone's selection */ if (nearBone->flag & BONE_SELECTED) { /* deselect this bone */ - nearBone->flag &= ~(BONE_TIPSEL|BONE_SELECTED); + nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED); /* only deselect parent tip if it is not selected */ if (!(nearBone->parent->flag & BONE_SELECTED)) nearBone->parent->flag &= ~BONE_TIPSEL; @@ -1891,11 +1891,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend) if (extend) { /* hold shift inverts this bone's selection */ if (nearBone->flag & BONE_SELECTED) - nearBone->flag &= ~(BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL); else - nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL); } - else nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL); + else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL); } } else { @@ -1910,11 +1910,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend) if (nearBone) { /* then now check for active status */ if (ebone_select_flag(nearBone)) { - arm->act_edbone= nearBone; + arm->act_edbone = nearBone; } } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); return 1; } @@ -1923,13 +1923,13 @@ int mouse_armature(bContext *C, const int mval[2], int extend) void ED_armature_edit_free(struct Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; EditBone *eBone; /* Clear the editbones list */ if (arm->edbo) { if (arm->edbo->first) { - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->prop) { IDP_FreeProperty(eBone->prop); MEM_freeN(eBone->prop); @@ -1939,19 +1939,19 @@ void ED_armature_edit_free(struct Object *ob) BLI_freelistN(arm->edbo); } MEM_freeN(arm->edbo); - arm->edbo= NULL; + arm->edbo = NULL; } } /* Put armature in EditMode */ void ED_armature_to_edit(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; ED_armature_edit_free(ob); - arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature"); - arm->act_edbone= make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone); - arm->act_bone= NULL; + arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); + arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone); + arm->act_bone = NULL; // BIF_freeTemplates(); /* force template update when entering editmode */ } @@ -1977,7 +1977,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short sub_v3_v3v3(align_axis_proj, align_axis, vec); if (axis_only) { - if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) { + if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI / 2.0)) { negate_v3(align_axis_proj); } } @@ -2010,44 +2010,44 @@ static EnumPropertyItem prop_calc_roll_types[] = { static int armature_calc_roll_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - const short type= RNA_enum_get(op->ptr, "type"); - const short axis_only= RNA_boolean_get(op->ptr, "axis_only"); - const short axis_flip= RNA_boolean_get(op->ptr, "axis_flip"); + Object *ob = CTX_data_edit_object(C); + const short type = RNA_enum_get(op->ptr, "type"); + const short axis_only = RNA_boolean_get(op->ptr, "axis_only"); + const short axis_flip = RNA_boolean_get(op->ptr, "axis_flip"); float imat[3][3]; - bArmature *arm= ob->data; + bArmature *arm = ob->data; EditBone *ebone; copy_m3_m4(imat, ob->obmat); invert_m3(imat); - if (type==7) { /* Cursor */ - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); /* can be NULL */ + if (type == 7) { /* Cursor */ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ float cursor_local[3]; - float *cursor= give_cursor(scene, v3d); + float *cursor = give_cursor(scene, v3d); copy_v3_v3(cursor_local, cursor); mul_m3_v3(imat, cursor_local); /* cursor */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { float cursor_rel[3]; sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); if (axis_flip) negate_v3(cursor_rel); - ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only); + ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only); } } } else { - float vec[3]= {0.0f, 0.0f, 0.0f}; - if (type==6) { /* View */ - RegionView3D *rv3d= CTX_wm_region_view3d(C); - if (rv3d==NULL) { + float vec[3] = {0.0f, 0.0f, 0.0f}; + if (type == 6) { /* View */ + RegionView3D *rv3d = CTX_wm_region_view3d(C); + if (rv3d == NULL) { BKE_report(op->reports, RPT_ERROR, "No region view3d available"); return OPERATOR_CANCELLED; } @@ -2055,10 +2055,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) copy_v3_v3(vec, rv3d->viewinv[2]); mul_m3_v3(imat, vec); } - else if (type==5) { + else if (type == 5) { float mat[3][3], nor[3]; - ebone= (EditBone *)arm->act_edbone; - if (ebone==NULL) { + ebone = (EditBone *)arm->act_edbone; + if (ebone == NULL) { BKE_report(op->reports, RPT_ERROR, "No active bone set"); return OPERATOR_CANCELLED; } @@ -2069,34 +2069,34 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } else { /* Axis */ assert(type >= 0 && type <= 5); - if (type<3) vec[type]= 1.0f; - else vec[type-2]= -1.0f; + if (type < 3) vec[type] = 1.0f; + else vec[type - 2] = -1.0f; mul_m3_v3(imat, vec); } if (axis_flip) negate_v3(vec); - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ - ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); } } } if (arm->flag & ARM_MIRROR_EDIT) { - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { - ebone->roll= -ebone_mirr->roll; + ebone->roll = -ebone_mirr->roll; } } } } /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2114,7 +2114,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", ""); @@ -2131,61 +2131,61 @@ typedef struct UndoArmature { static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data)) { - UndoArmature *uarm= uarmv; - bArmature *arm= armv; + UndoArmature *uarm = uarmv; + bArmature *arm = armv; EditBone *ebo, *newebo; BLI_freelistN(arm->edbo); /* copy */ - for (ebo= uarm->lb.first; ebo; ebo= ebo->next) { - newebo= MEM_dupallocN(ebo); - ebo->temp= newebo; + for (ebo = uarm->lb.first; ebo; ebo = ebo->next) { + newebo = MEM_dupallocN(ebo); + ebo->temp = newebo; BLI_addtail(arm->edbo, newebo); } /* active bone */ if (uarm->act_edbone) { - ebo= uarm->act_edbone; - arm->act_edbone= ebo->temp; + ebo = uarm->act_edbone; + arm->act_edbone = ebo->temp; } else - arm->act_edbone= NULL; + arm->act_edbone = NULL; /* set pointers */ - for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { - if (newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo = arm->edbo->first; newebo; newebo = newebo->next) { + if (newebo->parent) newebo->parent = newebo->parent->temp; } /* be sure they don't hang ever */ - for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { - newebo->temp= NULL; + for (newebo = arm->edbo->first; newebo; newebo = newebo->next) { + newebo->temp = NULL; } } static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata)) { - bArmature *arm= armv; + bArmature *arm = armv; UndoArmature *uarm; EditBone *ebo, *newebo; - uarm= MEM_callocN(sizeof(UndoArmature), "listbase undo"); + uarm = MEM_callocN(sizeof(UndoArmature), "listbase undo"); /* copy */ - for (ebo= arm->edbo->first; ebo; ebo= ebo->next) { - newebo= MEM_dupallocN(ebo); - ebo->temp= newebo; + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + newebo = MEM_dupallocN(ebo); + ebo->temp = newebo; BLI_addtail(&uarm->lb, newebo); } /* active bone */ if (arm->act_edbone) { - ebo= arm->act_edbone; - uarm->act_edbone= ebo->temp; + ebo = arm->act_edbone; + uarm->act_edbone = ebo->temp; } /* set pointers */ - for (newebo= uarm->lb.first; newebo; newebo= newebo->next) { - if (newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo = uarm->lb.first; newebo; newebo = newebo->next) { + if (newebo->parent) newebo->parent = newebo->parent->temp; } return uarm; @@ -2193,7 +2193,7 @@ static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata)) static void free_undoBones(void *uarmv) { - UndoArmature *uarm= uarmv; + UndoArmature *uarm = uarmv; BLI_freelistN(&uarm->lb); MEM_freeN(uarm); @@ -2201,8 +2201,8 @@ static void free_undoBones(void *uarmv) static void *get_armature_edit(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_ARMATURE) { + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_ARMATURE) { return obedit->data; } return NULL; @@ -2223,7 +2223,7 @@ void undo_push_armature(bContext *C, const char *name) /* default bone add, returns it selected, but without tail set */ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) { - EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone"); + EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); unique_editbone_name(arm->edbo, bone->name, NULL); @@ -2231,16 +2231,16 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) BLI_addtail(arm->edbo, bone); bone->flag |= BONE_TIPSEL; - bone->weight= 1.0f; - bone->dist= 0.25f; - bone->xwidth= 0.1f; - bone->zwidth= 0.1f; - bone->ease1= 1.0f; - bone->ease2= 1.0f; - bone->rad_head= 0.10f; - bone->rad_tail= 0.05f; - bone->segments= 1; - bone->layer= arm->layer; + bone->weight = 1.0f; + bone->dist = 0.25f; + bone->xwidth = 0.1f; + bone->zwidth = 0.1f; + bone->ease1 = 1.0f; + bone->ease2 = 1.0f; + bone->rad_head = 0.10f; + bone->rad_tail = 0.05f; + bone->segments = 1; + bone->layer = arm->layer; return bone; } @@ -2248,10 +2248,10 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) /* v3d and rv3d are allowed to be NULL */ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; - float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; - EditBone *bone; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; + float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; + EditBone *bone; /* Get inverse point for head and orientation for tail */ invert_m4_m4(obedit->imat, obedit->obmat); @@ -2268,16 +2268,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) ED_armature_deselect_all(obedit, 0); /* Create a bone */ - bone= ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_edit_bone_add(arm, "Bone"); - arm->act_edbone= bone; + arm->act_edbone = bone; copy_v3_v3(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z } @@ -2290,25 +2290,25 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) bArmature *arm; EditBone *ebone, *newbone, *flipbone; float *curs, mat[3][3], imat[3][3]; - int a, to_root= 0; + int a, to_root = 0; Object *obedit; Scene *scene; scene = CTX_data_scene(C); - v3d= CTX_wm_view3d(C); - obedit= CTX_data_edit_object(C); - arm= obedit->data; + v3d = CTX_wm_view3d(C); + obedit = CTX_data_edit_object(C); + arm = obedit->data; /* find the active or selected bone */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone) break; } } - if (ebone==NULL) { - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + if (ebone == NULL) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone) break; @@ -2317,60 +2317,60 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) if (ebone == NULL) return OPERATOR_CANCELLED; - to_root= 1; + to_root = 1; } ED_armature_deselect_all(obedit, 0); /* we re-use code for mirror editing... */ - flipbone= NULL; + flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) - flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); - for (a=0; a<2; a++) { - if (a==1) { - if (flipbone==NULL) + for (a = 0; a < 2; a++) { + if (a == 1) { + if (flipbone == NULL) break; else { SWAP(EditBone *, flipbone, ebone); } } - newbone= ED_armature_edit_bone_add(arm, ebone->name); - arm->act_edbone= newbone; + newbone = ED_armature_edit_bone_add(arm, ebone->name); + arm->act_edbone = newbone; if (to_root) { copy_v3_v3(newbone->head, ebone->head); - newbone->rad_head= ebone->rad_tail; - newbone->parent= ebone->parent; + newbone->rad_head = ebone->rad_tail; + newbone->parent = ebone->parent; } else { copy_v3_v3(newbone->head, ebone->tail); - newbone->rad_head= ebone->rad_tail; - newbone->parent= ebone; + newbone->rad_head = ebone->rad_tail; + newbone->parent = ebone; newbone->flag |= BONE_CONNECTED; } - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); copy_v3_v3(newbone->tail, curs); sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); - if (a==1) - newbone->tail[0]= -newbone->tail[0]; + if (a == 1) + newbone->tail[0] = -newbone->tail[0]; copy_m3_m4(mat, obedit->obmat); invert_m3_m3(imat, mat); mul_m3_v3(imat, newbone->tail); - newbone->length= len_v3v3(newbone->head, newbone->tail); - newbone->rad_tail= newbone->length*0.05f; - newbone->dist= newbone->length*0.25f; + newbone->length = len_v3v3(newbone->head, newbone->tail); + newbone->rad_tail = newbone->length * 0.05f; + newbone->dist = newbone->length * 0.25f; } ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -2387,11 +2387,11 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e float *fp = NULL, tvec[3], oldcurs[3], mval_f[2]; int retv; - scene= CTX_data_scene(C); - ar= CTX_wm_region(C); + scene = CTX_data_scene(C); + ar = CTX_wm_region(C); v3d = CTX_wm_view3d(C); - fp= give_cursor(scene, v3d); + fp = give_cursor(scene, v3d); copy_v3_v3(oldcurs, fp); @@ -2400,7 +2400,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e copy_v3_v3(fp, tvec); /* extrude to the where new cursor is and store the operation result */ - retv= armature_click_extrude_exec(C, op); + retv = armature_click_extrude_exec(C, op); /* restore previous 3d cursor position */ copy_v3_v3(fp, oldcurs); @@ -2421,17 +2421,17 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ } /* adds an EditBone between the nominated locations (should be in the right space) */ -static EditBone *add_points_bone (Object *obedit, float head[], float tail[]) +static EditBone *add_points_bone(Object *obedit, float head[], float tail[]) { EditBone *ebo; - ebo= ED_armature_edit_bone_add(obedit->data, "Bone"); + ebo = ED_armature_edit_bone_add(obedit->data, "Bone"); copy_v3_v3(ebo->head, head); copy_v3_v3(ebo->tail, tail); @@ -2445,7 +2445,7 @@ static EditBone *get_named_editbone(ListBase *edbo, char *name) EditBone *eBone; if (name) { - for (eBone=edbo->first; eBone; eBone=eBone->next) { + for (eBone = edbo->first; eBone; eBone = eBone->next) { if (!strcmp(name, eBone->name)) return eBone; } @@ -2481,20 +2481,20 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj bConstraint *curcon; ListBase *conlist; - if ( (pchan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) { + if ( (pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name)) ) { if ( (conlist = &pchan->constraints) ) { - for (curcon = conlist->first; curcon; curcon=curcon->next) { + for (curcon = conlist->first; curcon; curcon = curcon->next) { /* does this constraint have a subtarget in * this armature? */ - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == src_ob) && (ct->subtarget[0])) { ct->tar = dst_ob; /* update target */ oldtarget = get_named_editbone(editbones, ct->subtarget); @@ -2544,7 +2544,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase /* copy the ID property */ if (curBone->prop) - eBone->prop= IDP_CopyProperty(curBone->prop); + eBone->prop = IDP_CopyProperty(curBone->prop); /* Lets duplicate the list of constraints that the * current bone has. @@ -2552,15 +2552,15 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase if (src_ob->pose) { bPoseChannel *chanold, *channew; - chanold = verify_pose_channel(src_ob->pose, curBone->name); + chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name); if (chanold) { /* WARNING: this creates a new posechannel, but there will not be an attached bone * yet as the new bones created here are still 'EditBones' not 'Bones'. */ - channew= verify_pose_channel(dst_ob->pose, eBone->name); + channew = BKE_pose_channel_verify(dst_ob->pose, eBone->name); if (channew) { - duplicate_pose_channel_data(channew, chanold); + BKE_pose_channel_copy_data(channew, chanold); } } } @@ -2577,12 +2577,12 @@ EditBone *duplicateEditBone(EditBone *curBone, const char *name, ListBase *editb static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; - EditBone *eBone = NULL; - EditBone *curBone; - EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */ + EditBone *eBone = NULL; + EditBone *curBone; + EditBone *firstDup = NULL; /* The beginning of the duplicated bones in the edbo list */ - Object *obedit= CTX_data_edit_object(C); - arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + arm = obedit->data; /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) @@ -2594,7 +2594,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { eBone = ED_armature_bone_get_mirrored(arm->edbo, curBone); @@ -2607,24 +2607,24 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* Find the selected bones and duplicate them as needed */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { - eBone= duplicateEditBone(curBone, curBone->name, arm->edbo, obedit); + eBone = duplicateEditBone(curBone, curBone->name, arm->edbo, obedit); if (!firstDup) - firstDup=eBone; + firstDup = eBone; } } } /* Run though the list and fix the pointers */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { - eBone=(EditBone*) curBone->temp; + eBone = (EditBone *) curBone->temp; if (!curBone->parent) { /* If this bone has no parent, @@ -2636,13 +2636,13 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* If this bone has a parent that was duplicated, * Set the duplicate->parent to the curBone->parent->temp */ - eBone->parent= (EditBone *)curBone->parent->temp; + eBone->parent = (EditBone *)curBone->parent->temp; } else { /* If this bone has a parent that IS not selected, * Set the duplicate->parent to the curBone->parent */ - eBone->parent=(EditBone*) curBone->parent; + eBone->parent = (EditBone *) curBone->parent; eBone->flag &= ~BONE_CONNECTED; } @@ -2656,20 +2656,20 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* correct the active bone */ if (arm->act_edbone) { - eBone= arm->act_edbone; + eBone = arm->act_edbone; if (eBone->temp) - arm->act_edbone= eBone->temp; + arm->act_edbone = eBone->temp; } /* Deselect the old bones and select the new ones */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } ED_armature_validate_active(arm); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -2687,7 +2687,7 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2698,27 +2698,27 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) typedef struct EditBonePoint { struct EditBonePoint *next, *prev; - EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ - EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ + EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ + EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ - float vec[3]; /* the actual location of the point in local/EditMode space */ + float vec[3]; /* the actual location of the point in local/EditMode space */ } EditBonePoint; /* find chain-tips (i.e. bones without children) */ -static void chains_find_tips (ListBase *edbo, ListBase *list) +static void chains_find_tips(ListBase *edbo, ListBase *list) { EditBone *curBone, *ebo; LinkData *ld; /* note: this is potentially very slow ... there's got to be a better way */ - for (curBone= edbo->first; curBone; curBone= curBone->next) { - short stop= 0; + for (curBone = edbo->first; curBone; curBone = curBone->next) { + short stop = 0; /* is this bone contained within any existing chain? (skip if so) */ - for (ld= list->first; ld; ld= ld->next) { - for (ebo= ld->data; ebo; ebo= ebo->parent) { + for (ld = list->first; ld; ld = ld->next) { + for (ebo = ld->data; ebo; ebo = ebo->parent) { if (ebo == curBone) { - stop= 1; + stop = 1; break; } } @@ -2729,12 +2729,12 @@ static void chains_find_tips (ListBase *edbo, ListBase *list) if (stop) continue; /* is any existing chain part of the chain formed by this bone? */ - stop= 0; - for (ebo= curBone->parent; ebo; ebo= ebo->parent) { - for (ld= list->first; ld; ld= ld->next) { + stop = 0; + for (ebo = curBone->parent; ebo; ebo = ebo->parent) { + for (ld = list->first; ld; ld = ld->next) { if (ld->data == ebo) { - ld->data= curBone; - stop= 1; + ld->data = curBone; + stop = 1; break; } } @@ -2745,19 +2745,19 @@ static void chains_find_tips (ListBase *edbo, ListBase *list) if (stop) continue; /* add current bone to a new chain */ - ld= MEM_callocN(sizeof(LinkData), "BoneChain"); - ld->data= curBone; + ld = MEM_callocN(sizeof(LinkData), "BoneChain"); + ld->data = curBone; BLI_addtail(list, ld); } } /* --------------------- */ -static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) +static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) { EditBonePoint *ebp; float vec[3]; - short found= 0; + short found = 0; if (eb_tail) { copy_v3_v3(vec, ebo->tail); @@ -2766,20 +2766,20 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) copy_v3_v3(vec, ebo->head); } - for (ebp= points->first; ebp; ebp= ebp->next) { + for (ebp = points->first; ebp; ebp = ebp->next) { if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { /* so this bone's tail owner is this bone */ - ebp->tail_owner= ebo; - found= 1; + ebp->tail_owner = ebo; + found = 1; break; } } else { if ((ebp->tail_owner) && (ebo->parent == ebp->tail_owner)) { /* so this bone's head owner is this bone */ - ebp->head_owner= ebo; + ebp->head_owner = ebo; found = 1; break; } @@ -2789,15 +2789,15 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) /* allocate a new point if no existing point was related */ if (found == 0) { - ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); + ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); if (eb_tail) { copy_v3_v3(ebp->vec, ebo->tail); - ebp->tail_owner= ebo; + ebp->tail_owner = ebo; } else { copy_v3_v3(ebp->vec, ebo->head); - ebp->head_owner= ebo; + ebp->head_owner = ebo; } BLI_addtail(points, ebp); @@ -2805,12 +2805,12 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) } /* bone adding between selected joints */ -static int armature_fill_bones_exec (bContext *C, wmOperator *op) +static int armature_fill_bones_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= (obedit) ? obedit->data : NULL; - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = (obedit) ? obedit->data : NULL; + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); ListBase points = {NULL, NULL}; int count; @@ -2829,11 +2829,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* the number of joints determines how we fill: - * 1) between joint and cursor (joint=head, cursor=tail) - * 2) between the two joints (order is dependent on active-bone/hierachy) - * 3+) error (a smarter method involving finding chains needs to be worked out + * 1) between joint and cursor (joint=head, cursor=tail) + * 2) between the two joints (order is dependent on active-bone/hierachy) + * 3+) error (a smarter method involving finding chains needs to be worked out */ - count= BLI_countlist(&points); + count = BLI_countlist(&points); if (count == 0) { BKE_report(op->reports, RPT_ERROR, "No joints selected"); @@ -2844,7 +2844,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) float curs[3]; /* Get Points - selected joint */ - ebp= (EditBonePoint *)points.first; + ebp = (EditBonePoint *)points.first; /* Get points - cursor (tail) */ invert_m4_m4(obedit->imat, obedit->obmat); @@ -2859,15 +2859,15 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) short headtail = 0; /* check that the points don't belong to the same bone */ - ebp= (EditBonePoint *)points.first; - ebp2= ebp->next; + ebp = (EditBonePoint *)points.first; + ebp2 = ebp->next; - if ((ebp->head_owner==ebp2->tail_owner) && (ebp->head_owner!=NULL)) { + if ((ebp->head_owner == ebp2->tail_owner) && (ebp->head_owner != NULL)) { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); return OPERATOR_CANCELLED; } - if ((ebp->tail_owner==ebp2->head_owner) && (ebp->tail_owner!=NULL)) { + if ((ebp->tail_owner == ebp2->head_owner) && (ebp->tail_owner != NULL)) { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); return OPERATOR_CANCELLED; @@ -2887,11 +2887,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* get distances */ sub_v3_v3v3(vecA, ebp->vec, curs); sub_v3_v3v3(vecB, ebp2->vec, curs); - distA= len_v3(vecA); - distB= len_v3(vecB); + distA = len_v3(vecA); + distB = len_v3(vecB); /* compare distances - closer one therefore acts as direction for bone to go */ - headtail= (distA < distB) ? 2 : 1; + headtail = (distA < distB) ? 2 : 1; } else if (ebp->head_owner) { headtail = 1; @@ -2912,22 +2912,22 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* add new bone and parent it to the appropriate end */ if (headtail) { - EditBone *newbone= add_points_bone(obedit, head, tail); + EditBone *newbone = add_points_bone(obedit, head, tail); /* do parenting (will need to set connected flag too) */ if (headtail == 2) { /* ebp tail or head - tail gets priority */ if (ebp->tail_owner) - newbone->parent= ebp->tail_owner; + newbone->parent = ebp->tail_owner; else - newbone->parent= ebp->head_owner; + newbone->parent = ebp->head_owner; } else { /* ebp2 tail or head - tail gets priority */ if (ebp2->tail_owner) - newbone->parent= ebp2->tail_owner; + newbone->parent = ebp2->tail_owner; else - newbone->parent= ebp2->head_owner; + newbone->parent = ebp2->head_owner; } newbone->flag |= BONE_CONNECTED; @@ -2941,7 +2941,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) } /* updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); /* free points */ BLI_freelistN(&points); @@ -2961,7 +2961,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------------------- */ @@ -2971,7 +2971,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot) */ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *ebo, *ebone, *newbone; LinkData *chain; float head[3], tail[3]; @@ -2989,23 +2989,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone * - tail = head/tail of end (default tail) * - parent = parent of start */ - if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) { + if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED) == 0) { copy_v3_v3(head, start->tail); } else { copy_v3_v3(head, start->head); } - if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) { + if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED) == 0) { copy_v3_v3(tail, end->head); } else { copy_v3_v3(tail, end->tail); } - newbone= add_points_bone(obedit, head, tail); + newbone = add_points_bone(obedit, head, tail); newbone->parent = start->parent; /* TODO, copy more things to the new bone */ - newbone->flag= start->flag & (BONE_HINGE|BONE_NO_DEFORM|BONE_NO_SCALE|BONE_NO_CYCLICOFFSET|BONE_NO_LOCAL_LOCATION|BONE_DONE); + newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE); /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge * - potentially several tips for side chains leading to some tree exist... @@ -3037,24 +3037,24 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone /* step 2b: parent child of end to newbone (child from this chain) */ if (endchild) - endchild->parent= newbone; + endchild->parent = newbone; /* step 3: delete all bones between and including start and end */ - for (ebo= end; ebo; ebo= ebone) { - ebone= (ebo == start) ? (NULL) : (ebo->parent); + for (ebo = end; ebo; ebo = ebone) { + ebone = (ebo == start) ? (NULL) : (ebo->parent); bone_free(arm, ebo); } - newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED); + newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); ED_armature_sync_selection(arm->edbo); } -static int armature_merge_exec (bContext *C, wmOperator *op) +static int armature_merge_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= (obedit) ? obedit->data : NULL; - short type= RNA_enum_get(op->ptr, "type"); + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = (obedit) ? obedit->data : NULL; + short type = RNA_enum_get(op->ptr, "type"); /* sanity checks */ if (ELEM(NULL, obedit, arm)) @@ -3074,28 +3074,28 @@ static int armature_merge_exec (bContext *C, wmOperator *op) if (chains.first == NULL) return OPERATOR_CANCELLED; /* each 'chain' is the last bone in the chain (with no children) */ - for (chain= chains.first; chain; chain= nchain) { - EditBone *bstart= NULL, *bend= NULL; - EditBone *bchild= NULL, *child=NULL; + for (chain = chains.first; chain; chain = nchain) { + EditBone *bstart = NULL, *bend = NULL; + EditBone *bchild = NULL, *child = NULL; /* temporarily remove chain from list of chains */ - nchain= chain->next; + nchain = chain->next; BLI_remlink(&chains, chain); /* only consider bones that are visible and selected */ - for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) { + for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) { /* check if visible + selected */ - if ( EBONE_VISIBLE(arm, ebo) && - ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) && - (ebo->flag & BONE_SELECTED) ) + if (EBONE_VISIBLE(arm, ebo) && + ((ebo->flag & BONE_CONNECTED) || (ebo->parent == NULL)) && + (ebo->flag & BONE_SELECTED) ) { /* set either end or start (end gets priority, unless it is already set) */ if (bend == NULL) { - bend= ebo; - bchild= child; + bend = ebo; + bchild = child; } else - bstart= ebo; + bstart = ebo; } else { /* chain is broken... merge any continous segments then clear */ @@ -3123,7 +3123,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op) /* updates */ ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); return OPERATOR_FINISHED; } @@ -3146,7 +3146,7 @@ void ARMATURE_OT_merge(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", ""); @@ -3157,19 +3157,19 @@ void ARMATURE_OT_merge(wmOperatorType *ot) static int armature_hide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *ebone; - const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0; + const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0; /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) return OPERATOR_CANCELLED; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if ((ebone->flag & BONE_SELECTED) != invert) { - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag |= BONE_HIDDEN_A; } } @@ -3177,7 +3177,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op) ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3194,7 +3194,7 @@ void ARMATURE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -3202,14 +3202,14 @@ void ARMATURE_OT_hide(wmOperatorType *ot) static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { - ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; } } @@ -3217,7 +3217,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3234,20 +3234,20 @@ void ARMATURE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } #if 0 // remove this? static void hide_selected_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_SELECTED) { - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag |= BONE_HIDDEN_A; } } @@ -3258,14 +3258,14 @@ static void hide_selected_armature_bones(Scene *scene) static void hide_unselected_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - bArmature *arm= obedit->data; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + bArmature *arm = obedit->data; if (EBONE_VISIBLE(arm, ebone)) { - if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL)); + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ; else { ebone->flag |= BONE_HIDDEN_A; } @@ -3278,14 +3278,14 @@ static void hide_unselected_armature_bones(Scene *scene) void show_all_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { - ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; } } @@ -3302,15 +3302,15 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) { Object *obedit; bArmature *arm; - EditBone *newbone, *ebone, *flipbone, *first=NULL; - int a, totbone= 0, do_extrude; + EditBone *newbone, *ebone, *flipbone, *first = NULL; + int a, totbone = 0, do_extrude; int forked = RNA_boolean_get(op->ptr, "forked"); - obedit= CTX_data_edit_object(C); - arm= obedit->data; + obedit = CTX_data_edit_object(C); + arm = obedit->data; /* since we allow root extrude too, we have to make sure selection is OK */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { @@ -3322,36 +3322,36 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } /* Duplicate the necessary bones */ - for (ebone = arm->edbo->first; ((ebone) && (ebone!=first)); ebone=ebone->next) { + for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { /* we extrude per definition the tip */ - do_extrude= 0; - if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED)) - do_extrude= 1; + do_extrude = 0; + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) + do_extrude = 1; else if (ebone->flag & BONE_ROOTSEL) { /* but, a bone with parent deselected we do the root... */ - if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)); - else do_extrude= 2; + if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ; + else do_extrude = 2; } if (do_extrude) { /* we re-use code for mirror editing... */ - flipbone= NULL; + flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) { - flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); if (flipbone) { - forked= 0; // we extrude 2 different bones - if (flipbone->flag & (BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED)) + forked = 0; // we extrude 2 different bones + if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) /* don't want this bone to be selected... */ - flipbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } - if ((flipbone==NULL) && (forked)) - flipbone= ebone; + if ((flipbone == NULL) && (forked)) + flipbone = ebone; } - for (a=0; a<2; a++) { - if (a==1) { - if (flipbone==NULL) + for (a = 0; a < 2; a++) { + if (a == 1) { + if (flipbone == NULL) break; else { SWAP(EditBone *, flipbone, ebone); @@ -3361,43 +3361,43 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) totbone++; newbone = MEM_callocN(sizeof(EditBone), "extrudebone"); - if (do_extrude==1) { + if (do_extrude == 1) { copy_v3_v3(newbone->head, ebone->tail); copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; - newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone + newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone if (newbone->parent) newbone->flag |= BONE_CONNECTED; } else { copy_v3_v3(newbone->head, ebone->head); copy_v3_v3(newbone->tail, ebone->head); - newbone->parent= ebone->parent; + newbone->parent = ebone->parent; - newbone->flag= BONE_TIPSEL; + newbone->flag = BONE_TIPSEL; if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; } } - newbone->weight= ebone->weight; - newbone->dist= ebone->dist; - newbone->xwidth= ebone->xwidth; - newbone->zwidth= ebone->zwidth; - newbone->ease1= ebone->ease1; - newbone->ease2= ebone->ease2; - newbone->rad_head= ebone->rad_tail; // don't copy entire bone... - newbone->rad_tail= ebone->rad_tail; - newbone->segments= 1; - newbone->layer= ebone->layer; - - BLI_strncpy (newbone->name, ebone->name, sizeof(newbone->name)); - - if (flipbone && forked) { // only set if mirror edit - if (strlen(newbone->name)<30) { - if (a==0) strcat(newbone->name, "_L"); + newbone->weight = ebone->weight; + newbone->dist = ebone->dist; + newbone->xwidth = ebone->xwidth; + newbone->zwidth = ebone->zwidth; + newbone->ease1 = ebone->ease1; + newbone->ease2 = ebone->ease2; + newbone->rad_head = ebone->rad_tail; // don't copy entire bone... + newbone->rad_tail = ebone->rad_tail; + newbone->segments = 1; + newbone->layer = ebone->layer; + + BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); + + if (flipbone && forked) { // only set if mirror edit + if (strlen(newbone->name) < 30) { + if (a == 0) strcat(newbone->name, "_L"); else strcat(newbone->name, "_R"); } } @@ -3409,24 +3409,24 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) first = newbone; /* restore ebone if we were flipping */ - if (a==1 && flipbone) + if (a == 1 && flipbone) SWAP(EditBone *, flipbone, ebone); } } /* Deselect the old bone */ - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } } /* if only one bone, make this one active */ - if (totbone==1 && first) arm->act_edbone= first; + if (totbone == 1 && first) arm->act_edbone = first; - if (totbone==0) return OPERATOR_CANCELLED; + if (totbone == 0) return OPERATOR_CANCELLED; /* Transform the endpoints */ ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3443,7 +3443,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "forked", 0, "Forked", ""); @@ -3454,7 +3454,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); Object *obedit = CTX_data_edit_object(C); EditBone *bone; float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; @@ -3479,17 +3479,17 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) ED_armature_deselect_all(obedit, 0); /* Create a bone */ - bone= ED_armature_edit_bone_add(obedit->data, name); + bone = ED_armature_edit_bone_add(obedit->data, name); copy_v3_v3(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3506,7 +3506,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone"); @@ -3523,28 +3523,28 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) static int armature_subdivide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *newbone, *tbone; int numcuts, i; /* there may not be a number_cuts property defined (for 'simple' subdivide) */ - numcuts= RNA_int_get(op->ptr, "number_cuts"); + numcuts = RNA_int_get(op->ptr, "number_cuts"); /* loop over all editable bones */ // XXX the old code did this in reverse order though! CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { - for (i=numcuts+1; i>1; i--) { + for (i = numcuts + 1; i > 1; i--) { /* compute cut ratio first */ - float cutratio= 1.0f / (float)i; - float cutratioI= 1.0f - cutratio; + float cutratio = 1.0f / (float)i; + float cutratioI = 1.0f - cutratio; float val1[3]; float val2[3]; float val3[3]; - newbone= MEM_mallocN(sizeof(EditBone), "ebone subdiv"); + newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv"); *newbone = *ebone; BLI_addtail(arm->edbo, newbone); @@ -3553,33 +3553,33 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) copy_v3_v3(val2, ebone->tail); copy_v3_v3(val3, newbone->head); - val3[0]= val1[0]*cutratio + val2[0]*cutratioI; - val3[1]= val1[1]*cutratio + val2[1]*cutratioI; - val3[2]= val1[2]*cutratio + val2[2]*cutratioI; + val3[0] = val1[0] * cutratio + val2[0] * cutratioI; + val3[1] = val1[1] * cutratio + val2[1] * cutratioI; + val3[2] = val1[2] * cutratio + val2[2] * cutratioI; copy_v3_v3(newbone->head, val3); copy_v3_v3(newbone->tail, ebone->tail); copy_v3_v3(ebone->tail, newbone->head); - newbone->rad_head= 0.5f * (ebone->rad_head + ebone->rad_tail); - ebone->rad_tail= newbone->rad_head; + newbone->rad_head = 0.5f * (ebone->rad_head + ebone->rad_tail); + ebone->rad_tail = newbone->rad_head; newbone->flag |= BONE_CONNECTED; unique_editbone_name(arm->edbo, newbone->name, NULL); /* correct parent bones */ - for (tbone = arm->edbo->first; tbone; tbone=tbone->next) { - if (tbone->parent==ebone) - tbone->parent= newbone; + for (tbone = arm->edbo->first; tbone; tbone = tbone->next) { + if (tbone->parent == ebone) + tbone->parent = newbone; } - newbone->parent= ebone; + newbone->parent = ebone; } } CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3598,7 +3598,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties */ prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10); @@ -3616,8 +3616,8 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; ListBase chains = {NULL, NULL}; LinkData *chain; @@ -3628,16 +3628,16 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_tag_select_mirrored(arm); /* loop over chains, only considering selected and visible bones */ - for (chain= chains.first; chain; chain= chain->next) { - EditBone *ebo, *child=NULL, *parent=NULL; + for (chain = chains.first; chain; chain = chain->next) { + EditBone *ebo, *child = NULL, *parent = NULL; /* loop over bones in chain */ - for (ebo= chain->data; ebo; ebo= parent) { + for (ebo = chain->data; ebo; ebo = parent) { /* parent is this bone's original parent * - we store this, as the next bone that is checked is this one * but the value of ebo->parent may change here... */ - parent= ebo->parent; + parent = ebo->parent; /* only if selected and editable */ if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { @@ -3650,7 +3650,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * - use 'child' as new parent * - connected flag is only set if points are coincidental */ - ebo->parent= child; + ebo->parent = child; if ((child) && equals_v3v3(ebo->head, child->tail)) ebo->flag |= BONE_CONNECTED; else @@ -3659,14 +3659,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) /* get next bones * - child will become the new parent of next bone */ - child= ebo; + child = ebo; } else { /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it * as it will be facing in opposite direction */ if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { - ebo->parent= NULL; + ebo->parent = NULL; ebo->flag &= ~BONE_CONNECTED; } @@ -3674,7 +3674,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * - child will become new parent of next bone (not swapping occurred, * so set to NULL to prevent infinite-loop) */ - child= NULL; + child = NULL; } } } @@ -3685,7 +3685,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_tag_unselect(arm); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3702,13 +3702,13 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Parenting *********************** */ /* armature parenting options */ #define ARM_PAR_CONNECT 1 -#define ARM_PAR_OFFSET 2 +#define ARM_PAR_OFFSET 2 /* check for null, before calling! */ static void bone_connect_to_existing_parent(EditBone *bone) @@ -3727,12 +3727,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo selbone->parent->flag &= ~(BONE_TIPSEL); /* make actbone the parent of selbone */ - selbone->parent= actbone; + selbone->parent = actbone; /* in actbone tree we cannot have a loop */ - for (ebone= actbone->parent; ebone; ebone= ebone->parent) { - if (ebone->parent==selbone) { - ebone->parent= NULL; + for (ebone = actbone->parent; ebone; ebone = ebone->parent) { + if (ebone->parent == selbone) { + ebone->parent = NULL; ebone->flag &= ~BONE_CONNECTED; } } @@ -3743,16 +3743,16 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo sub_v3_v3v3(offset, actbone->tail, selbone->head); copy_v3_v3(selbone->head, actbone->tail); - selbone->rad_head= actbone->rad_tail; + selbone->rad_head = actbone->rad_tail; add_v3_v3(selbone->tail, offset); /* offset for all its children */ - for (ebone = edbo->first; ebone; ebone=ebone->next) { + for (ebone = edbo->first; ebone; ebone = ebone->next) { EditBone *par; - for (par= ebone->parent; par; par= par->parent) { - if (par==selbone) { + for (par = ebone->parent; par; par = par->parent) { + if (par == selbone) { add_v3_v3(ebone->head, offset); add_v3_v3(ebone->tail, offset); break; @@ -3774,8 +3774,8 @@ static EnumPropertyItem prop_editarm_make_parent_types[] = { static int armature_parent_set_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); EditBone *actmirb = NULL; short val = RNA_enum_get(op->ptr, "type"); @@ -3793,9 +3793,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) - actmirb= actbone; + actmirb = actbone; } /* if there is only 1 selected bone, we assume that that is the active bone, @@ -3817,7 +3817,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * - the context iterator contains both selected bones and their mirrored copies, * so we assume that unselected bones are mirrored copies of some selected bone * - since the active one (and/or its mirror) will also be selected, we also need - * to check that we are not trying to operate on them, since such an operation + * to check that we are not trying to operate on them, since such an operation * would cause errors */ @@ -3836,7 +3836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3844,14 +3844,14 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { EditBone *actbone = CTX_data_active_bone(C); - uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, "Make Parent ", ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); int allchildbones = 0; CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { if (ebone != actbone) { - if (ebone->parent != actbone) allchildbones= 1; + if (ebone->parent != actbone) allchildbones = 1; } } CTX_DATA_END; @@ -3880,7 +3880,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting"); } @@ -3898,14 +3898,14 @@ static void editbone_clear_parent(EditBone *ebone, int mode) ebone->parent->flag &= ~(BONE_TIPSEL); } - if (mode==1) ebone->parent= NULL; + if (mode == 1) ebone->parent = NULL; ebone->flag &= ~BONE_CONNECTED; } static int armature_parent_clear_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; int val = RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -3917,7 +3917,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) ED_armature_sync_selection(arm->edbo); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3935,7 +3935,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } @@ -3955,7 +3955,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); return OPERATOR_FINISHED; } @@ -3972,7 +3972,7 @@ void ARMATURE_OT_select_inverse(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int armature_de_select_all_exec(bContext *C, wmOperator *op) @@ -3993,30 +3993,30 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) /* ignore bone if selection can't change */ if ((ebone->flag & BONE_UNSELECTABLE) == 0) { switch (action) { - case SEL_SELECT: - ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (ebone->parent) - ebone->parent->flag |= (BONE_TIPSEL); - break; - case SEL_DESELECT: - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - break; - case SEL_INVERT: - if (ebone->flag & BONE_SELECTED) { - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - } - else { + case SEL_SELECT: ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); if (ebone->parent) ebone->parent->flag |= (BONE_TIPSEL); - } - break; + break; + case SEL_DESELECT: + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + break; + case SEL_INVERT: + if (ebone->flag & BONE_SELECTED) { + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } + else { + ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + if (ebone->parent) + ebone->parent->flag |= (BONE_TIPSEL); + } + break; } } } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); return OPERATOR_FINISHED; } @@ -4033,7 +4033,7 @@ void ARMATURE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -4077,7 +4077,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { if ((ebone->length >= len_min) && - (ebone->length <= len_max)) + (ebone->length <= len_max)) { ED_armature_edit_bone_select(ebone); } @@ -4227,30 +4227,30 @@ void ARMATURE_OT_select_similar(wmOperatorType *ot) { static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); Object *ob; bArmature *arm; EditBone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); int add_to_sel = RNA_boolean_get(op->ptr, "extend"); - ob= obedit; - arm= (bArmature *)ob->data; + ob = obedit; + arm = (bArmature *)ob->data; - for (curbone= arm->edbo->first; curbone; curbone= curbone->next) { + for (curbone = arm->edbo->first; curbone; curbone = curbone->next) { /* only work on bone if it is visible and its selection can change */ - if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE)==0) { + if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE) == 0) { if (curbone == arm->act_edbone) { if (direction == BONE_SELECT_PARENT) { if (curbone->parent == NULL) continue; else pabone = curbone->parent; if (EBONE_VISIBLE(arm, pabone)) { - pabone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_edbone= pabone; - if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; + pabone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_edbone = pabone; + if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; - if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); break; } @@ -4259,12 +4259,12 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) chbone = editbone_get_child(arm, curbone, 1); if (chbone == NULL) continue; - if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE)==0) { - chbone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_edbone= chbone; + if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE) == 0) { + chbone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_edbone = chbone; if (!add_to_sel) { - curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL); + curbone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL); if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL; } break; @@ -4276,17 +4276,17 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { - {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, - {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, - {0, NULL, 0, NULL, NULL} + static EnumPropertyItem direction_items[] = { + {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, + {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ @@ -4299,7 +4299,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_enum(ot->srna, "direction", direction_items, @@ -4329,7 +4329,7 @@ static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone) { EditBone *selbone; - for (selbone = edbo->first; selbone; selbone=selbone->next) { + for (selbone = edbo->first; selbone; selbone = selbone->next) { if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) { fix_connected_bone(selbone); fix_editbone_connected_children(edbo, selbone); @@ -4361,10 +4361,10 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb static int armature_align_bones_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; - EditBone *actbone= CTX_data_active_bone(C); - EditBone *actmirb= NULL; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; + EditBone *actbone = CTX_data_active_bone(C); + EditBone *actmirb = NULL; /* there must be an active bone */ if (actbone == NULL) { @@ -4379,9 +4379,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) - actmirb= actbone; + actmirb = actbone; } /* if there is only 1 selected bone, we assume that that is the active bone, @@ -4422,7 +4422,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -4440,14 +4440,14 @@ void ARMATURE_OT_align(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Pose tools ********************* */ // XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer static int bone_looper(Object *ob, Bone *bone, void *data, - int (*bone_func)(Object *, Bone *, void *)) + int (*bone_func)(Object *, Bone *, void *)) { /* We want to apply the function bone_func to every bone * in an armature -- feed bone_looper the first bone and @@ -4477,49 +4477,49 @@ static int bone_looper(Object *ob, Bone *bone, void *data, /* assumes scene obact and basact is still on old situation */ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend) { - Object *ob= base->object; + Object *ob = base->object; Bone *nearBone; if (!ob || !ob->pose) return 0; - nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1); + nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1); /* if the bone cannot be affected, don't do anything */ if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) { - Object *ob_act= OBACT; - bArmature *arm= ob->data; + Object *ob_act = OBACT; + bArmature *arm = ob->data; /* since we do unified select, we don't shift+select a bone if the * armature object was not active yet. * note, special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode - campbell */ - if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT)==0))) { + if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) { ED_pose_deselectall(ob, 0); - nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_bone= nearBone; + nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_bone = nearBone; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 1); } else { if (nearBone->flag & BONE_SELECTED) { /* if not active, we make it active */ if (nearBone != arm->act_bone) { - arm->act_bone= nearBone; + arm->act_bone = nearBone; } else { - nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 0); } } else { - nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_bone= nearBone; + nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_bone = nearBone; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 1); } } @@ -4534,7 +4534,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } - return nearBone!=NULL; + return nearBone != NULL; } /* test==0: deselect all @@ -4544,16 +4544,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor */ void ED_pose_deselectall(Object *ob, int test) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - int selectmode= 0; + int selectmode = 0; /* we call this from outliner too */ if (ELEM(NULL, ob, ob->pose)) return; /* Determine if we're selecting or deselecting */ - if (test==1) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if (test == 1) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) break; @@ -4561,21 +4561,21 @@ void ED_pose_deselectall(Object *ob, int test) } if (pchan == NULL) - selectmode= 1; + selectmode = 1; } else if (test == 2) - selectmode= 2; + selectmode = 2; /* Set the flags accordingly */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* ignore the pchan if it isn't visible or if its selection cannot be changed */ - if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) { - if (test==3) { - pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) { + if (test == 3) { + pchan->bone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } else { - if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED; + if (selectmode == 0) pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + else if (selectmode == 1) pchan->bone->flag |= BONE_SELECTED; } } } @@ -4611,7 +4611,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4619,7 +4619,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) if (data->list != NULL) { hbone = (Bone ***) &data->list; - for (a=0; a<segments; a++) { + for (a = 0; a < segments; a++) { **hbone = bone; ++*hbone; } @@ -4670,15 +4670,15 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) * pointers to bDeformGroups, all with names * of skinnable bones. */ - bDeformGroup ***hgroup, *defgroup= NULL; + bDeformGroup ***hgroup, *defgroup = NULL; int a, segments; - struct { Object *armob; void *list; int heat; } *data= datap; + struct { Object *armob; void *list; int heat; } *data = datap; int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); - bArmature *arm= data->armob->data; + bArmature *arm = data->armob->data; if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) { - if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (!(bone->flag & BONE_NO_DEFORM)) { + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4690,7 +4690,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) if (data->list != NULL) { hgroup = (bDeformGroup ***) &data->list; - for (a=0; a<segments; a++) { + for (a = 0; a < segments; a++) { **hgroup = defgroup; ++*hgroup; } @@ -4720,11 +4720,11 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i int i, iflip, j; /* for each vertex in the mesh */ - for (i=0; i < mesh->totvert; i++) { - iflip = (dgroupflip)? mesh_get_x_mirror_vert(ob, i): 0; + for (i = 0; i < mesh->totvert; i++) { + iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i) : 0; /* for each skinnable bone */ - for (j=0; j < numbones; ++j) { + for (j = 0; j < numbones; ++j) { if (!selected[j]) continue; @@ -4732,22 +4732,22 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i dgroup = dgrouplist[j]; /* store the distance-factor from the vertex to the bone */ - distance = distfactor_to_bone (verts[i], root[j], tip[j], - bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); + distance = distfactor_to_bone(verts[i], root[j], tip[j], + bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); /* add the vert to the deform group if weight!=0.0 */ if (distance != 0.0f) - ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE); + ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE); else - ED_vgroup_vert_remove (ob, dgroup, i); + ED_vgroup_vert_remove(ob, dgroup, i); /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip >= 0) { if (distance != 0.0f) - ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance, - WEIGHT_REPLACE); + ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance, + WEIGHT_REPLACE); else - ED_vgroup_vert_remove (ob, dgroupflip[j], iflip); + ED_vgroup_vert_remove(ob, dgroupflip[j], iflip); } } } @@ -4767,7 +4767,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, * when parenting, or simply the original mesh coords. */ - bArmature *arm= par->data; + bArmature *arm = par->data; Bone **bonelist, *bone; bDeformGroup **dgrouplist, **dgroupflip; bDeformGroup *dgroup; @@ -4781,8 +4781,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, struct { Object *armob; void *list; int heat; } looper_data; looper_data.armob = par; - looper_data.heat= heat; - looper_data.list= NULL; + looper_data.heat = heat; + looper_data.list = NULL; /* count the number of skinnable bones */ numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); @@ -4792,26 +4792,26 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* create an array of pointer to bones that are skinnable * and fill it with all of the skinnable bones */ - bonelist = MEM_callocN(numbones*sizeof(Bone *), "bonelist"); - looper_data.list= bonelist; + bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); + looper_data.list = bonelist; bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); /* create an array of pointers to the deform groups that * coorespond to the skinnable bones (creating them * as necessary. */ - dgrouplist = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgrouplist"); - dgroupflip = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgroupflip"); + dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist"); + dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip"); - looper_data.list= dgrouplist; + looper_data.list = dgrouplist; bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb); /* create an array of root and tip positions transformed into * global coords */ - root = MEM_callocN(numbones*sizeof(float)*3, "root"); - tip = MEM_callocN(numbones*sizeof(float)*3, "tip"); - selected = MEM_callocN(numbones*sizeof(int), "selected"); + root = MEM_callocN(numbones * sizeof(float) * 3, "root"); + tip = MEM_callocN(numbones * sizeof(float) * 3, "tip"); + selected = MEM_callocN(numbones * sizeof(int), "selected"); - for (j=0; j < numbones; ++j) { + for (j = 0; j < numbones; ++j) { bone = bonelist[j]; dgroup = dgrouplist[j]; @@ -4821,7 +4821,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, segments = 1; bbone = NULL; - if ((par->pose) && (pchan=get_pose_channel(par->pose, bone->name))) { + if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) { if (bone->segments > 1) { segments = bone->segments; bbone = b_bone_spline_setup(pchan, 1); @@ -4835,8 +4835,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* compute root and tip */ if (bbone) { mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]); - if ((segments+1) < bone->segments) { - mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]); + if ((segments + 1) < bone->segments) { + mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments + 1].mat[3]); } else { copy_v3_v3(tip[j], bone->arm_tail); @@ -4869,15 +4869,15 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } /* create verts */ - mesh = (Mesh*)ob->data; - verts = MEM_callocN(mesh->totvert*sizeof(*verts), "closestboneverts"); + mesh = (Mesh *)ob->data; + verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"); if (wpmode) { /* if in weight paint mode, use final verts from derivedmesh */ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); if (dm->foreachMappedVert) { - dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void*)verts); + dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void *)verts); vertsfilled = 1; } @@ -4892,7 +4892,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } /* transform verts to global space */ - for (i=0; i < mesh->totvert; i++) { + for (i = 0; i < mesh->totvert; i++) { if (!vertsfilled) copy_v3_v3(verts[i], mesh->mvert[i].co); mul_m4_v3(ob->obmat, verts[i]); @@ -4900,9 +4900,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* compute the weights based on gathered vertices and bones */ if (heat) { - const char *error= NULL; + const char *error = NULL; heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip, - root, tip, selected, &error); + root, tip, selected, &error); if (error) { BKE_report(reports, RPT_WARNING, error); @@ -4910,7 +4910,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } else { envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist, - dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); + dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); } /* only generated in some cases but can call anyway */ @@ -4931,7 +4931,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, /* Lets try to create some vertex groups * based on the bones of the parent armature. */ - bArmature *arm= par->data; + bArmature *arm = par->data; if (mode == ARM_GROUPS_NAME) { /* Traverse the bone list, trying to create empty vertex @@ -4955,41 +4955,41 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, /* clear scale of pose-channel */ static void pchan_clear_scale(bPoseChannel *pchan) { - if ((pchan->protectflag & OB_LOCK_SCALEX)==0) - pchan->size[0]= 1.0f; - if ((pchan->protectflag & OB_LOCK_SCALEY)==0) - pchan->size[1]= 1.0f; - if ((pchan->protectflag & OB_LOCK_SCALEZ)==0) - pchan->size[2]= 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) + pchan->size[0] = 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) + pchan->size[1] = 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) + pchan->size[2] = 1.0f; } /* clear location of pose-channel */ static void pchan_clear_loc(bPoseChannel *pchan) { - if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= 0.0f; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[1]= 0.0f; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[2]= 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + pchan->loc[0] = 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + pchan->loc[1] = 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + pchan->loc[2] = 0.0f; } /* clear rotation of pose-channel */ static void pchan_clear_rot(bPoseChannel *pchan) { - if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) { + if (pchan->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) { /* check if convert to eulers for locking... */ if (pchan->protectflag & OB_LOCK_ROT4D) { /* perform clamping on a component by component basis */ if (pchan->rotmode == ROT_MODE_AXISANGLE) { if ((pchan->protectflag & OB_LOCK_ROTW) == 0) - pchan->rotAngle= 0.0f; + pchan->rotAngle = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->rotAxis[0]= 0.0f; + pchan->rotAxis[0] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->rotAxis[1]= 0.0f; + pchan->rotAxis[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->rotAxis[2]= 0.0f; + pchan->rotAxis[2] = 0.0f; /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) @@ -4997,22 +4997,22 @@ static void pchan_clear_rot(bPoseChannel *pchan) } else if (pchan->rotmode == ROT_MODE_QUAT) { if ((pchan->protectflag & OB_LOCK_ROTW) == 0) - pchan->quat[0]= 1.0f; + pchan->quat[0] = 1.0f; if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->quat[1]= 0.0f; + pchan->quat[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->quat[2]= 0.0f; + pchan->quat[2] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->quat[3]= 0.0f; + pchan->quat[3] = 0.0f; } else { /* the flag may have been set for the other modes, so just ignore the extra flag... */ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->eul[0]= 0.0f; + pchan->eul[0] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->eul[1]= 0.0f; + pchan->eul[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->eul[2]= 0.0f; + pchan->eul[2] = 0.0f; } } else { @@ -5021,7 +5021,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) float qlen = 0.0f; if (pchan->rotmode == ROT_MODE_QUAT) { - qlen= normalize_qt_qt(quat1, pchan->quat); + qlen = normalize_qt_qt(quat1, pchan->quat); quat_to_eul(oldeul, quat1); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { @@ -5031,14 +5031,14 @@ static void pchan_clear_rot(bPoseChannel *pchan) copy_v3_v3(oldeul, pchan->eul); } - eul[0]= eul[1]= eul[2]= 0.0f; + eul[0] = eul[1] = eul[2] = 0.0f; if (pchan->protectflag & OB_LOCK_ROTX) - eul[0]= oldeul[0]; + eul[0] = oldeul[0]; if (pchan->protectflag & OB_LOCK_ROTY) - eul[1]= oldeul[1]; + eul[1] = oldeul[1]; if (pchan->protectflag & OB_LOCK_ROTZ) - eul[2]= oldeul[2]; + eul[2] = oldeul[2]; if (pchan->rotmode == ROT_MODE_QUAT) { eul_to_quat(pchan->quat, eul); @@ -5047,7 +5047,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) mul_qt_fl(pchan->quat, qlen); /* quaternions flip w sign to accumulate rotations correctly */ - if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) { + if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) { mul_qt_fl(pchan->quat, -1.0f); } } @@ -5058,7 +5058,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) copy_v3_v3(pchan->eul, eul); } } - } // Duplicated in source/blender/editors/object/object_transform.c + } /* Duplicated in source/blender/editors/object/object_transform.c */ else { if (pchan->rotmode == ROT_MODE_QUAT) { unit_qt(pchan->quat); @@ -5085,10 +5085,10 @@ static void pchan_clear_transforms(bPoseChannel *pchan) /* generic exec for clear-pose operators */ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, - void (*clear_func)(bPoseChannel*), const char default_ksName[]) + void (*clear_func)(bPoseChannel *), const char default_ksName[]) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); short autokey = 0; /* sanity checks */ @@ -5098,7 +5098,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, } /* only clear relevant transforms for selected bones */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* run provided clearing function */ clear_func(pchan); @@ -5136,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -5160,7 +5160,7 @@ void POSE_OT_scale_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5181,7 +5181,7 @@ void POSE_OT_rot_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5202,7 +5202,7 @@ void POSE_OT_loc_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5223,7 +5223,7 @@ void POSE_OT_transforms_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** selections ********************** */ @@ -5232,11 +5232,11 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int multipaint = scene->toolsettings->multipaint; if (action == SEL_TOGGLE) { - action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; + action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; } /* Set the flags */ @@ -5244,26 +5244,26 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) { /* select pchan only if selectable, but deselect works always */ switch (action) { - case SEL_SELECT: - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) - pchan->bone->flag |= BONE_SELECTED; - break; - case SEL_DESELECT: - pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - break; - case SEL_INVERT: - if (pchan->bone->flag & BONE_SELECTED) { - pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - } - else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + case SEL_SELECT: + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag |= BONE_SELECTED; - } - break; + break; + case SEL_DESELECT: + pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + break; + case SEL_INVERT: + if (pchan->bone->flag & BONE_SELECTED) { + pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } + else if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { + pchan->bone->flag |= BONE_SELECTED; + } + break; } } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); if (multipaint) { Object *ob = ED_object_context(C); @@ -5285,24 +5285,24 @@ void POSE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan, *parent; /* Determine if there is an active bone */ - pchan=CTX_data_active_pose_bone(C); + pchan = CTX_data_active_pose_bone(C); if (pchan) { - bArmature *arm= ob->data; - parent=pchan->parent; - if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) { + bArmature *arm = ob->data; + parent = pchan->parent; + if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) { parent->bone->flag |= BONE_SELECTED; - arm->act_bone= parent->bone; + arm->act_bone = parent->bone; } else { return OPERATOR_CANCELLED; @@ -5312,7 +5312,7 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5329,7 +5329,7 @@ void POSE_OT_select_parent(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5337,14 +5337,14 @@ void POSE_OT_select_parent(wmOperatorType *ot) static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; - if (arm->act_bone==bone) - arm->act_bone= NULL; + if (arm->act_bone == bone) + arm->act_bone = NULL; } } return 0; @@ -5352,14 +5352,14 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { // hrm... typo here? - if ((bone->flag & BONE_SELECTED)==0) { + if ((bone->flag & BONE_SELECTED) == 0) { bone->flag |= BONE_HIDDEN_P; - if (arm->act_bone==bone) - arm->act_bone= NULL; + if (arm->act_bone == bone) + arm->act_bone = NULL; } } return 0; @@ -5368,8 +5368,8 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr /* active object is armature in posemode, poll checked */ static int pose_hide_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; if (RNA_boolean_get(op->ptr, "unselected")) bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb); @@ -5377,7 +5377,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op) bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5394,7 +5394,7 @@ void POSE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", ""); @@ -5402,7 +5402,7 @@ void POSE_OT_hide(wmOperatorType *ot) static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { if (bone->flag & BONE_HIDDEN_P) { @@ -5417,13 +5417,13 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) /* active object is armature in posemode, poll checked */ static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5440,14 +5440,14 @@ void POSE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************* RENAMING DISASTERS ************ */ static int bone_unique_check(void *arg, const char *name) { - return get_named_bone((bArmature *)arg, name) != NULL; + return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL; } static void unique_bone_name(bArmature *arm, char *name) @@ -5461,14 +5461,14 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam bConstraint *curcon; bConstraintTarget *ct; - for (curcon = conlist->first; curcon; curcon=curcon->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + for (curcon = conlist->first; curcon; curcon = curcon->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { if (!strcmp(ct->subtarget, oldname) ) BLI_strncpy(ct->subtarget, newname, MAXBONENAME); @@ -5500,7 +5500,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { - EditBone *eBone= editbone_name_exists(arm->edbo, oldname); + EditBone *eBone = editbone_name_exists(arm->edbo, oldname); if (eBone) { unique_editbone_name(arm->edbo, newname, NULL); @@ -5509,7 +5509,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n else return; } else { - Bone *bone= get_named_bone(arm, oldname); + Bone *bone = BKE_armature_find_bone_name(arm, oldname); if (bone) { unique_bone_name(arm, newname); @@ -5519,16 +5519,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } /* do entire dbase - objects */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { ModifierData *md; /* we have the object using the armature */ - if (arm==ob->data) { + if (arm == ob->data) { Object *cob; /* Rename the pose channel, if it exists */ if (ob->pose) { - bPoseChannel *pchan = get_pose_channel(ob->pose, oldname); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname); if (pchan) { BLI_strncpy(pchan->name, newname, MAXBONENAME); @@ -5543,12 +5543,12 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } /* Update any object constraints to use the new bone name */ - for (cob= G.main->object.first; cob; cob= cob->id.next) { + for (cob = G.main->object.first; cob; cob = cob->id.next) { if (cob->constraints.first) constraint_bone_name_fix(ob, &cob->constraints, oldname, newname); if (cob->pose) { bPoseChannel *pchan; - for (pchan = cob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) { constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname); } } @@ -5557,7 +5557,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* See if an object is parented to this armature */ if (ob->parent && (ob->parent->data == arm)) { - if (ob->partype==PARBONE) { + if (ob->partype == PARBONE) { /* bone name in object */ if (!strcmp(ob->parsubstr, oldname)) BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); @@ -5565,14 +5565,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } if (modifiers_usesArmature(ob, arm)) { - bDeformGroup *dg= defgroup_find_name(ob, oldname); + bDeformGroup *dg = defgroup_find_name(ob, oldname); if (dg) { BLI_strncpy(dg->name, newname, MAXBONENAME); } } /* fix modifiers that might be using this name */ - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; @@ -5596,14 +5596,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* correct view locking */ { bScreen *screen; - for (screen= G.main->screen.first; screen; screen= screen->id.next) { + for (screen = G.main->screen.first; screen; screen = screen->id.next) { ScrArea *sa; /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; if (v3d->ob_centre && v3d->ob_centre->data == arm) { if (!strcmp(v3d->ob_centre_bone, oldname)) { BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); @@ -5618,16 +5618,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } -static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) +static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); bArmature *arm; char newname[MAXBONENAME]; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -5641,7 +5641,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -5658,21 +5658,21 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int armature_autoside_names_exec (bContext *C, wmOperator *op) +static int armature_autoside_names_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); bArmature *arm; char newname[MAXBONENAME]; - short axis= RNA_enum_get(op->ptr, "type"); + short axis = RNA_enum_get(op->ptr, "type"); /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -5687,15 +5687,15 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } void ARMATURE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[]= { - {0, "XAXIS", 0, "X-Axis", "Left/Right"}, + static EnumPropertyItem axis_items[] = { + {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, {0, NULL, 0, NULL, NULL}}; @@ -5711,7 +5711,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* settings */ ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with"); @@ -5723,27 +5723,27 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) /* context; editmode armature, with mirror editing enabled */ void transform_armature_mirror_update(Object *obedit) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *ebo, *eboflip; - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { /* no layer check, correct mirror is more important */ - if (ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) { - eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebo); + if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { + eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo); if (eboflip) { /* we assume X-axis flipping for now */ if (ebo->flag & BONE_TIPSEL) { EditBone *children; - eboflip->tail[0]= -ebo->tail[0]; - eboflip->tail[1]= ebo->tail[1]; - eboflip->tail[2]= ebo->tail[2]; - eboflip->rad_tail= ebo->rad_tail; - eboflip->roll= -ebo->roll; + eboflip->tail[0] = -ebo->tail[0]; + eboflip->tail[1] = ebo->tail[1]; + eboflip->tail[2] = ebo->tail[2]; + eboflip->rad_tail = ebo->rad_tail; + eboflip->roll = -ebo->roll; /* Also move connected children, in case children's name aren't mirrored properly */ - for (children=arm->edbo->first; children; children=children->next) { + for (children = arm->edbo->first; children; children = children->next) { if (children->parent == eboflip && children->flag & BONE_CONNECTED) { copy_v3_v3(children->head, eboflip->tail); children->rad_head = ebo->rad_tail; @@ -5751,11 +5751,11 @@ void transform_armature_mirror_update(Object *obedit) } } if (ebo->flag & BONE_ROOTSEL) { - eboflip->head[0]= -ebo->head[0]; - eboflip->head[1]= ebo->head[1]; - eboflip->head[2]= ebo->head[2]; - eboflip->rad_head= ebo->rad_head; - eboflip->roll= -ebo->roll; + eboflip->head[0] = -ebo->head[0]; + eboflip->head[1] = ebo->head[1]; + eboflip->head[2] = ebo->head[2]; + eboflip->rad_head = ebo->rad_head; + eboflip->roll = -ebo->roll; /* Also move connected parent, in case parent's name isn't mirrored properly */ if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { @@ -5765,10 +5765,10 @@ void transform_armature_mirror_update(Object *obedit) } } if (ebo->flag & BONE_SELECTED) { - eboflip->dist= ebo->dist; - eboflip->roll= -ebo->roll; - eboflip->xwidth= ebo->xwidth; - eboflip->zwidth= ebo->zwidth; + eboflip->dist = ebo->dist; + eboflip->roll = -ebo->roll; + eboflip->xwidth = ebo->xwidth; + eboflip->zwidth = ebo->zwidth; } } } @@ -5784,14 +5784,14 @@ void transform_armature_mirror_update(Object *obedit) /**************************************** SUBDIVISION ALGOS ******************************************/ -EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *lastBone = NULL; if (scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float *previous = NULL, *current = NULL; EditBone *child = NULL; EditBone *parent = NULL; @@ -5799,7 +5799,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode float angleLimit = (float)cos(scene->toolsettings->skgen_angle_limit * M_PI / 180.0f); parent = ED_armature_edit_bone_add(arm, "Bone"); - parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + parent->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; copy_v3_v3(parent->head, head->p); root = parent; @@ -5809,8 +5809,8 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode previous = iter->p; for (IT_next(iter); - IT_stopped(iter) == 0; - previous = iter->p, IT_next(iter)) + IT_stopped(iter) == 0; + previous = iter->p, IT_next(iter)) { float vec1[3], vec2[3]; float len1, len2; @@ -5829,7 +5829,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode child = ED_armature_edit_bone_add(arm, "Bone"); copy_v3_v3(child->head, parent->tail); child->parent = parent; - child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + child->flag |= BONE_CONNECTED | BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; parent = child; /* new child is next parent */ } @@ -5840,7 +5840,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode * to let subsequent subdivision methods do their thing. * */ if (parent == root) { - if (parent==arm->act_edbone) arm->act_edbone= NULL; + if (parent == arm->act_edbone) arm->act_edbone = NULL; ED_armature_edit_bone_remove(arm, parent); parent = NULL; } @@ -5851,16 +5851,16 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode return lastBone; } -EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { EditBone *lastBone = NULL; if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION) { - float invmat[4][4]= MAT4_UNITY; - float tmat[3][3]= MAT3_UNITY; + float invmat[4][4] = MAT4_UNITY; + float tmat[3][3] = MAT3_UNITY; ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; - bArmature *arm= obedit->data; + BArcIterator *iter = (BArcIterator *)&arc_iter; + bArmature *arm = obedit->data; initArcIterator(iter, arc, head); @@ -5894,17 +5894,17 @@ float arcLengthRatio(ReebArc *arc) return embedLength / arcLength; } -EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { EditBone *lastBone = NULL; if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) && - arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio) + arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio) { - float invmat[4][4]= MAT4_UNITY; - float tmat[3][3]= MAT3_UNITY; + float invmat[4][4] = MAT4_UNITY; + float tmat[3][3] = MAT3_UNITY; ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; - bArmature *arm= obedit->data; + BArcIterator *iter = (BArcIterator *)&arc_iter; + bArmature *arm = obedit->data; initArcIterator(iter, arc, head); @@ -5918,7 +5918,7 @@ EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, Re void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context GHash *arcBoneMap = NULL; ReebArc *arc = NULL; ReebNode *node = NULL; @@ -5932,22 +5932,22 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) ED_armature_edit_free(obedit); } - dst = add_object(scene, OB_ARMATURE); - ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot - obedit= scene->basact->object; + dst = BKE_object_add(scene, OB_ARMATURE); + ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot + obedit = scene->basact->object; /* Copy orientation from source */ copy_v3_v3(dst->loc, src->obmat[3]); mat4_to_eul(dst->rot, src->obmat); mat4_to_size(dst->size, src->obmat); - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); ED_armature_to_edit(obedit); arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh"); - BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit); for (arc = rg->arcs.first; arc; arc = arc->next) { @@ -6008,9 +6008,9 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) } if (lastBone == NULL) { - EditBone *bone; + EditBone *bone; bone = ED_armature_edit_bone_add(obedit->data, "Bone"); - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; copy_v3_v3(bone->head, head->p); copy_v3_v3(bone->tail, tail->p); @@ -6029,7 +6029,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) int i; for (i = 0; i < node->degree; i++) { - arc = (ReebArc*)node->arcs[i]; + arc = (ReebArc *)node->arcs[i]; /* if arc is incoming into the node */ if ((arc->head == node && arc->flag == -1) || diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 5b56f5fe7fe..7f966dbc884 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -257,7 +257,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st return -1; } -EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion) +EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion) { EditBone *lastBone = NULL; EditBone *child = NULL; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index a97823ebcc8..566dbc901b8 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -70,15 +70,15 @@ /************ RIG RETARGET DATA STRUCTURES ***************/ typedef struct MemoNode { - float weight; - int next; + float weight; + int next; } MemoNode; typedef struct RetargetParam { - RigGraph *rigg; - RigArc *iarc; - RigNode *inode_start; - bContext *context; + RigGraph *rigg; + RigArc *iarc; + RigNode *inode_start; + bContext *context; } RetargetParam; typedef enum @@ -128,7 +128,7 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent) return count; } -static EditBone* nextEditBoneChild(ListBase *list, EditBone *parent, int n) +static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n) { EditBone *ebone; @@ -247,12 +247,12 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) static void RIG_freeRigArc(BArc *arc) { - BLI_freelistN(&((RigArc*)arc)->edges); + BLI_freelistN(&((RigArc *)arc)->edges); } void RIG_freeRigGraph(BGraph *rg) { - RigGraph *rigg = (RigGraph*)rg; + RigGraph *rigg = (RigGraph *)rg; BNode *node; BArc *arc; @@ -270,7 +270,7 @@ void RIG_freeRigGraph(BGraph *rg) BLI_freelistN(&rg->arcs); for (node = rg->nodes.first; node; node = node->next) { - BLI_freeNode(rg, (BNode*)node); + BLI_freeNode(rg, (BNode *)node); } BLI_freelistN(&rg->nodes); @@ -311,7 +311,7 @@ static RigGraph *newRigGraph(void) // } // else // { - totthread = BLI_system_thread_count(); + totthread = BLI_system_thread_count(); // } rg->worker = BLI_create_worker(exec_retargetArctoArc, totthread, 20); /* fix number of threads */ @@ -428,13 +428,13 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo { int i, j; - for (i = 0, j = 0; i < (MAXBONENAME-1) && j < (MAXBONENAME-1) && template_name[i] != '\0'; i++) { + for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) { if (template_name[i] == '&') { - if (template_name[i+1] == 'S' || template_name[i+1] == 's') { + if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') { j += sprintf(name + j, "%s", side_string); i++; } - else if (template_name[i+1] == 'N' || template_name[i+1] == 'n') { + else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') { j += sprintf(name + j, "%s", num_string); i++; } @@ -471,7 +471,7 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string); ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob); - ctrl->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone); ctrl->link = src_ctrl->link; @@ -514,7 +514,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * char name[MAXBONENAME]; renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string); edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob); - edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone); } @@ -526,7 +526,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string) { - GHash *ptr_hash; + GHash *ptr_hash; RigNode *node; RigArc *arc; RigControl *ctrl; @@ -691,7 +691,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) } /* if there's already a link - * overwrite only if new link is higher in the chain */ + * overwrite only if new link is higher in the chain */ if (ctrl->link && flag == ctrl->flag) { EditBone *bone = NULL; @@ -732,9 +732,9 @@ static void RIG_reconnectControlBones(RigGraph *rg) int found = 0; /* DO SOME MAGIC HERE */ - for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -744,7 +744,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) cti->get_constraint_targets(con, &targets); - for (target_index = 0, ct= targets.first; ct; target_index++, ct= ct->next) { + for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) { if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { /* SET bone link to bone corresponding to pchan */ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name); @@ -857,9 +857,9 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* check constraints first */ /* DO SOME MAGIC HERE */ - for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -867,7 +867,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { /* SET bone link to ctrl corresponding to pchan */ RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name); @@ -918,8 +918,8 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* look on deform bones first */ BLI_ghashIterator_init(&ghi, rg->bones_map); - for ( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { - EditBone *bone = (EditBone*)BLI_ghashIterator_getValue(&ghi); + for (; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { + EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi); /* don't link with parent */ if (bone->parent != ctrl->bone) { @@ -972,9 +972,9 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr joined_arc2->edges.first = joined_arc2->edges.last = NULL; - BLI_removeArc((BGraph*)rg, (BArc*)joined_arc2); + BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2); - BLI_removeNode((BGraph*)rg, (BNode*)node); + BLI_removeNode((BGraph *)rg, (BNode *)node); } static void RIG_removeNormalNodes(RigGraph *rg) @@ -1020,12 +1020,12 @@ static void RIG_removeUneededOffsets(RigGraph *rg) MEM_freeN(first_edge); } else if (arc->head->degree == 1) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001f); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f); if (new_node) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head); } else { RigEdge *next_edge = first_edge->next; @@ -1062,7 +1062,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } if (other_arc == NULL) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001); if (new_node) { /* remove null edge in other arcs too */ @@ -1070,13 +1070,13 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (other_arc != arc) { RigEdge *test_edge; if (other_arc->head == arc->head) { - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head); test_edge = other_arc->edges.first; BLI_remlink(&other_arc->edges, test_edge); MEM_freeN(test_edge); } else if (other_arc->tail == arc->head) { - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->tail); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail); test_edge = other_arc->edges.last; BLI_remlink(&other_arc->edges, test_edge); MEM_freeN(test_edge); @@ -1086,7 +1086,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head); } else { RigEdge *next_edge = first_edge->next; @@ -1125,14 +1125,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg) MEM_freeN(last_edge); } else if (arc->tail->degree == 1) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001f); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f); if (new_node) { RigEdge *previous_edge = last_edge->prev; BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->tail); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail); /* set previous angle to 0, since there's no following edges */ if (previous_edge) { @@ -1235,7 +1235,7 @@ static void RIG_findHead(RigGraph *rg) if (BLI_countlist(&rg->arcs) == 1) { RigArc *arc = rg->arcs.first; - rg->head = (RigNode*)arc->head; + rg->head = (RigNode *)arc->head; } else { RigArc *arc; @@ -1243,7 +1243,7 @@ static void RIG_findHead(RigGraph *rg) for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge = arc->edges.last; - if (edge->bone->flag & (BONE_TIPSEL|BONE_SELECTED)) { + if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) { rg->head = arc->tail; break; } @@ -1323,7 +1323,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc) { RigEdge *edge; - RIG_printNode((RigNode*)arc->head, "head"); + RIG_printNode((RigNode *)arc->head, "head"); for (edge = arc->edges.first; edge; edge = edge->next) { printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]); @@ -1336,7 +1336,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc) } printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); - RIG_printNode((RigNode*)arc->tail, "tail"); + RIG_printNode((RigNode *)arc->tail, "tail"); } void RIG_printGraph(RigGraph *rg) @@ -1380,27 +1380,27 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { + for (ebone = rg->editbones->first; ebone; ebone = ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0); } } - BLI_removeDoubleNodes((BGraph*)rg, 0.001); + BLI_removeDoubleNodes((BGraph *)rg, 0.001); RIG_removeNormalNodes(rg); RIG_removeUneededOffsets(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); RIG_findHead(rg); - BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - if (BLI_isGraphCyclic((BGraph*)rg)) { + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } @@ -1428,27 +1428,27 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { + for (ebone = rg->editbones->first; ebone; ebone = ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1); } } - BLI_removeDoubleNodes((BGraph*)rg, 0.001); + BLI_removeDoubleNodes((BGraph *)rg, 0.001); RIG_removeNormalNodes(rg); RIG_removeUneededOffsets(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); RIG_findHead(rg); - BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - if (BLI_isGraphCyclic((BGraph*)rg)) { + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } @@ -1459,7 +1459,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm #if 0 static EditBone *add_editbonetolist(char *name, ListBase *list) { - EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone"); + EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); unique_editbone_name(list, bone->name, NULL); @@ -1467,16 +1467,16 @@ static EditBone *add_editbonetolist(char *name, ListBase *list) BLI_addtail(list, bone); bone->flag |= BONE_TIPSEL; - bone->weight= 1.0F; - bone->dist= 0.25F; - bone->xwidth= 0.1; - bone->zwidth= 0.1; - bone->ease1= 1.0; - bone->ease2= 1.0; - bone->rad_head= 0.10; - bone->rad_tail= 0.05; - bone->segments= 1; - bone->layer= 1;//arm->layer; + bone->weight = 1.0F; + bone->dist = 0.25F; + bone->xwidth = 0.1; + bone->zwidth = 0.1; + bone->ease1 = 1.0; + bone->ease2 = 1.0; + bone->rad_head = 0.10; + bone->rad_tail = 0.05; + bone->segments = 1; + bone->layer = 1; //arm->layer; return bone; } @@ -1887,7 +1887,7 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, } } -static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight) +static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight) { MemoNode *node; int index = indexMemoNode(nb_positions, previous, current, joints_left); @@ -1910,8 +1910,8 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c MemoNode *min_node = NULL; float *vec0 = vec_cache[previous]; float *vec1 = vec_cache[current]; - float min_weight= 0.0f; - int min_next= 0; + float min_weight = 0.0f; + int min_next = 0; int next; for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) { @@ -1969,7 +1969,7 @@ static int testFlipArc(RigArc *iarc, RigNode *inode_start) static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; RigEdge *edge; EmbedBucket *bucket = NULL; ReebNode *node_start, *node_end; @@ -2019,7 +2019,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, #ifndef USE_THREADS MemoNode *result; #endif - float **positions_cache = MEM_callocN(sizeof(float*) * (nb_positions + 2), "positions cache"); + float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache"); int i; positions_cache[0] = node_start->p; @@ -2084,7 +2084,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; ReebArc *earc = iarc->link_mesh; ReebNode *node_start, *node_end; RigEdge *edge; @@ -2096,12 +2096,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri if (testFlipArc(iarc, inode_start)) { - node_start = (ReebNode*)earc->tail; - node_end = (ReebNode*)earc->head; + node_start = (ReebNode *)earc->tail; + node_end = (ReebNode *)earc->head; } else { - node_start = (ReebNode*)earc->head; - node_end = (ReebNode*)earc->tail; + node_start = (ReebNode *)earc->head; + node_end = (ReebNode *)earc->tail; } initArcIterator(iter, earc, node_start); @@ -2183,7 +2183,7 @@ static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode void *exec_retargetArctoArc(void *param) { - RetargetParam *p = (RetargetParam*)param; + RetargetParam *p = (RetargetParam *)param; RigGraph *rigg = p->rigg; RigArc *iarc = p->iarc; bContext *C = p->context; @@ -2224,8 +2224,8 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); int ishape, eshape; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; inode->link_mesh = enode; @@ -2234,7 +2234,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t enode = enode->link_down; reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */ - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; } } @@ -2243,7 +2243,7 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode) int i; for (i = 0; i < enode->degree; i++) { - ReebArc *earc = (ReebArc*)enode->arcs[i]; + ReebArc *earc = (ReebArc *)enode->arcs[i]; if (earc->flag == ARC_FREE) { earc->flag = ARC_TAKEN; @@ -2260,7 +2260,7 @@ static void markMultiResolutionArc(ReebArc *start_earc) { if (start_earc->link_up) { ReebArc *earc; - for (earc = start_earc->link_up ; earc; earc = earc->link_up) { + for (earc = start_earc->link_up; earc; earc = earc->link_up) { earc->flag = ARC_TAKEN; if (earc->tail->index != start_earc->tail->index) { @@ -2276,8 +2276,8 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); int ishape, eshape; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)start_node, (BArc*)next_iarc, 1) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; while (ishape != eshape && next_earc->link_up) { next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels @@ -2285,7 +2285,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc next_earc = next_earc->link_up; reebg = reebg->link_up; enode = next_earc->head; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; } next_earc->flag = ARC_USED; @@ -2307,15 +2307,15 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R enode = reebg->nodes.first; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)rigg->link_mesh, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; while (ishape != eshape && reebg->link_up) { reebg = reebg->link_up; enode = reebg->nodes.first; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; } inode->link_mesh = enode; @@ -2340,7 +2340,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // } for (i = 0; i < enode->degree; i++) { - next_earc = (ReebArc*)enode->arcs[i]; + next_earc = (ReebArc *)enode->arcs[i]; // if (next_earc->flag == ARC_FREE) // { @@ -2351,9 +2351,9 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // } if (next_earc->flag == ARC_FREE && - next_earc->symmetry_flag == symmetry_flag && - next_earc->symmetry_group == symmetry_group && - next_earc->symmetry_level == symmetry_level) + next_earc->symmetry_flag == symmetry_flag && + next_earc->symmetry_group == symmetry_group && + next_earc->symmetry_level == symmetry_level) { // printf("CORRESPONDING ARC FOUND\n"); // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); @@ -2394,7 +2394,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta /* Emergency matching */ for (i = 0; i < enode->degree; i++) { - next_earc = (ReebArc*)enode->arcs[i]; + next_earc = (ReebArc *)enode->arcs[i]; if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) { // printf("USING:\n"); @@ -2420,14 +2420,14 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig retargetArctoArc(C, rigg, start_arc, start_node); enode = BIF_otherNodeFromIndex(earc, enode); - inode = (RigNode*)BLI_otherNode((BArc*)start_arc, (BNode*)inode); + inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode); /* match with lowest node with correct shape */ matchMultiResolutionNode(rigg, inode, enode); } for (i = 0; i < inode->degree; i++) { - RigArc *next_iarc = (RigArc*)inode->arcs[i]; + RigArc *next_iarc = (RigArc *)inode->arcs[i]; /* no back tracking */ if (next_iarc != start_arc) { @@ -2448,7 +2448,7 @@ static void finishRetarget(RigGraph *rigg) static void adjustGraphs(bContext *C, RigGraph *rigg) { - bArmature *arm= rigg->ob->data; + bArmature *arm = rigg->ob->data; RigArc *arc; for (arc = rigg->arcs.first; arc; arc = arc->next) { @@ -2468,7 +2468,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg) static void retargetGraphs(bContext *C, RigGraph *rigg) { - bArmature *arm= rigg->ob->data; + bArmature *arm = rigg->ob->data; ReebGraph *reebg = rigg->link_mesh; RigNode *inode; @@ -2534,7 +2534,7 @@ int RIG_nbJoints(RigGraph *rg) static void BIF_freeRetarget(void) { if (GLOBAL_RIGG) { - RIG_freeRigGraph((BGraph*)GLOBAL_RIGG); + RIG_freeRigGraph((BGraph *)GLOBAL_RIGG); GLOBAL_RIGG = NULL; } } @@ -2544,7 +2544,7 @@ void BIF_retargetArmature(bContext *C) ReebGraph *reebg; double start_time, end_time; double gstart_time, gend_time; - double reeb_time, rig_time=0.0, retarget_time=0.0, total_time; + double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time; gstart_time = start_time = PIL_check_seconds_timer(); @@ -2555,11 +2555,11 @@ void BIF_retargetArmature(bContext *C) printf("Reeb Graph created\n"); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { Object *ob = base->object; - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { RigGraph *rigg; bArmature *arm; @@ -2658,9 +2658,9 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) /* free template if it comes from the edit armature */ if (free_template) { - RIG_freeRigGraph((BGraph*)template_rigg); + RIG_freeRigGraph((BGraph *)template_rigg); } - RIG_freeRigGraph((BGraph*)rigg); + RIG_freeRigGraph((BGraph *)rigg); ED_armature_validate_active(armedit); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 09b0226c58c..2201bcf7224 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -70,31 +70,31 @@ -typedef int (*GestureDetectFct)(bContext*, SK_Gesture*, SK_Sketch *); -typedef void (*GestureApplyFct)(bContext*, SK_Gesture*, SK_Sketch *); +typedef int (*GestureDetectFct)(bContext *, SK_Gesture *, SK_Sketch *); +typedef void (*GestureApplyFct)(bContext *, SK_Gesture *, SK_Sketch *); typedef struct SK_GestureAction { char name[64]; - GestureDetectFct detect; - GestureApplyFct apply; + GestureDetectFct detect; + GestureApplyFct apply; } SK_GestureAction; #if 0 /* UNUSED 2.5 */ static SK_Point boneSnap; #endif -static int LAST_SNAP_POINT_VALID = 0; -static float LAST_SNAP_POINT[3]; +static int LAST_SNAP_POINT_VALID = 0; +static float LAST_SNAP_POINT[3]; typedef struct SK_StrokeIterator { - HeadFct head; - TailFct tail; - PeekFct peek; - NextFct next; - NextNFct nextN; - PreviousFct previous; - StoppedFct stopped; + HeadFct head; + TailFct tail; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; float *p, *no; float size; @@ -127,30 +127,29 @@ void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); -SK_Sketch* contextSketch(const bContext *c, int create); -SK_Sketch* viewcontextSketch(ViewContext *vc, int create); +SK_Sketch *contextSketch(const bContext *c, int create); +SK_Sketch *viewcontextSketch(ViewContext *vc, int create); void sk_resetOverdraw(SK_Sketch *sketch); int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk); /******************** GESTURE ACTIONS ******************************/ -static SK_GestureAction GESTURE_ACTIONS[] = - { - {"Cut", sk_detectCutGesture, sk_applyCutGesture}, - {"Trim", sk_detectTrimGesture, sk_applyTrimGesture}, - {"Command", sk_detectCommandGesture, sk_applyCommandGesture}, - {"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture}, - {"Merge", sk_detectMergeGesture, sk_applyMergeGesture}, - {"Reverse", sk_detectReverseGesture, sk_applyReverseGesture}, - {"Convert", sk_detectConvertGesture, sk_applyConvertGesture}, - {"", NULL, NULL} - }; +static SK_GestureAction GESTURE_ACTIONS[] = { + {"Cut", sk_detectCutGesture, sk_applyCutGesture}, + {"Trim", sk_detectTrimGesture, sk_applyTrimGesture}, + {"Command", sk_detectCommandGesture, sk_applyCommandGesture}, + {"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture}, + {"Merge", sk_detectMergeGesture, sk_applyMergeGesture}, + {"Reverse", sk_detectReverseGesture, sk_applyReverseGesture}, + {"Convert", sk_detectConvertGesture, sk_applyConvertGesture}, + {"", NULL, NULL} +}; /******************** TEMPLATES UTILS *************************/ static char *TEMPLATES_MENU = NULL; -static int TEMPLATES_CURRENT = 0; +static int TEMPLATES_CURRENT = 0; static GHash *TEMPLATES_HASH = NULL; static RigGraph *TEMPLATE_RIGG = NULL; @@ -169,7 +168,7 @@ void BIF_makeListTemplates(const bContext *C) TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh"); TEMPLATES_CURRENT = 0; - for ( base = FIRSTBASE; base; base = base->next ) { + for (base = FIRSTBASE; base; base = base->next) { Object *ob = base->object; if (ob != obedit && ob->type == OB_ARMATURE) { @@ -205,7 +204,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C)) Object *ob = BLI_ghashIterator_getValue(&ghi); int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi)); - p += sprintf(p, "|%s%%x%i", ob->id.name+2, key); + p += sprintf(p, "|%s%%x%i", ob->id.name + 2, key); BLI_ghashIterator_step(&ghi); } @@ -237,7 +236,7 @@ int BIF_currentTemplate(const bContext *C) return TEMPLATES_CURRENT; } -static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob) +static RigGraph *sk_makeTemplateGraph(const bContext *C, Object *ob) { Object *obedit = CTX_data_edit_object(C); if (ob == obedit) { @@ -246,7 +245,7 @@ static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob) if (ob != NULL) { if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); TEMPLATE_RIGG = NULL; } @@ -275,7 +274,7 @@ int BIF_nbJointsTemplate(const bContext *C) } } -const char * BIF_nameBoneTemplate(const bContext *C) +const char *BIF_nameBoneTemplate(const bContext *C) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *stk = contextSketch(C, 1); @@ -308,7 +307,7 @@ void BIF_freeTemplates(bContext *UNUSED(C)) } if (TEMPLATE_RIGG != NULL) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); TEMPLATE_RIGG = NULL; } } @@ -323,7 +322,7 @@ void BIF_setTemplate(bContext *C, int index) ts->skgen_template = NULL; if (TEMPLATE_RIGG != NULL) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); } TEMPLATE_RIGG = NULL; } @@ -349,21 +348,21 @@ static void sk_autoname(bContext *C, ReebArc *arc) if (side[0] == '\0') { valid = 1; } - else if (strcmp(side, "R")==0 || strcmp(side, "L")==0) { + else if (strcmp(side, "R") == 0 || strcmp(side, "L") == 0) { valid = 1; caps = 1; } - else if (strcmp(side, "r")==0 || strcmp(side, "l")==0) { + else if (strcmp(side, "r") == 0 || strcmp(side, "l") == 0) { valid = 1; caps = 0; } if (valid) { if (arc->head->p[0] < 0) { - BLI_snprintf(side, 8, caps?"R":"r"); + BLI_snprintf(side, 8, caps ? "R" : "r"); } else { - BLI_snprintf(side, 8, caps?"L":"l"); + BLI_snprintf(side, 8, caps ? "L" : "l"); } } } @@ -433,7 +432,7 @@ static void sk_retargetStroke(bContext *C, SK_Stroke *stk) MEM_freeN(arc->head); MEM_freeN(arc->tail); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); } /**************************************************************/ @@ -473,7 +472,7 @@ static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float si angle = angle_normalized_v3v3(vec2, vec1); - glRotatef(angle * (float)(180.0/M_PI) + 180.0f, axis[0], axis[1], axis[2]); + glRotatef(angle * (float)(180.0 / M_PI) + 180.0f, axis[0], axis[1], axis[2]); gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8); } @@ -493,7 +492,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig angle = angle_normalized_v3v3(vec2, pt->no); - glRotatef(angle * (float)(180.0/M_PI), axis[0], axis[1], axis[2]); + glRotatef(angle * (float)(180.0 / M_PI), axis[0], axis[1], axis[2]); glColor3f(0, 1, 1); gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2); @@ -569,7 +568,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion) { - SK_Stroke *stk = ((SK_StrokeIterator*)iter)->stroke; + SK_Stroke *stk = ((SK_StrokeIterator *)iter)->stroke; float head[3], tail[3]; int bone_start = 0; int end = iter->length; @@ -622,7 +621,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) else { if (i - head_index > 1) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; initStrokeIterator(iter, stk, head_index, i); @@ -733,10 +732,10 @@ void sk_resetOverdraw(SK_Sketch *sketch) int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk) { - return sketch->over.target && - sketch->over.count >= SK_OVERDRAW_LIMIT && - (sketch->over.target == stk || stk == NULL) && - (sketch->over.start != -1 || sketch->over.end != -1); + return sketch->over.target && + sketch->over.count >= SK_OVERDRAW_LIMIT && + (sketch->over.target == stk || stk == NULL) && + (sketch->over.start != -1 || sketch->over.end != -1); } static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd) @@ -991,8 +990,8 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S BLI_freelistN(&sketch->depth_peels); sketch->depth_peels.first = sketch->depth_peels.last = NULL; - mvalf[0]= dd->mval[0]; - mvalf[1]= dd->mval[1]; + mvalf[0] = dd->mval[0]; + mvalf[1] = dd->mval[1]; peelObjectsContext(C, &sketch->depth_peels, mvalf, SNAP_ALL); if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) { @@ -1195,12 +1194,12 @@ static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_S /********************************************/ -static void* headPoint(void *arg); -static void* tailPoint(void *arg); -static void* nextPoint(void *arg); -static void* nextNPoint(void *arg, int n); -static void* peekPoint(void *arg, int n); -static void* previousPoint(void *arg); +static void *headPoint(void *arg); +static void *tailPoint(void *arg); +static void *nextPoint(void *arg); +static void *nextNPoint(void *arg, int n); +static void *peekPoint(void *arg, int n); +static void *previousPoint(void *arg); static int iteratorStopped(void *arg); static void initIteratorFct(SK_StrokeIterator *iter) @@ -1214,7 +1213,7 @@ static void initIteratorFct(SK_StrokeIterator *iter) iter->stopped = iteratorStopped; } -static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index) +static SK_Point *setIteratorValues(SK_StrokeIterator *iter, int index) { SK_Point *pt = NULL; @@ -1235,7 +1234,7 @@ static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index) void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; initIteratorFct(iter); iter->stroke = stk; @@ -1257,9 +1256,9 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) } -static void* headPoint(void *arg) +static void *headPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; result = &(iter->stroke->points[iter->start - iter->stride]); @@ -1270,9 +1269,9 @@ static void* headPoint(void *arg) return result; } -static void* tailPoint(void *arg) +static void *tailPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; result = &(iter->stroke->points[iter->end + iter->stride]); @@ -1283,9 +1282,9 @@ static void* tailPoint(void *arg) return result; } -static void* nextPoint(void *arg) +static void *nextPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; iter->index++; @@ -1296,9 +1295,9 @@ static void* nextPoint(void *arg) return result; } -static void* nextNPoint(void *arg, int n) +static void *nextNPoint(void *arg, int n) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; iter->index += n; @@ -1311,9 +1310,9 @@ static void* nextNPoint(void *arg, int n) return result; } -static void* peekPoint(void *arg, int n) +static void *peekPoint(void *arg, int n) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; int index = iter->index + n; @@ -1325,9 +1324,9 @@ static void* peekPoint(void *arg, int n) return result; } -static void* previousPoint(void *arg) +static void *previousPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; if (iter->index > 0) { @@ -1340,7 +1339,7 @@ static void* previousPoint(void *arg) static int iteratorStopped(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; if (iter->index >= iter->length) { return 1; @@ -1383,7 +1382,7 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) if (i - head_index > 1) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; initStrokeIterator(iter, stk, head_index, i); @@ -1410,12 +1409,12 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) } new_parent = bone; - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; /* move to end of chain */ while (bone->parent != NULL) { bone = bone->parent; - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } if (parent != NULL) { @@ -1594,7 +1593,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; float CORRELATION_THRESHOLD = 0.99f; float *vec; @@ -1706,7 +1705,7 @@ int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN SK_Intersection *isect, *self_isect; /* get the the last intersection of the first pair */ - for ( isect = gest->intersections.first; isect; isect = isect->next ) { + for (isect = gest->intersections.first; isect; isect = isect->next) { if (isect->stroke == isect->next->stroke) { isect = isect->next; break; @@ -1801,7 +1800,7 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1])); /* if gesture is a circle */ - if ( dist <= 20 ) { + if (dist <= 20) { SK_Intersection *isect; /* check if it circled around an exact point */ @@ -1971,14 +1970,14 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in view3d_set_viewcontext(C, &vc); - rect.xmin = mval[0]-5; - rect.xmax = mval[0]+5; - rect.ymin = mval[1]-5; - rect.ymax = mval[1]+5; + rect.xmin = mval[0] - 5; + rect.xmax = mval[0] + 5; + rect.ymin = mval[1] - 5; + rect.ymax = mval[1] + 5; hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); - if (hits>0) { + if (hits > 0) { int besthitresult = -1; if (hits == 1) { @@ -2027,7 +2026,7 @@ static void sk_queueRedrawSketch(SK_Sketch *sketch) static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, int with_names) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; SK_Stroke *stk; glClear(GL_DEPTH_BUFFER_BIT); @@ -2053,7 +2052,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, sk_adjustIndexes(sketch, &start, &end); } - sk_drawStroke(stk, -1, (stk->selected==1?selected_rgb:unselected_rgb), start, end); + sk_drawStroke(stk, -1, (stk->selected == 1 ? selected_rgb : unselected_rgb), start, end); if (stk->selected == 1) { sk_drawStrokeSubdivision(ts, stk); @@ -2204,11 +2203,11 @@ static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra static int ValidSketchViewContext(ViewContext *vc) { Object *obedit = vc->obedit; - Scene *scene= vc->scene; + Scene *scene = vc->scene; if (obedit && - obedit->type == OB_ARMATURE && - scene->toolsettings->bone_sketching & BONE_SKETCHING) + obedit->type == OB_ARMATURE && + scene->toolsettings->bone_sketching & BONE_SKETCHING) { return 1; } @@ -2247,7 +2246,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev sk_deleteSelectedStrokes(sketch); // allqueue(REDRAWVIEW3D, 0); } - WM_event_add_notifier(C, NC_SCREEN|ND_SKETCH|NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_SKETCH | NA_REMOVED, NULL); return OPERATOR_FINISHED; } @@ -2303,7 +2302,7 @@ void BIF_selectAllSketch(bContext *C, int mode) } #endif -SK_Sketch* contextSketch(const bContext *C, int create) +SK_Sketch *contextSketch(const bContext *C, int create) { Object *obedit = CTX_data_edit_object(C); SK_Sketch *sketch = NULL; @@ -2320,7 +2319,7 @@ SK_Sketch* contextSketch(const bContext *C, int create) return sketch; } -SK_Sketch* viewcontextSketch(ViewContext *vc, int create) +SK_Sketch *viewcontextSketch(ViewContext *vc, int create) { Object *obedit = vc->obedit; SK_Sketch *sketch = NULL; @@ -2442,51 +2441,51 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short int retval = OPERATOR_RUNNING_MODAL; switch (event->type) { - case LEFTCTRLKEY: - case RIGHTCTRLKEY: - snap = event->ctrl; - RNA_boolean_set(op->ptr, "snap", snap); - break; - case MOUSEMOVE: - case INBETWEEN_MOUSEMOVE: - dd->mval[0] = event->mval[0]; - dd->mval[1] = event->mval[1]; - sk_draw_stroke(C, sketch, stk, dd, snap); - ED_area_tag_redraw(CTX_wm_area(C)); - break; - case ESCKEY: - op->type->cancel(C, op); - ED_area_tag_redraw(CTX_wm_area(C)); - retval = OPERATOR_CANCELLED; - break; - case LEFTMOUSE: - if (event->val == KM_RELEASE) { - if (gesture == 0) { - sk_endContinuousStroke(stk); - sk_filterLastContinuousStroke(stk); - sk_updateNextPoint(sketch, stk); - ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); - retval = OPERATOR_FINISHED; - } - else { - sk_endContinuousStroke(stk); - sk_filterLastContinuousStroke(stk); - - if (stk->nb_points > 1) { - /* apply gesture here */ - sk_applyGesture(C, sketch); + case LEFTCTRLKEY: + case RIGHTCTRLKEY: + snap = event->ctrl; + RNA_boolean_set(op->ptr, "snap", snap); + break; + case MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: + dd->mval[0] = event->mval[0]; + dd->mval[1] = event->mval[1]; + sk_draw_stroke(C, sketch, stk, dd, snap); + ED_area_tag_redraw(CTX_wm_area(C)); + break; + case ESCKEY: + op->type->cancel(C, op); + ED_area_tag_redraw(CTX_wm_area(C)); + retval = OPERATOR_CANCELLED; + break; + case LEFTMOUSE: + if (event->val == KM_RELEASE) { + if (gesture == 0) { + sk_endContinuousStroke(stk); + sk_filterLastContinuousStroke(stk); + sk_updateNextPoint(sketch, stk); + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(op->customdata); + retval = OPERATOR_FINISHED; } + else { + sk_endContinuousStroke(stk); + sk_filterLastContinuousStroke(stk); - sk_freeStroke(stk); - sketch->gesture = NULL; + if (stk->nb_points > 1) { + /* apply gesture here */ + sk_applyGesture(C, sketch); + } - ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); - retval = OPERATOR_FINISHED; + sk_freeStroke(stk); + sketch->gesture = NULL; + + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(op->customdata); + retval = OPERATOR_FINISHED; + } } - } - break; + break; } return retval; @@ -2517,7 +2516,7 @@ static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event) ED_area_tag_redraw(CTX_wm_area(C)); } - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } /* ============================================== Poll Functions ============================================= */ @@ -2528,8 +2527,8 @@ int ED_operator_sketch_mode_active_stroke(bContext *C) SK_Sketch *sketch = contextSketch(C, 0); if (ts->bone_sketching & BONE_SKETCHING && - sketch != NULL && - sketch->active_stroke != NULL) + sketch != NULL && + sketch->active_stroke != NULL) { return 1; } @@ -2544,9 +2543,9 @@ static int ED_operator_sketch_mode_gesture(bContext *C) SK_Sketch *sketch = contextSketch(C, 0); if (ts->bone_sketching & BONE_SKETCHING && - (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 && - sketch != NULL && - sketch->active_stroke == NULL) + (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 && + sketch != NULL && + sketch->active_stroke == NULL) { return 1; } @@ -2561,9 +2560,9 @@ int ED_operator_sketch_full_mode(bContext *C) ToolSettings *ts = CTX_data_tool_settings(C); if (obedit && - obedit->type == OB_ARMATURE && - ts->bone_sketching & BONE_SKETCHING && - (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0) + obedit->type == OB_ARMATURE && + ts->bone_sketching & BONE_SKETCHING && + (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0) { return 1; } @@ -2578,8 +2577,8 @@ int ED_operator_sketch_mode(const bContext *C) ToolSettings *ts = CTX_data_tool_settings(C); if (obedit && - obedit->type == OB_ARMATURE && - ts->bone_sketching & BONE_SKETCHING) + obedit->type == OB_ARMATURE && + ts->bone_sketching & BONE_SKETCHING) { return 1; } @@ -2595,6 +2594,7 @@ void SKETCH_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "SKETCH_OT_delete"; + ot->description = "Delete a sketch stroke"; /* api callbacks */ ot->invoke = sketch_delete; @@ -2610,6 +2610,7 @@ void SKETCH_OT_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select"; ot->idname = "SKETCH_OT_select"; + ot->description = "Select a sketch stroke"; /* api callbacks */ ot->invoke = sketch_select; @@ -2625,6 +2626,7 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Cancel Stroke"; ot->idname = "SKETCH_OT_cancel_stroke"; + ot->description = "Cancel the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_cancel; @@ -2640,6 +2642,7 @@ void SKETCH_OT_convert(wmOperatorType *ot) /* identifiers */ ot->name = "Convert"; ot->idname = "SKETCH_OT_convert"; + ot->description = "Convert the selected sketch strokes to bone chains"; /* api callbacks */ ot->invoke = sketch_convert; @@ -2655,6 +2658,7 @@ void SKETCH_OT_finish_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "End Stroke"; ot->idname = "SKETCH_OT_finish_stroke"; + ot->description = "End and keep the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_finish; @@ -2670,6 +2674,7 @@ void SKETCH_OT_draw_preview(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Preview"; ot->idname = "SKETCH_OT_draw_preview"; + ot->description = "Draw preview of current sketch stroke (internal use)"; /* api callbacks */ ot->invoke = sketch_draw_preview; @@ -2687,6 +2692,7 @@ void SKETCH_OT_draw_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Stroke"; ot->idname = "SKETCH_OT_draw_stroke"; + ot->description = "Start to draw a sketch stroke"; /* api callbacks */ ot->invoke = sketch_draw_stroke; @@ -2706,6 +2712,7 @@ void SKETCH_OT_gesture(wmOperatorType *ot) /* identifiers */ ot->name = "Gesture"; ot->idname = "SKETCH_OT_gesture"; + ot->description = "Start to draw a gesture stroke"; /* api callbacks */ ot->invoke = sketch_draw_gesture; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 3828c025bcd..ccba3599318 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -80,40 +80,40 @@ static void error(const char *str) { printf("error: %s\n", str); } /************************** Laplacian System *****************************/ struct LaplacianSystem { - NLContext context; /* opennl context */ + NLContext context; /* opennl context */ int totvert, totface; - float **verts; /* vertex coordinates */ - float *varea; /* vertex weights for laplacian computation */ - char *vpinned; /* vertex pinning */ - int (*faces)[3]; /* face vertex indices */ - float (*fweights)[3]; /* cotangent weights per face */ + float **verts; /* vertex coordinates */ + float *varea; /* vertex weights for laplacian computation */ + char *vpinned; /* vertex pinning */ + int (*faces)[3]; /* face vertex indices */ + float (*fweights)[3]; /* cotangent weights per face */ - int areaweights; /* use area in cotangent weights? */ - int storeweights; /* store cotangent weights in fweights */ - int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */ + int areaweights; /* use area in cotangent weights? */ + int storeweights; /* store cotangent weights in fweights */ + int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */ - EdgeHash *edgehash; /* edge hash for construction */ + EdgeHash *edgehash; /* edge hash for construction */ struct HeatWeighting { MFace *mface; int totvert; int totface; - float (*verts)[3]; /* vertex coordinates */ - float (*vnors)[3]; /* vertex normals */ + float (*verts)[3]; /* vertex coordinates */ + float (*vnors)[3]; /* vertex normals */ - float (*root)[3]; /* bone root */ - float (*tip)[3]; /* bone tip */ + float (*root)[3]; /* bone root */ + float (*tip)[3]; /* bone tip */ float (*source)[3]; /* vertex source */ int numsource; - float *H; /* diagonal H matrix */ - float *p; /* values from all p vectors */ - float *mindist; /* minimum distance to a bone for all vertices */ + float *H; /* diagonal H matrix */ + float *p; /* values from all p vectors */ + float *mindist; /* minimum distance to a bone for all vertices */ - BVHTree *bvhtree; /* ray tracing acceleration structure */ - MFace **vface; /* a face that the vertex belongs to */ + BVHTree *bvhtree; /* ray tracing acceleration structure */ + MFace **vface; /* a face that the vertex belongs to */ } heat; #ifdef RIGID_DEFORM @@ -143,9 +143,9 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2) void **p = BLI_edgehash_lookup_p(edgehash, v1, v2); if (p) - *p = (void*)((intptr_t)*p + (intptr_t)1); + *p = (void *)((intptr_t)*p + (intptr_t)1); else - BLI_edgehash_insert(edgehash, v1, v2, (void*)(intptr_t)1); + BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1); } static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2) @@ -166,81 +166,81 @@ static float cotan_weight(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - return dot_v3v3(a, b)/clen; + return dot_v3v3(a, b) / clen; } static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3) { float t1, t2, t3, len1, len2, len3, area; - float *varea= sys->varea, *v1, *v2, *v3; + float *varea = sys->varea, *v1, *v2, *v3; int obtuse = 0; - v1= sys->verts[i1]; - v2= sys->verts[i2]; - v3= sys->verts[i3]; + v1 = sys->verts[i1]; + v2 = sys->verts[i2]; + v3 = sys->verts[i3]; - t1= cotan_weight(v1, v2, v3); - t2= cotan_weight(v2, v3, v1); - t3= cotan_weight(v3, v1, v2); + t1 = cotan_weight(v1, v2, v3); + t2 = cotan_weight(v2, v3, v1); + t3 = cotan_weight(v3, v1, v2); - if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse= 1; - else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; - else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; + if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse = 1; + else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse = 2; + else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse = 3; if (obtuse > 0) { - area= area_tri_v3(v1, v2, v3); + area = area_tri_v3(v1, v2, v3); - varea[i1] += (obtuse == 1)? area: area*0.5f; - varea[i2] += (obtuse == 2)? area: area*0.5f; - varea[i3] += (obtuse == 3)? area: area*0.5f; + varea[i1] += (obtuse == 1) ? area : area * 0.5f; + varea[i2] += (obtuse == 2) ? area : area * 0.5f; + varea[i3] += (obtuse == 3) ? area : area * 0.5f; } else { - len1= len_v3v3(v2, v3); - len2= len_v3v3(v1, v3); - len3= len_v3v3(v1, v2); + len1 = len_v3v3(v2, v3); + len2 = len_v3v3(v1, v3); + len3 = len_v3v3(v1, v2); - t1 *= len1*len1; - t2 *= len2*len2; - t3 *= len3*len3; + t1 *= len1 * len1; + t2 *= len2 * len2; + t3 *= len3 * len3; - varea[i1] += (t2 + t3)*0.25f; - varea[i2] += (t1 + t3)*0.25f; - varea[i3] += (t1 + t2)*0.25f; + varea[i1] += (t2 + t3) * 0.25f; + varea[i2] += (t1 + t3) * 0.25f; + varea[i3] += (t1 + t2) * 0.25f; } } static void laplacian_triangle_weights(LaplacianSystem *sys, int f, int i1, int i2, int i3) { float t1, t2, t3; - float *varea= sys->varea, *v1, *v2, *v3; + float *varea = sys->varea, *v1, *v2, *v3; - v1= sys->verts[i1]; - v2= sys->verts[i2]; - v3= sys->verts[i3]; + v1 = sys->verts[i1]; + v2 = sys->verts[i2]; + v3 = sys->verts[i3]; /* instead of *0.5 we divided by the number of faces of the edge, it still * needs to be verified that this is indeed the correct thing to do! */ - t1= cotan_weight(v1, v2, v3)/laplacian_edge_count(sys->edgehash, i2, i3); - t2= cotan_weight(v2, v3, v1)/laplacian_edge_count(sys->edgehash, i3, i1); - t3= cotan_weight(v3, v1, v2)/laplacian_edge_count(sys->edgehash, i1, i2); + t1 = cotan_weight(v1, v2, v3) / laplacian_edge_count(sys->edgehash, i2, i3); + t2 = cotan_weight(v2, v3, v1) / laplacian_edge_count(sys->edgehash, i3, i1); + t3 = cotan_weight(v3, v1, v2) / laplacian_edge_count(sys->edgehash, i1, i2); - nlMatrixAdd(i1, i1, (t2+t3)*varea[i1]); - nlMatrixAdd(i2, i2, (t1+t3)*varea[i2]); - nlMatrixAdd(i3, i3, (t1+t2)*varea[i3]); + nlMatrixAdd(i1, i1, (t2 + t3) * varea[i1]); + nlMatrixAdd(i2, i2, (t1 + t3) * varea[i2]); + nlMatrixAdd(i3, i3, (t1 + t2) * varea[i3]); - nlMatrixAdd(i1, i2, -t3*varea[i1]); - nlMatrixAdd(i2, i1, -t3*varea[i2]); + nlMatrixAdd(i1, i2, -t3 * varea[i1]); + nlMatrixAdd(i2, i1, -t3 * varea[i2]); - nlMatrixAdd(i2, i3, -t1*varea[i2]); - nlMatrixAdd(i3, i2, -t1*varea[i3]); + nlMatrixAdd(i2, i3, -t1 * varea[i2]); + nlMatrixAdd(i3, i2, -t1 * varea[i3]); - nlMatrixAdd(i3, i1, -t2*varea[i3]); - nlMatrixAdd(i1, i3, -t2*varea[i1]); + nlMatrixAdd(i3, i1, -t2 * varea[i3]); + nlMatrixAdd(i1, i3, -t2 * varea[i1]); if (sys->storeweights) { - sys->fweights[f][0]= t1*varea[i1]; - sys->fweights[f][1]= t2*varea[i2]; - sys->fweights[f][2]= t3*varea[i3]; + sys->fweights[f][0] = t1 * varea[i1]; + sys->fweights[f][1] = t2 * varea[i2]; + sys->fweights[f][2] = t3 * varea[i3]; } } @@ -248,17 +248,17 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac { LaplacianSystem *sys; - sys= MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem"); + sys = MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem"); - sys->verts= MEM_callocN(sizeof(float*)*totvert, "LaplacianSystemVerts"); - sys->vpinned= MEM_callocN(sizeof(char)*totvert, "LaplacianSystemVpinned"); - sys->faces= MEM_callocN(sizeof(int)*3*totface, "LaplacianSystemFaces"); + sys->verts = MEM_callocN(sizeof(float *) * totvert, "LaplacianSystemVerts"); + sys->vpinned = MEM_callocN(sizeof(char) * totvert, "LaplacianSystemVpinned"); + sys->faces = MEM_callocN(sizeof(int) * 3 * totface, "LaplacianSystemFaces"); - sys->totvert= 0; - sys->totface= 0; + sys->totvert = 0; + sys->totface = 0; - sys->areaweights= 1; - sys->storeweights= 0; + sys->areaweights = 1; + sys->storeweights = 0; /* create opennl context */ nlNewContext(); @@ -266,53 +266,53 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac if (lsq) nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); - sys->context= nlGetCurrent(); + sys->context = nlGetCurrent(); return sys; } void laplacian_add_vertex(LaplacianSystem *sys, float *co, int pinned) { - sys->verts[sys->totvert]= co; - sys->vpinned[sys->totvert]= pinned; + sys->verts[sys->totvert] = co; + sys->vpinned[sys->totvert] = pinned; sys->totvert++; } void laplacian_add_triangle(LaplacianSystem *sys, int v1, int v2, int v3) { - sys->faces[sys->totface][0]= v1; - sys->faces[sys->totface][1]= v2; - sys->faces[sys->totface][2]= v3; + sys->faces[sys->totface][0] = v1; + sys->faces[sys->totface][1] = v2; + sys->faces[sys->totface][2] = v3; sys->totface++; } static void laplacian_system_construct_end(LaplacianSystem *sys) { int (*face)[3]; - int a, totvert=sys->totvert, totface=sys->totface; + int a, totvert = sys->totvert, totface = sys->totface; laplacian_begin_solve(sys, 0); - sys->varea= MEM_callocN(sizeof(float)*totvert, "LaplacianSystemVarea"); + sys->varea = MEM_callocN(sizeof(float) * totvert, "LaplacianSystemVarea"); - sys->edgehash= BLI_edgehash_new(); - for (a=0, face=sys->faces; a<sys->totface; a++, face++) { + sys->edgehash = BLI_edgehash_new(); + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) { laplacian_increase_edge_count(sys->edgehash, (*face)[0], (*face)[1]); laplacian_increase_edge_count(sys->edgehash, (*face)[1], (*face)[2]); laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]); } if (sys->areaweights) - for (a=0, face=sys->faces; a<sys->totface; a++, face++) + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - for (a=0; a<totvert; a++) { + for (a = 0; a < totvert; a++) { if (sys->areaweights) { if (sys->varea[a] != 0.0f) - sys->varea[a]= 0.5f/sys->varea[a]; + sys->varea[a] = 0.5f / sys->varea[a]; } else - sys->varea[a]= 1.0f; + sys->varea[a] = 1.0f; /* for heat weighting */ if (sys->heat.H) @@ -320,21 +320,21 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) } if (sys->storeweights) - sys->fweights= MEM_callocN(sizeof(float)*3*totface, "LaplacianFWeight"); + sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight"); - for (a=0, face=sys->faces; a<totface; a++, face++) + for (a = 0, face = sys->faces; a < totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); MEM_freeN(sys->faces); - sys->faces= NULL; + sys->faces = NULL; if (sys->varea) { MEM_freeN(sys->varea); - sys->varea= NULL; + sys->varea = NULL; } BLI_edgehash_free(sys->edgehash, NULL); - sys->edgehash= NULL; + sys->edgehash = NULL; } static void laplacian_system_delete(LaplacianSystem *sys) @@ -357,7 +357,7 @@ void laplacian_begin_solve(LaplacianSystem *sys, int index) nlBegin(NL_SYSTEM); if (index >= 0) { - for (a=0; a<sys->totvert; a++) { + for (a = 0; a < sys->totvert; a++) { if (sys->vpinned[a]) { nlSetVariable(0, a, sys->verts[a][index]); nlLockVariable(a); @@ -395,10 +395,10 @@ float laplacian_system_get_solution(int v) /* From "Automatic Rigging and Animation of 3D Characters" * Ilya Baran and Jovan Popovic, SIGGRAPH 2007 */ -#define C_WEIGHT 1.0f -#define WEIGHT_LIMIT_START 0.05f -#define WEIGHT_LIMIT_END 0.025f -#define DISTANCE_EPSILON 1e-4f +#define C_WEIGHT 1.0f +#define WEIGHT_LIMIT_START 0.05f +#define WEIGHT_LIMIT_END 0.025f +#define DISTANCE_EPSILON 1e-4f typedef struct BVHCallbackUserData { float start[3]; @@ -408,7 +408,7 @@ typedef struct BVHCallbackUserData { static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { - BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata; + BVHCallbackUserData *data = (struct BVHCallbackUserData *)userdata; MFace *mf = data->sys->heat.mface + index; float (*verts)[3] = data->sys->heat.verts; float lambda, uv[2], n[3], dir[3]; @@ -444,27 +444,27 @@ static void heat_ray_tree_create(LaplacianSystem *sys) int a; sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6); - sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces"); + sys->heat.vface = MEM_callocN(sizeof(MFace *) * totvert, "HeatVFaces"); - for (a=0; a<totface; a++) { - MFace *mf = mface+a; + for (a = 0; a < totface; a++) { + MFace *mf = mface + a; float bb[6]; - INIT_MINMAX(bb, bb+3); - DO_MINMAX(verts[mf->v1], bb, bb+3); - DO_MINMAX(verts[mf->v2], bb, bb+3); - DO_MINMAX(verts[mf->v3], bb, bb+3); + INIT_MINMAX(bb, bb + 3); + DO_MINMAX(verts[mf->v1], bb, bb + 3); + DO_MINMAX(verts[mf->v2], bb, bb + 3); + DO_MINMAX(verts[mf->v3], bb, bb + 3); if (mf->v4) { - DO_MINMAX(verts[mf->v4], bb, bb+3); + DO_MINMAX(verts[mf->v4], bb, bb + 3); } BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); //Setup inverse pointers to use on isect.orig - sys->heat.vface[mf->v1]= mf; - sys->heat.vface[mf->v2]= mf; - sys->heat.vface[mf->v3]= mf; - if (mf->v4) sys->heat.vface[mf->v4]= mf; + sys->heat.vface[mf->v1] = mf; + sys->heat.vface[mf->v2] = mf; + sys->heat.vface[mf->v3] = mf; + if (mf->v4) sys->heat.vface[mf->v4] = mf; } BLI_bvhtree_balance(sys->heat.bvhtree); @@ -478,16 +478,16 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) float end[3]; int visible; - mface= sys->heat.vface[vertex]; + mface = sys->heat.vface[vertex]; if (!mface) return 1; - data.sys= sys; + data.sys = sys; copy_v3_v3(data.start, sys->heat.verts[vertex]); if (sys->heat.root) /* bone */ closest_to_line_segment_v3(end, data.start, - sys->heat.root[source], sys->heat.tip[source]); + sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ copy_v3_v3(end, sys->heat.source[source]); @@ -499,7 +499,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) hit.index = -1; hit.dist = normalize_v3(data.vec); - visible= BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void*)&data) == -1; + visible = BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void *)&data) == -1; return visible; } @@ -511,26 +511,26 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) /* compute euclidian distance */ if (sys->heat.root) /* bone */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], - sys->heat.root[source], sys->heat.tip[source]); + sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ copy_v3_v3(closest, sys->heat.source[source]); sub_v3_v3v3(d, sys->heat.verts[vertex], closest); - dist= normalize_v3(d); + dist = normalize_v3(d); /* if the vertex normal does not point along the bone, increase distance */ - cosine= dot_v3v3(d, sys->heat.vnors[vertex]); + cosine = dot_v3v3(d, sys->heat.vnors[vertex]); - return dist/(0.5f*(cosine + 1.001f)); + return dist / (0.5f * (cosine + 1.001f)); } static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) { float dist; - dist= heat_source_distance(sys, vertex, source); + dist = heat_source_distance(sys, vertex, source); - if (dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) + if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) if (heat_ray_source_visible(sys, vertex, source)) return 1; @@ -542,34 +542,34 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) float dist, mindist, h; int j, numclosest = 0; - mindist= 1e10; + mindist = 1e10; /* compute minimum distance */ - for (j=0; j<sys->heat.numsource; j++) { - dist= heat_source_distance(sys, vertex, j); + for (j = 0; j < sys->heat.numsource; j++) { + dist = heat_source_distance(sys, vertex, j); if (dist < mindist) - mindist= dist; + mindist = dist; } - sys->heat.mindist[vertex]= mindist; + sys->heat.mindist[vertex] = mindist; /* count number of sources with approximately this minimum distance */ - for (j=0; j<sys->heat.numsource; j++) + for (j = 0; j < sys->heat.numsource; j++) if (heat_source_closest(sys, vertex, j)) numclosest++; - sys->heat.p[vertex]= (numclosest > 0)? 1.0f/numclosest: 0.0f; + sys->heat.p[vertex] = (numclosest > 0) ? 1.0f / numclosest : 0.0f; /* compute H entry */ if (numclosest > 0) { - mindist= maxf(mindist, 1e-4f); - h= numclosest*C_WEIGHT/(mindist*mindist); + mindist = maxf(mindist, 1e-4f); + h = numclosest * C_WEIGHT / (mindist * mindist); } else - h= 0.0f; + h = 0.0f; - sys->heat.H[vertex]= h; + sys->heat.H[vertex] = h; } static void heat_calc_vnormals(LaplacianSystem *sys) @@ -577,12 +577,12 @@ static void heat_calc_vnormals(LaplacianSystem *sys) float fnor[3]; int a, v1, v2, v3, (*face)[3]; - sys->heat.vnors= MEM_callocN(sizeof(float)*3*sys->totvert, "HeatVNors"); + sys->heat.vnors = MEM_callocN(sizeof(float) * 3 * sys->totvert, "HeatVNors"); - for (a=0, face=sys->faces; a<sys->totface; a++, face++) { - v1= (*face)[0]; - v2= (*face)[1]; - v3= (*face)[2]; + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) { + v1 = (*face)[0]; + v2 = (*face)[1]; + v3 = (*face)[2]; normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]); @@ -591,27 +591,27 @@ static void heat_calc_vnormals(LaplacianSystem *sys) add_v3_v3(sys->heat.vnors[v3], fnor); } - for (a=0; a<sys->totvert; a++) + for (a = 0; a < sys->totvert; a++) normalize_v3(sys->heat.vnors[a]); } static void heat_laplacian_create(LaplacianSystem *sys) { MFace *mface = sys->heat.mface, *mf; - int totface= sys->heat.totface; - int totvert= sys->heat.totvert; + int totface = sys->heat.totface; + int totvert = sys->heat.totvert; int a; /* heat specific definitions */ - sys->heat.mindist= MEM_callocN(sizeof(float)*totvert, "HeatMinDist"); - sys->heat.H= MEM_callocN(sizeof(float)*totvert, "HeatH"); - sys->heat.p= MEM_callocN(sizeof(float)*totvert, "HeatP"); + sys->heat.mindist = MEM_callocN(sizeof(float) * totvert, "HeatMinDist"); + sys->heat.H = MEM_callocN(sizeof(float) * totvert, "HeatH"); + sys->heat.p = MEM_callocN(sizeof(float) * totvert, "HeatP"); /* add verts and faces to laplacian */ - for (a=0; a<totvert; a++) + for (a = 0; a < totvert; a++) laplacian_add_vertex(sys, sys->heat.verts[a], 0); - for (a=0, mf=mface; a<totface; a++, mf++) { + for (a = 0, mf = mface; a < totface; a++, mf++) { laplacian_add_triangle(sys, mf->v1, mf->v2, mf->v3); if (mf->v4) laplacian_add_triangle(sys, mf->v1, mf->v3, mf->v4); @@ -620,7 +620,7 @@ static void heat_laplacian_create(LaplacianSystem *sys) /* for distance computation in set_H */ heat_calc_vnormals(sys); - for (a=0; a<totvert; a++) + for (a = 0; a < totvert; a++) heat_set_H(sys, a); } @@ -643,8 +643,8 @@ static float heat_limit_weight(float weight) return 0.0f; } else if (weight < WEIGHT_LIMIT_START) { - t= (weight - WEIGHT_LIMIT_END)/(WEIGHT_LIMIT_START - WEIGHT_LIMIT_END); - return t*WEIGHT_LIMIT_START; + t = (weight - WEIGHT_LIMIT_END) / (WEIGHT_LIMIT_START - WEIGHT_LIMIT_END); + return t * WEIGHT_LIMIT_START; } else return weight; @@ -657,23 +657,23 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, MLoop *ml; MFace *mf; float solution, weight; - int *vertsflipped = NULL, *mask= NULL; + int *vertsflipped = NULL, *mask = NULL; int a, tottri, j, bbone, firstsegment, lastsegment; MVert *mvert = me->mvert; - int use_vert_sel= FALSE; - int use_face_sel= FALSE; + int use_vert_sel = FALSE; + int use_face_sel = FALSE; - *err_str= NULL; + *err_str = NULL; /* count triangles and create mask */ - if ( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) || - (use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0))) + if ( (use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { - mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask"); + mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); } - for (a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ if (use_vert_sel) { for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { @@ -702,13 +702,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* create laplacian */ sys = laplacian_system_construct_begin(me->totvert, tottri, 1); - sys->heat.mface= me->mface; - sys->heat.totface= me->totface; - sys->heat.totvert= me->totvert; - sys->heat.verts= verts; - sys->heat.root= root; - sys->heat.tip= tip; - sys->heat.numsource= numsource; + sys->heat.mface = me->mface; + sys->heat.totface = me->totface; + sys->heat.totvert = me->totvert; + sys->heat.verts = verts; + sys->heat.root = root; + sys->heat.tip = tip; + sys->heat.numsource = numsource; heat_ray_tree_create(sys); heat_laplacian_create(sys); @@ -716,23 +716,23 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, laplacian_system_construct_end(sys); if (dgroupflip) { - vertsflipped = MEM_callocN(sizeof(int)*me->totvert, "vertsflipped"); - for (a=0; a<me->totvert; a++) + vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped"); + for (a = 0; a < me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, a); } /* compute weights per bone */ - for (j=0; j<numsource; j++) { + for (j = 0; j < numsource; j++) { if (!selected[j]) continue; - firstsegment= (j == 0 || dgrouplist[j-1] != dgrouplist[j]); - lastsegment= (j == numsource-1 || dgrouplist[j] != dgrouplist[j+1]); - bbone= !(firstsegment && lastsegment); + firstsegment = (j == 0 || dgrouplist[j - 1] != dgrouplist[j]); + lastsegment = (j == numsource - 1 || dgrouplist[j] != dgrouplist[j + 1]); + bbone = !(firstsegment && lastsegment); /* clear weights */ if (bbone && firstsegment) { - for (a=0; a<me->totvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; @@ -745,30 +745,30 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* fill right hand side */ laplacian_begin_solve(sys, -1); - for (a=0; a<me->totvert; a++) + for (a = 0; a < me->totvert; a++) if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, - sys->heat.H[a]*sys->heat.p[a]); + sys->heat.H[a] * sys->heat.p[a]); /* solve */ if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for (a=0; a<me->totvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; - solution= laplacian_system_get_solution(a); + solution = laplacian_system_get_solution(a); if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, - WEIGHT_ADD); + WEIGHT_ADD); } else { - weight= heat_limit_weight(solution); + weight = heat_limit_weight(solution); if (weight > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, - WEIGHT_REPLACE); + WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgrouplist[j], a); } @@ -778,13 +778,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], - solution, WEIGHT_ADD); + solution, WEIGHT_ADD); } else { - weight= heat_limit_weight(solution); + weight = heat_limit_weight(solution); if (weight > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], - weight, WEIGHT_REPLACE); + weight, WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } @@ -792,24 +792,24 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } else if (*err_str == NULL) { - *err_str= "Bone Heat Weighting: failed to find solution for one or more bones"; + *err_str = "Bone Heat Weighting: failed to find solution for one or more bones"; break; } /* remove too small vertex weights */ if (bbone && lastsegment) { - for (a=0; a<me->totvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; - weight= ED_vgroup_vert_weight(ob, dgrouplist[j], a); - weight= heat_limit_weight(weight); + weight = ED_vgroup_vert_weight(ob, dgrouplist[j], a); + weight = heat_limit_weight(weight); if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgrouplist[j], a); if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { - weight= ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); - weight= heat_limit_weight(weight); + weight = ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); + weight = heat_limit_weight(weight); if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } @@ -848,10 +848,10 @@ static void rigid_add_half_edge_to_R(LaplacianSystem *sys, EditVert *v1, EditVer sub_v3_v3v3(e_, v1->co, v2->co); /* formula (5) */ - for (i=0; i<3; i++) { - sys->rigid.R[v1->tmp.l][i][0] += w*e[0]*e_[i]; - sys->rigid.R[v1->tmp.l][i][1] += w*e[1]*e_[i]; - sys->rigid.R[v1->tmp.l][i][2] += w*e[2]*e_[i]; + for (i = 0; i < 3; i++) { + sys->rigid.R[v1->tmp.l][i][0] += w * e[0] * e_[i]; + sys->rigid.R[v1->tmp.l][i][1] += w * e[1] * e_[i]; + sys->rigid.R[v1->tmp.l][i][2] += w * e[2] * e_[i]; } } @@ -897,7 +897,7 @@ static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert * void rigid_deform_iteration() { - LaplacianSystem *sys= RigidDeformSystem; + LaplacianSystem *sys = RigidDeformSystem; EditMesh *em; EditVert *eve; EditFace *efa; @@ -907,13 +907,13 @@ void rigid_deform_iteration() return; nlMakeCurrent(sys->context); - em= sys->rigid.mesh; + em = sys->rigid.mesh; /* compute R */ - memset(sys->rigid.R, 0, sizeof(float)*3*3*sys->totvert); - memset(sys->rigid.rhs, 0, sizeof(float)*3*sys->totvert); + memset(sys->rigid.R, 0, sizeof(float) * 3 * 3 * sys->totvert); + memset(sys->rigid.rhs, 0, sizeof(float) * 3 * sys->totvert); - for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) { rigid_add_edge_to_R(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_R(sys, efa->v3, efa->v1, sys->fweights[a][1]); @@ -926,13 +926,13 @@ void rigid_deform_iteration() } } - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) { rigid_orthogonalize_R(sys->rigid.R[a]); - eve->tmp.l= a; + eve->tmp.l = a; } /* compute right hand sides for solving */ - for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) { rigid_add_edge_to_rhs(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v1, sys->fweights[a][1]); @@ -946,21 +946,21 @@ void rigid_deform_iteration() } /* solve for positions, for X, Y and Z separately */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { laplacian_begin_solve(sys, i); - for (a=0; a<sys->totvert; a++) + for (a = 0; a < sys->totvert; a++) if (!sys->vpinned[a]) laplacian_add_right_hand_side(sys, a, sys->rigid.rhs[a][i]); if (laplacian_system_solve(sys)) { - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) - eve->co[i]= laplacian_system_get_solution(a); + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) + eve->co[i] = laplacian_system_get_solution(a); } else { if (!sys->rigid.thrownerror) { error("RigidDeform: failed to find solution"); - sys->rigid.thrownerror= 1; + sys->rigid.thrownerror = 1; } break; } @@ -975,17 +975,17 @@ static void rigid_laplacian_create(LaplacianSystem *sys) int a; /* add verts and faces to laplacian */ - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) { laplacian_add_vertex(sys, eve->co, eve->pinned); - eve->tmp.l= a; + eve->tmp.l = a; } - for (efa=em->faces.first; efa; efa=efa->next) { + for (efa = em->faces.first; efa; efa = efa->next) { laplacian_add_triangle(sys, - efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); + efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); if (efa->v4) laplacian_add_triangle(sys, - efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); + efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); } } @@ -997,10 +997,10 @@ void rigid_deform_begin(EditMesh *em) int a, totvert, totface; /* count vertices, triangles */ - for (totvert=0, eve=em->verts.first; eve; eve=eve->next) + for (totvert = 0, eve = em->verts.first; eve; eve = eve->next) totvert++; - for (totface=0, efa=em->faces.first; efa; efa=efa->next) { + for (totface = 0, efa = em->faces.first; efa; efa = efa->next) { totface++; if (efa->v4) totface++; } @@ -1008,16 +1008,16 @@ void rigid_deform_begin(EditMesh *em) /* create laplacian */ sys = laplacian_system_construct_begin(totvert, totface, 0); - sys->rigid.mesh= em; - sys->rigid.R = MEM_callocN(sizeof(float)*3*3*totvert, "RigidDeformR"); - sys->rigid.rhs = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformRHS"); - sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); + sys->rigid.mesh = em; + sys->rigid.R = MEM_callocN(sizeof(float) * 3 * 3 * totvert, "RigidDeformR"); + sys->rigid.rhs = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformRHS"); + sys->rigid.origco = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformCo"); - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) copy_v3_v3(sys->rigid.origco[a], eve->co); - sys->areaweights= 0; - sys->storeweights= 1; + sys->areaweights = 0; + sys->storeweights = 1; rigid_laplacian_create(sys); @@ -1036,7 +1036,7 @@ void rigid_deform_end(int cancel) int a; if (cancel) - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) if (!eve->pinned) copy_v3_v3(eve->co, sys->rigid.origco[a]); @@ -1068,8 +1068,9 @@ void rigid_deform_end(int cancel) #define MESHDEFORM_MIN_INFLUENCE 0.0005f -static int MESHDEFORM_OFFSET[7][3] = - {{0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}}; +static int MESHDEFORM_OFFSET[7][3] = { + {0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1} +}; typedef struct MDefBoundIsect { float co[3], uvw[4]; @@ -1154,7 +1155,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate U parameter and test bounds */ u = dot_v3v3(tvec, pvec) * inv_det; - if (u < -EPSILON || u > 1.0f+EPSILON) + if (u < -EPSILON || u > 1.0f + EPSILON) return 0; /* prepare to test V parameter */ @@ -1162,16 +1163,16 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate V parameter and test bounds */ v = dot_v3v3(dir, qvec) * inv_det; - if (v < -EPSILON || u + v > 1.0f+EPSILON) + if (v < -EPSILON || u + v > 1.0f + EPSILON) return 0; - isectco[0]= (1.0f - u - v)*vert0[0] + u*vert1[0] + v*vert2[0]; - isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1]; - isectco[2]= (1.0f - u - v)*vert0[2] + u*vert1[2] + v*vert2[2]; + isectco[0] = (1.0f - u - v) * vert0[0] + u * vert1[0] + v * vert2[0]; + isectco[1] = (1.0f - u - v) * vert0[1] + u * vert1[1] + v * vert2[1]; + isectco[2] = (1.0f - u - v) * vert0[2] + u * vert1[2] + v * vert2[2]; - uvw[0]= 1.0f - u - v; - uvw[1]= u; - uvw[2]= v; + uvw[0] = 1.0f - u - v; + uvw[1] = u; + uvw[2] = v; /* check if it is within the length of the line segment */ sub_v3_v3v3(isectdir, isectco, orig); @@ -1189,16 +1190,16 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) { MFace *mface; float face[4][3], co[3], uvw[3], len, nor[3], end[3]; - int f, hit, is= 0, totface; + int f, hit, is = 0, totface; - isec->labda= 1e10; + isec->labda = 1e10; - mface= mdb->cagedm->getTessFaceArray(mdb->cagedm); - totface= mdb->cagedm->getNumTessFaces(mdb->cagedm); + mface = mdb->cagedm->getTessFaceArray(mdb->cagedm); + totface = mdb->cagedm->getNumTessFaces(mdb->cagedm); add_v3_v3v3(end, isec->start, isec->vec); - for (f=0; f<totface; f++, mface++) { + for (f = 0; f < totface; f++, mface++) { copy_v3_v3(face[0], mdb->cagecos[mface->v1]); copy_v3_v3(face[1], mdb->cagecos[mface->v2]); copy_v3_v3(face[2], mdb->cagecos[mface->v3]); @@ -1211,22 +1212,22 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) normal_tri_v3(nor, face[0], face[1], face[2]); } else { - hit= meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); + hit = meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); normal_tri_v3(nor, face[0], face[2], face[3]); } } else { - hit= meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); + hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); normal_tri_v3(nor, face[0], face[1], face[2]); } if (hit) { - len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); + len = len_v3v3(isec->start, co) / len_v3v3(isec->start, end); if (len < isec->labda) { - isec->labda= len; + isec->labda = len; isec->face = mface; - isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f); - is= 1; + isec->isect = (dot_v3v3(isec->vec, nor) <= 0.0f); + is = 1; } } } @@ -1241,42 +1242,42 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float float (*cagecos)[3]; MFace *mface; float vert[4][3], len, end[3]; - static float epsilon[3]= {0, 0, 0}; //1e-4, 1e-4, 1e-4}; + static float epsilon[3] = {0, 0, 0}; //1e-4, 1e-4, 1e-4}; /* setup isec */ memset(&isec, 0, sizeof(isec)); - isec.labda= 1e10f; + isec.labda = 1e10f; add_v3_v3v3(isec.start, co1, epsilon); add_v3_v3v3(end, co2, epsilon); sub_v3_v3v3(isec.vec, end, isec.start); if (meshdeform_intersect(mdb, &isec)) { - len= isec.labda; - mface=(MFace*)isec.face; + len = isec.labda; + mface = (MFace *)isec.face; /* create MDefBoundIsect */ - isect= BLI_memarena_alloc(mdb->memarena, sizeof(*isect)); + isect = BLI_memarena_alloc(mdb->memarena, sizeof(*isect)); /* compute intersection coordinate */ - isect->co[0]= co1[0] + isec.vec[0]*len; - isect->co[1]= co1[1] + isec.vec[1]*len; - isect->co[2]= co1[2] + isec.vec[2]*len; + isect->co[0] = co1[0] + isec.vec[0] * len; + isect->co[1] = co1[1] + isec.vec[1] * len; + isect->co[2] = co1[2] + isec.vec[2] * len; - isect->len= len_v3v3(co1, isect->co); + isect->len = len_v3v3(co1, isect->co); if (isect->len < MESHDEFORM_LEN_THRESHOLD) - isect->len= MESHDEFORM_LEN_THRESHOLD; + isect->len = MESHDEFORM_LEN_THRESHOLD; - isect->v[0]= mface->v1; - isect->v[1]= mface->v2; - isect->v[2]= mface->v3; - isect->v[3]= mface->v4; - isect->nvert= (mface->v4)? 4: 3; + isect->v[0] = mface->v1; + isect->v[1] = mface->v2; + isect->v[2] = mface->v3; + isect->v[3] = mface->v4; + isect->nvert = (mface->v4) ? 4 : 3; - isect->facing= isec.isect; + isect->facing = isec.isect; /* compute mean value coordinates for interpolation */ - cagecos= mdb->cagecos; + cagecos = mdb->cagecos; copy_v3_v3(vert[0], cagecos[mface->v1]); copy_v3_v3(vert[1], cagecos[mface->v2]); copy_v3_v3(vert[2], cagecos[mface->v3]); @@ -1295,10 +1296,10 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) float outside[3], start[3], dir[3]; int i; - for (i=1; i<=6; i++) { - outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0]; - outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; - outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; + for (i = 1; i <= 6; i++) { + outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f) * MESHDEFORM_OFFSET[i][0]; + outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f) * MESHDEFORM_OFFSET[i][1]; + outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f) * MESHDEFORM_OFFSET[i][2]; copy_v3_v3(start, co); sub_v3_v3v3(dir, outside, start); @@ -1316,7 +1317,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) { - int size= mdb->size; + int size = mdb->size; x += MESHDEFORM_OFFSET[n][0]; y += MESHDEFORM_OFFSET[n][1]; @@ -1329,7 +1330,7 @@ static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) if (z < 0 || z >= mdb->size) return -1; - return x + y*size + z*size*size; + return x + y * size + z * size * size; } static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int n, float *center) @@ -1338,9 +1339,9 @@ static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; - center[0]= mdb->min[0] + x*mdb->width[0] + mdb->halfwidth[0]; - center[1]= mdb->min[1] + y*mdb->width[1] + mdb->halfwidth[1]; - center[2]= mdb->min[2] + z*mdb->width[2] + mdb->halfwidth[2]; + center[0] = mdb->min[0] + x * mdb->width[0] + mdb->halfwidth[0]; + center[1] = mdb->min[1] + y * mdb->width[1] + mdb->halfwidth[1]; + center[2] = mdb->min[2] + z * mdb->width[2] + mdb->halfwidth[2]; } static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int z) @@ -1349,72 +1350,72 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int float center[3], ncenter[3]; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); meshdeform_cell_center(mdb, x, y, z, 0, center); /* check each outgoing edge for intersection */ - for (i=1; i<=6; i++) { + for (i = 1; i <= 6; i++) { if (meshdeform_index(mdb, x, y, z, i) == -1) continue; meshdeform_cell_center(mdb, x, y, z, i, ncenter); - isect= meshdeform_ray_tree_intersect(mdb, center, ncenter); + isect = meshdeform_ray_tree_intersect(mdb, center, ncenter); if (isect) { - mdb->boundisect[a][i-1]= isect; - mdb->tag[a]= MESHDEFORM_TAG_BOUNDARY; + mdb->boundisect[a][i - 1] = isect; + mdb->tag[a] = MESHDEFORM_TAG_BOUNDARY; } } } static void meshdeform_bind_floodfill(MeshDeformBind *mdb) { - int *stack, *tag= mdb->tag; - int a, b, i, xyz[3], stacksize, size= mdb->size; + int *stack, *tag = mdb->tag; + int a, b, i, xyz[3], stacksize, size = mdb->size; - stack= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindStack"); + stack = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindStack"); /* we know lower left corner is EXTERIOR because of padding */ - tag[0]= MESHDEFORM_TAG_EXTERIOR; - stack[0]= 0; - stacksize= 1; + tag[0] = MESHDEFORM_TAG_EXTERIOR; + stack[0] = 0; + stacksize = 1; /* floodfill exterior tag */ while (stacksize > 0) { - a= stack[--stacksize]; + a = stack[--stacksize]; - xyz[2]= a/(size*size); - xyz[1]= (a - xyz[2]*size*size)/size; - xyz[0]= a - xyz[1]*size - xyz[2]*size*size; + xyz[2] = a / (size * size); + xyz[1] = (a - xyz[2] * size * size) / size; + xyz[0] = a - xyz[1] * size - xyz[2] * size * size; - for (i=1; i<=6; i++) { - b= meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); + for (i = 1; i <= 6; i++) { + b = meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); if (b != -1) { if (tag[b] == MESHDEFORM_TAG_UNTYPED || - (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i-1])) { - tag[b]= MESHDEFORM_TAG_EXTERIOR; - stack[stacksize++]= b; + (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i - 1])) { + tag[b] = MESHDEFORM_TAG_EXTERIOR; + stack[stacksize++] = b; } } } } /* other cells are interior */ - for (a=0; a<size*size*size; a++) - if (tag[a]==MESHDEFORM_TAG_UNTYPED) - tag[a]= MESHDEFORM_TAG_INTERIOR; + for (a = 0; a < size * size * size; a++) + if (tag[a] == MESHDEFORM_TAG_UNTYPED) + tag[a] = MESHDEFORM_TAG_INTERIOR; #if 0 { int tb, ti, te, ts; - tb= ti= te= ts= 0; - for (a=0; a<size*size*size; a++) - if (tag[a]==MESHDEFORM_TAG_BOUNDARY) + tb = ti = te = ts = 0; + for (a = 0; a < size * size * size; a++) + if (tag[a] == MESHDEFORM_TAG_BOUNDARY) tb++; - else if (tag[a]==MESHDEFORM_TAG_INTERIOR) + else if (tag[a] == MESHDEFORM_TAG_INTERIOR) ti++; - else if (tag[a]==MESHDEFORM_TAG_EXTERIOR) { + else if (tag[a] == MESHDEFORM_TAG_EXTERIOR) { te++; if (mdb->semibound[a]) @@ -1432,7 +1433,7 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect { int a; - for (a=0; a<isect->nvert; a++) + for (a = 0; a < isect->nvert; a++) if (isect->v[a] == cagevert) return isect->uvw[a]; @@ -1441,32 +1442,32 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNUSED(vec), int UNUSED(cagevert)) { - float dvec[3], ivec[3], wx, wy, wz, result=0.0f; - float weight, totweight= 0.0f; + float dvec[3], ivec[3], wx, wy, wz, result = 0.0f; + float weight, totweight = 0.0f; int i, a, x, y, z; - for (i=0; i<3; i++) { - ivec[i]= (int)gridvec[i]; - dvec[i]= gridvec[i] - ivec[i]; + for (i = 0; i < 3; i++) { + ivec[i] = (int)gridvec[i]; + dvec[i] = gridvec[i] - ivec[i]; } - for (i=0; i<8; i++) { - if (i & 1) { x= ivec[0]+1; wx= dvec[0]; } - else { x= ivec[0]; wx= 1.0f-dvec[0]; } + for (i = 0; i < 8; i++) { + if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; } + else { x = ivec[0]; wx = 1.0f - dvec[0]; } - if (i & 2) { y= ivec[1]+1; wy= dvec[1]; } - else { y= ivec[1]; wy= 1.0f-dvec[1]; } + if (i & 2) { y = ivec[1] + 1; wy = dvec[1]; } + else { y = ivec[1]; wy = 1.0f - dvec[1]; } - if (i & 4) { z= ivec[2]+1; wz= dvec[2]; } - else { z= ivec[2]; wz= 1.0f-dvec[2]; } + if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } - CLAMP(x, 0, mdb->size-1); - CLAMP(y, 0, mdb->size-1); - CLAMP(z, 0, mdb->size-1); + CLAMP(x, 0, mdb->size - 1); + CLAMP(y, 0, mdb->size - 1); + CLAMP(z, 0, mdb->size - 1); - a= meshdeform_index(mdb, x, y, z, 0); - weight= wx*wy*wz; - result += weight*mdb->phi[a]; + a = meshdeform_index(mdb, x, y, z, 0); + weight = wx * wy * wz; + result += weight * mdb->phi[a]; totweight += weight; } @@ -1480,33 +1481,33 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z) { int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) return; - for (i=1; i<=6; i++) - if (mdb->boundisect[a][i-1]) - mdb->semibound[a]= 1; + for (i = 1; i <= 6; i++) + if (mdb->boundisect[a][i - 1]) + mdb->semibound[a] = 1; } static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, int z) { - float weight, totweight= 0.0f; + float weight, totweight = 0.0f; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); /* count weight for neighbor cells */ - for (i=1; i<=6; i++) { + for (i = 1; i <= 6; i++) { if (meshdeform_index(mdb, x, y, z, i) == -1) continue; - if (mdb->boundisect[a][i-1]) - weight= 1.0f/mdb->boundisect[a][i-1]->len; + if (mdb->boundisect[a][i - 1]) + weight = 1.0f / mdb->boundisect[a][i - 1]->len; else if (!mdb->semibound[a]) - weight= 1.0f/mdb->width[0]; + weight = 1.0f / mdb->width[0]; else - weight= 0.0f; + weight = 0.0f; totweight += weight; } @@ -1520,21 +1521,21 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, int x, int y, int z) float weight, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) continue; - isect= mdb->boundisect[acenter][i-1]; + isect = mdb->boundisect[acenter][i - 1]; if (!isect) { - weight= (1.0f/mdb->width[0])/totweight; + weight = (1.0f / mdb->width[0]) / totweight; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[a], -weight); } } @@ -1546,21 +1547,21 @@ static void meshdeform_matrix_add_rhs(MeshDeformBind *mdb, int x, int y, int z, float rhs, weight, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a == -1) continue; - isect= mdb->boundisect[acenter][i-1]; + isect = mdb->boundisect[acenter][i - 1]; if (isect) { - weight= (1.0f/isect->len)/totweight; - rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert); + weight = (1.0f / isect->len) / totweight; + rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert); nlRightHandSideAdd(0, mdb->varidx[acenter], rhs); } } @@ -1572,19 +1573,19 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int float rhs, weight, totweight; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); if (!mdb->semibound[a]) return; - mdb->phi[a]= 0.0f; + mdb->phi[a] = 0.0f; - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - isect= mdb->boundisect[a][i-1]; + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + isect = mdb->boundisect[a][i - 1]; if (isect) { - weight= (1.0f/isect->len)/totweight; - rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert); + weight = (1.0f / isect->len) / totweight; + rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert); mdb->phi[a] += rhs; } } @@ -1595,14 +1596,14 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y float phi, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) return; - phi= 0.0f; - totweight= 0.0f; - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + phi = 0.0f; + totweight = 0.0f; + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a != -1 && mdb->semibound[a]) { phi += mdb->phi[a]; @@ -1611,7 +1612,7 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y } if (totweight != 0.0f) - mdb->phi[acenter]= phi/totweight; + mdb->phi[acenter] = phi / totweight; } static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind *mdb) @@ -1622,9 +1623,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind char message[256]; /* setup variable indices */ - mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx"); - for (a=0, totvar=0; a<mdb->size3; a++) - mdb->varidx[a]= (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)? -1: totvar++; + mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx"); + for (a = 0, totvar = 0; a < mdb->size3; a++) + mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++; if (totvar == 0) { MEM_freeN(mdb->varidx); @@ -1635,7 +1636,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind /* setup opennl solver */ nlNewContext(); - context= nlGetCurrent(); + context = nlGetCurrent(); nlSolverParameteri(NL_NB_VARIABLES, totvar); nlSolverParameteri(NL_NB_ROWS, totvar); @@ -1645,22 +1646,22 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlBegin(NL_MATRIX); /* build matrix */ - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_cell(mdb, x, y, z); /* solve for each cage vert */ - for (a=0; a<mdb->totcagevert; a++) { + for (a = 0; a < mdb->totcagevert; a++) { if (a != 0) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } /* fill in right hand side and solve */ - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_rhs(mdb, x, y, z, a); nlEnd(NL_MATRIX); @@ -1671,32 +1672,32 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind #endif if (nlSolveAdvanced(NULL, NL_TRUE)) { - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a); - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a); - for (b=0; b<mdb->size3; b++) { + for (b = 0; b < mdb->size3; b++) { if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) - mdb->phi[b]= nlGetVariable(0, mdb->varidx[b]); + mdb->phi[b] = nlGetVariable(0, mdb->varidx[b]); mdb->totalphi[b] += mdb->phi[b]; } if (mdb->weights) { /* static bind : compute weights for each vertex */ - for (b=0; b<mdb->totvert; b++) { + for (b = 0; b < mdb->totvert; b++) { if (mdb->inside[b]) { copy_v3_v3(vec, mdb->vertexcos[b]); - gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; - gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; - gridvec[2]= (vec[2] - mdb->min[2] - mdb->halfwidth[2])/mdb->width[2]; + gridvec[0] = (vec[0] - mdb->min[0] - mdb->halfwidth[0]) / mdb->width[0]; + gridvec[1] = (vec[1] - mdb->min[1] - mdb->halfwidth[1]) / mdb->width[1]; + gridvec[2] = (vec[2] - mdb->min[2] - mdb->halfwidth[2]) / mdb->width[2]; - mdb->weights[b*mdb->totcagevert + a]= meshdeform_interp_w(mdb, gridvec, vec, a); + mdb->weights[b * mdb->totcagevert + a] = meshdeform_interp_w(mdb, gridvec, vec, a); } } } @@ -1704,13 +1705,13 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind MDefBindInfluence *inf; /* dynamic bind */ - for (b=0; b<mdb->size3; b++) { + for (b = 0; b < mdb->size3; b++) { if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { - inf= BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); - inf->vertex= a; - inf->weight= mdb->phi[b]; - inf->next= mdb->dyngrid[b]; - mdb->dyngrid[b]= inf; + inf = BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); + inf->vertex = a; + inf->weight = mdb->phi[b]; + inf->next = mdb->dyngrid[b]; + mdb->dyngrid[b] = inf; } } } @@ -1721,17 +1722,17 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind break; } - BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert); - progress_bar((float)(a+1)/(float)(mdb->totcagevert), message); + BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a + 1, mdb->totcagevert); + progress_bar((float)(a + 1) / (float)(mdb->totcagevert), message); } #if 0 /* sanity check */ - for (b=0; b<mdb->size3; b++) + for (b = 0; b < mdb->size3; b++) if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) if (fabs(mdb->totalphi[b] - 1.0f) > 1e-4) printf("totalphi deficiency [%s|%d] %d: %.10f\n", - (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR)? "interior": "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); + (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif /* free */ @@ -1751,78 +1752,78 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* compute bounding box of the cage mesh */ INIT_MINMAX(mdb->min, mdb->max); - for (a=0; a<mdb->totcagevert; a++) + for (a = 0; a < mdb->totcagevert; a++) DO_MINMAX(mdb->cagecos[a], mdb->min, mdb->max); /* allocate memory */ - mdb->size= (2<<(mmd->gridsize-1)) + 2; - mdb->size3= mdb->size*mdb->size*mdb->size; - mdb->tag= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindTag"); - mdb->phi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindPhi"); - mdb->totalphi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindTotalPhi"); - mdb->boundisect= MEM_callocN(sizeof(*mdb->boundisect)*mdb->size3, "MDefBoundIsect"); - mdb->semibound= MEM_callocN(sizeof(int)*mdb->size3, "MDefSemiBound"); + mdb->size = (2 << (mmd->gridsize - 1)) + 2; + mdb->size3 = mdb->size * mdb->size * mdb->size; + mdb->tag = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindTag"); + mdb->phi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindPhi"); + mdb->totalphi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi"); + mdb->boundisect = MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect"); + mdb->semibound = MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound"); - mdb->inside= MEM_callocN(sizeof(int)*mdb->totvert, "MDefInside"); + mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside"); if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) - mdb->dyngrid= MEM_callocN(sizeof(MDefBindInfluence*)*mdb->size3, "MDefDynGrid"); + mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid"); else - mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); + mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights"); - mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); + mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); BLI_memarena_use_calloc(mdb->memarena); /* make bounding box equal size in all directions, add padding, and compute * width of the cells */ maxwidth = -1.0f; - for (a=0; a<3; a++) - if (mdb->max[a]-mdb->min[a] > maxwidth) - maxwidth= mdb->max[a]-mdb->min[a]; + for (a = 0; a < 3; a++) + if (mdb->max[a] - mdb->min[a] > maxwidth) + maxwidth = mdb->max[a] - mdb->min[a]; - for (a=0; a<3; a++) { - center[a]= (mdb->min[a]+mdb->max[a])*0.5f; - mdb->min[a]= center[a] - maxwidth*0.5f; - mdb->max[a]= center[a] + maxwidth*0.5f; + for (a = 0; a < 3; a++) { + center[a] = (mdb->min[a] + mdb->max[a]) * 0.5f; + mdb->min[a] = center[a] - maxwidth * 0.5f; + mdb->max[a] = center[a] + maxwidth * 0.5f; - mdb->width[a]= (mdb->max[a]-mdb->min[a])/(mdb->size-4); - mdb->min[a] -= 2.1f*mdb->width[a]; - mdb->max[a] += 2.1f*mdb->width[a]; + mdb->width[a] = (mdb->max[a] - mdb->min[a]) / (mdb->size - 4); + mdb->min[a] -= 2.1f * mdb->width[a]; + mdb->max[a] += 2.1f * mdb->width[a]; - mdb->width[a]= (mdb->max[a]-mdb->min[a])/mdb->size; - mdb->halfwidth[a]= mdb->width[a]*0.5f; + mdb->width[a] = (mdb->max[a] - mdb->min[a]) / mdb->size; + mdb->halfwidth[a] = mdb->width[a] * 0.5f; } progress_bar(0, "Setting up mesh deform system"); - totinside= 0; - for (a=0; a<mdb->totvert; a++) { + totinside = 0; + for (a = 0; a < mdb->totvert; a++) { copy_v3_v3(vec, mdb->vertexcos[a]); - mdb->inside[a]= meshdeform_inside_cage(mdb, vec); + mdb->inside[a] = meshdeform_inside_cage(mdb, vec); if (mdb->inside[a]) totinside++; } /* free temporary MDefBoundIsects */ BLI_memarena_free(mdb->memarena); - mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); + mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); /* start with all cells untyped */ - for (a=0; a<mdb->size3; a++) - mdb->tag[a]= MESHDEFORM_TAG_UNTYPED; + for (a = 0; a < mdb->size3; a++) + mdb->tag[a] = MESHDEFORM_TAG_UNTYPED; /* detect intersections and tag boundary cells */ - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_add_intersections(mdb, x, y, z); /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); - for (z=0; z<mdb->size; z++) - for (y=0; y<mdb->size; y++) - for (x=0; x<mdb->size; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_check_semibound(mdb, x, y, z); /* solve */ @@ -1830,45 +1831,45 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* assign results */ if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { - mmd->totinfluence= 0; - for (a=0; a<mdb->size3; a++) - for (inf=mdb->dyngrid[a]; inf; inf=inf->next) + mmd->totinfluence = 0; + for (a = 0; a < mdb->size3; a++) + for (inf = mdb->dyngrid[a]; inf; inf = inf->next) mmd->totinfluence++; /* convert MDefBindInfluences to smaller MDefInfluences */ - mmd->dyngrid= MEM_callocN(sizeof(MDefCell)*mdb->size3, "MDefDynGrid"); - mmd->dyninfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefInfluence"); - offset= 0; - for (a=0; a<mdb->size3; a++) { - cell= &mmd->dyngrid[a]; - cell->offset= offset; - - totweight= 0.0f; - mdinf= mmd->dyninfluences + cell->offset; - for (inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { - mdinf->weight= inf->weight; - mdinf->vertex= inf->vertex; + mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid"); + mmd->dyninfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->totinfluence, "MDefInfluence"); + offset = 0; + for (a = 0; a < mdb->size3; a++) { + cell = &mmd->dyngrid[a]; + cell->offset = offset; + + totweight = 0.0f; + mdinf = mmd->dyninfluences + cell->offset; + for (inf = mdb->dyngrid[a]; inf; inf = inf->next, mdinf++) { + mdinf->weight = inf->weight; + mdinf->vertex = inf->vertex; totweight += mdinf->weight; cell->totinfluence++; } if (totweight > 0.0f) { - mdinf= mmd->dyninfluences + cell->offset; - for (b=0; b<cell->totinfluence; b++, mdinf++) + mdinf = mmd->dyninfluences + cell->offset; + for (b = 0; b < cell->totinfluence; b++, mdinf++) mdinf->weight /= totweight; } offset += cell->totinfluence; } - mmd->dynverts= mdb->inside; - mmd->dyngridsize= mdb->size; + mmd->dynverts = mdb->inside; + mmd->dyngridsize = mdb->size; copy_v3_v3(mmd->dyncellmin, mdb->min); - mmd->dyncellwidth= mdb->width[0]; + mmd->dyncellwidth = mdb->width[0]; MEM_freeN(mdb->dyngrid); } else { - mmd->bindweights= mdb->weights; + mmd->bindweights = mdb->weights; MEM_freeN(mdb->inside); } @@ -1884,16 +1885,16 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifierData *mmd, MeshDeformBind *mdb) { LaplacianSystem *sys; - MFace *mface= dm->getTessFaceArray(dm), *mf; - int totvert= dm->getNumVerts(dm); - int totface= dm->getNumTessFaces(dm); + MFace *mface = dm->getTessFaceArray(dm), *mf; + int totvert = dm->getNumVerts(dm); + int totface = dm->getNumTessFaces(dm); float solution, weight; int a, tottri, j, thrownerror = 0; - mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); + mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights"); /* count triangles */ - for (tottri=0, a=0, mf=mface; a<totface; a++, mf++) { + for (tottri = 0, a = 0, mf = mface; a < totface; a++, mf++) { tottri++; if (mf->v4) tottri++; } @@ -1901,12 +1902,12 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie /* create laplacian */ sys = laplacian_system_construct_begin(totvert, tottri, 1); - sys->heat.mface= mface; - sys->heat.totface= totface; - sys->heat.totvert= totvert; - sys->heat.verts= mdb->vertexcos; + sys->heat.mface = mface; + sys->heat.totface = totface; + sys->heat.totvert = totvert; + sys->heat.verts = mdb->vertexcos; sys->heat.source = mdb->cagecos; - sys->heat.numsource= mdb->totcagevert; + sys->heat.numsource = mdb->totcagevert; heat_ray_tree_create(sys); heat_laplacian_create(sys); @@ -1914,30 +1915,30 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie laplacian_system_construct_end(sys); /* compute weights per bone */ - for (j=0; j<mdb->totcagevert; j++) { + for (j = 0; j < mdb->totcagevert; j++) { /* fill right hand side */ laplacian_begin_solve(sys, -1); - for (a=0; a<totvert; a++) + for (a = 0; a < totvert; a++) if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, - sys->heat.H[a]*sys->heat.p[a]); + sys->heat.H[a] * sys->heat.p[a]); /* solve */ if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for (a=0; a<totvert; a++) { - solution= laplacian_system_get_solution(a); + for (a = 0; a < totvert; a++) { + solution = laplacian_system_get_solution(a); - weight= heat_limit_weight(solution); + weight = heat_limit_weight(solution); if (weight > 0.0f) - mdb->weights[a*mdb->totcagevert + j] = weight; + mdb->weights[a * mdb->totcagevert + j] = weight; } } else if (!thrownerror) { error("Mesh Deform Heat Weighting:" - " failed to find solution for one or more vertices"); - thrownerror= 1; + " failed to find solution for one or more vertices"); + thrownerror = 1; break; } } @@ -1946,7 +1947,7 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie heat_system_free(sys); laplacian_system_delete(sys); - mmd->bindweights= mdb->weights; + mmd->bindweights = mdb->weights; } #endif @@ -1962,19 +1963,19 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco memset(&mdb, 0, sizeof(MeshDeformBind)); /* get mesh and cage mesh */ - mdb.vertexcos= MEM_callocN(sizeof(float)*3*totvert, "MeshDeformCos"); - mdb.totvert= totvert; + mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); + mdb.totvert = totvert; - mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); - mdb.totcagevert= mdb.cagedm->getNumVerts(mdb.cagedm); - mdb.cagecos= MEM_callocN(sizeof(*mdb.cagecos)*mdb.totcagevert, "MeshDeformBindCos"); + mdb.cagedm = mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); + mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm); + mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos"); copy_m4_m4(mdb.cagemat, cagemat); - mvert= mdb.cagedm->getVertArray(mdb.cagedm); - for (a=0; a<mdb.totcagevert; a++) + mvert = mdb.cagedm->getVertArray(mdb.cagedm); + for (a = 0; a < mdb.totcagevert; a++) copy_v3_v3(mdb.cagecos[a], mvert[a].co); - for (a=0; a<mdb.totvert; a++) - mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a*3); + for (a = 0; a < mdb.totvert; a++) + mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a * 3); /* solve */ #if 0 @@ -1987,21 +1988,21 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco #endif /* assign bind variables */ - mmd->bindcagecos= (float*)mdb.cagecos; - mmd->totvert= mdb.totvert; - mmd->totcagevert= mdb.totcagevert; + mmd->bindcagecos = (float *)mdb.cagecos; + mmd->totvert = mdb.totvert; + mmd->totcagevert = mdb.totcagevert; copy_m4_m4(mmd->bindmat, mmd->object->obmat); /* transform bindcagecos to world space */ - for (a=0; a<mdb.totcagevert; a++) - mul_m4_v3(mmd->object->obmat, mmd->bindcagecos+a*3); + for (a = 0; a < mdb.totcagevert; a++) + mul_m4_v3(mmd->object->obmat, mmd->bindcagecos + a * 3); /* free */ mdb.cagedm->release(mdb.cagedm); MEM_freeN(mdb.vertexcos); /* compact weights */ - modifier_mdef_compact_influences((ModifierData*)mmd); + modifier_mdef_compact_influences((ModifierData *)mmd); end_progress_bar(); waitcursor(0); diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 095de4ac9a9..da512f2df12 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -62,9 +62,9 @@ float laplacian_system_get_solution(int v); /* Heat Weighting */ void heat_bone_weighting(struct Object *ob, struct Mesh *me, float (*verts)[3], - int numbones, struct bDeformGroup **dgrouplist, - struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - int *selected, const char **error); + int numbones, struct bDeformGroup **dgrouplist, + struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], + int *selected, const char **error); #ifdef RIGID_DEFORM /* As-Rigid-As-Possible Deformation */ diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 40dc0a7cd36..824a39374fd 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -91,63 +91,63 @@ /* Temporary data shared between these operators */ typedef struct tPoseSlideOp { - Scene *scene; /* current scene */ - ScrArea *sa; /* area that we're operating in (needed for modal()) */ - ARegion *ar; /* region that we're operating in (needed for modal()) */ - Object *ob; /* active object that Pose Info comes from */ - bArmature *arm; /* armature for pose */ - - ListBase pfLinks; /* links between posechannels and f-curves */ - DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */ - - int cframe; /* current frame number */ - int prevFrame; /* frame before current frame (blend-from) */ - int nextFrame; /* frame after current frame (blend-to) */ + Scene *scene; /* current scene */ + ScrArea *sa; /* area that we're operating in (needed for modal()) */ + ARegion *ar; /* region that we're operating in (needed for modal()) */ + Object *ob; /* active object that Pose Info comes from */ + bArmature *arm; /* armature for pose */ + + ListBase pfLinks; /* links between posechannels and f-curves */ + DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */ + + int cframe; /* current frame number */ + int prevFrame; /* frame before current frame (blend-from) */ + int nextFrame; /* frame after current frame (blend-to) */ - int mode; /* sliding mode (ePoseSlide_Modes) */ - int flag; // unused for now, but can later get used for storing runtime settings.... + int mode; /* sliding mode (ePoseSlide_Modes) */ + int flag; // unused for now, but can later get used for storing runtime settings.... - float percentage; /* 0-1 value for determining the influence of whatever is relevant */ + float percentage; /* 0-1 value for determining the influence of whatever is relevant */ } tPoseSlideOp; /* Pose Sliding Modes */ typedef enum ePoseSlide_Modes { - POSESLIDE_PUSH = 0, /* exaggerate the pose... */ - POSESLIDE_RELAX, /* soften the pose... */ - POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */ + POSESLIDE_PUSH = 0, /* exaggerate the pose... */ + POSESLIDE_RELAX, /* soften the pose... */ + POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */ } ePoseSlide_Modes; /* ------------------------------------ */ /* operator init */ -static int pose_slide_init (bContext *C, wmOperator *op, short mode) +static int pose_slide_init(bContext *C, wmOperator *op, short mode) { tPoseSlideOp *pso; - bAction *act= NULL; + bAction *act = NULL; /* init slide-op data */ - pso= op->customdata= MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); + pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); /* get info from context */ - pso->scene= CTX_data_scene(C); - pso->ob= object_pose_armature_get(CTX_data_active_object(C)); - pso->arm= (pso->ob)? pso->ob->data : NULL; - pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */ - pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */ + pso->scene = CTX_data_scene(C); + pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + pso->arm = (pso->ob) ? pso->ob->data : NULL; + pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */ + pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */ - pso->cframe= pso->scene->r.cfra; - pso->mode= mode; + pso->cframe = pso->scene->r.cfra; + pso->mode = mode; /* set range info from property values - these may get overridden for the invoke() */ - pso->percentage= RNA_float_get(op->ptr, "percentage"); - pso->prevFrame= RNA_int_get(op->ptr, "prev_frame"); - pso->nextFrame= RNA_int_get(op->ptr, "next_frame"); + pso->percentage = RNA_float_get(op->ptr, "percentage"); + pso->prevFrame = RNA_int_get(op->ptr, "prev_frame"); + pso->nextFrame = RNA_int_get(op->ptr, "next_frame"); /* check the settings from the context */ if (ELEM4(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action)) return 0; else - act= pso->ob->adt->action; + act = pso->ob->adt->action; /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... @@ -155,7 +155,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act); /* set depsgraph flags */ - /* make sure the lock is set OK, unlock can be accidentally saved? */ + /* make sure the lock is set OK, unlock can be accidentally saved? */ pso->ob->pose->flag |= POSE_LOCKED; pso->ob->pose->flag &= ~POSE_DO_UNLOCK; @@ -171,7 +171,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) /* exiting the operator - free data */ static void pose_slide_exit(wmOperator *op) { - tPoseSlideOp *pso= op->customdata; + tPoseSlideOp *pso = op->customdata; /* if data exists, clear its data and exit */ if (pso) { @@ -186,36 +186,36 @@ static void pose_slide_exit(wmOperator *op) } /* cleanup */ - op->customdata= NULL; + op->customdata = NULL; } /* ------------------------------------ */ /* helper for apply() / reset() - refresh the data */ -static void pose_slide_refresh (bContext *C, tPoseSlideOp *pso) +static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso) { /* wrapper around the generic version, allowing us to add some custom stuff later still */ poseAnim_mapping_refresh(C, pso->scene, pso->ob); } /* helper for apply() - perform sliding for some value */ -static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) +static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) { float cframe = (float)pso->cframe; float sVal, eVal; float w1, w2; /* get keyframe values for endpoint poses to blend with */ - /* previous/start */ - sVal= evaluate_fcurve(fcu, (float)pso->prevFrame); - /* next/end */ - eVal= evaluate_fcurve(fcu, (float)pso->nextFrame); + /* previous/start */ + sVal = evaluate_fcurve(fcu, (float)pso->prevFrame); + /* next/end */ + eVal = evaluate_fcurve(fcu, (float)pso->nextFrame); /* calculate the relative weights of the endpoints */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* get weights from the percentage control */ - w1= pso->percentage; /* this must come second */ - w2= 1.0f - w1; /* this must come first */ + w1 = pso->percentage; /* this must come second */ + w2 = 1.0f - w1; /* this must come first */ } else { /* - these weights are derived from the relative distance of these @@ -228,8 +228,8 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) w2 = (float)pso->nextFrame - cframe; wtot = w1 + w2; - w1 = (w1/wtot); - w2 = (w2/wtot); + w1 = (w1 / wtot); + w2 = (w2 / wtot); } /* depending on the mode, calculate the new value @@ -243,13 +243,13 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be larger than denominator to 'expand' the result * - perform this weighting a number of times given by the percentage... */ - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed while (iters-- > 0) { - (*val)= ( -((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; + (*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; } } - break; + break; case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */ { @@ -257,36 +257,36 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be smaller than denominator to 'relax' the result * - perform this weighting a number of times given by the percentage... */ - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed while (iters-- > 0) { - (*val)= ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; + (*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; } } - break; + break; case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */ { /* perform simple linear interpolation - coefficient for start must come from pso->percentage... */ // TODO: make this use some kind of spline interpolation instead? - (*val)= ((sVal * w2) + (eVal * w1)); + (*val) = ((sVal * w2) + (eVal * w1)); } - break; + break; } } /* helper for apply() - perform sliding for some 3-element vector */ -static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[]) +static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[]) { - LinkData *ld=NULL; - char *path=NULL; + LinkData *ld = NULL; + char *path = NULL; /* get the path to use... */ - path= BLI_sprintfN("%s.%s", pfl->pchan_path, propName); + path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName); /* using this path, find each matching F-Curve for the variables we're interested in */ - while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { - FCurve *fcu= (FCurve *)ld->data; + while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { + FCurve *fcu = (FCurve *)ld->data; /* just work on these channels one by one... there's no interaction between values */ pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]); @@ -297,7 +297,7 @@ static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, flo } /* helper for apply() - perform sliding for custom properties */ -static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) +static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl) { PointerRNA ptr = {{NULL}}; LinkData *ld; @@ -337,7 +337,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) pose_slide_apply_val(pso, fcu, &tval); RNA_property_float_set(&ptr, prop, tval); } - break; + break; case PROP_BOOLEAN: case PROP_ENUM: case PROP_INT: @@ -346,7 +346,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) pose_slide_apply_val(pso, fcu, &tval); RNA_property_int_set(&ptr, prop, (int)tval); } - break; + break; default: /* cannot handle */ //printf("Cannot Pose Slide non-numerical property\n"); @@ -358,37 +358,37 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) } /* helper for apply() - perform sliding for quaternion rotations (using quat blending) */ -static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) +static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) { - FCurve *fcu_w=NULL, *fcu_x=NULL, *fcu_y=NULL, *fcu_z=NULL; - bPoseChannel *pchan= pfl->pchan; - LinkData *ld=NULL; - char *path=NULL; + FCurve *fcu_w = NULL, *fcu_x = NULL, *fcu_y = NULL, *fcu_z = NULL; + bPoseChannel *pchan = pfl->pchan; + LinkData *ld = NULL; + char *path = NULL; float cframe; /* get the path to use - this should be quaternion rotations only (needs care) */ - path= BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion"); + path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion"); /* get the current frame number */ - cframe= (float)pso->cframe; + cframe = (float)pso->cframe; /* using this path, find each matching F-Curve for the variables we're interested in */ - while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { - FCurve *fcu= (FCurve *)ld->data; + while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { + FCurve *fcu = (FCurve *)ld->data; /* assign this F-Curve to one of the relevant pointers... */ switch (fcu->array_index) { case 3: /* z */ - fcu_z= fcu; + fcu_z = fcu; break; case 2: /* y */ - fcu_y= fcu; + fcu_y = fcu; break; case 1: /* x */ - fcu_x= fcu; + fcu_x = fcu; break; case 0: /* w */ - fcu_w= fcu; + fcu_w = fcu; break; } } @@ -428,18 +428,18 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else { float quat_interp[4], quat_orig[4]; - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ - interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame)); + interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame)); /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); /* tricky interpolations - blending between original and new */ - interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f); } } } @@ -461,13 +461,13 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } /* for each link, handle each set of transforms */ - for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) { + for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { /* valid transforms for each PoseChannel should have been noted already * - sliding the pose should be a straightforward exercise for location+rotation, * but rotations get more complicated since we may want to use quaternion blending * for quaternions instead... */ - bPoseChannel *pchan= pfl->pchan; + bPoseChannel *pchan = pfl->pchan; if (pchan->flag & POSE_LOC) { /* calculate these for the 'location' vector, and use location curves */ @@ -505,14 +505,14 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } /* perform autokeyframing after changes were made + confirmed */ -static void pose_slide_autoKeyframe (bContext *C, tPoseSlideOp *pso) +static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso) { /* wrapper around the generic call */ poseAnim_mapping_autoKeyframe(C, pso->scene, pso->ob, &pso->pfLinks, (float)pso->cframe); } /* reset changes made to current pose */ -static void pose_slide_reset (tPoseSlideOp *pso) +static void pose_slide_reset(tPoseSlideOp *pso) { /* wrapper around the generic call, so that custom stuff can be added later */ poseAnim_mapping_reset(&pso->pfLinks); @@ -521,7 +521,7 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* ------------------------------------ */ /* draw percentage indicator in header */ -static void pose_slide_draw_status (tPoseSlideOp *pso) +static void pose_slide_draw_status(tPoseSlideOp *pso) { char status_str[32]; char mode_str[32]; @@ -543,24 +543,24 @@ static void pose_slide_draw_status (tPoseSlideOp *pso) break; } - BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f)); + BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage * 100.0f)); ED_area_headerprint(pso->sa, status_str); } /* common code for invoke() methods */ -static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso) +static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *pso) { tPChanFCurveLink *pfl; - AnimData *adt= pso->ob->adt; - wmWindow *win= CTX_wm_window(C); + AnimData *adt = pso->ob->adt; + wmWindow *win = CTX_wm_window(C); /* for each link, add all its keyframes to the search tree */ - for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) { + for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { LinkData *ld; /* do this for each F-Curve */ - for (ld= pfl->fcurves.first; ld; ld= ld->next) { - FCurve *fcu= (FCurve *)ld->data; + for (ld = pfl->fcurves.first; ld; ld = ld->next) { + FCurve *fcu = (FCurve *)ld->data; fcurve_to_keylist(adt, fcu, &pso->keys, NULL); } } @@ -568,34 +568,34 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * /* consolidate these keyframes, and figure out the nearest ones */ BLI_dlrbTree_linkedlist_sync(&pso->keys); - /* cancel if no keyframes found... */ + /* cancel if no keyframes found... */ if (pso->keys.root) { ActKeyColumn *ak; - float cframe= (float)pso->cframe; + float cframe = (float)pso->cframe; /* firstly, check if the current frame is a keyframe... */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe); + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe); if (ak == NULL) { /* current frame is not a keyframe, so search */ - ActKeyColumn *pk= (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe); - ActKeyColumn *nk= (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe); + ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe); + ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe); /* new set the frames */ - /* prev frame */ - pso->prevFrame= (pk)? (pk->cfra) : (pso->cframe - 1); + /* prev frame */ + pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1); RNA_int_set(op->ptr, "prev_frame", pso->prevFrame); - /* next frame */ - pso->nextFrame= (nk)? (nk->cfra) : (pso->cframe + 1); + /* next frame */ + pso->nextFrame = (nk) ? (nk->cfra) : (pso->cframe + 1); RNA_int_set(op->ptr, "next_frame", pso->nextFrame); } else { /* current frame itself is a keyframe, so just take keyframes on either side */ - /* prev frame */ - pso->prevFrame= (ak->prev)? (ak->prev->cfra) : (pso->cframe - 1); + /* prev frame */ + pso->prevFrame = (ak->prev) ? (ak->prev->cfra) : (pso->cframe - 1); RNA_int_set(op->ptr, "prev_frame", pso->prevFrame); - /* next frame */ - pso->nextFrame= (ak->next)? (ak->next->cfra) : (pso->cframe + 1); + /* next frame */ + pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1); RNA_int_set(op->ptr, "next_frame", pso->nextFrame); } } @@ -624,13 +624,13 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * } /* common code for modal() */ -static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_slide_modal(bContext *C, wmOperator *op, wmEvent *evt) { - tPoseSlideOp *pso= op->customdata; - wmWindow *win= CTX_wm_window(C); + tPoseSlideOp *pso = op->customdata; + wmWindow *win = CTX_wm_window(C); switch (evt->type) { - case LEFTMOUSE: /* confirm */ + case LEFTMOUSE: /* confirm */ { /* return to normal cursor and header status */ ED_area_headerprint(pso->sa, NULL); @@ -644,7 +644,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) return OPERATOR_FINISHED; } - case ESCKEY: /* cancel */ + case ESCKEY: /* cancel */ case RIGHTMOUSE: { /* return to normal cursor and header status */ @@ -669,7 +669,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) /* calculate percentage based on position of mouse (we only use x-axis for now. * since this is more convenient for users to do), and store new percentage value */ - pso->percentage= (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); + pso->percentage = (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); RNA_float_set(op->ptr, "percentage", pso->percentage); /* update percentage indicator in header */ @@ -681,11 +681,11 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) /* apply... */ pose_slide_apply(C, pso); } - break; + break; default: /* unhandled event (maybe it was some view manip? */ /* allow to pass through */ - return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH; + return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH; } /* still running... */ @@ -693,7 +693,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) } /* common code for cancel() */ -static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op) +static int pose_slide_cancel(bContext *UNUSED(C), wmOperator *op) { /* cleanup and done */ pose_slide_exit(op); @@ -701,7 +701,7 @@ static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op) } /* common code for exec() methods */ -static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *pso) +static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso) { /* settings should have been set up ok for applying, so just apply! */ pose_slide_apply(C, pso); @@ -716,7 +716,7 @@ static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *ps } /* common code for defining RNA properties */ -static void pose_slide_opdef_properties (wmOperatorType *ot) +static void pose_slide_opdef_properties(wmOperatorType *ot) { RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50); RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50); @@ -726,7 +726,7 @@ static void pose_slide_opdef_properties (wmOperatorType *ot) /* ------------------------------------ */ /* invoke() - for 'push' mode */ -static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_push_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -736,14 +736,14 @@ static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED( return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for push */ -static int pose_slide_push_exec (bContext *C, wmOperator *op) +static int pose_slide_push_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -753,7 +753,7 @@ static int pose_slide_push_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -774,7 +774,7 @@ void POSE_OT_push(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -783,7 +783,7 @@ void POSE_OT_push(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'relax' mode */ -static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_relax_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -793,14 +793,14 @@ static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for relax */ -static int pose_slide_relax_exec (bContext *C, wmOperator *op) +static int pose_slide_relax_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -810,7 +810,7 @@ static int pose_slide_relax_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -831,7 +831,7 @@ void POSE_OT_relax(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -840,7 +840,7 @@ void POSE_OT_relax(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'breakdown' mode */ -static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -850,14 +850,14 @@ static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UN return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for breakdown */ -static int pose_slide_breakdown_exec (bContext *C, wmOperator *op) +static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -867,7 +867,7 @@ static int pose_slide_breakdown_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -888,7 +888,7 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -899,18 +899,18 @@ void POSE_OT_breakdown(wmOperatorType *ot) /* "termination conditions" - i.e. when we stop */ typedef enum ePosePropagate_Termination { - /* stop after the current hold ends */ + /* stop after the current hold ends */ POSE_PROPAGATE_SMART_HOLDS = 0, - /* only do on the last keyframe */ + /* only do on the last keyframe */ POSE_PROPAGATE_LAST_KEY, - /* stop after the next keyframe */ + /* stop after the next keyframe */ POSE_PROPAGATE_NEXT_KEY, - /* stop after the specified frame */ + /* stop after the specified frame */ POSE_PROPAGATE_BEFORE_FRAME, - /* stop when we run out of keyframes */ + /* stop when we run out of keyframes */ POSE_PROPAGATE_BEFORE_END, - /* only do on the frames where markers are selected */ + /* only do on the frames where markers are selected */ POSE_PROPAGATE_SELECTED_MARKERS } ePosePropagate_Termination; @@ -927,15 +927,15 @@ typedef union tPosePropagate_ModeData { /* get frame on which the "hold" for the bone ends * XXX: this may not really work that well if a bone moves on some channels and not others - * if this happens to be a major issue, scrap this, and just make this happen + * if this happens to be a major issue, scrap this, and just make this happen * independently per F-Curve */ -static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *pfl, float startFrame) +static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *pfl, float startFrame) { DLRBT_Tree keys, blocks; ActKeyBlock *ab; - AnimData *adt= ob->adt; + AnimData *adt = ob->adt; LinkData *ld; float endFrame = startFrame; @@ -958,8 +958,8 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink * if (actkeyblock_is_valid(ab, &keys) == 0) { /* There are only two cases for no-exact match: - * 1) the current frame is just before another key but not on a key itself - * 2) the current frame is on a key, but that key doesn't link to the next + * 1) the current frame is just before another key but not on a key itself + * 2) the current frame is on a key, but that key doesn't link to the next * * If we've got the first case, then we can search for another block, * otherwise forget it, as we'd be overwriting some valid data. @@ -1025,11 +1025,11 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink * } /* get reference value from F-Curve using RNA */ -static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) +static short pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - short found= FALSE; + short found = FALSE; /* base pointer is always the object -> id_ptr */ RNA_id_pointer_create(&ob->id, &id_ptr); @@ -1039,41 +1039,41 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) if (RNA_property_array_check(prop)) { /* array */ if (fcu->array_index < RNA_property_array_length(&ptr, prop)) { - found= TRUE; + found = TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - *value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); + *value = (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); break; case PROP_INT: - *value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); + *value = (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); break; case PROP_FLOAT: - *value= RNA_property_float_get_index(&ptr, prop, fcu->array_index); + *value = RNA_property_float_get_index(&ptr, prop, fcu->array_index); break; default: - found= FALSE; + found = FALSE; break; } } } else { /* not an array */ - found= TRUE; + found = TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - *value= (float)RNA_property_boolean_get(&ptr, prop); + *value = (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - *value= (float)RNA_property_int_get(&ptr, prop); + *value = (float)RNA_property_int_get(&ptr, prop); break; case PROP_ENUM: - *value= (float)RNA_property_enum_get(&ptr, prop); + *value = (float)RNA_property_enum_get(&ptr, prop); break; case PROP_FLOAT: - *value= RNA_property_float_get(&ptr, prop); + *value = RNA_property_float_get(&ptr, prop); break; default: - found= FALSE; + found = FALSE; break; } } @@ -1083,8 +1083,8 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) } /* propagate just works along each F-Curve in turn */ -static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, - float startFrame, tPosePropagate_ModeData modeData) +static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, + float startFrame, tPosePropagate_ModeData modeData) { const int mode = RNA_enum_get(op->ptr, "mode"); @@ -1092,7 +1092,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, float refVal = 0.0f; short keyExists; int i, match; - short first=1; + short first = 1; /* skip if no keyframes to edit */ if ((fcu->bezt == NULL) || (fcu->totvert < 2)) @@ -1102,13 +1102,13 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, * doesn't need to firstly keyframe the pose (though this doesn't mean that * they can't either) */ - if ( !pose_propagate_get_refVal(ob, fcu, &refVal)) + if (!pose_propagate_get_refVal(ob, fcu, &refVal)) return; /* find the first keyframe to start propagating from * - if there's a keyframe on the current frame, we probably want to save this value there too * since it may be as of yet unkeyed - * - if starting before the starting frame, don't touch the key, as it may have had some valid + * - if starting before the starting frame, don't touch the key, as it may have had some valid * values */ match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists); @@ -1132,7 +1132,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, } else if (mode == POSE_PROPAGATE_LAST_KEY) { /* only affect this frame if it will be the last one */ - if (i != (fcu->totvert-1)) + if (i != (fcu->totvert - 1)) continue; } else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { @@ -1162,11 +1162,11 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, /* --------------------------------- */ -static int pose_propagate_exec (bContext *C, wmOperator *op) +static int pose_propagate_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bAction *act= (ob && ob->adt)? ob->adt->action : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bAction *act = (ob && ob->adt) ? ob->adt->action : NULL; ListBase pflinks = {NULL, NULL}; tPChanFCurveLink *pfl; @@ -1210,7 +1210,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) } /* go through propagating pose to keyframes, curve by curve */ - for (ld = pfl->fcurves.first; ld; ld= ld->next) + for (ld = pfl->fcurves.first; ld; ld = ld->next) pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData); } @@ -1230,7 +1230,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) void POSE_OT_propagate(wmOperatorType *ot) { - static EnumPropertyItem terminate_items[]= { + static EnumPropertyItem terminate_items[] = { {POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held", "Propagate pose to all keyframes after current frame that don't change (Default behavior)"}, {POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe", "Propagate pose to first keyframe following the current frame only"}, {POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "To Last Keyframe", "Propagate pose to the last keyframe only (i.e. making action cyclic)"}, @@ -1249,7 +1249,7 @@ void POSE_OT_propagate(wmOperatorType *ot) ot->poll = ED_operator_posemode; // XXX: needs selected bones! /* flag */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ // TODO: add "fade out" control for tapering off amount of propagation as time goes by? diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 3c855ff96e6..4e0398168d3 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -79,25 +79,25 @@ /* FCurves <-> PoseChannels Links */ /* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */ -static void fcurves_to_pchan_links_get (ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan) +static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan) { ListBase curves = {NULL, NULL}; int transFlags = action_get_item_transforms(act, ob, pchan, &curves); - pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); /* check if any transforms found... */ if (transFlags) { /* make new linkage data */ - tPChanFCurveLink *pfl= MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); + tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); PointerRNA ptr; - pfl->fcurves= curves; - pfl->pchan= pchan; + pfl->fcurves = curves; + pfl->pchan = pchan; /* get the RNA path to this pchan - this needs to be freed! */ RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr); - pfl->pchan_path= RNA_path_from_ID_to_struct(&ptr); + pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr); /* add linkage data to operator data */ BLI_addtail(pfLinks, pfl); @@ -131,7 +131,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } @@ -141,7 +141,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a * i.e. if nothing selected, do whole pose */ if (pfLinks->first == NULL) { - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } @@ -152,11 +152,11 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a /* free F-Curve <-> PoseChannel links */ void poseAnim_mapping_free(ListBase *pfLinks) { - tPChanFCurveLink *pfl, *pfln=NULL; + tPChanFCurveLink *pfl, *pfln = NULL; /* free the temp pchan links and their data */ - for (pfl= pfLinks->first; pfl; pfl= pfln) { - pfln= pfl->next; + for (pfl = pfLinks->first; pfl; pfl = pfln) { + pfln = pfl->next; /* free custom properties */ if (pfl->oldprops) { @@ -180,19 +180,19 @@ void poseAnim_mapping_free(ListBase *pfLinks) /* helper for apply() / reset() - refresh the data */ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? - if ((arm->flag & ARM_DELAYDEFORM)==0) + if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } /* reset changes made to current pose */ @@ -201,8 +201,8 @@ void poseAnim_mapping_reset(ListBase *pfLinks) tPChanFCurveLink *pfl; /* iterate over each pose-channel affected, restoring all channels to their original values */ - for (pfl= pfLinks->first; pfl; pfl= pfl->next) { - bPoseChannel *pchan= pfl->pchan; + for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + bPoseChannel *pchan = pfl->pchan; /* just copy all the values over regardless of whether they changed or not */ copy_v3_v3(pchan->loc, pfl->oldloc); @@ -231,8 +231,8 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa /* XXX: here we already have the information about what transforms exist, though * it might be easier to just overwrite all using normal mechanisms */ - for (pfl= pfLinks->first; pfl; pfl= pfl->next) { - bPoseChannel *pchan= pfl->pchan; + for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + bPoseChannel *pchan = pfl->pchan; /* add datasource override for the PoseChannel, to be used later */ ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); @@ -262,14 +262,14 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa /* find the next F-Curve for a PoseChannel with matching path... * - path is not just the pfl rna_path, since that path doesn't have property info yet */ -LinkData *poseAnim_mapping_getNextFCurve (ListBase *fcuLinks, LinkData *prev, const char *path) +LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path) { - LinkData *first= (prev)? prev->next : (fcuLinks)? fcuLinks->first : NULL; + LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL; LinkData *ld; /* check each link to see if the linked F-Curve has a matching path */ - for (ld= first; ld; ld= ld->next) { - FCurve *fcu= (FCurve *)ld->data; + for (ld = first; ld; ld = ld->next) { + FCurve *fcu = (FCurve *)ld->data; /* check if paths match */ if (strcmp(path, fcu->rna_path) == 0) diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 8791a345489..36c15c50809 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -89,9 +89,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* == POSE-LIBRARY TOOL FOR BLENDER == * * Overview: - * This tool allows animators to store a set of frequently used poses to dump into - * the active action to help in "budget" productions to quickly block out new actions. - * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. + * This tool allows animators to store a set of frequently used poses to dump into + * the active action to help in "budget" productions to quickly block out new actions. + * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. * * Features: * - PoseLibs are simply normal Actions @@ -108,10 +108,10 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* gets the first available frame in poselib to store a pose on * - frames start from 1, and a pose should occur on every frame... 0 is error! */ -static int poselib_get_free_index (bAction *act) +static int poselib_get_free_index(bAction *act) { TimeMarker *marker; - int low=0, high=0; + int low = 0, high = 0; short changed = 0; /* sanity checks */ @@ -124,7 +124,7 @@ static int poselib_get_free_index (bAction *act) do { changed = 0; - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { /* only increase low if value is 1 greater than low, to find "gaps" where * poses were removed from the poselib */ @@ -135,7 +135,7 @@ static int poselib_get_free_index (bAction *act) /* value replaces high if it is the highest value encountered yet */ if (marker->frame > high) { - high= marker->frame; + high = marker->frame; changed = 1; } } @@ -151,17 +151,17 @@ static int poselib_get_free_index (bAction *act) } /* returns the active pose for a poselib */ -static TimeMarker *poselib_get_active_pose (bAction *act) +static TimeMarker *poselib_get_active_pose(bAction *act) { if ((act) && (act->active_marker)) - return BLI_findlink(&act->markers, act->active_marker-1); + return BLI_findlink(&act->markers, act->active_marker - 1); else return NULL; } /* Get object that Pose Lib should be found on */ - /* XXX C can be zero */ -static Object *get_poselib_object (bContext *C) +/* XXX C can be zero */ +static Object *get_poselib_object(bContext *C) { ScrArea *sa; @@ -174,11 +174,11 @@ static Object *get_poselib_object (bContext *C) if (sa && (sa->spacetype == SPACE_BUTS)) return ED_object_context(C); else - return object_pose_armature_get(CTX_data_active_object(C)); + return BKE_object_pose_armature_get(CTX_data_active_object(C)); } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ -static int has_poselib_pose_data_poll (bContext *C) +static int has_poselib_pose_data_poll(bContext *C) { Object *ob = get_poselib_object(C); return (ob && ob->poselib); @@ -187,7 +187,7 @@ static int has_poselib_pose_data_poll (bContext *C) /* ----------------------------------- */ /* Initialize a new poselib (whether it is needed or not) */ -static bAction *poselib_init_new (Object *ob) +static bAction *poselib_init_new(Object *ob) { /* sanity checks - only for armatures */ if (ELEM(NULL, ob, ob->pose)) @@ -196,13 +196,13 @@ static bAction *poselib_init_new (Object *ob) /* init object's poselib action (unlink old one if there) */ if (ob->poselib) id_us_min(&ob->poselib->id); - ob->poselib= add_empty_action("PoseLib"); + ob->poselib = add_empty_action("PoseLib"); return ob->poselib; } /* Initialize a new poselib (checks if that needs to happen) */ -static bAction *poselib_validate (Object *ob) +static bAction *poselib_validate(Object *ob) { if (ELEM(NULL, ob, ob->pose)) return NULL; @@ -215,7 +215,7 @@ static bAction *poselib_validate (Object *ob) /* ************************************************************* */ /* Pose Lib UI Operators */ -static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -227,7 +227,7 @@ static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) poselib_init_new(ob); /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -244,12 +244,12 @@ void POSELIB_OT_new(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------------ */ -static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -262,7 +262,7 @@ static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) ob->poselib = NULL; /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -279,7 +279,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************* */ @@ -288,10 +288,10 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ -static int poselib_sanitise_exec (bContext *C, wmOperator *op) +static int poselib_sanitise_exec(bContext *C, wmOperator *op) { Object *ob = get_poselib_object(C); - bAction *act = (ob)? ob->poselib : NULL; + bAction *act = (ob) ? ob->poselib : NULL; DLRBT_Tree keys; ActKeyColumn *ak; TimeMarker *marker, *markern; @@ -304,14 +304,14 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* determine which frames have keys */ BLI_dlrbTree_init(&keys); - action_to_keylist(NULL, act, &keys, NULL); + action_to_keylist(NULL, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); /* for each key, make sure there is a corresponding pose */ - for (ak= keys.first; ak; ak= ak->next) { + for (ak = keys.first; ak; ak = ak->next) { /* check if any pose matches this */ // TODO: don't go looking through the list like this every time... - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; break; @@ -321,20 +321,20 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* add new if none found */ if (marker == NULL) { /* add pose to poselib */ - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, "Pose", sizeof(marker->name)); - marker->frame= (int)ak->cfra; - marker->flag= -1; + marker->frame = (int)ak->cfra; + marker->flag = -1; BLI_addtail(&act->markers, marker); } } /* remove all untagged poses (unused), and remove all tags */ - for (marker= act->markers.first; marker; marker= markern) { - markern= marker->next; + for (marker = act->markers.first; marker; marker = markern) { + markern = marker->next; if (marker->flag != -1) BLI_freelinkN(&act->markers, marker); @@ -348,7 +348,7 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -365,15 +365,15 @@ void POSELIB_OT_action_sanitise(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------ */ -static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *UNUSED(arg)) +static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg)) { - Object *ob= get_poselib_object(C); - bAction *act= ob->poselib; /* never NULL */ + Object *ob = get_poselib_object(C); + bAction *act = ob->poselib; /* never NULL */ TimeMarker *marker; wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); @@ -384,7 +384,7 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add each marker to this menu */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { PointerRNA props_ptr; props_ptr = uiItemFullO_ptr(layout, ot, @@ -396,11 +396,11 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, } } -static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int poselib_add_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Scene *scene= CTX_data_scene(C); - Object *ob= get_poselib_object(C); - bPose *pose= (ob) ? ob->pose : NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = get_poselib_object(C); + bPose *pose = (ob) ? ob->pose : NULL; uiPopupMenu *pup; uiLayout *layout; @@ -409,8 +409,8 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED return OPERATOR_CANCELLED; /* start building */ - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add new (adds to the first unoccupied frame) */ @@ -432,14 +432,14 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } -static int poselib_add_exec (bContext *C, wmOperator *op) +static int poselib_add_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); bAction *act = poselib_validate(ob); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; TimeMarker *marker; - KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ - int frame= RNA_int_get(op->ptr, "frame"); + KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ + int frame = RNA_int_get(op->ptr, "frame"); char name[64]; /* sanity check (invoke should have checked this anyway) */ @@ -453,17 +453,17 @@ static int poselib_add_exec (bContext *C, wmOperator *op) * - for the 'replace' option, this should end up finding the appropriate marker, * so no new one will be added */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (marker->frame == frame) { BLI_strncpy(marker->name, name, sizeof(marker->name)); break; } } if (marker == NULL) { - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, name, sizeof(marker->name)); - marker->frame= frame; + marker->frame = frame; BLI_addtail(&act->markers, marker); } @@ -477,7 +477,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op) ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ - act->active_marker= BLI_countlist(&act->markers); + act->active_marker = BLI_countlist(&act->markers); /* done */ return OPERATOR_FINISHED; @@ -496,7 +496,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX); @@ -511,9 +511,9 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; if (C == NULL) { return DummyRNA_NULL_items; @@ -522,24 +522,24 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS /* check that the action exists */ if (act) { /* add each marker to the list */ - for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) { - item_tmp.identifier= item_tmp.name= marker->name; - item_tmp.icon= ICON_ARMATURE_DATA; - item_tmp.value= i; + for (marker = act->markers.first, i = 0; marker; marker = marker->next, i++) { + item_tmp.identifier = item_tmp.name = marker->name; + item_tmp.icon = ICON_ARMATURE_DATA; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } -static int poselib_remove_exec (bContext *C, wmOperator *op) +static int poselib_remove_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; int marker_index; FCurve *fcu; @@ -567,12 +567,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) } /* remove relevant keyframes */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i; if (fcu->bezt) { - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if remove */ if (IS_EQ(bezt->vec[1][0], marker->frame)) { delete_fcurve_key(fcu, i, 1); @@ -586,12 +586,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) BLI_freelinkN(&act->markers, marker); /* fix active pose number */ - act->active_marker= 0; + act->active_marker = 0; /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -612,7 +612,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove"); @@ -620,10 +620,10 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->prop = prop; } -static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int poselib_rename_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; /* check if valid poselib */ @@ -633,14 +633,14 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, act->active_marker-1); + marker = BLI_findlink(&act->markers, act->active_marker - 1); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; } else { /* use the existing name of the marker as the name, and use the active marker as the one to rename */ - RNA_enum_set(op->ptr, "pose", act->active_marker-1); + RNA_enum_set(op->ptr, "pose", act->active_marker - 1); RNA_string_set(op->ptr, "name", marker->name); } @@ -648,10 +648,10 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) return WM_operator_props_popup(C, op, evt); } -static int poselib_rename_exec (bContext *C, wmOperator *op) +static int poselib_rename_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; @@ -662,7 +662,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; @@ -678,7 +678,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -702,13 +702,13 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ + /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose"); - prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); - RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); + prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); + RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); } /* ************************************************************* */ @@ -716,31 +716,31 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) /* Simple struct for storing settings/data for use during PoseLib preview */ typedef struct tPoseLib_PreviewData { - ListBase backups; /* tPoseLib_Backup structs for restoring poses */ - ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - - Scene *scene; /* active scene */ - ScrArea *sa; /* active area */ + ListBase backups; /* tPoseLib_Backup structs for restoring poses */ + ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ - Object *ob; /* object to work on */ - bArmature *arm; /* object's armature data */ - bPose *pose; /* object's pose */ - bAction *act; /* poselib to use */ - TimeMarker *marker; /* 'active' pose */ + Scene *scene; /* active scene */ + ScrArea *sa; /* active area */ - int selcount; /* number of selected elements to work on */ - int totcount; /* total number of elements to work on */ - - short state; /* state of main loop */ - short redraw; /* redraw/update settings during main loop */ - short flag; /* flags for various settings */ - - short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ - char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ - char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ + PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ + Object *ob; /* object to work on */ + bArmature *arm; /* object's armature data */ + bPose *pose; /* object's pose */ + bAction *act; /* poselib to use */ + TimeMarker *marker; /* 'active' pose */ + + int selcount; /* number of selected elements to work on */ + int totcount; /* total number of elements to work on */ + + short state; /* state of main loop */ + short redraw; /* redraw/update settings during main loop */ + short flag; /* flags for various settings */ + + short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ + char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ + char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ - char headerstr[200]; /* Info-text to print in header */ + char headerstr[200]; /* Info-text to print in header */ } tPoseLib_PreviewData; /* defines for tPoseLib_PreviewData->state values */ @@ -761,8 +761,8 @@ enum { /* defines for tPoseLib_PreviewData->flag values */ enum { - PL_PREVIEW_FIRSTTIME = (1<<0), - PL_PREVIEW_SHOWORIGINAL = (1<<1) + PL_PREVIEW_FIRSTTIME = (1 << 0), + PL_PREVIEW_SHOWORIGINAL = (1 << 1) }; /* ---------------------------- */ @@ -771,35 +771,35 @@ enum { typedef struct tPoseLib_Backup { struct tPoseLib_Backup *next, *prev; - bPoseChannel *pchan; /* pose channel backups are for */ + bPoseChannel *pchan; /* pose channel backups are for */ - bPoseChannel olddata; /* copy of pose channel's old data (at start) */ - IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ + bPoseChannel olddata; /* copy of pose channel's old data (at start) */ + IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ } tPoseLib_Backup; /* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */ -static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) +static void poselib_backup_posecopy(tPoseLib_PreviewData *pld) { bActionGroup *agrp; bPoseChannel *pchan; /* for each posechannel that has an actionchannel in */ - for (agrp= pld->act->groups.first; agrp; agrp= agrp->next) { + for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) { /* try to find posechannel */ - pchan= get_pose_channel(pld->pose, agrp->name); + pchan = BKE_pose_channel_find_name(pld->pose, agrp->name); /* backup data if available */ if (pchan) { tPoseLib_Backup *plb; /* store backup */ - plb= MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); + plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); - plb->pchan= pchan; + plb->pchan = pchan; memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel)); if (pchan->prop) - plb->oldprops= IDP_CopyProperty(pchan->prop); + plb->oldprops = IDP_CopyProperty(pchan->prop); BLI_addtail(&pld->backups, plb); @@ -812,11 +812,11 @@ static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) } /* Restores original pose */ -static void poselib_backup_restore (tPoseLib_PreviewData *pld) +static void poselib_backup_restore(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb; - for (plb= pld->backups.first; plb; plb= plb->next) { + for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); @@ -829,12 +829,12 @@ static void poselib_backup_restore (tPoseLib_PreviewData *pld) } /* Free list of backups, including any side data it may use */ -static void poselib_backup_free_data (tPoseLib_PreviewData *pld) +static void poselib_backup_free_data(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb, *plbn; - for (plb= pld->backups.first; plb; plb= plbn) { - plbn= plb->next; + for (plb = pld->backups.first; plb; plb = plbn) { + plbn = plb->next; /* free custom data */ if (plb->oldprops) { @@ -852,48 +852,48 @@ static void poselib_backup_free_data (tPoseLib_PreviewData *pld) /* Applies the appropriate stored pose from the pose-library to the current pose * - assumes that a valid object, with a poselib has been supplied * - gets the string to print in the header - * - this code is based on the code for extract_pose_from_action in blenkernel/action.c + * - this code is based on the code for extract_pose_from_action in blenkernel/action.c */ -static void poselib_apply_pose (tPoseLib_PreviewData *pld) +static void poselib_apply_pose(tPoseLib_PreviewData *pld) { - PointerRNA *ptr= &pld->rna_ptr; - bArmature *arm= pld->arm; - bPose *pose= pld->pose; + PointerRNA *ptr = &pld->rna_ptr; + bArmature *arm = pld->arm; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc group_ok_cb; - int frame= 1; + int frame = 1; /* get the frame */ if (pld->marker) - frame= pld->marker->frame; + frame = pld->marker->frame; else return; /* init settings for testing groups for keyframes */ - group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - ked.f1= ((float)frame) - 0.5f; - ked.f2= ((float)frame) + 0.5f; + group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + ked.f1 = ((float)frame) - 0.5f; + ked.f2 = ((float)frame) + 0.5f; /* start applying - only those channels which have a key at this point in time! */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* check if group has any keyframes */ if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) { /* has keyframe on this frame, so try to get a PoseChannel with this name */ - pchan= get_pose_channel(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { - short ok= 0; + short ok = 0; /* check if this bone should get any animation applied */ if (pld->selcount == 0) { /* if no bones are selected, then any bone is ok */ - ok= 1; + ok = 1; } else if (pchan->bone) { /* only ok if bone is visible and selected */ @@ -913,11 +913,11 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld) } /* Auto-keys/tags bones affected by the pose used from the poselib */ -static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData *pld) +static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData *pld) { - bPose *pose= pld->pose; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); @@ -925,9 +925,9 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData short autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); /* start tagging/keying */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only for selected bones unless there aren't any selected, in which case all are included */ - pchan= get_pose_channel(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) { @@ -956,38 +956,38 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData } /* send notifiers for this */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* Apply the relevant changes to the pose */ -static void poselib_preview_apply (bContext *C, wmOperator *op) +static void poselib_preview_apply(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; /* only recalc pose (and its dependencies) if pose has changed */ if (pld->redraw == PL_PREVIEW_REDRAWALL) { /* don't clear pose if firsttime */ - if ((pld->flag & PL_PREVIEW_FIRSTTIME)==0) + if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0) poselib_backup_restore(pld); else pld->flag &= ~PL_PREVIEW_FIRSTTIME; /* pose should be the right one to draw (unless we're temporarily not showing it) */ - if ((pld->flag & PL_PREVIEW_SHOWORIGINAL)==0) { + if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) { RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker)); poselib_apply_pose(pld); } else - RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ + RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? - if ((pld->arm->flag & ARM_DELAYDEFORM)==0) + if ((pld->arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(pld->scene, pld->ob); + BKE_pose_where_is(pld->scene, pld->ob); } /* do header print - if interactively previewing */ @@ -1004,12 +1004,12 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) short index; /* get search-string */ - index= pld->search_cursor; + index = pld->search_cursor; if (index >= 0 && index <= sizeof(tempstr) - 1) { memcpy(&tempstr[0], &pld->searchstr[0], index); - tempstr[index]= '|'; - memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); + tempstr[index] = '|'; + memcpy(&tempstr[index + 1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); } else { BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr)); @@ -1035,8 +1035,8 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) } /* request drawing of view + clear redraw flag */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pld->ob); - pld->redraw= PL_PREVIEW_NOREDRAW; + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob); + pld->redraw = PL_PREVIEW_NOREDRAW; } /* ---------------------------- */ @@ -1044,7 +1044,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* This helper function is called during poselib_preview_poses to find the * pose to preview next (after a change event) */ -static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) +static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) { /* stop if not going anywhere, as we assume that there is a direction to move in */ if (step == 0) @@ -1061,91 +1061,91 @@ static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) BLI_freelistN(&pld->searchp); /* generate a new list of search matches */ - for (marker= pld->act->markers.first; marker; marker= marker->next) { + for (marker = pld->act->markers.first; marker; marker = marker->next) { /* does the name partially match? - * - don't worry about case, to make it easier for users to quickly input a name (or + * - don't worry about case, to make it easier for users to quickly input a name (or * part of one), which is the whole point of this feature */ if (BLI_strcasestr(marker->name, pld->searchstr)) { /* make link-data to store reference to it */ - ld= MEM_callocN(sizeof(LinkData), "PoseMatch"); - ld->data= marker; + ld = MEM_callocN(sizeof(LinkData), "PoseMatch"); + ld->data = marker; BLI_addtail(&pld->searchp, ld); } } /* set current marker to NULL (so that we start from first) */ - pld->marker= NULL; + pld->marker = NULL; } /* check if any matches */ if (pld->searchp.first == NULL) { - pld->marker= NULL; + pld->marker = NULL; return; } /* find first match */ - for (ldc= pld->searchp.first; ldc; ldc= ldc->next) { + for (ldc = pld->searchp.first; ldc; ldc = ldc->next) { if (ldc->data == pld->marker) break; } if (ldc == NULL) - ldc= pld->searchp.first; + ldc = pld->searchp.first; /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (ld=ldc; ld && step; ld=ldn, step--) - ldn= (ld->next) ? ld->next : pld->searchp.first; + for (ld = ldc; ld && step; ld = ldn, step--) + ldn = (ld->next) ? ld->next : pld->searchp.first; } else { - for (ld=ldc; ld && step; ld=ldn, step++) - ldn= (ld->prev) ? ld->prev : pld->searchp.last; + for (ld = ldc; ld && step; ld = ldn, step++) + ldn = (ld->prev) ? ld->prev : pld->searchp.last; } /* set marker */ if (ld) - pld->marker= ld->data; + pld->marker = ld->data; } else { TimeMarker *marker, *next; /* if no marker, because we just ended searching, then set that to the start of the list */ if (pld->marker == NULL) - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (marker=pld->marker; marker && step; marker=next, step--) - next= (marker->next) ? marker->next : pld->act->markers.first; + for (marker = pld->marker; marker && step; marker = next, step--) + next = (marker->next) ? marker->next : pld->act->markers.first; } else { - for (marker=pld->marker; marker && step; marker=next, step++) - next= (marker->prev) ? marker->prev : pld->act->markers.last; + for (marker = pld->marker; marker && step; marker = next, step++) + next = (marker->prev) ? marker->prev : pld->act->markers.last; } /* it should be fairly impossible for marker to be NULL */ if (marker) - pld->marker= marker; + pld->marker = marker; } } /* specially handle events for searching */ -static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned short event, char ascii) +static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned short event, char ascii) { /* try doing some form of string manipulation first */ switch (event) { case BACKSPACEKEY: if (pld->searchstr[0] && pld->search_cursor) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; short i; for (i = index; i <= len; i++) - pld->searchstr[i-1] = pld->searchstr[i]; + pld->searchstr[i - 1] = pld->searchstr[i]; pld->search_cursor--; @@ -1157,13 +1157,13 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s case DELKEY: if (pld->searchstr[0] && pld->searchstr[1]) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; int i; if (index < len) { for (i = index; i < len; i++) - pld->searchstr[i] = pld->searchstr[i+1]; + pld->searchstr[i] = pld->searchstr[i + 1]; poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; @@ -1175,18 +1175,18 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s if (ascii) { /* character to add to the string */ - short index= pld->search_cursor; - short len= (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; + short index = pld->search_cursor; + short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; short i; if (len) { for (i = len; i > index; i--) - pld->searchstr[i]= pld->searchstr[i-1]; + pld->searchstr[i] = pld->searchstr[i - 1]; } else - pld->searchstr[1]= 0; + pld->searchstr[1] = 0; - pld->searchstr[index]= ascii; + pld->searchstr[index] = ascii; pld->search_cursor++; poselib_preview_get_next(pld, 1); @@ -1195,9 +1195,9 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s } /* handle events for poselib_preview_poses */ -static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wmEvent *event) +static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret = OPERATOR_RUNNING_MODAL; /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ @@ -1217,7 +1217,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1225,7 +1225,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* view manipulation */ @@ -1243,7 +1243,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* quicky compare to original */ case TABKEY: pld->flag &= ~PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; } @@ -1257,7 +1257,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1265,39 +1265,39 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* toggle between original pose and poselib pose*/ case TABKEY: pld->flag |= PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to previous pose (cyclic) */ case PAGEUPKEY: case WHEELUPMOUSE: poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose (cyclic) */ case PAGEDOWNKEY: case WHEELDOWNMOUSE: poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, back) */ case DOWNARROWKEY: poselib_preview_get_next(pld, -5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, forward) */ case UPARROWKEY: poselib_preview_get_next(pld, 5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose or searching cursor control */ @@ -1306,12 +1306,12 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the right */ if (pld->search_cursor < strlen(pld->searchstr)) pld->search_cursor++; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to next pose (cyclic) */ poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1321,42 +1321,42 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the left */ if (pld->search_cursor) pld->search_cursor--; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to previous pose (cyclic) */ poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to first pose or start of searching string */ case HOMEKEY: if (pld->searchstr[0]) { - pld->search_cursor= 0; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = 0; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to first pose */ - pld->marker= pld->act->markers.first; - pld->act->active_marker= 1; + pld->marker = pld->act->markers.first; + pld->act->active_marker = 1; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to last pose or start of searching string */ case ENDKEY: if (pld->searchstr[0]) { - pld->search_cursor= strlen(pld->searchstr); - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = strlen(pld->searchstr); + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to last pose */ - pld->marker= pld->act->markers.last; - pld->act->active_marker= BLI_countlist(&pld->act->markers); + pld->marker = pld->act->markers.last; + pld->act->active_marker = BLI_countlist(&pld->act->markers); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1396,53 +1396,53 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* ---------------------------- */ /* Init PoseLib Previewing data */ -static void poselib_preview_init_data (bContext *C, wmOperator *op) +static void poselib_preview_init_data(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); int pose_index = RNA_int_get(op->ptr, "pose_index"); /* set up preview state info */ - op->customdata= pld= MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); + op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); /* get basic data */ - pld->ob= ob; - pld->arm= (ob) ? (ob->data) : NULL; - pld->pose= (ob) ? (ob->pose) : NULL; - pld->act= (ob) ? (ob->poselib) : NULL; + pld->ob = ob; + pld->arm = (ob) ? (ob->data) : NULL; + pld->pose = (ob) ? (ob->pose) : NULL; + pld->act = (ob) ? (ob->poselib) : NULL; - pld->scene= CTX_data_scene(C); - pld->sa= CTX_wm_area(C); + pld->scene = CTX_data_scene(C); + pld->sa = CTX_wm_area(C); /* get starting pose based on RNA-props for this operator */ if (pose_index == -1) - pld->marker= poselib_get_active_pose(pld->act); + pld->marker = poselib_get_active_pose(pld->act); else if (pose_index == -2) pld->flag |= PL_PREVIEW_SHOWORIGINAL; else - pld->marker= (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; + pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; /* check if valid poselib */ if (ELEM3(NULL, pld->ob, pld->pose, pld->arm)) { BKE_report(op->reports, RPT_ERROR, "PoseLib is only for Armatures in PoseMode"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object doesn't have a valid PoseLib"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->marker == NULL) { if (pld->act->markers.first) { /* just use first one then... */ - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; if (pose_index > -2) BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose"); } else { BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } } @@ -1454,30 +1454,30 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op) poselib_backup_posecopy(pld); /* set flags for running */ - pld->state= PL_PREVIEW_RUNNING; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->state = PL_PREVIEW_RUNNING; + pld->redraw = PL_PREVIEW_REDRAWALL; pld->flag |= PL_PREVIEW_FIRSTTIME; /* set depsgraph flags */ - /* make sure the lock is set OK, unlock can be accidentally saved? */ + /* make sure the lock is set OK, unlock can be accidentally saved? */ pld->pose->flag |= POSE_LOCKED; pld->pose->flag &= ~POSE_DO_UNLOCK; /* clear strings + search */ - pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0'; - pld->search_cursor= 0; + pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0'; + pld->search_cursor = 0; } /* After previewing poses */ -static void poselib_preview_cleanup (bContext *C, wmOperator *op) +static void poselib_preview_cleanup(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; - Scene *scene= pld->scene; - Object *ob= pld->ob; - bPose *pose= pld->pose; - bArmature *arm= pld->arm; - bAction *act= pld->act; - TimeMarker *marker= pld->marker; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; + Scene *scene = pld->scene; + Object *ob = pld->ob; + bPose *pose = pld->pose; + bArmature *arm = pld->arm; + bAction *act = pld->act; + TimeMarker *marker = pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ ED_area_headerprint(pld->sa, NULL); @@ -1492,10 +1492,10 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - if ((arm->flag & ARM_DELAYDEFORM)==0) + if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (pld->state == PL_PREVIEW_CONFIRM) { @@ -1503,7 +1503,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) poselib_keytag_pose(C, scene, pld); /* change active pose setting */ - act->active_marker= BLI_findindex(&act->markers, marker) + 1; + act->active_marker = BLI_findindex(&act->markers, marker) + 1; action_set_activemarker(act, marker, NULL); /* Update event for pose and deformation children */ @@ -1514,7 +1514,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) //remake_action_ipos(ob->action); } else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } /* free memory used for backups and searching */ @@ -1523,13 +1523,13 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* free temp data for operator */ MEM_freeN(pld); - op->customdata= NULL; + op->customdata = NULL; } /* End previewing operation */ -static int poselib_preview_exit (bContext *C, wmOperator *op) +static int poselib_preview_exit(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int exit_state = pld->state; /* finish up */ @@ -1542,16 +1542,16 @@ static int poselib_preview_exit (bContext *C, wmOperator *op) } /* Cancel previewing operation (called when exiting Blender) */ -static int poselib_preview_cancel (bContext *C, wmOperator *op) +static int poselib_preview_cancel(bContext *C, wmOperator *op) { poselib_preview_exit(C, op); return OPERATOR_CANCELLED; } /* main modal status check */ -static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) +static int poselib_preview_modal(bContext *C, wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret; /* 1) check state to see if we're still running */ @@ -1559,7 +1559,7 @@ static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) return poselib_preview_exit(C, op); /* 2) handle events */ - ret= poselib_preview_handle_event(C, op, event); + ret = poselib_preview_handle_event(C, op, event); /* 3) apply changes and redraw, otherwise, confirming goes wrong */ if (pld->redraw) @@ -1575,7 +1575,7 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1593,13 +1593,13 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e } /* Repeat operator */ -static int poselib_preview_exec (bContext *C, wmOperator *op) +static int poselib_preview_exec(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1637,10 +1637,10 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); // XXX: percentage vs factor? @@ -1660,9 +1660,9 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 8a2af14e6f3..e9c960c4080 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -83,8 +83,8 @@ /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { - ReportList *reports= CTX_wm_reports(C); - Object *ob= base->object; + ReportList *reports = CTX_wm_reports(C); + Object *ob = base->object; if (ob->id.lib) { BKE_report(reports, RPT_WARNING, "Can't pose libdata"); @@ -96,7 +96,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) ob->restore_mode = ob->mode; ob->mode |= OB_MODE_POSE; - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL); break; default: @@ -110,12 +110,12 @@ void ED_armature_enter_posemode(bContext *C, Base *base) void ED_armature_exit_posemode(bContext *C, Base *base) { if (base) { - Object *ob= base->object; + Object *ob = base->object; ob->restore_mode = ob->mode; ob->mode &= ~OB_MODE_POSE; - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); } } @@ -127,13 +127,13 @@ static short pose_has_protected_selected(Object *ob, short warn) /* check protection */ if (ob->proxy) { bPoseChannel *pchan; - bArmature *arm= ob->data; + bArmature *arm = ob->data; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone && (pchan->bone->layer & arm->layer)) { if (pchan->bone->layer & arm->layer_protected) { if (pchan->bone->flag & BONE_SELECTED) - break; + break; } } } @@ -154,17 +154,17 @@ static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level) /* No need to check if constraint is active (has influence), * since all constraints with CONSTRAINT_IK_AUTO are active */ - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data= con->data; + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = con->data; if (data->rootbone == 0 || data->rootbone > level) { - if ((data->flag & CONSTRAINT_IK_AUTO)==0) + if ((data->flag & CONSTRAINT_IK_AUTO) == 0) return 1; } } } - for (bone= pchan->bone->childbase.first; bone; bone= bone->next) { - pchan= get_pose_channel(ob->pose, bone->name); + for (bone = pchan->bone->childbase.first; bone; bone = bone->next) { + pchan = BKE_pose_channel_find_name(ob->pose, bone->name); if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) return 1; } @@ -197,10 +197,11 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -227,8 +228,8 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNU */ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); - Scene *scene= CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -246,7 +247,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) } /* set up path data for bones being calculated */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* verify makes sure that the selected bone has a bone with the appropriate settings */ animviz_verify_motionpaths(op->reports, scene, ob, pchan); @@ -276,17 +277,52 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", - "First frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + "First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", - "Last frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + "Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); RNA_def_enum(ot->srna, "bake_location", motionpath_bake_location_items, 0, "Bake Location", - "Which point on the bones is used when calculating paths"); + "Which point on the bones is used when calculating paths"); +} + +/* --------- */ + +static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + + if (ELEM(NULL, ob, scene)) + return OPERATOR_CANCELLED; + + /* calculate the bones that now have motionpaths... */ + // TODO: only make for the selected bones? + ED_pose_recalculate_paths(scene, ob); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Bone Paths"; + ot->idname = "POSE_OT_paths_update"; + ot->description = "Recalculate paths for bones that already have them"; + + /* api callbakcs */ + ot->exec = pose_update_paths_exec; + ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------- */ @@ -301,11 +337,11 @@ static void ED_pose_clear_paths(Object *ob) return; /* free the motionpath blocks, but also take note of whether we skipped some... */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->mpath) { if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) { animviz_free_motionpath(pchan->mpath); - pchan->mpath= NULL; + pchan->mpath = NULL; } else skipped = 1; @@ -318,9 +354,9 @@ static void ED_pose_clear_paths(Object *ob) } /* operator callback for this */ -static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_clear_paths_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) @@ -347,34 +383,34 @@ void POSE_OT_paths_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* Select Constraint Target Operator ************* */ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bConstraint *con; - int found= 0; + int found = 0; CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if (pchan->bone->flag & BONE_SELECTED) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { - bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget); + bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { - pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - found= 1; + pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; + found = 1; } } } @@ -390,7 +426,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op if (!found) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -407,36 +443,36 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* select hierarchy operator ************* */ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; Bone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); int add_to_sel = RNA_boolean_get(op->ptr, "extend"); - int found= 0; + int found = 0; CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - curbone= pchan->bone; + curbone = pchan->bone; - if ((curbone->flag & BONE_UNSELECTABLE)==0) { + if ((curbone->flag & BONE_UNSELECTABLE) == 0) { if (curbone == arm->act_bone) { if (direction == BONE_SELECT_PARENT) { if (pchan->parent == NULL) continue; - else pabone= pchan->parent->bone; + else pabone = pchan->parent->bone; if (PBONE_VISIBLE(arm, pabone)) { if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; pabone->flag |= BONE_SELECTED; - arm->act_bone= pabone; + arm->act_bone = pabone; - found= 1; + found = 1; break; } } @@ -469,9 +505,9 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) if (PBONE_VISIBLE(arm, chbone)) { if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; chbone->flag |= BONE_SELECTED; - arm->act_bone= chbone; + arm->act_bone = chbone; - found= 1; + found = 1; break; } } @@ -483,14 +519,14 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) if (found == 0) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } void POSE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} @@ -506,7 +542,7 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", ""); @@ -516,39 +552,39 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) /* ******************* select grouped operator ************* */ -static short pose_select_same_group (bContext *C, Object *ob, short extend) +static short pose_select_same_group(bContext *C, Object *ob, short extend) { - bArmature *arm= (ob)? ob->data : NULL; - bPose *pose= (ob)? ob->pose : NULL; + bArmature *arm = (ob) ? ob->data : NULL; + bPose *pose = (ob) ? ob->pose : NULL; char *group_flags; int numGroups = 0; - short changed=0, tagged=0; + short changed = 0, tagged = 0; /* sanity checks */ if (ELEM3(NULL, ob, pose, arm)) return 0; /* count the number of groups */ - numGroups= BLI_countlist(&pose->agroups); + numGroups = BLI_countlist(&pose->agroups); if (numGroups == 0) return 0; /* alloc a small array to keep track of the groups to use - * - each cell stores on/off state for whether group should be used + * - each cell stores on/off state for whether group should be used * - size is numGroups + 1, since index=0 is used for no-group */ - group_flags= MEM_callocN(numGroups+1, "pose_select_same_group"); + group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group"); CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* keep track of group as group to use later? */ if (pchan->bone->flag & BONE_SELECTED) { group_flags[pchan->agrp_index] = 1; - tagged= 1; + tagged = 1; } /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -558,11 +594,11 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend) /* only if group matches (and is not selected or current bone) */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { /* check if the group used by this bone is counted */ if (group_flags[pchan->agrp_index]) { pchan->bone->flag |= BONE_SELECTED; - changed= 1; + changed = 1; } } } @@ -575,12 +611,12 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend) return changed; } -static short pose_select_same_layer (bContext *C, Object *ob, short extend) +static short pose_select_same_layer(bContext *C, Object *ob, short extend) { - bPose *pose= (ob)? ob->pose : NULL; - bArmature *arm= (ob)? ob->data : NULL; - short changed= 0; - int layers= 0; + bPose *pose = (ob) ? ob->pose : NULL; + bArmature *arm = (ob) ? ob->data : NULL; + short changed = 0; + int layers = 0; if (ELEM3(NULL, ob, pose, arm)) return 0; @@ -593,7 +629,7 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) layers |= pchan->bone->layer; /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -604,9 +640,9 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* if bone is on a suitable layer, and the bone can have its selection changed, select it */ - if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { pchan->bone->flag |= BONE_SELECTED; - changed= 1; + changed = 1; } } CTX_DATA_END; @@ -619,9 +655,9 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); KS_Path *ksp; - bArmature *arm = (ob)? ob->data : NULL; - bPose *pose= (ob)? ob->pose : NULL; - short changed= 0; + bArmature *arm = (ob) ? ob->data : NULL; + bPose *pose = (ob) ? ob->pose : NULL; + short changed = 0; /* sanity checks: validate Keying Set and object */ if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0)) @@ -634,7 +670,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) if (extend == 0) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -650,12 +686,12 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); if (boneName) { - bPoseChannel *pchan = get_pose_channel(pose, boneName); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName); if (pchan) { /* select if bone is visible and can be affected */ if ((PBONE_VISIBLE(arm, pchan->bone)) && - (pchan->bone->flag & BONE_UNSELECTABLE)==0) + (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { pchan->bone->flag |= BONE_SELECTED; changed = 1; @@ -672,10 +708,10 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) return changed; } -static int pose_select_grouped_exec (bContext *C, wmOperator *op) +static int pose_select_grouped_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - short extend= RNA_boolean_get(op->ptr, "extend"); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + short extend = RNA_boolean_get(op->ptr, "extend"); short changed = 0; /* sanity check */ @@ -687,18 +723,18 @@ static int pose_select_grouped_exec (bContext *C, wmOperator *op) */ switch (RNA_enum_get(op->ptr, "type")) { case 1: /* group */ - changed= pose_select_same_group(C, ob, extend); + changed = pose_select_same_group(C, ob, extend); break; case 2: /* Keying Set */ - changed= pose_select_same_keyingset(C, ob, extend); + changed = pose_select_same_keyingset(C, ob, extend); break; default: /* layer */ - changed= pose_select_same_layer(C, ob, extend); + changed = pose_select_same_layer(C, ob, extend); break; } /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (changed) @@ -727,7 +763,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -738,25 +774,25 @@ void POSE_OT_select_grouped(wmOperatorType *ot) /* ********************************************** */ /* context active object, or weightpainted object with armature in posemode */ -static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob_act= CTX_data_active_object(C); - Object *ob= object_pose_armature_get(ob_act); + Object *ob_act = CTX_data_active_object(C); + Object *ob = BKE_object_pose_armature_get(ob_act); if (ob && (ob->mode & OB_MODE_POSE)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->act_bone) { bPoseChannel *pchanf; char name[MAXBONENAME]; flip_side_name(name, arm->act_bone->name, TRUE); - pchanf= get_pose_channel(ob->pose, name); + pchanf = BKE_pose_channel_find_name(ob->pose, name); if (pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; pchanf->bone->flag |= BONE_SELECTED; - arm->act_bone= pchanf->bone; + arm->act_bone = pchanf->bone; /* in weightpaint we select the associated vertex group too */ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { @@ -764,7 +800,7 @@ static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -786,7 +822,7 @@ void POSE_OT_select_flip_active(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -794,49 +830,49 @@ void POSE_OT_select_flip_active(wmOperatorType *ot) #if 0 /* UNUSED 2.5 */ static void pose_copy_menu(Scene *scene) { - Object *obedit= scene->obedit; // XXX context - Object *ob= OBACT; + Object *obedit = scene->obedit; // XXX context + Object *ob = OBACT; bArmature *arm; bPoseChannel *pchan, *pchanact; - short nr=0; - int i=0; + short nr = 0; + int i = 0; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; - if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; + if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return; - pchan= get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); - if (pchan==NULL) return; - pchanact= pchan; - arm= ob->data; + if (pchan == NULL) return; + pchanact = pchan; + arm = ob->data; /* if proxy-protected bones selected, some things (such as locks + displays) shouldn't be changeable, * but for constraints (just add local constraints) */ if (pose_has_protected_selected(ob, 0)) { - i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ + i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ if (i < 25) - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5"); else - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4"); } else { - i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ + i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ if (i < 25) - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); else - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); } if (nr <= 0) return; if (nr != 5) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && - (pchan->bone->flag & BONE_SELECTED) && - (pchan != pchanact) ) + (pchan->bone->flag & BONE_SELECTED) && + (pchan != pchanact) ) { switch (nr) { case 1: /* Local Location */ @@ -861,7 +897,7 @@ static void pose_copy_menu(Scene *scene) bConstraint *con; /* add proxy-local tags */ - for (con= tmp_constraints.first; con; con= con->next) + for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); @@ -872,7 +908,7 @@ static void pose_copy_menu(Scene *scene) if (ob->pose) ob->pose->flag |= POSE_RECALC; } - break; + break; case 6: /* Transform Locks */ pchan->protectflag = pchanact->protectflag; break; @@ -882,22 +918,22 @@ static void pose_copy_menu(Scene *scene) copy_v3_v3(pchan->limitmin, pchanact->limitmin); copy_v3_v3(pchan->limitmax, pchanact->limitmax); copy_v3_v3(pchan->stiffness, pchanact->stiffness); - pchan->ikstretch= pchanact->ikstretch; - pchan->ikrotweight= pchanact->ikrotweight; - pchan->iklinweight= pchanact->iklinweight; + pchan->ikstretch = pchanact->ikstretch; + pchan->ikrotweight = pchanact->ikrotweight; + pchan->iklinweight = pchanact->iklinweight; } - break; + break; case 8: /* Custom Bone Shape */ pchan->custom = pchanact->custom; break; case 9: /* Visual Location */ - armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); + BKE_armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); break; case 10: /* Visual Rotation */ { float delta_mat[4][4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); if (pchan->rotmode == ROT_MODE_AXISANGLE) { float tmp_quat[4]; @@ -911,12 +947,12 @@ static void pose_copy_menu(Scene *scene) else mat4_to_eulO(pchan->eul, pchan->rotmode, delta_mat); } - break; + break; case 11: /* Visual Size */ { float delta_mat[4][4], size[4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); mat4_to_size(size, delta_mat); copy_v3_v3(pchan->size, size); } @@ -926,14 +962,14 @@ static void pose_copy_menu(Scene *scene) } else { /* constraints, optional (note: max we can have is 24 constraints) */ bConstraint *con, *con_back; - int const_toggle[24]= {0}; /* XXX, initialize as 0 to quiet errors */ + int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */ ListBase const_copy = {NULL, NULL}; BLI_duplicatelist(&const_copy, &(pchanact->constraints)); /* build the puplist of constraints */ - for (con = pchanact->constraints.first, i=0; con; con=con->next, i++) { - const_toggle[i]= 1; + for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) { + const_toggle[i] = 1; // add_numbut(i, TOG|INT, con->name, 0, 0, &(const_toggle[i]), ""); } @@ -943,22 +979,22 @@ static void pose_copy_menu(Scene *scene) // } /* now build a new listbase from the options selected */ - for (i=0, con=const_copy.first; con; i++) { + for (i = 0, con = const_copy.first; con; i++) { /* if not selected, free/remove it from the list */ if (!const_toggle[i]) { - con_back= con->next; + con_back = con->next; BLI_freelinkN(&const_copy, con); - con= con_back; + con = con_back; } else - con= con->next; + con = con->next; } /* Copy the temo listbase to the selected posebones */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && - (pchan->bone->flag & BONE_SELECTED) && - (pchan!=pchanact) ) + (pchan->bone->flag & BONE_SELECTED) && + (pchan != pchanact) ) { ListBase tmp_constraints = {NULL, NULL}; @@ -968,7 +1004,7 @@ static void pose_copy_menu(Scene *scene) copy_constraints(&tmp_constraints, &const_copy, TRUE); if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) { /* add proxy-local tags */ - for (con= tmp_constraints.first; con; con= con->next) + for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); @@ -978,13 +1014,13 @@ static void pose_copy_menu(Scene *scene) } } BLI_freelistN(&const_copy); - update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ + BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ if (ob->pose) ob->pose->flag |= POSE_RECALC; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations BIF_undo_push("Copy Pose Attributes"); @@ -1001,7 +1037,7 @@ void free_posebuf(void) if (g_posebuf) { bPoseChannel *pchan; - for (pchan= g_posebuf->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = g_posebuf->chanbase.first; pchan; pchan = pchan->next) { if (pchan->prop) { IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); @@ -1013,20 +1049,20 @@ void free_posebuf(void) MEM_freeN(g_posebuf); } - g_posebuf=NULL; + g_posebuf = NULL; } /* This function is used to indicate that a bone is selected * and needs to be included in copy buffer (used to be for inserting keys) */ -static void set_pose_keys (Object *ob) +static void set_pose_keys(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *chan; if (ob->pose) { - for (chan=ob->pose->chanbase.first; chan; chan=chan->next) { - Bone *bone= chan->bone; + for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { + Bone *bone = chan->bone; if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) chan->flag |= POSE_KEY; else @@ -1043,7 +1079,7 @@ static void set_pose_keys (Object *ob) * * > returns: whether the bone that we pasted to if we succeeded */ -static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip) +static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short selOnly, short flip) { bPoseChannel *pchan; char name[MAXBONENAME]; @@ -1051,20 +1087,20 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* get the name - if flipping, we must flip this first */ if (flip) - flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ + flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ else BLI_strncpy(name, chan->name, sizeof(name)); /* only copy when: - * 1) channel exists - poses are not meant to add random channels to anymore - * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical + * 1) channel exists - poses are not meant to add random channels to anymore + * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical */ - pchan= get_pose_channel(ob->pose, name); + pchan = BKE_pose_channel_find_name(ob->pose, name); if (selOnly) - paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED)); + paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED)); else - paste_ok= ((pchan != NULL)); + paste_ok = ((pchan != NULL)); /* continue? */ if (paste_ok) { @@ -1073,7 +1109,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s */ copy_v3_v3(pchan->loc, chan->loc); copy_v3_v3(pchan->size, chan->size); - pchan->flag= chan->flag; + pchan->flag = chan->flag; /* check if rotation modes are compatible (i.e. do they need any conversions) */ if (pchan->rotmode == chan->rotmode) { @@ -1113,7 +1149,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* paste flipped pose? */ if (flip) { - pchan->loc[0]*= -1; + pchan->loc[0] *= -1; /* has to be done as eulers... */ if (pchan->rotmode > 0) { @@ -1124,8 +1160,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s float eul[3]; axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle); - eul[1]*= -1; - eul[2]*= -1; + eul[1] *= -1; + eul[2] *= -1; eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT); } else { @@ -1133,8 +1169,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s normalize_qt(pchan->quat); quat_to_eul(eul, pchan->quat); - eul[1]*= -1; - eul[2]*= -1; + eul[1] *= -1; + eul[2] *= -1; eul_to_quat(pchan->quat, eul); } } @@ -1150,7 +1186,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s } else { /* no existing properties, so assume that we want copies too? */ - pchan->prop= IDP_CopyProperty(chan->prop); + pchan->prop = IDP_CopyProperty(chan->prop); } } } @@ -1161,9 +1197,9 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* ---- */ -static int pose_copy_exec (bContext *C, wmOperator *op) +static int pose_copy_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* sanity checking */ if (ELEM(NULL, ob, ob->pose)) { @@ -1176,7 +1212,7 @@ static int pose_copy_exec (bContext *C, wmOperator *op) /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); - copy_pose(&g_posebuf, ob->pose, 0); + BKE_pose_copy_data(&g_posebuf, ob->pose, 0); return OPERATOR_FINISHED; @@ -1199,13 +1235,13 @@ void POSE_OT_copy(wmOperatorType *ot) /* ---- */ -static int pose_paste_exec (bContext *C, wmOperator *op) +static int pose_paste_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - Scene *scene= CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); bPoseChannel *chan; - int flip= RNA_boolean_get(op->ptr, "flipped"); - int selOnly= RNA_boolean_get(op->ptr, "selected_mask"); + int flip = RNA_boolean_get(op->ptr, "flipped"); + int selOnly = RNA_boolean_get(op->ptr, "selected_mask"); /* get KeyingSet to use */ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOC_ROT_SCALE_ID); @@ -1228,7 +1264,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op) } /* Safely merge all of the channels in the buffer pose into any existing pose */ - for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) { + for (chan = g_posebuf->chanbase.first; chan; chan = chan->next) { if (chan->flag & POSE_KEY) { /* try to perform paste on this bone */ bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip); @@ -1244,7 +1280,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1263,7 +1299,7 @@ void POSE_OT_paste(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flag */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ prop = RNA_def_boolean(ot->srna, "flipped", FALSE, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose"); @@ -1275,26 +1311,26 @@ void POSE_OT_paste(wmOperatorType *ot) /* ********************************************** */ /* Bone Groups */ -static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_add_group(ob); + BKE_pose_add_group(ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1311,30 +1347,30 @@ void POSE_OT_group_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_remove_group(ob); + BKE_pose_remove_group(ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1351,15 +1387,15 @@ void POSE_OT_group_remove(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------ */ /* invoke callback which presents a list of bone-groups for the user to choose from */ -static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; bPose *pose; @@ -1370,20 +1406,20 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - pose= ob->pose; + pose = ob->pose; /* if there's no active group (or active is invalid), create a new menu to find it */ if (pose->active_group <= 0) { /* create a new menu, and start populating it with group names */ - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); /* special entry - allow to create new group, then use that * (not to be used for removing though) @@ -1394,7 +1430,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } /* add entries for each group */ - for (grp= pose->agroups.first, i=1; grp; grp=grp->next, i++) + for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); /* finish building the menu, and process it (should result in calling self again) */ @@ -1410,42 +1446,42 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } /* Assign selected pchans to the bone group that the user selects */ -static int pose_group_assign_exec (bContext *C, wmOperator *op) +static int pose_group_assign_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; bPose *pose; - short done= 0; + short done = 0; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - pose= ob->pose; + pose = ob->pose; /* set the active group number to the one from operator props - * - if 0 after this, make a new group... + * - if 0 after this, make a new group... */ - pose->active_group= RNA_int_get(op->ptr, "type"); + pose->active_group = RNA_int_get(op->ptr, "type"); if (pose->active_group == 0) - pose_add_group(ob); + BKE_pose_add_group(ob); /* add selected bones to group then */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { - pchan->agrp_index= pose->active_group; - done= 1; + pchan->agrp_index = pose->active_group; + done = 1; } CTX_DATA_END; /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (done) @@ -1467,41 +1503,41 @@ void POSE_OT_group_assign(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "type", 0, 0, 10, "Bone Group Index", "", 0, INT_MAX); } -static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; - short done= 0; + short done = 0; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; /* find selected bones to remove from all bone groups */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { if (pchan->agrp_index) { - pchan->agrp_index= 0; - done= 1; + pchan->agrp_index = 0; + done = 1; } } CTX_DATA_END; /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (done) @@ -1522,16 +1558,16 @@ void POSE_OT_group_unassign(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int group_move_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; bActionGroup *grp; - int dir= RNA_enum_get(op->ptr, "direction"); + int dir = RNA_enum_get(op->ptr, "direction"); int grpIndexA, grpIndexB; if (ELEM(NULL, ob, pose)) @@ -1540,7 +1576,7 @@ static int group_move_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get group to move */ - grp= BLI_findlink(&pose->agroups, pose->active_group-1); + grp = BLI_findlink(&pose->agroups, pose->active_group - 1); if (grp == NULL) return OPERATOR_CANCELLED; @@ -1572,15 +1608,15 @@ static int group_move_exec(bContext *C, wmOperator *op) } /* fix changed bone group indices in bones (swap grpIndexA with grpIndexB) */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->agrp_index == grpIndexB) - pchan->agrp_index= grpIndexA; + pchan->agrp_index = grpIndexA; else if (pchan->agrp_index == grpIndexA) - pchan->agrp_index= grpIndexB; + pchan->agrp_index = grpIndexB; } /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1603,7 +1639,7 @@ void POSE_OT_group_move(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", group_slot_move, 0, "Direction", "Direction to move, UP or DOWN"); } @@ -1611,14 +1647,14 @@ void POSE_OT_group_move(wmOperatorType *ot) /* bone group sort element */ typedef struct tSortActionGroup { bActionGroup *agrp; - int index; + int index; } tSortActionGroup; /* compare bone groups by name */ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) { - tSortActionGroup *sgrp_a= (tSortActionGroup *)sgrp_a_ptr; - tSortActionGroup *sgrp_b= (tSortActionGroup *)sgrp_b_ptr; + tSortActionGroup *sgrp_a = (tSortActionGroup *)sgrp_a_ptr; + tSortActionGroup *sgrp_b = (tSortActionGroup *)sgrp_b_ptr; return strcmp(sgrp_a->agrp->name, sgrp_b->agrp->name); } @@ -1626,7 +1662,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; tSortActionGroup *agrp_array; bActionGroup *agrp; @@ -1641,26 +1677,26 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) /* create temporary array with bone groups and indices */ agrp_count = BLI_countlist(&pose->agroups); agrp_array = MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups"); - for (agrp= pose->agroups.first, i= 0; agrp; agrp= agrp->next, i++) { + for (agrp = pose->agroups.first, i = 0; agrp; agrp = agrp->next, i++) { BLI_assert(i < agrp_count); agrp_array[i].agrp = agrp; - agrp_array[i].index = i+1; + agrp_array[i].index = i + 1; } /* sort bone groups by name */ qsort(agrp_array, agrp_count, sizeof(tSortActionGroup), compare_agroup); /* create sorted bone group list from sorted array */ - pose->agroups.first= pose->agroups.last= NULL; - for (i= 0; i < agrp_count; i++) { + pose->agroups.first = pose->agroups.last = NULL; + for (i = 0; i < agrp_count; i++) { BLI_addtail(&pose->agroups, agrp_array[i].agrp); } /* fix changed bone group indizes in bones */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (i= 0; i < agrp_count; i++) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (i = 0; i < agrp_count; i++) { if (pchan->agrp_index == agrp_array[i].index) { - pchan->agrp_index= i+1; + pchan->agrp_index = i + 1; break; } } @@ -1670,7 +1706,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(agrp_array); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1687,16 +1723,16 @@ void POSE_OT_group_sort(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static void pose_group_select(bContext *C, Object *ob, int select) { - bPose *pose= ob->pose; + bPose *pose = ob->pose; - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { if (select) { if (pchan->agrp_index == pose->active_group) pchan->bone->flag |= BONE_SELECTED; @@ -1710,16 +1746,16 @@ static void pose_group_select(bContext *C, Object *ob, int select) CTX_DATA_END; } -static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1728,7 +1764,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op)) pose_group_select(C, ob, 1); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1745,19 +1781,19 @@ void POSE_OT_group_select(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1766,7 +1802,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) pose_group_select(C, ob, 0); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1783,23 +1819,23 @@ void POSE_OT_group_deselect(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ -static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { char newname[MAXBONENAME]; flip_side_name(newname, pchan->name, TRUE); @@ -1811,7 +1847,7 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1828,25 +1864,25 @@ void POSE_OT_flip_names(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------ */ -static int pose_autoside_names_exec (bContext *C, wmOperator *op) +static int pose_autoside_names_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; char newname[MAXBONENAME]; - short axis= RNA_enum_get(op->ptr, "axis"); + short axis = RNA_enum_get(op->ptr, "axis"); /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { BLI_strncpy(newname, pchan->name, sizeof(newname)); if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) @@ -1858,18 +1894,19 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } void POSE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[]= { + static EnumPropertyItem axis_items[] = { {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "AutoName by Axis"; @@ -1882,7 +1919,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* settings */ ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with"); @@ -1890,7 +1927,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) /* ********************************************** */ -static int pose_bone_rotmode_exec (bContext *C, wmOperator *op) +static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); int mode = RNA_enum_get(op->ptr, "type"); @@ -1904,7 +1941,7 @@ static int pose_bone_rotmode_exec (bContext *C, wmOperator *op) /* notifiers and updates */ DAG_id_tag_update((ID *)ob, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -1922,7 +1959,7 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", posebone_rotmode_items, 0, "Rotation Mode", ""); @@ -1931,18 +1968,18 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) /* ********************************************** */ /* Show all armature layers */ -static int pose_armature_layers_showall_poll (bContext *C) +static int pose_armature_layers_showall_poll(bContext *C) { /* this single operator can be used in posemode OR editmode for armatures */ return ED_operator_posemode(C) || ED_operator_editarmature(C); } -static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) +static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = (ob)? ob->data : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; - int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16; + int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ int i; @@ -1951,7 +1988,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* use RNA to set the layers - * although it would be faster to just set directly using bitflags, we still + * although it would be faster to just set directly using bitflags, we still * need to setup a RNA pointer so that we get the "update" callbacks for free... */ RNA_id_pointer_create(&arm->id, &ptr); @@ -1962,7 +1999,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* done */ return OPERATOR_FINISHED; @@ -1980,7 +2017,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) ot->poll = pose_armature_layers_showall_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)"); @@ -1989,10 +2026,10 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_armature_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= (ob)? ob->data : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2010,9 +2047,9 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev } /* Set the visible layers for the active armature (edit and pose modes) */ -static int pose_armature_layers_exec (bContext *C, wmOperator *op) +static int pose_armature_layers_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2028,7 +2065,7 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2047,7 +2084,7 @@ void POSE_OT_armature_layers(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); @@ -2066,7 +2103,7 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); @@ -2075,9 +2112,9 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -2085,9 +2122,9 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) short bit; /* loop over the bits for this pchan's layers, adding layers where they're needed */ - for (bit= 0; bit < 32; bit++) { - if (pchan->bone->layer & (1<<bit)) - layers[bit]= 1; + for (bit = 0; bit < 32; bit++) { + if (pchan->bone->layer & (1 << bit)) + layers[bit] = 1; } } CTX_DATA_END; @@ -2095,18 +2132,18 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* copy layers to operator */ RNA_boolean_set_array(op->ptr, "layers", layers); - /* part to sync with other similar operators... */ + /* part to sync with other similar operators... */ return WM_operator_props_popup(C, op, evt); } /* Set the visible layers for the active armature (edit and pose modes) */ -static int pose_bone_layers_exec (bContext *C, wmOperator *op) +static int pose_bone_layers_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - if (ob==NULL || ob->data==NULL) { + if (ob == NULL || ob->data == NULL) { return OPERATOR_CANCELLED; } @@ -2123,7 +2160,7 @@ static int pose_bone_layers_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2141,7 +2178,7 @@ void POSE_OT_bone_layers(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); @@ -2150,9 +2187,9 @@ void POSE_OT_bone_layers(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int armature_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -2160,9 +2197,9 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev short bit; /* loop over the bits for this pchan's layers, adding layers where they're needed */ - for (bit= 0; bit < 32; bit++) { - if (ebone->layer & (1<<bit)) - layers[bit]= 1; + for (bit = 0; bit < 32; bit++) { + if (ebone->layer & (1 << bit)) + layers[bit] = 1; } } CTX_DATA_END; @@ -2170,15 +2207,15 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev /* copy layers to operator */ RNA_boolean_set_array(op->ptr, "layers", layers); - /* part to sync with other similar operators... */ + /* part to sync with other similar operators... */ return WM_operator_props_popup(C, op, evt); } /* Set the visible layers for the active armature (edit and pose modes) */ -static int armature_bone_layers_exec (bContext *C, wmOperator *op) +static int armature_bone_layers_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (ob)? ob->data : NULL; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2195,7 +2232,7 @@ static int armature_bone_layers_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2213,7 +2250,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); @@ -2222,14 +2259,14 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) /* ********************************************** */ /* Flip Quats */ -static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); /* loop through all selected pchans, flipping and keying (as needed) */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* only if bone is using quaternion rotation */ if (pchan->rotmode == ROT_MODE_QUAT) { @@ -2243,7 +2280,7 @@ static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -2260,17 +2297,18 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ /* Clear User Transforms */ -static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); float cframe = (float)CFRA; + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); if ((ob->adt) && (ob->adt->action)) { /* XXX: this is just like this to avoid contaminating anything else; @@ -2281,7 +2319,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan; /* execute animation step for current frame using a dummy copy of the pose */ - copy_pose(&dummyPose, ob->pose, 0); + BKE_pose_copy_data(&dummyPose, ob->pose, 0); BLI_strncpy(workob.id.name, "OB<ClearTfmWorkOb>", sizeof(workob.id.name)); workob.type = OB_ARMATURE; @@ -2293,12 +2331,12 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { - pose_bone_do_paste(ob, pchan, 1, 0); + pose_bone_do_paste(ob, pchan, only_select, 0); } /* free temp data - free manually as was copied without constraints */ if (dummyPose) { - for (pchan= dummyPose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->prop) { IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); @@ -2314,12 +2352,12 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* no animation, so just reset whole pose to rest pose * (cannot just restore for selected though) */ - rest_pose(ob->pose); + BKE_pose_rest(ob->pose); } /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -2336,6 +2374,9 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "only_selected", TRUE, "Only Selected", "Only visible/selected bones"); } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index efcbab78884..2564683ddd2 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -98,7 +98,7 @@ typedef struct VertexData { typedef struct EdgeIndex { EditEdge **edges; - int *offset; + int *offset; } EdgeIndex; typedef enum { @@ -110,12 +110,12 @@ typedef enum { int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1); void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction); int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1); -EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index); +EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index); void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc); void addFacetoArc(ReebArc *arc, EditFace *efa); -void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count); -void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2); +void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count); +void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2); void flipArcBuckets(ReebArc *arc); @@ -145,34 +145,34 @@ static VertexData *allocVertexData(EditMesh *em) static int indexData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->i; + return ((VertexData *)eve->tmp.p)->i; } static float weightData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->w; + return ((VertexData *)eve->tmp.p)->w; } static void weightSetData(EditVert *eve, float w) { - ((VertexData*)eve->tmp.p)->w = w; + ((VertexData *)eve->tmp.p)->w = w; } -static ReebNode* nodeData(EditVert *eve) +static ReebNode *nodeData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->n; + return ((VertexData *)eve->tmp.p)->n; } static void nodeSetData(EditVert *eve, ReebNode *n) { - ((VertexData*)eve->tmp.p)->n = n; + ((VertexData *)eve->tmp.p)->n = n; } #endif void REEB_freeArc(BArc *barc) { - ReebArc *arc = (ReebArc*)barc; + ReebArc *arc = (ReebArc *)barc; BLI_freelistN(&arc->edges); if (arc->buckets) @@ -191,7 +191,7 @@ void REEB_freeGraph(ReebGraph *rg) // free nodes for (node = rg->nodes.first; node; node = node->next) { - BLI_freeNode((BGraph*)rg, (BNode*)node); + BLI_freeNode((BGraph *)rg, (BNode *)node); } BLI_freelistN(&rg->nodes); @@ -199,7 +199,7 @@ void REEB_freeGraph(ReebGraph *rg) arc = rg->arcs.first; while (arc) { ReebArc *next = arc->next; - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); arc = next; } @@ -214,7 +214,7 @@ void REEB_freeGraph(ReebGraph *rg) MEM_freeN(rg); } -ReebGraph * newReebGraph(void) +ReebGraph *newReebGraph(void) { ReebGraph *rg; rg = MEM_callocN(sizeof(ReebGraph), "reeb graph"); @@ -233,13 +233,13 @@ ReebGraph * newReebGraph(void) void BIF_flagMultiArcs(ReebGraph *rg, int flag) { - for ( ; rg; rg = rg->link_up) { - BLI_flagArcs((BGraph*)rg, flag); + for (; rg; rg = rg->link_up) { + BLI_flagArcs((BGraph *)rg, flag); } } #if 0 /* UNUSED */ -static ReebNode * addNode(ReebGraph *rg, EditVert *eve) +static ReebNode *addNode(ReebGraph *rg, EditVert *eve) { float weight; ReebNode *node = NULL; @@ -264,7 +264,7 @@ static ReebNode * addNode(ReebGraph *rg, EditVert *eve) return node; } -static ReebNode * copyNode(ReebGraph *rg, ReebNode *node) +static ReebNode *copyNode(ReebGraph *rg, ReebNode *node) { ReebNode *cp_node = NULL; @@ -329,7 +329,7 @@ ReebNode *BIF_lowestLevelNode(ReebNode *node) } #if 0 /* UNUSED */ -static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc) +static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) { ReebArc *cp_arc; ReebNode *node; @@ -375,7 +375,7 @@ static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc) return cp_arc; } -static ReebGraph * copyReebGraph(ReebGraph *rg, int level) +static ReebGraph *copyReebGraph(ReebGraph *rg, int level) { ReebNode *node; ReebArc *arc; @@ -399,7 +399,7 @@ static ReebGraph * copyReebGraph(ReebGraph *rg, int level) copyArc(cp_rg, arc); } - BLI_buildAdjacencyList((BGraph*)cp_rg); + BLI_buildAdjacencyList((BGraph *)cp_rg); return cp_rg; } @@ -417,7 +417,7 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node) } #if 0 /* UNUSED */ -static ReebEdge * copyEdge(ReebEdge *edge) +static ReebEdge *copyEdge(ReebEdge *edge) { ReebEdge *newEdge = NULL; @@ -433,11 +433,11 @@ static ReebEdge * copyEdge(ReebEdge *edge) static void printArc(ReebArc *arc) { ReebEdge *edge; - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight); - for (edge = arc->edges.first; edge ; edge = edge->next) + for (edge = arc->edges.first; edge; edge = edge->next) { printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index); } @@ -475,8 +475,8 @@ static void NodeDegreeIncrement(ReebGraph *UNUSED(rg), ReebNode *node) } #else -#define NodeDegreeDecrement(rg, node) {node->degree--;} -#define NodeDegreeIncrement(rg, node) {node->degree++;} +#define NodeDegreeDecrement(rg, node) {node->degree--; } +#define NodeDegreeIncrement(rg, node) {node->degree++; } #endif void repositionNodes(ReebGraph *rg) @@ -490,14 +490,14 @@ void repositionNodes(ReebGraph *rg) } for (arc = rg->arcs.first; arc; arc = arc->next) { - if (((ReebArc*)arc)->bcount > 0) { + if (((ReebArc *)arc)->bcount > 0) { float p[3]; - copy_v3_v3(p, ((ReebArc*)arc)->buckets[0].p); + copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p); mul_v3_fl(p, 1.0f / arc->head->degree); add_v3_v3(arc->head->p, p); - copy_v3_v3(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p); + copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p); mul_v3_fl(p, 1.0f / arc->tail->degree); add_v3_v3(arc->tail->p, p); } @@ -529,15 +529,15 @@ void verifyNodeDegree(ReebGraph *rg) static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc) { - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; if (arc->bcount > 0) { int i; for (i = 0; i < arc->bcount; i++) { if (arc->buckets[i].nv == 0) { printArc(arc); - printf("count error in bucket %i/%i\n", i+1, arc->bcount); + printf("count error in bucket %i/%i\n", i + 1, arc->bcount); } } @@ -653,12 +653,12 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end indexSrc++; } - for ( ; indexDst < aDst->bcount && - indexSrc < aSrc->bcount && - aDst->buckets[indexDst].val <= end && - aSrc->buckets[indexSrc].val <= end + for (; indexDst < aDst->bcount && + indexSrc < aSrc->bcount && + aDst->buckets[indexDst].val <= end && + aSrc->buckets[indexSrc].val <= end - ; indexDst++, indexSrc++) + ; indexDst++, indexSrc++) { mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc); } @@ -809,7 +809,7 @@ static void fillArcEmptyBuckets(ReebArc *arc) static void ExtendArcBuckets(ReebArc *arc) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; EmbedBucket *last_bucket, *first_bucket; float *previous = NULL; float average_length = 0, length; @@ -823,10 +823,10 @@ static void ExtendArcBuckets(ReebArc *arc) IT_next(iter); previous = iter->p; - for ( IT_next(iter); - IT_stopped(iter) == 0; - previous = iter->p, IT_next(iter) - ) + for (IT_next(iter); + IT_stopped(iter) == 0; + previous = iter->p, IT_next(iter) + ) { average_length += len_v3v3(previous, iter->p); } @@ -880,7 +880,7 @@ static void extendGraphBuckets(ReebGraph *rg) static void calculateArcLength(ReebArc *arc) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float *vec0, *vec1; arc->length = 0; @@ -913,9 +913,9 @@ static void calculateGraphLength(ReebGraph *rg) /**************************************** SYMMETRY HANDLING ******************************************/ -void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) +void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) { - ReebNode *node = (ReebNode*)root_node; + ReebNode *node = (ReebNode *)root_node; float axis[3]; int i; @@ -932,11 +932,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); - node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); + node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - arc1 = (ReebArc*)ring[i].arc; - arc2 = (ReebArc*)ring[j].arc; + arc1 = (ReebArc *)ring[i].arc; + arc2 = (ReebArc *)ring[j].arc; /* mirror first node and mix with the second */ BLI_mirrorAlongAxis(node1->p, root_node->p, normal); @@ -947,12 +947,12 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - initArcIterator(iter1, arc1, (ReebNode*)root_node); - initArcIterator(iter2, arc2, (ReebNode*)root_node); + initArcIterator(iter1, arc1, (ReebNode *)root_node); + initArcIterator(iter2, arc2, (ReebNode *)root_node); bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); @@ -967,7 +967,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } - for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket2->nv += bucket1->nv; /* add counts */ /* mirror on axis */ @@ -989,11 +989,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); - node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); + node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - arc1 = (ReebArc*)ring[i].arc; - arc2 = (ReebArc*)ring[j].arc; + arc1 = (ReebArc *)ring[i].arc; + arc2 = (ReebArc *)ring[j].arc; /* copy first node than mirror */ copy_v3_v3(node2->p, node1->p); @@ -1004,8 +1004,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; initArcIterator(iter1, arc1, node); @@ -1024,7 +1024,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } - for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; copy_v3_v3(bucket2->p, bucket1->p); @@ -1034,13 +1034,13 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } } -void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2) +void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2) { ReebArc *arc1, *arc2; float nor[3], p[3]; - arc1 = (ReebArc*)barc1; - arc2 = (ReebArc*)barc2; + arc1 = (ReebArc *)barc1; + arc2 = (ReebArc *)barc2; copy_v3_v3(nor, root_node->symmetry_axis); @@ -1061,12 +1061,12 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - initArcIterator(iter1, arc1, (ReebNode*)root_node); - initArcIterator(iter2, arc2, (ReebNode*)root_node); + initArcIterator(iter1, arc1, (ReebNode *)root_node); + initArcIterator(iter2, arc2, (ReebNode *)root_node); bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); @@ -1081,7 +1081,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr } - for ( ; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket1->nv += bucket2->nv; /* add counts */ /* mirror on axis */ @@ -1110,21 +1110,21 @@ void postprocessGraph(ReebGraph *rg, char mode) switch (mode) { - case SKGEN_AVERAGE: - fac1 = fac2 = fac3 = 1.0f / 3.0f; - break; - case SKGEN_SMOOTH: - fac1 = fac3 = 0.25f; - fac2 = 0.5f; - break; - case SKGEN_SHARPEN: - fac1 = fac3 = -0.25f; - fac2 = 1.5f; - break; - default: + case SKGEN_AVERAGE: + fac1 = fac2 = fac3 = 1.0f / 3.0f; + break; + case SKGEN_SMOOTH: + fac1 = fac3 = 0.25f; + fac2 = 0.5f; + break; + case SKGEN_SHARPEN: + fac1 = fac3 = -0.25f; + fac2 = 1.5f; + break; + default: // XXX // error("Unknown post processing mode"); - return; + return; } for (arc = rg->arcs.first; arc; arc = arc->next) @@ -1145,8 +1145,8 @@ void postprocessGraph(ReebGraph *rg, char mode) static int compareNodesWeight(void *vnode1, void *vnode2) { - ReebNode *node1 = (ReebNode*)vnode1; - ReebNode *node2 = (ReebNode*)vnode2; + ReebNode *node1 = (ReebNode *)vnode1; + ReebNode *node2 = (ReebNode *)vnode2; if (node1->weight < node2->weight) { @@ -1156,8 +1156,7 @@ static int compareNodesWeight(void *vnode1, void *vnode2) { return 1; } - else - { + else { return 0; } } @@ -1169,10 +1168,10 @@ void sortNodes(ReebGraph *rg) static int compareArcsWeight(void *varc1, void *varc2) { - ReebArc *arc1 = (ReebArc*)varc1; - ReebArc *arc2 = (ReebArc*)varc2; - ReebNode *node1 = (ReebNode*)arc1->head; - ReebNode *node2 = (ReebNode*)arc2->head; + ReebArc *arc1 = (ReebArc *)varc1; + ReebArc *arc2 = (ReebArc *)varc2; + ReebNode *node1 = (ReebNode *)arc1->head; + ReebNode *node2 = (ReebNode *)arc2->head; if (node1->weight < node2->weight) { @@ -1182,8 +1181,7 @@ static int compareArcsWeight(void *varc1, void *varc2) { return 1; } - else - { + else { return 0; } } @@ -1201,7 +1199,7 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight); int i; - node = (ReebNode*)BLI_otherNode((BArc*)arc, (BNode*)start_node); + node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node); /* prevent backtracking */ if (node->flag == 1) @@ -1243,7 +1241,7 @@ static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_we { int i; - BLI_flagNodes((BGraph*)rg, 0); + BLI_flagNodes((BGraph *)rg, 0); for (i = 0; i < start_node->degree; i++) { @@ -1317,15 +1315,15 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) if (merging) { - BLI_ReflagSubgraph((BGraph*)rg, end_node->flag, subgraph); + BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph); resizeArcBuckets(start_arc); fillArcEmptyBuckets(start_arc); NodeDegreeIncrement(rg, end_node); - BLI_rebuildAdjacencyListForNode((BGraph*)rg, (BNode*)end_node); + BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node); - BLI_removeNode((BGraph*)rg, (BNode*)start_node); + BLI_removeNode((BGraph *)rg, (BNode *)start_node); } joined = 1; @@ -1368,10 +1366,9 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) int nb_subgraphs; int joined = 0; - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); - if (BLI_isGraphCyclic((BGraph*)rg)) - { + if (BLI_isGraphCyclic((BGraph *)rg)) { /* don't deal with cyclic graphs YET */ return 0; } @@ -1379,13 +1376,13 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) /* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */ sortNodes(rg); - nb_subgraphs = BLI_FlagSubgraphs((BGraph*)rg); + nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg); /* Harmonic function can create flipped arcs, take the occasion to fix them */ // XXX // if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC) // { - fixSubgraphsOrientation(rg, nb_subgraphs); + fixSubgraphsOrientation(rg, nb_subgraphs); // } if (nb_subgraphs > 1) @@ -1395,7 +1392,7 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) if (joined) { removeNormalNodes(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); } } @@ -1407,8 +1404,8 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) static float lengthArc(ReebArc *arc) { #if 0 - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; return tail->weight - head->weight; #else @@ -1418,8 +1415,8 @@ static float lengthArc(ReebArc *arc) static int compareArcs(void *varc1, void *varc2) { - ReebArc *arc1 = (ReebArc*)varc1; - ReebArc *arc2 = (ReebArc*)varc2; + ReebArc *arc1 = (ReebArc *)varc1; + ReebArc *arc2 = (ReebArc *)varc2; float len1 = lengthArc(arc1); float len2 = lengthArc(arc2); @@ -1434,7 +1431,7 @@ static int compareArcs(void *varc1, void *varc2) } } -static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc * srcArc, int merging) +static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc *srcArc, int merging) { ReebArc *arc = NULL, *nextArc = NULL; @@ -1470,7 +1467,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R // If it's srcArc, it'll be removed later, so keep it for now if (arc != srcArc) { BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); } } else { @@ -1509,8 +1506,8 @@ void filterNullReebGraph(ReebGraph *rg) nextArc = arc->next; // Only collapse arcs too short to have any embed bucket if (arc->bcount == 0) { - ReebNode *newNode = (ReebNode*)arc->head; - ReebNode *removedNode = (ReebNode*)arc->tail; + ReebNode *newNode = (ReebNode *)arc->head; + ReebNode *removedNode = (ReebNode *)arc->tail; float blend; blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors @@ -1523,9 +1520,9 @@ void filterNullReebGraph(ReebGraph *rg) nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); } arc = nextArc; @@ -1561,9 +1558,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } @@ -1613,9 +1610,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } } @@ -1641,7 +1638,7 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold) NodeDegreeDecrement(rg, arc1->tail); BLI_remlink(&rg->arcs, arc2); - REEB_freeArc((BArc*)arc2); + REEB_freeArc((BArc *)arc2); filtered = 1; } @@ -1662,7 +1659,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) #ifdef DEBUG_REEB { EditFace *efa; - for (efa=G.editMesh->faces.first; efa; efa=efa->next) { + for (efa = G.editMesh->faces.first; efa; efa = efa->next) { efa->tmp.fp = -1; } } @@ -1686,14 +1683,14 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) float avg_vec[3] = {0, 0, 0}; for (BLI_ghashIterator_init(&ghi, arc->faces); - !BLI_ghashIterator_isDone(&ghi); - BLI_ghashIterator_step(&ghi)) + !BLI_ghashIterator_isDone(&ghi); + BLI_ghashIterator_step(&ghi)) { EditFace *efa = BLI_ghashIterator_getValue(&ghi); #if 0 ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; EmbedBucket *bucket = NULL; EmbedBucket *previous = NULL; float min_distance = -1; @@ -1716,8 +1713,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) vec0 = arc->head->p; } /* Previous is a valid bucket */ - else - { + else { vec0 = previous->p; } @@ -1805,7 +1801,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); BLI_freelinkN(&rg->nodes, removedNode); value = 1; @@ -1858,7 +1854,7 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method) { int i; - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); sortNodes(rg); @@ -1873,10 +1869,10 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method) /************************************** WEIGHT SPREADING ***********************************************/ -static int compareVerts(const void* a, const void* b) +static int compareVerts(const void *a, const void *b) { - EditVert *va = *(EditVert**)a; - EditVert *vb = *(EditVert**)b; + EditVert *va = *(EditVert **)a; + EditVert *vb = *(EditVert **)b; int value = 0; if (weightData(va) < weightData(vb)) { @@ -1897,7 +1893,7 @@ static void spreadWeight(EditMesh *em) int i; int work_needed = 1; - verts = MEM_callocN(sizeof(EditVert*) * totvert, "verts array"); + verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array"); for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) { verts[i] = eve; @@ -1905,7 +1901,7 @@ static void spreadWeight(EditMesh *em) while (work_needed == 1) { work_needed = 0; - qsort(verts, totvert, sizeof(EditVert*), compareVerts); + qsort(verts, totvert, sizeof(EditVert *), compareVerts); for (i = 0; i < totvert; i++) { eve = verts[i]; @@ -1976,7 +1972,7 @@ static void removeZeroNodes(ReebGraph *rg) next_node = node->next; if (node->degree == 0) { - BLI_removeNode((BGraph*)rg, (BNode*)node); + BLI_removeNode((BGraph *)rg, (BNode *)node); } } } @@ -1992,7 +1988,7 @@ void removeNormalNodes(ReebGraph *rg) while (arc->head->degree == 2 || arc->tail->degree == 2) { // merge at v1 if (arc->head->degree == 2) { - ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->head); + ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->head); /* If arcs are one after the other */ if (arc->head == connectedArc->tail) { @@ -2015,7 +2011,7 @@ void removeNormalNodes(ReebGraph *rg) /* merge at v2 */ if (arc->tail->degree == 2) { - ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->tail); + ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail); /* If arcs are one after the other */ if (arc->tail == connectedArc->head) { @@ -2073,8 +2069,8 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc) GHashIterator ghi; for (BLI_ghashIterator_init(&ghi, aSrc->faces); - !BLI_ghashIterator_isDone(&ghi); - BLI_ghashIterator_step(&ghi)) + !BLI_ghashIterator_isDone(&ghi); + BLI_ghashIterator_step(&ghi)) { EditFace *efa = BLI_ghashIterator_getValue(&ghi); BLI_ghash_insert(aDst->faces, efa, efa); @@ -2107,11 +2103,11 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d // if edge was the first in the list, point the edit edge to the new reeb edge instead. if (*p == e) { - *p = (void*)newEdge; + *p = (void *)newEdge; } // otherwise, advance in the list until the predecessor is found then insert it there else { - ReebEdge *previous = (ReebEdge*)*p; + ReebEdge *previous = (ReebEdge *)*p; while (previous->nextEdge != e) { previous = previous->nextEdge; @@ -2155,9 +2151,9 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) // remove a1 from graph BLI_remlink(&rg->arcs, a1); - REEB_freeArc((BArc*)a1); + REEB_freeArc((BArc *)a1); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); result = 1; return result; @@ -2183,7 +2179,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) // remove a1 from graph BLI_remlink(&rg->arcs, a1); - REEB_freeArc((BArc*)a1); + REEB_freeArc((BArc *)a1); result = 1; } else if (a0->tail->weight > a1->tail->weight) { /* a1->tail->weight is in the middle */ @@ -2266,9 +2262,9 @@ static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e else { a1 = nextArcMappedToEdge(a1, e1); } - } } } +} static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2) { @@ -2281,7 +2277,7 @@ static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2) glueByMergeSort(rg, a0, a2, e0, e2); } -static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) +static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) { ReebEdge *edge; @@ -2359,7 +2355,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) return edge; } -static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, ReebNode * n3, EditFace *efa) +static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNode *n3, EditFace *efa) { ReebEdge *re1, *re2, *re3; ReebEdge *e1, *e2, *e3; @@ -2408,7 +2404,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, Reeb mergePaths(rg, e1, e2, e3); } -ReebGraph * generateReebGraph(EditMesh *em, int subdivisions) +ReebGraph *generateReebGraph(EditMesh *em, int subdivisions) { ReebGraph *rg; EditVert *eve; @@ -2536,13 +2532,13 @@ static float cotan_weight(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - return dot_v3v3(a, b)/clen; + return dot_v3v3(a, b) / clen; } static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3) { /* Angle opposite e1 */ - float t1= cotan_weight(v1->co, v2->co, v3->co) / e2; + float t1 = cotan_weight(v1->co, v2->co, v3->co) / e2; /* Angle opposite e2 */ float t2 = cotan_weight(v2->co, v3->co, v1->co) / e3; @@ -2554,9 +2550,9 @@ static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2 int i2 = indexData(v2); int i3 = indexData(v3); - nlMatrixAdd(i1, i1, t2+t3); - nlMatrixAdd(i2, i2, t1+t3); - nlMatrixAdd(i3, i3, t1+t2); + nlMatrixAdd(i1, i1, t2 + t3); + nlMatrixAdd(i2, i2, t1 + t3); + nlMatrixAdd(i3, i3, t1 + t2); nlMatrixAdd(i1, i2, -t3); nlMatrixAdd(i2, i1, -t3); @@ -2688,7 +2684,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } -EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index) +EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index) { static int offset = -1; @@ -2712,7 +2708,7 @@ EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index) static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeIndex *indexed_edges) { - Heap *edge_heap; + Heap *edge_heap; EditVert *current_eve = NULL; EditEdge *eed = NULL; EditEdge *select_eed = NULL; @@ -2725,7 +2721,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd BLI_heap_insert(edge_heap, FLT_MAX, NULL); /* Initialize edge flag */ - for (eed= em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { eed->f1 = 0; } @@ -2744,8 +2740,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd } /* Find next shortest edge with unselected verts */ - do - { + do { current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap)); select_eed = BLI_heap_popmin(edge_heap); } while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1); @@ -2795,7 +2790,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) tot_indexed += totvert; - indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge*), "EdgeIndex edges"); + indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges"); /* setting vert offsets */ for (eve = em->verts.first; eve; eve = eve->next) { @@ -2807,7 +2802,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) } /* adding edges in array */ - for (eed = em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { int i; for (i = indexed_edges->offset[indexData(eed->v1)]; i < tot_indexed; i++) { @@ -2862,7 +2857,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) int allDone = 0; /* Calculate edge weight */ - for (eed = em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co); } @@ -2925,12 +2920,12 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) /****************************************** BUCKET ITERATOR **************************************************/ -static void* headNode(void *arg); -static void* tailNode(void *arg); -static void* nextBucket(void *arg); -static void* nextNBucket(void *arg, int n); -static void* peekBucket(void *arg, int n); -static void* previousBucket(void *arg); +static void *headNode(void *arg); +static void *tailNode(void *arg); +static void *nextBucket(void *arg); +static void *nextNBucket(void *arg, int n); +static void *peekBucket(void *arg, int n); +static void *previousBucket(void *arg); static int iteratorStopped(void *arg); static void initIteratorFct(ReebArcIterator *iter) @@ -2959,7 +2954,7 @@ static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket) void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -2982,7 +2977,7 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNode *head, int start) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -3009,7 +3004,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -3029,9 +3024,9 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end) iter->length = abs(iter->end - iter->start) + 1; } -static void* headNode(void *arg) +static void *headNode(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; if (iter->start < iter->end) { @@ -3048,9 +3043,9 @@ static void* headNode(void *arg) return node; } -static void* tailNode(void *arg) +static void *tailNode(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; if (iter->start < iter->end) { @@ -3067,9 +3062,9 @@ static void* tailNode(void *arg) return node; } -static void* nextBucket(void *arg) +static void *nextBucket(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; iter->index++; @@ -3082,9 +3077,9 @@ static void* nextBucket(void *arg) return result; } -static void* nextNBucket(void *arg, int n) +static void *nextNBucket(void *arg, int n) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; iter->index += n; @@ -3098,9 +3093,9 @@ static void* nextNBucket(void *arg, int n) return result; } -static void* peekBucket(void *arg, int n) +static void *peekBucket(void *arg, int n) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; int index = iter->index + n; @@ -3113,9 +3108,9 @@ static void* peekBucket(void *arg, int n) return result; } -static void* previousBucket(void *arg) +static void *previousBucket(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; if (iter->index > 0) { @@ -3129,7 +3124,7 @@ static void* previousBucket(void *arg) static int iteratorStopped(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; if (iter->index >= iter->length) { return 1; @@ -3148,7 +3143,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) #if 0 Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - EditMesh *em = BKE_mesh_get_editmesh(((Mesh*)obedit->data)); + EditMesh *em = BKE_mesh_get_editmesh(((Mesh *)obedit->data)); EdgeIndex indexed_edges; VertexData *data; ReebGraph *rg = NULL; @@ -3193,10 +3188,10 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) joinSubgraphs(rg, 1.0); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); /* calc length before copy, so we have same length on all levels */ - BLI_calcGraphLength((BGraph*)rg); + BLI_calcGraphLength((BGraph *)rg); previous = NULL; for (i = 0; i <= nb_levels; i++) @@ -3214,8 +3209,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) { internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal; } - else - { + else { internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels); } @@ -3231,7 +3225,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro); - BLI_markdownSymmetry((BGraph*)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit); if (previous != NULL) { @@ -3306,10 +3300,10 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) joinSubgraphs(rg, 1.0); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); /* calc length before copy, so we have same length on all levels */ - BLI_calcGraphLength((BGraph*)rg); + BLI_calcGraphLength((BGraph *)rg); filterGraph(rg, G.scene->toolsettings->skgen_options, G.scene->toolsettings->skgen_threshold_internal, G.scene->toolsettings->skgen_threshold_external); @@ -3323,7 +3317,7 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) #endif printf("DONE\n"); - printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph*)rg)); + printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph *)rg)); MEM_freeN(data); @@ -3363,13 +3357,12 @@ void REEB_draw() if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG) { - for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up); + for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ; } - else - { + else { i = G.scene->toolsettings->skgen_multi_level; - for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up); + for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ; } glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE)); @@ -3378,7 +3371,7 @@ void REEB_draw() for (arc = rg->arcs.first; arc; arc = arc->next, i++) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float vec[3]; char text[128]; char *s = text; @@ -3386,18 +3379,18 @@ void REEB_draw() glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2); glColor3f(0, 0, 0); glBegin(GL_LINE_STRIP); - glVertex3fv(arc->head->p); + glVertex3fv(arc->head->p); - if (arc->bcount) + if (arc->bcount) + { + initArcIterator(iter, arc, arc->head); + for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter)) { - initArcIterator(iter, arc, arc->head); - for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter)) - { - glVertex3fv(iter->p); - } + glVertex3fv(iter->p); } + } - glVertex3fv(arc->tail->p); + glVertex3fv(arc->tail->p); glEnd(); glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE)); @@ -3414,23 +3407,22 @@ void REEB_draw() { glColor3f(0.5f, 1, 0); } - else - { + else { glColor3f(1, 1, 0); } glBegin(GL_LINE_STRIP); - glVertex3fv(arc->head->p); + glVertex3fv(arc->head->p); - if (arc->bcount) + if (arc->bcount) + { + initArcIterator(iter, arc, arc->head); + for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) { - initArcIterator(iter, arc, arc->head); - for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) - { - glVertex3fv(iter->p); - } + glVertex3fv(iter->p); } + } - glVertex3fv(arc->tail->p); + glVertex3fv(arc->tail->p); glEnd(); @@ -3438,18 +3430,18 @@ void REEB_draw() { glColor3f(1, 1, 1); glBegin(GL_POINTS); - glVertex3fv(arc->head->p); - glVertex3fv(arc->tail->p); + glVertex3fv(arc->head->p); + glVertex3fv(arc->tail->p); - glColor3f(0.5f, 0.5f, 1); - if (arc->bcount) + glColor3f(0.5f, 0.5f, 1); + if (arc->bcount) + { + initArcIterator(iter, arc, arc->head); + for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) { - initArcIterator(iter, arc, arc->head); - for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) - { - glVertex3fv(iter->p); - } + glVertex3fv(iter->p); } + } glEnd(); } diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h index a9b32da4e5b..d71e80ca0ca 100644 --- a/source/blender/editors/armature/reeb.h +++ b/source/blender/editors/armature/reeb.h @@ -41,15 +41,15 @@ struct ReebEdge; struct ReebNode; typedef struct ReebGraph { - ListBase arcs; - ListBase nodes; + ListBase arcs; + ListBase nodes; float length; - FreeArc free_arc; - FreeNode free_node; - RadialSymmetry radial_symmetry; - AxialSymmetry axial_symmetry; + FreeArc free_arc; + FreeNode free_node; + RadialSymmetry radial_symmetry; + AxialSymmetry axial_symmetry; /*********************************/ int resolution; @@ -61,7 +61,7 @@ typedef struct ReebGraph { typedef struct EmbedBucket { float val; - int nv; + int nv; float p[3]; float no[3]; /* if non-null, normal of the bucket */ } EmbedBucket; @@ -85,7 +85,7 @@ typedef struct ReebNode { int index; float weight; - int multi_level; + int multi_level; struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */ struct ReebNode *link_up; } ReebNode; @@ -120,13 +120,13 @@ typedef struct ReebArc { } ReebArc; typedef struct ReebArcIterator { - HeadFct head; - TailFct tail; - PeekFct peek; - NextFct next; - NextNFct nextN; - PreviousFct previous; - StoppedFct stopped; + HeadFct head; + TailFct tail; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; float *p, *no; float size; @@ -134,7 +134,7 @@ typedef struct ReebArcIterator { int length; int index; /*********************************/ - struct ReebArc *arc; + struct ReebArc *arc; int start; int end; int stride; @@ -151,8 +151,8 @@ void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index); void angleToVCol(struct EditMesh *em, int index); void renormalizeWeight(struct EditMesh *em, float newmax); -ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions); -ReebGraph * newReebGraph(void); +ReebGraph *generateReebGraph(struct EditMesh *me, int subdivisions); +ReebGraph *newReebGraph(void); void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head); void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end); @@ -178,7 +178,7 @@ void verifyNodeDegree(ReebGraph *rg); /*********************** PUBLIC *********************************/ -#define REEB_MAX_MULTI_LEVEL 10 +#define REEB_MAX_MULTI_LEVEL 10 struct bContext; diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 94ec7c7ce93..dea7ccb161d 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -140,15 +140,15 @@ void ED_operatormacros_curve(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate curve and move"; + ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Extrude curve and move result"; + ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", + "Extrude curve and move result", OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 09c01c2bf8c..be10e3c4c3f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -29,7 +29,6 @@ * \ingroup edcurve */ - #include <math.h> #include <string.h> @@ -108,9 +107,9 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus); /* still need to eradicate a few :( */ -#define callocstructN(x, y, name) (x*)MEM_callocN((y)* sizeof(x), name) +#define callocstructN(x, y, name) (x *)MEM_callocN((y) * sizeof(x), name) -static float nurbcircle[8][2]= { +static float nurbcircle[8][2] = { {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0} }; @@ -118,7 +117,7 @@ static float nurbcircle[8][2]= { ListBase *object_editcurve_get(Object *ob) { if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) { - Curve *cu= ob->data; + Curve *cu = ob->data; return &cu->editnurb->nurbs; } return NULL; @@ -127,39 +126,39 @@ ListBase *object_editcurve_get(Object *ob) /* this replaces the active flag used in uv/face mode */ static void set_actNurb(Object *obedit, Nurb *nu) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; - if (nu==NULL) + if (nu == NULL) cu->actnu = -1; else { - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + ListBase *nurbs = BKE_curve_editNurbs_get(cu); cu->actnu = BLI_findindex(nurbs, nu); } } static Nurb *get_actNurb(Object *obedit) { - Curve *cu= obedit->data; - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + Curve *cu = obedit->data; + ListBase *nurbs = BKE_curve_editNurbs_get(cu); return BLI_findlink(nurbs, cu->actnu); } /* ******************* SELECTION FUNCTIONS ********************* */ -#define HIDDEN 1 -#define VISIBLE 0 +#define HIDDEN 1 +#define VISIBLE 0 -#define FIRST 1 -#define LAST 0 +#define FIRST 1 +#define LAST 0 /* returns 1 in case (de)selection was successful */ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden) { if (bezt) { - if ((bezt->hide==0) || (hidden==1)) { - if (selstatus==1) { /* selects */ + if ((bezt->hide == 0) || (hidden == 1)) { + if (selstatus == 1) { /* selects */ bezt->f1 |= flag; bezt->f2 |= flag; bezt->f3 |= flag; @@ -181,8 +180,8 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden) { if (bp) { - if ((bp->hide==0) || (hidden==1)) { - if (selstatus==1) { + if ((bp->hide == 0) || (hidden == 1)) { + if (selstatus == 1) { bp->f1 |= flag; return 1; } @@ -219,18 +218,18 @@ int isNurbsel(Nurb *nu) int a; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1; bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if ( (bp->f1 & SELECT) ) return 1; + if (bp->f1 & SELECT) return 1; bp++; } } @@ -241,19 +240,19 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) { BezTriple *bezt; BPoint *bp; - int a, sel=0; + int a, sel = 0; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++; bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if ( (bp->f1 & SELECT) ) sel++; bp++; @@ -266,19 +265,19 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) void printknots(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; int a, num; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu) && nu->type == CU_NURBS) { if (nu->knotsu) { - num= KNOTSU(nu); - for (a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]); + num = KNOTSU(nu); + for (a = 0; a < num; a++) printf("knotu %d: %f\n", a, nu->knotsu[a]); } if (nu->knotsv) { - num= KNOTSV(nu); - for (a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]); + num = KNOTSV(nu); + for (a = 0; a < num; a++) printf("knotv %d: %f\n", a, nu->knotsv[a]); } } } @@ -290,66 +289,66 @@ static CVKeyIndex *init_cvKeyIndex(void *cv, int key_index, int nu_index, int pt { CVKeyIndex *cvIndex = MEM_callocN(sizeof(CVKeyIndex), "init_cvKeyIndex"); - cvIndex->orig_cv= cv; - cvIndex->key_index= key_index; - cvIndex->nu_index= nu_index; - cvIndex->pt_index= pt_index; - cvIndex->switched= 0; - cvIndex->orig_nu= orig_nu; + cvIndex->orig_cv = cv; + cvIndex->key_index = key_index; + cvIndex->nu_index = nu_index; + cvIndex->pt_index = pt_index; + cvIndex->switched = 0; + cvIndex->orig_nu = orig_nu; return cvIndex; } static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase) { - Nurb *nu= editnurb->nurbs.first; - Nurb *orignu= origBase->first; + Nurb *nu = editnurb->nurbs.first; + Nurb *orignu = origBase->first; GHash *gh; BezTriple *bezt, *origbezt; BPoint *bp, *origbp; CVKeyIndex *keyIndex; - int a, key_index= 0, nu_index= 0, pt_index= 0; + int a, key_index = 0, nu_index = 0, pt_index = 0; if (editnurb->keyindex) return; - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex"); while (orignu) { if (orignu->bezt) { - a= orignu->pntsu; - bezt= nu->bezt; - origbezt= orignu->bezt; - pt_index= 0; + a = orignu->pntsu; + bezt = nu->bezt; + origbezt = orignu->bezt; + pt_index = 0; while (a--) { - keyIndex= init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu); + keyIndex = init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu); BLI_ghash_insert(gh, bezt, keyIndex); - key_index+= 12; + key_index += 12; bezt++; origbezt++; pt_index++; } } else { - a= orignu->pntsu * orignu->pntsv; - bp= nu->bp; - origbp= orignu->bp; - pt_index= 0; + a = orignu->pntsu * orignu->pntsv; + bp = nu->bp; + origbp = orignu->bp; + pt_index = 0; while (a--) { - keyIndex= init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu); + keyIndex = init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu); BLI_ghash_insert(gh, bp, keyIndex); - key_index+= 4; + key_index += 4; bp++; origbp++; pt_index++; } } - nu= nu->next; - orignu= orignu->next; + nu = nu->next; + orignu = orignu->next; nu_index++; } - editnurb->keyindex= gh; + editnurb->keyindex = gh; } static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv) @@ -359,29 +358,29 @@ static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv) static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, BezTriple *bezt) { - CVKeyIndex *index= getCVKeyIndex(editnurb, bezt); + CVKeyIndex *index = getCVKeyIndex(editnurb, bezt); if (!index) { return NULL; } - return (BezTriple*)index->orig_cv; + return (BezTriple *)index->orig_cv; } static BPoint *getKeyIndexOrig_bp(EditNurb *editnurb, BPoint *bp) { - CVKeyIndex *index= getCVKeyIndex(editnurb, bp); + CVKeyIndex *index = getCVKeyIndex(editnurb, bp); if (!index) { return NULL; } - return (BPoint*)index->orig_cv; + return (BPoint *)index->orig_cv; } static int getKeyIndexOrig_keyIndex(EditNurb *editnurb, void *cv) { - CVKeyIndex *index= getCVKeyIndex(editnurb, cv); + CVKeyIndex *index = getCVKeyIndex(editnurb, cv); if (!index) { return -1; @@ -418,38 +417,38 @@ static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu) } if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; while (a--) { BLI_ghash_remove(editnurb->keyindex, bezt, NULL, (GHashValFreeFP)MEM_freeN); - ++bezt; + bezt++; } } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { BLI_ghash_remove(editnurb->keyindex, bp, NULL, (GHashValFreeFP)MEM_freeN); - ++bp; + bp++; } } } static void keyIndex_delNurbList(EditNurb *editnurb, ListBase *nubase) { - Nurb *nu= nubase->first; + Nurb *nu = nubase->first; while (nu) { keyIndex_delNurb(editnurb, nu); - nu= nu->next; + nu = nu->next; } } static void keyIndex_updateCV(EditNurb *editnurb, char *cv, - char *newcv, int count, int size) + char *newcv, int count, int size) { int i; CVKeyIndex *index; @@ -460,7 +459,7 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv, } for (i = 0; i < count; i++) { - index= getCVKeyIndex(editnurb, cv); + index = getCVKeyIndex(editnurb, cv); BLI_ghash_remove(editnurb->keyindex, cv, NULL, NULL); @@ -474,15 +473,15 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv, } static void keyIndex_updateBezt(EditNurb *editnurb, BezTriple *bezt, - BezTriple *newbezt, int count) + BezTriple *newbezt, int count) { - keyIndex_updateCV(editnurb, (char*)bezt, (char*)newbezt, count, sizeof(BezTriple)); + keyIndex_updateCV(editnurb, (char *)bezt, (char *)newbezt, count, sizeof(BezTriple)); } static void keyIndex_updateBP(EditNurb *editnurb, BPoint *bp, - BPoint *newbp, int count) + BPoint *newbp, int count) { - keyIndex_updateCV(editnurb, (char*)bp, (char*)newbp, count, sizeof(BPoint)); + keyIndex_updateCV(editnurb, (char *)bp, (char *)newbp, count, sizeof(BPoint)); } static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu) @@ -497,8 +496,8 @@ static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu) static void keyIndex_swap(EditNurb *editnurb, void *a, void *b) { - CVKeyIndex *index1= getCVKeyIndex(editnurb, a); - CVKeyIndex *index2= getCVKeyIndex(editnurb, b); + CVKeyIndex *index1 = getCVKeyIndex(editnurb, a); + CVKeyIndex *index2 = getCVKeyIndex(editnurb, b); BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL); BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL); @@ -515,25 +514,25 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) if (nu->bezt) { BezTriple *bezt1, *bezt2; - a= nu->pntsu; + a = nu->pntsu; - bezt1= nu->bezt; - bezt2= bezt1+(a-1); + bezt1 = nu->bezt; + bezt2 = bezt1 + (a - 1); if (a & 1) ++a; - a/=2; + a /= 2; while (a--) { - index1= getCVKeyIndex(editnurb, bezt1); - index2= getCVKeyIndex(editnurb, bezt2); + index1 = getCVKeyIndex(editnurb, bezt1); + index2 = getCVKeyIndex(editnurb, bezt2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bezt1 != bezt2) { keyIndex_swap(editnurb, bezt1, bezt2); - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; } bezt1++; @@ -544,18 +543,18 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) BPoint *bp1, *bp2; if (nu->pntsv == 1) { - a= nu->pntsu; - bp1= nu->bp; - bp2= bp1+(a-1); - a/= 2; - while (bp1!=bp2 && a>0) { - index1= getCVKeyIndex(editnurb, bp1); - index2= getCVKeyIndex(editnurb, bp2); + a = nu->pntsu; + bp1 = nu->bp; + bp2 = bp1 + (a - 1); + a /= 2; + while (bp1 != bp2 && a > 0) { + index1 = getCVKeyIndex(editnurb, bp1); + index2 = getCVKeyIndex(editnurb, bp2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bp1 != bp2) { - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -568,21 +567,21 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) else { int b; - for (b=0; b<nu->pntsv; b++) { + for (b = 0; b < nu->pntsv; b++) { - bp1= nu->bp+b*nu->pntsu; - a= nu->pntsu; - bp2= bp1+(a-1); - a/= 2; + bp1 = &nu->bp[b * nu->pntsu]; + a = nu->pntsu; + bp2 = bp1 + (a - 1); + a /= 2; - while (bp1!=bp2 && a>0) { - index1= getCVKeyIndex(editnurb, bp1); - index2= getCVKeyIndex(editnurb, bp2); + while (bp1 != bp2 && a > 0) { + index1 = getCVKeyIndex(editnurb, bp1); + index2 = getCVKeyIndex(editnurb, bp2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bp1 != bp2) { - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -600,26 +599,26 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) static void switch_keys_direction(Curve *cu, Nurb *actnu) { KeyBlock *currkey; - EditNurb *editnurb= cu->editnurb; - ListBase *nubase= &editnurb->nurbs; + EditNurb *editnurb = cu->editnurb; + ListBase *nubase = &editnurb->nurbs; Nurb *nu; float *fp; int a; currkey = cu->key->block.first; while (currkey) { - fp= currkey->data; + fp = currkey->data; - nu= nubase->first; + nu = nubase->first; while (nu) { if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; if (nu == actnu) { while (a--) { if (getKeyIndexOrig_bezt(editnurb, bezt)) { swap_v3_v3(fp, fp + 6); - *(fp+9) = -*(fp+9); + *(fp + 9) = -*(fp + 9); fp += 12; } bezt++; @@ -628,12 +627,12 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) else fp += a * 12; } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; if (nu == actnu) { while (a--) { if (getKeyIndexOrig_bp(editnurb, bp)) { - *(fp+3) = -*(fp+3); + *(fp + 3) = -*(fp + 3); fp += 4; } bp++; @@ -642,16 +641,16 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) else fp += a * 4; } - nu= nu->next; + nu = nu->next; } - currkey= currkey->next; + currkey = currkey->next; } } static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu) { - EditNurb *editnurb= cu->editnurb; + EditNurb *editnurb = cu->editnurb; if (!editnurb->keyindex) { /* no shape keys - nothing to do */ @@ -668,11 +667,12 @@ static GHash *dupli_keyIndexHash(GHash *keyindex) GHash *gh; GHashIterator *hashIter; - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh"); for (hashIter = BLI_ghashIterator_new(keyindex); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter)) { + !BLI_ghashIterator_isDone(hashIter); + BLI_ghashIterator_step(hashIter)) + { void *cv = BLI_ghashIterator_getKey(hashIter); CVKeyIndex *index = BLI_ghashIterator_getValue(hashIter); CVKeyIndex *newIndex = MEM_callocN(sizeof(CVKeyIndex), "dupli_keyIndexHash index"); @@ -691,7 +691,7 @@ static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt) { memcpy(bezt, basebezt, sizeof(BezTriple)); memcpy(bezt->vec, key, sizeof(float) * 9); - bezt->alfa= key[9]; + bezt->alfa = key[9]; } static void bezt_to_key(BezTriple *bezt, float *key) @@ -704,31 +704,31 @@ static void calc_keyHandles(ListBase *nurb, float *key) { Nurb *nu; int a; - float *fp= key; + float *fp = key; BezTriple *bezt; - nu= nurb->first; + nu = nurb->first; while (nu) { if (nu->bezt) { BezTriple *prevp, *nextp; BezTriple cur, prev, next; float *startfp, *prevfp, *nextfp; - bezt= nu->bezt; - a= nu->pntsu; - startfp= fp; + bezt = nu->bezt; + a = nu->pntsu; + startfp = fp; if (nu->flagu & CU_NURB_CYCLIC) { - prevp= bezt+(a-1); - prevfp= fp+(12 * (a-1)); + prevp = bezt + (a - 1); + prevfp = fp + (12 * (a - 1)); } else { - prevp= NULL; - prevfp= NULL; + prevp = NULL; + prevfp = NULL; } - nextp= bezt + 1; - nextfp= fp + 12; + nextp = bezt + 1; + nextfp = fp + 12; while (a--) { key_to_bezt(fp, bezt, &cur); @@ -739,99 +739,99 @@ static void calc_keyHandles(ListBase *nurb, float *key) BKE_nurb_handle_calc(&cur, prevp ? &prev : NULL, nextp ? &next : NULL, 0); bezt_to_key(&cur, fp); - prevp= bezt; - prevfp= fp; - if (a==1) { + prevp = bezt; + prevfp = fp; + if (a == 1) { if (nu->flagu & CU_NURB_CYCLIC) { - nextp= nu->bezt; - nextfp= startfp; + nextp = nu->bezt; + nextfp = startfp; } else { - nextp= NULL; - nextfp= NULL; + nextp = NULL; + nextfp = NULL; } } else { - ++nextp; + nextp++; nextfp += 12; } - ++bezt; + bezt++; fp += 12; } } else { - a= nu->pntsu * nu->pntsv; + a = nu->pntsu * nu->pntsv; fp += a * 4; } - nu= nu->next; + nu = nu->next; } } static void calc_shapeKeys(Object *obedit) { - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; /* are there keys? */ if (cu->key) { int a, i; - EditNurb *editnurb= cu->editnurb; + EditNurb *editnurb = cu->editnurb; KeyBlock *currkey; - KeyBlock *actkey= BLI_findlink(&cu->key->block, editnurb->shapenr-1); + KeyBlock *actkey = BLI_findlink(&cu->key->block, editnurb->shapenr - 1); BezTriple *bezt, *oldbezt; BPoint *bp, *oldbp; Nurb *nu; - int totvert= BKE_nurbList_verts_count(&editnurb->nurbs); + int totvert = BKE_nurbList_verts_count(&editnurb->nurbs); float (*ofs)[3] = NULL; float *oldkey, *newkey, *ofp; /* editing the base key should update others */ - if (cu->key->type==KEY_RELATIVE) { + if (cu->key->type == KEY_RELATIVE) { int act_is_basis = 0; /* find if this key is a basis for any others */ - for (currkey = cu->key->block.first; currkey; currkey= currkey->next) { - if (editnurb->shapenr-1 == currkey->relative) { + for (currkey = cu->key->block.first; currkey; currkey = currkey->next) { + if (editnurb->shapenr - 1 == currkey->relative) { act_is_basis = 1; break; } } if (act_is_basis) { /* active key is a base */ - int totvec= 0; + int totvec = 0; /* Calculate needed memory to store offset */ - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; while (nu) { if (nu->bezt) { /* Three vects to store handles and one for alfa */ - totvec+= nu->pntsu * 4; + totvec += nu->pntsu * 4; } else { - totvec+= 2 * nu->pntsu * nu->pntsv; + totvec += 2 * nu->pntsu * nu->pntsv; } - nu= nu->next; + nu = nu->next; } - ofs= MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); - nu= editnurb->nurbs.first; - i= 0; + ofs = MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); + nu = editnurb->nurbs.first; + i = 0; while (nu) { if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); + oldbezt = getKeyIndexOrig_bezt(editnurb, bezt); if (oldbezt) { int j; - for (j= 0; j < 3; ++j) { + for (j = 0; j < 3; ++j) { sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]); i++; } - ofs[i++][0]= bezt->alfa - oldbezt->alfa; + ofs[i++][0] = bezt->alfa - oldbezt->alfa; } else { i += 4; @@ -840,81 +840,81 @@ static void calc_shapeKeys(Object *obedit) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - oldbp= getKeyIndexOrig_bp(editnurb, bp); + oldbp = getKeyIndexOrig_bp(editnurb, bp); if (oldbp) { sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec); - ofs[i+1][0]= bp->alfa - oldbp->alfa; + ofs[i + 1][0] = bp->alfa - oldbp->alfa; } i += 2; - ++bp; + bp++; } } - nu= nu->next; + nu = nu->next; } } } currkey = cu->key->block.first; while (currkey) { - int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr-1 == currkey->relative)); + int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr - 1 == currkey->relative)); - float *fp= newkey= MEM_callocN(cu->key->elemsize * totvert, "currkey->data"); - ofp= oldkey = currkey->data; + float *fp = newkey = MEM_callocN(cu->key->elemsize * totvert, "currkey->data"); + ofp = oldkey = currkey->data; - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; i = 0; while (nu) { if (currkey == actkey) { - int restore= actkey != cu->key->refkey; + int restore = actkey != cu->key->refkey; if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { int j; - oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); + oldbezt = getKeyIndexOrig_bezt(editnurb, bezt); - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, bezt->vec[j]); if (restore && oldbezt) { copy_v3_v3(bezt->vec[j], oldbezt->vec[j]); } - fp+= 3; + fp += 3; } - fp[0]= bezt->alfa; + fp[0] = bezt->alfa; if (restore && oldbezt) { - bezt->alfa= oldbezt->alfa; + bezt->alfa = oldbezt->alfa; } - fp+= 3; ++i;/* alphas */ - ++bezt; + fp += 3; ++i; /* alphas */ + bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - oldbp= getKeyIndexOrig_bp(editnurb, bp); + oldbp = getKeyIndexOrig_bp(editnurb, bp); copy_v3_v3(fp, bp->vec); - fp[3]= bp->alfa; + fp[3] = bp->alfa; if (restore && oldbp) { copy_v3_v3(bp->vec, oldbp->vec); - bp->alfa= oldbp->alfa; + bp->alfa = oldbp->alfa; } - fp+= 4; - ++bp; - i+=2; + fp += 4; + bp++; + i += 2; } } } @@ -924,77 +924,77 @@ static void calc_shapeKeys(Object *obedit) if (oldkey) { if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - index= getKeyIndexOrig_keyIndex(editnurb, bezt); + index = getKeyIndexOrig_keyIndex(editnurb, bezt); if (index >= 0) { int j; - curofp= ofp + index; + curofp = ofp + index; - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, curofp); if (apply_offset) { add_v3_v3(fp, ofs[i]); } - fp+= 3; curofp+= 3; + fp += 3; curofp += 3; } - fp[0]= curofp[0]; + fp[0] = curofp[0]; if (apply_offset) { /* apply alfa offsets */ add_v3_v3(fp, ofs[i]); - ++i; + i++; } - fp+= 3; /* alphas */ + fp += 3; /* alphas */ } else { int j; - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, bezt->vec[j]); - fp+= 3; + fp += 3; } - fp[0]= bezt->alfa; + fp[0] = bezt->alfa; - fp+= 3; /* alphas */ + fp += 3; /* alphas */ } - ++bezt; + bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - index= getKeyIndexOrig_keyIndex(editnurb, bp); + index = getKeyIndexOrig_keyIndex(editnurb, bp); if (index >= 0) { - curofp= ofp + index; + curofp = ofp + index; copy_v3_v3(fp, curofp); - fp[3]= curofp[3]; + fp[3] = curofp[3]; if (apply_offset) { add_v3_v3(fp, ofs[i]); - fp[3]+=ofs[i+1][0]; + fp[3] += ofs[i + 1][0]; } } else { copy_v3_v3(fp, bp->vec); - fp[3]= bp->alfa; + fp[3] = bp->alfa; } - fp+= 4; - ++bp; - i+=2; + fp += 4; + bp++; + i += 2; } } } } - nu= nu->next; + nu = nu->next; } if (apply_offset) { @@ -1002,11 +1002,11 @@ static void calc_shapeKeys(Object *obedit) calc_keyHandles(&editnurb->nurbs, newkey); } - currkey->totelem= totvert; + currkey->totelem = totvert; if (currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; - currkey= currkey->next; + currkey = currkey->next; } if (ofs) MEM_freeN(ofs); @@ -1017,7 +1017,7 @@ static void calc_shapeKeys(Object *obedit) static int curve_is_animated(Curve *cu) { - AnimData *ad= BKE_animdata_from_id(&cu->id); + AnimData *ad = BKE_animdata_from_id(&cu->id); return ad && (ad->action || ad->drivers.first); } @@ -1025,16 +1025,16 @@ static int curve_is_animated(Curve *cu) static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path, ListBase *orig_curves, ListBase *curves) { FCurve *fcu, *nfcu, *nextfcu; - int len= strlen(orig_rna_path); + int len = strlen(orig_rna_path); - fcu= orig_curves->first; + fcu = orig_curves->first; while (fcu) { - nextfcu= fcu->next; + nextfcu = fcu->next; if (!strncmp(fcu->rna_path, orig_rna_path, len)) { - char *spath, *suffix= fcu->rna_path + len; - nfcu= copy_fcurve(fcu); - spath= nfcu->rna_path; - nfcu->rna_path= BLI_sprintfN("%s%s", rna_path, suffix); + char *spath, *suffix = fcu->rna_path + len; + nfcu = copy_fcurve(fcu); + spath = nfcu->rna_path; + nfcu->rna_path = BLI_sprintfN("%s%s", rna_path, suffix); BLI_addtail(curves, nfcu); if (fcu->grp) { @@ -1050,13 +1050,13 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path MEM_freeN(spath); } - fcu= nextfcu; + fcu = nextfcu; } } static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) { - if (orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu); + if (orig_curves == &ad->drivers) BLI_remlink(&ad->drivers, fcu); else action_groups_remove_channel(ad->action, fcu); free_fcurve(fcu); @@ -1064,23 +1064,23 @@ static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) { - int nu_index= 0, a, pt_index; - EditNurb *editnurb= cu->editnurb; - Nurb *nu= editnurb->nurbs.first; + int nu_index = 0, a, pt_index; + EditNurb *editnurb = cu->editnurb; + Nurb *nu = editnurb->nurbs.first; CVKeyIndex *keyIndex; char rna_path[64], orig_rna_path[64]; - AnimData *ad= BKE_animdata_from_id(&cu->id); - ListBase curves= {NULL, NULL}; + AnimData *ad = BKE_animdata_from_id(&cu->id); + ListBase curves = {NULL, NULL}; FCurve *fcu, *next; while (nu) { if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; - pt_index= 0; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; + pt_index = 0; while (a--) { - keyIndex= getCVKeyIndex(editnurb, bezt); + keyIndex = getCVKeyIndex(editnurb, bezt); if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index); @@ -1098,8 +1098,8 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); - keyIndex->nu_index= nu_index; - keyIndex->pt_index= pt_index; + keyIndex->nu_index = nu_index; + keyIndex->pt_index = pt_index; } bezt++; @@ -1107,50 +1107,50 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; - pt_index= 0; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; + pt_index = 0; while (a--) { - keyIndex= getCVKeyIndex(editnurb, bp); + keyIndex = getCVKeyIndex(editnurb, bp); if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); - keyIndex->nu_index= nu_index; - keyIndex->pt_index= pt_index; + keyIndex->nu_index = nu_index; + keyIndex->pt_index = pt_index; } bp++; pt_index++; } } - nu= nu->next; + nu = nu->next; nu_index++; } /* remove paths for removed control points * need this to make further step with copying non-cv related curves copying * not touching cv's f-curves */ - for (fcu= orig_curves->first; fcu; fcu= next) { - next= fcu->next; + for (fcu = orig_curves->first; fcu; fcu = next) { + next = fcu->next; if (!strncmp(fcu->rna_path, "splines", 7)) { - char *ch= strchr(fcu->rna_path, '.'); + char *ch = strchr(fcu->rna_path, '.'); if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7))) fcurve_remove(ad, orig_curves, fcu); } } - nu_index= 0; - nu= editnurb->nurbs.first; + nu_index = 0; + nu = editnurb->nurbs.first; while (nu) { - keyIndex= NULL; + keyIndex = NULL; if (nu->pntsu) { - if (nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]); - else keyIndex= getCVKeyIndex(editnurb, &nu->bp[0]); + if (nu->bezt) keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]); + else keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]); } if (keyIndex) { @@ -1160,25 +1160,25 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } nu_index++; - nu= nu->next; + nu = nu->next; } /* the remainders in orig_curves can be copied back (like follow path) */ /* (if it's not path to spline) */ - for (fcu= orig_curves->first; fcu; fcu= next) { - next= fcu->next; + for (fcu = orig_curves->first; fcu; fcu = next) { + next = fcu->next; if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu); else BLI_addtail(&curves, fcu); } - *orig_curves= curves; + *orig_curves = curves; } /* return 0 if animation data wasn't changed, 1 otherwise */ int ED_curve_updateAnimPaths(Curve *cu) { - AnimData *ad= BKE_animdata_from_id(&cu->id); + AnimData *ad = BKE_animdata_from_id(&cu->id); if (!curve_is_animated(cu)) return 0; @@ -1195,19 +1195,19 @@ int ED_curve_updateAnimPaths(Curve *cu) /* load editNurb in object */ void load_editNurb(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); - if (obedit==NULL) return; + if (obedit == NULL) return; set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; Nurb *nu, *newnu; - ListBase newnurb= {NULL, NULL}, oldnurb= cu->nurb; + ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb; - for (nu= editnurb->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = editnurb->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); BLI_addtail(&newnurb, newnu); if (nu->type == CU_NURBS) { @@ -1215,7 +1215,7 @@ void load_editNurb(Object *obedit) } } - cu->nurb= newnurb; + cu->nurb = newnurb; calc_shapeKeys(obedit); ED_curve_updateAnimPaths(obedit->data); @@ -1229,16 +1229,16 @@ void load_editNurb(Object *obedit) /* make copy in cu->editnurb */ void make_editNurb(Object *obedit) { - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - Nurb *nu, *newnu, *nu_act= NULL; + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + Nurb *nu, *newnu, *nu_act = NULL; KeyBlock *actkey; set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - actkey= ob_get_keyblock(obedit); + actkey = ob_get_keyblock(obedit); if (actkey) { // XXX strcpy(G.editModeTitleExtra, "(Key) "); @@ -1249,31 +1249,31 @@ void make_editNurb(Object *obedit) if (editnurb) { BKE_nurbList_free(&editnurb->nurbs); BKE_curve_editNurb_keyIndex_free(editnurb); - editnurb->keyindex= NULL; + editnurb->keyindex = NULL; } else { - editnurb= MEM_callocN(sizeof(EditNurb), "editnurb"); - cu->editnurb= editnurb; + editnurb = MEM_callocN(sizeof(EditNurb), "editnurb"); + cu->editnurb = editnurb; } - nu= cu->nurb.first; - cu->lastsel= NULL; /* for select row */ + nu = cu->nurb.first; + cu->lastsel = NULL; /* for select row */ while (nu) { - newnu= BKE_nurb_duplicate(nu); - BKE_nurb_test2D(newnu); // after join, or any other creation of curve + newnu = BKE_nurb_duplicate(nu); + BKE_nurb_test2D(newnu); // after join, or any other creation of curve BLI_addtail(&editnurb->nurbs, newnu); if (nu_act == NULL && isNurbsel(nu)) { - nu_act= newnu; + nu_act = newnu; set_actNurb(obedit, newnu); } - nu= nu->next; + nu = nu->next; } if (actkey) - editnurb->shapenr= obedit->shapenr; + editnurb->shapenr = obedit->shapenr; /* animation could be added in editmode even if there was no animdata i * object mode hence we always need CVs index be created */ @@ -1283,14 +1283,14 @@ void make_editNurb(Object *obedit) void free_editNurb(Object *obedit) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; BKE_curve_editNurb_free(cu); } void CU_deselect_all(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { selectend_nurb(obedit, FIRST, 0, DESELECT); /* set first control points as unselected */ @@ -1300,7 +1300,7 @@ void CU_deselect_all(Object *obedit) void CU_select_all(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { selectend_nurb(obedit, FIRST, 0, SELECT); /* set first control points as unselected */ @@ -1310,25 +1310,25 @@ void CU_select_all(Object *obedit) void CU_select_swap(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - cu->lastsel= NULL; + cu->lastsel = NULL; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->hide==0) { + if (bezt->hide == 0) { bezt->f2 ^= SELECT; /* always do the center point */ - if ((cu->drawflag & CU_HIDE_HANDLES)==0) { + if ((cu->drawflag & CU_HIDE_HANDLES) == 0) { bezt->f1 ^= SELECT; bezt->f3 ^= SELECT; } @@ -1337,8 +1337,8 @@ void CU_select_swap(Object *obedit) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { swap_selection_bpoint(bp); bp++; @@ -1352,18 +1352,18 @@ void CU_select_swap(Object *obedit) static int separate_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Nurb *nu, *nu1; Object *oldob, *newob; Base *oldbase, *newbase; Curve *oldcu, *newcu; EditNurb *oldedit, *newedit; - oldbase= CTX_data_active_base(C); - oldob= oldbase->object; - oldcu= oldob->data; - oldedit= oldcu->editnurb; + oldbase = CTX_data_active_base(C); + oldob = oldbase->object; + oldcu = oldob->data; + oldedit = oldcu->editnurb; if (oldcu->key) { BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys"); @@ -1373,23 +1373,23 @@ static int separate_exec(bContext *C, wmOperator *op) WM_cursor_wait(1); /* 1. duplicate the object and data */ - newbase= ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ + newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ ED_base_object_select(newbase, BA_DESELECT); - newob= newbase->object; + newob = newbase->object; - newcu= newob->data= BKE_curve_copy(oldcu); - newcu->editnurb= NULL; + newcu = newob->data = BKE_curve_copy(oldcu); + newcu->editnurb = NULL; oldcu->id.us--; /* because new curve is a copy: reduce user count */ /* 2. put new object in editmode and clear it */ make_editNurb(newob); - newedit= newcu->editnurb; + newedit = newcu->editnurb; BKE_nurbList_free(&newedit->nurbs); BKE_curve_editNurb_keyIndex_free(newedit); /* 3. move over parts from old object */ - for (nu= oldedit->nurbs.first; nu; nu=nu1) { - nu1= nu->next; + for (nu = oldedit->nurbs.first; nu; nu = nu1) { + nu1 = nu->next; if (isNurbsel(nu)) { BLI_remlink(&oldedit->nurbs, nu); @@ -1401,10 +1401,10 @@ static int separate_exec(bContext *C, wmOperator *op) load_editNurb(newob); free_editNurb(newob); - DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ - DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ + DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ + DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ - WM_event_add_notifier(C, NC_GEOM|ND_DATA, oldob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data); WM_cursor_wait(0); @@ -1423,7 +1423,7 @@ void CURVE_OT_separate(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* FLAGS ********************* */ @@ -1436,36 +1436,36 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag) BPoint *bp; int a, b, sel; - *u= *v= -1; + *u = *v = -1; - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { - sel= 0; - for (a=0; a<nu->pntsu; a++, bp++) { + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + sel = 0; + for (a = 0; a < nu->pntsu; a++, bp++) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsu) { - if (*u== -1) *u= b; + if (sel == nu->pntsu) { + if (*u == -1) *u = b; else return 0; } - else if (sel>1) return 0; /* because sel==1 is still ok */ + else if (sel > 1) return 0; /* because sel==1 is still ok */ } - for (a=0; a<nu->pntsu; a++) { - sel= 0; - bp= nu->bp+a; - for (b=0; b<nu->pntsv; b++, bp+=nu->pntsu) { + for (a = 0; a < nu->pntsu; a++) { + sel = 0; + bp = &nu->bp[a]; + for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsv) { - if (*v== -1) *v= a; + if (sel == nu->pntsv) { + if (*v == -1) *v = a; else return 0; } - else if (sel>1) return 0; + else if (sel > 1) return 0; } - if (*u==-1 && *v>-1) return 1; - if (*v==-1 && *u>-1) return 1; + if (*u == -1 && *v > -1) return 1; + if (*v == -1 && *u > -1) return 1; return 0; } @@ -1476,20 +1476,20 @@ static void setflagsNurb(ListBase *editnurb, short flag) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - bezt->f1= bezt->f2= bezt->f3= flag; + bezt->f1 = bezt->f2 = bezt->f3 = flag; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->f1= flag; + bp->f1 = flag; bp++; } } @@ -1503,10 +1503,10 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_NURBS) { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & flag) { @@ -1528,10 +1528,10 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3] BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { if (bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec); if (bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec); @@ -1540,8 +1540,8 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3] } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (bp->f1 & flag) add_v3_v3(bp->vec, vec); bp++; @@ -1558,14 +1558,14 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_NURBS) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (bp->f1 & flag) { /* a mode used to exist for replace/multiple but is was unused */ - bp->vec[3]*= w; + bp->vec[3] *= w; } bp++; } @@ -1575,102 +1575,100 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w) static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu, *next; BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if (obedit->type==OB_SURF); + if (obedit->type == OB_SURF) ; else return OPERATOR_CANCELLED; - cu->lastsel= NULL; + cu->lastsel = NULL; - nu= editnurb->first; + nu = editnurb->first; while (nu) { - next= nu->next; + next = nu->next; /* is entire nurb selected */ - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a) { a--; - if (bp->f1 & flag); + if (bp->f1 & flag) ; else break; bp++; } - if (a==0) { + if (a == 0) { BLI_remlink(editnurb, nu); keyIndex_delNurb(cu->editnurb, nu); - BKE_nurb_free(nu); nu=NULL; + BKE_nurb_free(nu); nu = NULL; } else { /* is nurb in U direction selected */ - newv= nu->pntsv; - bp= nu->bp; - for (b=0; b<nu->pntsv; b++) { - sel= 0; - for (a=0; a<nu->pntsu; a++, bp++) { + newv = nu->pntsv; + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + sel = 0; + for (a = 0; a < nu->pntsu; a++, bp++) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsu) { + if (sel == nu->pntsu) { newv--; } - else if (sel>=1) { + else if (sel >= 1) { /* don't delete */ break; } } - if (newv!=nu->pntsv && b==nu->pntsv) { + if (newv != nu->pntsv && b == nu->pntsv) { /* delete */ - bp= nu->bp; - bpn = newbp = - (BPoint*) MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); - for (b=0; b<nu->pntsv; b++) { - if ((bp->f1 & flag)==0) { - memcpy(bpn, bp, nu->pntsu*sizeof(BPoint)); + bp = nu->bp; + bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); + for (b = 0; b < nu->pntsv; b++) { + if ((bp->f1 & flag) == 0) { + memcpy(bpn, bp, nu->pntsu * sizeof(BPoint)); keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu); - bpn+= nu->pntsu; + bpn += nu->pntsu; } else { keyIndex_delBP(cu->editnurb, bp); } - bp+= nu->pntsu; + bp += nu->pntsu; } - nu->pntsv= newv; + nu->pntsv = newv; MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; BKE_nurb_order_clamp_v(nu); BKE_nurb_knot_calc_v(nu); } else { /* is the nurb in V direction selected */ - newu= nu->pntsu; - for (a=0; a<nu->pntsu; a++) { - bp= nu->bp+a; - sel= 0; - for (b=0; b<nu->pntsv; b++, bp+=nu->pntsu) { + newu = nu->pntsu; + for (a = 0; a < nu->pntsu; a++) { + bp = &nu->bp[a]; + sel = 0; + for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsv) { + if (sel == nu->pntsv) { newu--; } - else if (sel>=1) { + else if (sel >= 1) { /* don't delete */ break; } } - if (newu!=nu->pntsu && a==nu->pntsu) { + if (newu != nu->pntsu && a == nu->pntsu) { /* delete */ - bp= nu->bp; - bpn = newbp = - (BPoint*) MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); - for (b=0; b<nu->pntsv; b++) { - for (a=0; a<nu->pntsu; a++, bp++) { - if ((bp->f1 & flag)==0) { - *bpn= *bp; + bp = nu->bp; + bpn = newbp = (BPoint *)MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); + for (b = 0; b < nu->pntsv; b++) { + for (a = 0; a < nu->pntsu; a++, bp++) { + if ((bp->f1 & flag) == 0) { + *bpn = *bp; keyIndex_updateBP(cu->editnurb, bp, bpn, 1); bpn++; } @@ -1680,28 +1678,28 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) } } MEM_freeN(nu->bp); - nu->bp= newbp; - if (newu==1 && nu->pntsv>1) { /* make a U spline */ - nu->pntsu= nu->pntsv; - nu->pntsv= 1; + nu->bp = newbp; + if (newu == 1 && nu->pntsv > 1) { /* make a U spline */ + nu->pntsu = nu->pntsv; + nu->pntsv = 1; SWAP(short, nu->orderu, nu->orderv); BKE_nurb_order_clamp_u(nu); if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + nu->knotsv = NULL; } else { - nu->pntsu= newu; + nu->pntsu = newu; BKE_nurb_order_clamp_u(nu); } BKE_nurb_knot_calc_u(nu); } } } - nu= next; + nu = next; } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); return OPERATOR_FINISHED; } @@ -1711,30 +1709,29 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) { Nurb *nu; BPoint *bp, *bpn, *newbp; - int ok= 0, a, u, v, len; + int ok = 0, a, u, v, len; - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; while (nu) { - if (nu->pntsv==1) { - bp= nu->bp; - a= nu->pntsu; + if (nu->pntsv == 1) { + bp = nu->bp; + a = nu->pntsu; while (a) { - if (bp->f1 & flag); + if (bp->f1 & flag) ; else break; bp++; a--; } - if (a==0) { - ok= 1; - newbp = - (BPoint*)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1"); + if (a == 0) { + ok = 1; + newbp = (BPoint *)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1"); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - bp= newbp+ nu->pntsu; + bp = newbp + nu->pntsu; ED_curve_bpcpy(editnurb, bp, nu->bp, nu->pntsu); MEM_freeN(nu->bp); - nu->bp= newbp; - a= nu->pntsu; + nu->bp = newbp; + a = nu->pntsu; while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); select_bpoint(newbp, DESELECT, flag, HIDDEN); @@ -1742,83 +1739,81 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) newbp++; } - nu->pntsv= 2; - nu->orderv= 2; + nu->pntsv = 2; + nu->orderv = 2; BKE_nurb_knot_calc_v(nu); } } else { /* which row or column is selected */ - if ( isNurbselUV(nu, &u, &v, flag) ) { + if (isNurbselUV(nu, &u, &v, flag) ) { /* deselect all */ - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { select_bpoint(bp, DESELECT, flag, HIDDEN); bp++; } - if (u==0 || u== nu->pntsv-1) { /* row in u-direction selected */ - ok= 1; - newbp = - (BPoint*) MEM_mallocN(nu->pntsu*(nu->pntsv + 1) - * sizeof(BPoint), "extrudeNurb1"); - if (u==0) { - len= nu->pntsv*nu->pntsu; - ED_curve_bpcpy(editnurb, newbp+nu->pntsu, nu->bp, len); + if (u == 0 || u == nu->pntsv - 1) { /* row in u-direction selected */ + ok = 1; + newbp = (BPoint *)MEM_mallocN(nu->pntsu * (nu->pntsv + 1) * + sizeof(BPoint), "extrudeNurb1"); + if (u == 0) { + len = nu->pntsv * nu->pntsu; + ED_curve_bpcpy(editnurb, newbp + nu->pntsu, nu->bp, len); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - bp= newbp; + bp = newbp; } else { - len= nu->pntsv*nu->pntsu; + len = nu->pntsv * nu->pntsu; ED_curve_bpcpy(editnurb, newbp, nu->bp, len); - ED_curve_bpcpy(editnurb, newbp+len, nu->bp+len-nu->pntsu, nu->pntsu); - bp= newbp+len; + ED_curve_bpcpy(editnurb, newbp + len, &nu->bp[len - nu->pntsu], nu->pntsu); + bp = newbp + len; } - a= nu->pntsu; + a = nu->pntsu; while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); bp++; } MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; nu->pntsv++; BKE_nurb_knot_calc_v(nu); } - else if (v==0 || v== nu->pntsu-1) { /* column in v-direction selected */ - ok= 1; - bpn = newbp = - (BPoint*) MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); - bp= nu->bp; - - for (a=0; a<nu->pntsv; a++) { - if (v==0) { - *bpn= *bp; + else if (v == 0 || v == nu->pntsu - 1) { /* column in v-direction selected */ + ok = 1; + bpn = newbp = (BPoint *)MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); + bp = nu->bp; + + for (a = 0; a < nu->pntsv; a++) { + if (v == 0) { + *bpn = *bp; bpn->f1 |= flag; bpn++; } ED_curve_bpcpy(editnurb, bpn, bp, nu->pntsu); - bp+= nu->pntsu; - bpn+= nu->pntsu; - if (v== nu->pntsu-1) { - *bpn= *(bp-1); + bp += nu->pntsu; + bpn += nu->pntsu; + if (v == nu->pntsu - 1) { + *bpn = *(bp - 1); bpn->f1 |= flag; bpn++; } } MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; nu->pntsu++; BKE_nurb_knot_calc_u(nu); } } } - nu= nu->next; + nu = nu->next; } return ok; @@ -1826,49 +1821,48 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) static void adduplicateflagNurb(Object *obedit, short flag) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu, *newnu; BezTriple *bezt, *bezt1; BPoint *bp, *bp1; - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; int a, b, starta, enda, newu, newv; char *usel; - cu->lastsel= NULL; + cu->lastsel = NULL; - nu= editnurb->last; + nu = editnurb->last; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - for (a=0; a<nu->pntsu; a++) { - enda= -1; - starta= a; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu; a++) { + enda = -1; + starta = a; while ( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) { select_beztriple(bezt, DESELECT, flag, HIDDEN); - enda=a; - if (a>=nu->pntsu-1) break; + enda = a; + if (a >= nu->pntsu - 1) break; a++; bezt++; } - if (enda>=starta) { - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN"); + if (enda >= starta) { + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(editnurb, newnu); set_actNurb(obedit, newnu); - newnu->pntsu= enda-starta+1; - newnu->bezt= - (BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN"); - memcpy(newnu->bezt, nu->bezt+starta, newnu->pntsu*sizeof(BezTriple)); + newnu->pntsu = enda - starta + 1; + newnu->bezt = (BezTriple *)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN"); + memcpy(newnu->bezt, &nu->bezt[starta], newnu->pntsu * sizeof(BezTriple)); - b= newnu->pntsu; - bezt1= newnu->bezt; + b = newnu->pntsu; + bezt1 = newnu->bezt; while (b--) { select_beztriple(bezt1, SELECT, flag, HIDDEN); bezt1++; } if (nu->flagu & CU_NURB_CYCLIC) { - if (starta!=0 || enda!=nu->pntsu-1) { + if (starta != 0 || enda != nu->pntsu - 1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } @@ -1876,42 +1870,42 @@ static void adduplicateflagNurb(Object *obedit, short flag) bezt++; } } - else if (nu->pntsv==1) { /* because UV Nurb has a different method for dupli */ - bp= nu->bp; - for (a=0; a<nu->pntsu; a++) { - enda= -1; - starta= a; + else if (nu->pntsv == 1) { /* because UV Nurb has a different method for dupli */ + bp = nu->bp; + for (a = 0; a < nu->pntsu; a++) { + enda = -1; + starta = a; while (bp->f1 & flag) { select_bpoint(bp, DESELECT, flag, HIDDEN); - enda= a; - if (a>=nu->pntsu-1) break; + enda = a; + if (a >= nu->pntsu - 1) break; a++; bp++; } - if (enda>=starta) { - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3"); + if (enda >= starta) { + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN3"); memcpy(newnu, nu, sizeof(Nurb)); set_actNurb(obedit, newnu); BLI_addtail(editnurb, newnu); - newnu->pntsu= enda-starta+1; - newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4"); - memcpy(newnu->bp, nu->bp+starta, newnu->pntsu*sizeof(BPoint)); + newnu->pntsu = enda - starta + 1; + newnu->bp = (BPoint *)MEM_mallocN((enda - starta + 1) * sizeof(BPoint), "adduplicateN4"); + memcpy(newnu->bp, &nu->bp[starta], newnu->pntsu * sizeof(BPoint)); - b= newnu->pntsu; - bp1= newnu->bp; + b = newnu->pntsu; + bp1 = newnu->bp; while (b--) { select_bpoint(bp1, SELECT, flag, HIDDEN); bp1++; } if (nu->flagu & CU_NURB_CYCLIC) { - if (starta!=0 || enda!=nu->pntsu-1) { + if (starta != 0 || enda != nu->pntsu - 1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } /* knots */ - newnu->knotsu= NULL; + newnu->knotsu = NULL; BKE_nurb_knot_calc_u(newnu); } bp++; @@ -1920,52 +1914,51 @@ static void adduplicateflagNurb(Object *obedit, short flag) else { /* a rectangular area in nurb has to be selected */ if (isNurbsel(nu)) { - usel= MEM_callocN(nu->pntsu, "adduplicateN4"); - bp= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++, bp++) { + usel = MEM_callocN(nu->pntsu, "adduplicateN4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp++) { if (bp->f1 & flag) usel[b]++; } } - newu= 0; - newv= 0; - for (a=0; a<nu->pntsu; a++) { + newu = 0; + newv = 0; + for (a = 0; a < nu->pntsu; a++) { if (usel[a]) { - if (newv==0 || usel[a]==newv) { - newv= usel[a]; + if (newv == 0 || usel[a] == newv) { + newv = usel[a]; newu++; } else { - newv= 0; + newv = 0; break; } } } - if (newu==0 || newv==0) { + if (newu == 0 || newv == 0) { if (G.debug & G_DEBUG) printf("Can't duplicate Nurb\n"); } else { - if (newu==1) SWAP(short, newu, newv); + if (newu == 1) SWAP(short, newu, newv); - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(editnurb, newnu); set_actNurb(obedit, newnu); - newnu->pntsu= newu; - newnu->pntsv= newv; - newnu->bp = - (BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6"); + newnu->pntsu = newu; + newnu->pntsv = newv; + newnu->bp = (BPoint *)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6"); BKE_nurb_order_clamp_u(newnu); BKE_nurb_order_clamp_v(newnu); - newnu->knotsu= newnu->knotsv= NULL; + newnu->knotsu = newnu->knotsv = NULL; - bp= newnu->bp; - bp1= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++, bp1++) { + bp = newnu->bp; + bp1 = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp1++) { if (bp1->f1 & flag) { memcpy(bp, bp1, sizeof(BPoint)); select_bpoint(bp1, DESELECT, flag, HIDDEN); @@ -1974,16 +1967,16 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } if (BKE_nurb_check_valid_u(newnu)) { - if (nu->pntsu==newnu->pntsu && nu->knotsu) { - newnu->knotsu= MEM_dupallocN(nu->knotsu); + if (nu->pntsu == newnu->pntsu && nu->knotsu) { + newnu->knotsu = MEM_dupallocN(nu->knotsu); } else { BKE_nurb_knot_calc_u(newnu); } } if (BKE_nurb_check_valid_v(newnu)) { - if (nu->pntsv==newnu->pntsv && nu->knotsv) { - newnu->knotsv= MEM_dupallocN(nu->knotsv); + if (nu->pntsv == newnu->pntsv && nu->knotsv) { + newnu->knotsv = MEM_dupallocN(nu->knotsv); } else { BKE_nurb_knot_calc_v(newnu); @@ -1994,7 +1987,7 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } - nu= nu->prev; + nu = nu->prev; } /* actnu changed */ @@ -2004,22 +1997,22 @@ static void adduplicateflagNurb(Object *obedit, short flag) static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; - for (nu= editnurb->nurbs.first; nu; nu= nu->next) + for (nu = editnurb->nurbs.first; nu; nu = nu->next) if (isNurbsel(nu)) { BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -2036,38 +2029,38 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************** set weight operator *******************/ static int set_goal_weight_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - float weight= RNA_float_get(op->ptr, "weight"); + float weight = RNA_float_get(op->ptr, "weight"); int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) { + for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) - bezt->weight= weight; + bezt->weight = weight; } } else if (nu->bp) { - for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) { + for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { if (bp->f1 & SELECT) - bp->weight= weight; + bp->weight = weight; } } } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -2085,7 +2078,7 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_factor(ot->srna, "weight", 1.0f, 0.0f, 1.0f, "Weight", "", 0.0f, 1.0f); @@ -2095,30 +2088,30 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) static int set_radius_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - float radius= RNA_float_get(op->ptr, "radius"); + float radius = RNA_float_get(op->ptr, "radius"); int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (bezt=nu->bezt, a=0; a<nu->pntsu; a++, bezt++) { + for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) - bezt->radius= radius; + bezt->radius = radius; } } else if (nu->bp) { - for (bp=nu->bp, a=0; a<nu->pntsu*nu->pntsv; a++, bp++) { + for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { if (bp->f1 & SELECT) - bp->radius= radius; + bp->radius = radius; } } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2137,7 +2130,7 @@ void CURVE_OT_radius_set(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "radius", 1.0f, 0.0f, FLT_MAX, "Radius", "", 0.0001f, 10.0f); @@ -2147,24 +2140,24 @@ void CURVE_OT_radius_set(wmOperatorType *ot) static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt, *beztOrig; BPoint *bp, *bpOrig; float val, newval, offset; int a, i, change = 0; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { change = 0; beztOrig = MEM_dupallocN(nu->bezt); - for (bezt=nu->bezt+1, a=1; a<nu->pntsu-1; a++, bezt++) { + for (bezt = &nu->bezt[1], a = 1; a < nu->pntsu - 1; a++, bezt++) { if (bezt->f2 & SELECT) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { val = bezt->vec[1][i]; - newval = ((beztOrig+(a-1))->vec[1][i] * 0.5f) + ((beztOrig+(a+1))->vec[1][i] * 0.5f); - offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; + newval = ((beztOrig + (a - 1))->vec[1][i] * 0.5f) + ((beztOrig + (a + 1))->vec[1][i] * 0.5f); + offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; /* offset handles */ bezt->vec[1][i] += offset; bezt->vec[0][i] += offset; @@ -2180,12 +2173,12 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) else if (nu->bp) { bpOrig = MEM_dupallocN(nu->bp); /* Same as above, keep these the same! */ - for (bp=nu->bp+1, a=1; a<nu->pntsu-1; a++, bp++) { + for (bp = &nu->bp[1], a = 1; a < nu->pntsu - 1; a++, bp++) { if (bp->f1 & SELECT) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { val = bp->vec[i]; - newval = ((bpOrig+(a-1))->vec[i] * 0.5f) + ((bpOrig+(a+1))->vec[i] * 0.5f); - offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; + newval = ((bpOrig + (a - 1))->vec[i] * 0.5f) + ((bpOrig + (a + 1))->vec[i] * 0.5f); + offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; bp->vec[i] += offset; } @@ -2195,7 +2188,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2213,7 +2206,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /**************** smooth curve radius operator *************/ @@ -2221,8 +2214,8 @@ void CURVE_OT_smooth(wmOperatorType *ot) /* TODO, make smoothing distance based */ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; @@ -2233,15 +2226,15 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) int start_sel, end_sel; /* selection indices, inclusive */ float start_rad, end_rad, fac, range; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (last_sel=0; last_sel < nu->pntsu; last_sel++) { + for (last_sel = 0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for (bezt=nu->bezt+last_sel, a=last_sel; a<nu->pntsu; a++, bezt++) { + for (bezt = &nu->bezt[last_sel], a = last_sel; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) { start_sel = a; break; @@ -2249,8 +2242,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } /* in case there are no other selected verts */ end_sel = start_sel; - for (bezt=nu->bezt+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bezt++) { - if ((bezt->f2 & SELECT)==0) { + for (bezt = &nu->bezt[start_sel + 1], a = start_sel + 1; a < nu->pntsu; a++, bezt++) { + if ((bezt->f2 & SELECT) == 0) { break; } end_sel = a; @@ -2267,35 +2260,35 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == end_sel) { /* simple, only 1 point selected */ - if (start_sel>0) start_rad = (nu->bezt+start_sel-1)->radius; - if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bezt+start_sel+1)->radius; + if (start_sel > 0) start_rad = nu->bezt[start_sel - 1].radius; + if (end_sel != -1 && end_sel < nu->pntsu) end_rad = nu->bezt[start_sel + 1].radius; - if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0f) (nu->bezt+start_sel)->radius = start_rad; - else if (end_rad >= 0.0f) (nu->bezt+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) nu->bezt[start_sel].radius = (start_rad + end_rad) / 2.0f; + else if (start_rad >= 0.0f) nu->bezt[start_sel].radius = start_rad; + else if (end_rad >= 0.0f) nu->bezt[start_sel].radius = end_rad; } else { /* if endpoints selected, then use them */ - if (start_sel==0) { - start_rad = (nu->bezt+start_sel)->radius; + if (start_sel == 0) { + start_rad = nu->bezt[start_sel].radius; start_sel++; /* we don't want to edit the selected endpoint */ } else { - start_rad = (nu->bezt+start_sel-1)->radius; + start_rad = nu->bezt[start_sel - 1].radius; } - if (end_sel==nu->pntsu-1) { - end_rad = (nu->bezt+end_sel)->radius; + if (end_sel == nu->pntsu - 1) { + end_rad = nu->bezt[end_sel].radius; end_sel--; /* we don't want to edit the selected endpoint */ } else { - end_rad = (nu->bezt+end_sel+1)->radius; + end_rad = nu->bezt[end_sel + 1].radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for (bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) { - fac = (float)(1+a-start_sel) / range; - bezt->radius = start_rad*(1.0f-fac) + end_rad*fac; + for (bezt = &nu->bezt[start_sel], a = start_sel; a <= end_sel; a++, bezt++) { + fac = (float)(1 + a - start_sel) / range; + bezt->radius = start_rad * (1.0f - fac) + end_rad * fac; } } } @@ -2303,12 +2296,12 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } else if (nu->bp) { /* Same as above, keep these the same! */ - for (last_sel=0; last_sel < nu->pntsu; last_sel++) { + for (last_sel = 0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for (bp=nu->bp+last_sel, a=last_sel; a<nu->pntsu; a++, bp++) { + for (bp = &nu->bp[last_sel], a = last_sel; a < nu->pntsu; a++, bp++) { if (bp->f1 & SELECT) { start_sel = a; break; @@ -2316,8 +2309,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } /* in case there are no other selected verts */ end_sel = start_sel; - for (bp=nu->bp+(start_sel+1), a=start_sel+1; a<nu->pntsu; a++, bp++) { - if ((bp->f1 & SELECT)==0) { + for (bp = &nu->bp[start_sel + 1], a = start_sel + 1; a < nu->pntsu; a++, bp++) { + if ((bp->f1 & SELECT) == 0) { break; } end_sel = a; @@ -2334,35 +2327,35 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == end_sel) { /* simple, only 1 point selected */ - if (start_sel>0) start_rad = (nu->bp+start_sel-1)->radius; - if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bp+start_sel+1)->radius; + if (start_sel > 0) start_rad = nu->bp[start_sel - 1].radius; + if (end_sel != -1 && end_sel < nu->pntsu) end_rad = nu->bp[start_sel + 1].radius; - if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0f) (nu->bp+start_sel)->radius = start_rad; - else if (end_rad >= 0.0f) (nu->bp+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) nu->bp[start_sel].radius = (start_rad + end_rad) / 2; + else if (start_rad >= 0.0f) nu->bp[start_sel].radius = start_rad; + else if (end_rad >= 0.0f) nu->bp[start_sel].radius = end_rad; } else { /* if endpoints selected, then use them */ - if (start_sel==0) { - start_rad = (nu->bp+start_sel)->radius; + if (start_sel == 0) { + start_rad = nu->bp[start_sel].radius; start_sel++; /* we don't want to edit the selected endpoint */ } else { - start_rad = (nu->bp+start_sel-1)->radius; + start_rad = nu->bp[start_sel - 1].radius; } - if (end_sel==nu->pntsu-1) { - end_rad = (nu->bp+end_sel)->radius; + if (end_sel == nu->pntsu - 1) { + end_rad = nu->bp[end_sel].radius; end_sel--; /* we don't want to edit the selected endpoint */ } else { - end_rad = (nu->bp+end_sel+1)->radius; + end_rad = nu->bp[end_sel + 1].radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for (bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) { - fac = (float)(1+a-start_sel) / range; - bp->radius = start_rad*(1.0f-fac) + end_rad*fac; + for (bp = &nu->bp[start_sel], a = start_sel; a <= end_sel; a++, bp++) { + fac = (float)(1 + a - start_sel) / range; + bp->radius = start_rad * (1.0f - fac) + end_rad * fac; } } } @@ -2370,7 +2363,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2388,14 +2381,14 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** selection utility *************************/ -/* next == 1 -> select next */ -/* next == -1 -> select previous */ -/* cont == 1 -> select continuously */ +/* next == 1 -> select next */ +/* next == -1 -> select previous */ +/* cont == 1 -> select continuously */ /* selstatus, inverts behavior */ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus) { @@ -2403,52 +2396,52 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short BezTriple *bezt; BPoint *bp; int a; - short lastsel= 0; + short lastsel = 0; - if (next==0) return; + if (next == 0) return; - for (nu= editnurb->first; nu; nu= nu->next) { - lastsel=0; + for (nu = editnurb->first; nu; nu = nu->next) { + lastsel = 0; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; - if (next < 0) bezt= (nu->bezt + (a-1)); + a = nu->pntsu; + bezt = nu->bezt; + if (next < 0) bezt = &nu->bezt[a - 1]; while (a--) { - if (a-abs(next) < 0) break; - if ((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) { - bezt+=next; - if (!(bezt->f2 & SELECT) || (selstatus==0)) { - short sel= select_beztriple(bezt, selstatus, 1, VISIBLE); - if ((sel==1) && (cont==0)) lastsel= 1; + if (a - abs(next) < 0) break; + if ((lastsel == 0) && (bezt->hide == 0) && ((bezt->f2 & SELECT) || (selstatus == 0))) { + bezt += next; + if (!(bezt->f2 & SELECT) || (selstatus == 0)) { + short sel = select_beztriple(bezt, selstatus, 1, VISIBLE); + if ((sel == 1) && (cont == 0)) lastsel = 1; } } else { - bezt+=next; - lastsel= 0; + bezt += next; + lastsel = 0; } /* move around in zigzag way so that we go through each */ - bezt-=(next-next/abs(next)); + bezt -= (next - next / abs(next)); } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - if (next < 0) bp= (nu->bp + (a-1)); + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + if (next < 0) bp = &nu->bp[a - 1]; while (a--) { - if (a-abs(next) < 0) break; - if ((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) { - bp+=next; - if (!(bp->f1 & SELECT) || (selstatus==0)) { - short sel= select_bpoint(bp, selstatus, 1, VISIBLE); - if ((sel==1) && (cont==0)) lastsel= 1; + if (a - abs(next) < 0) break; + if ((lastsel == 0) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == 0))) { + bp += next; + if (!(bp->f1 & SELECT) || (selstatus == 0)) { + short sel = select_bpoint(bp, selstatus, 1, VISIBLE); + if ((sel == 1) && (cont == 0)) lastsel = 1; } } else { - bp+=next; - lastsel= 0; + bp += next; + lastsel = 0; } /* move around in zigzag way so that we go through each */ - bp-=(next-next/abs(next)); + bp -= (next - next / abs(next)); } } } @@ -2462,56 +2455,56 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short /* selstatus: selection status in case doswap is false */ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatus) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; Curve *cu; int a; - if (obedit==NULL) return; + if (obedit == NULL) return; - cu= (Curve*)obedit->data; - cu->lastsel= NULL; + cu = (Curve *)obedit->data; + cu->lastsel = NULL; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; + a = nu->pntsu; /* which point? */ - if (selfirst==0) { /* select last */ - bezt= (nu->bezt + (a-1)); + if (selfirst == 0) { /* select last */ + bezt = &nu->bezt[a - 1]; } else { /* select first */ - bezt= nu->bezt; + bezt = nu->bezt; } while (a--) { short sel; - if (doswap) sel= swap_selection_beztriple(bezt); - else sel= select_beztriple(bezt, selstatus, 1, VISIBLE); + if (doswap) sel = swap_selection_beztriple(bezt); + else sel = select_beztriple(bezt, selstatus, 1, VISIBLE); - if (sel==1) break; + if (sel == 1) break; } } else { - a= nu->pntsu*nu->pntsv; + a = nu->pntsu * nu->pntsv; /* which point? */ - if (selfirst==0) { /* select last */ - bp= (nu->bp + (a-1)); + if (selfirst == 0) { /* select last */ + bp = &nu->bp[a - 1]; } else { /* select first */ - bp= nu->bp; + bp = nu->bp; } while (a--) { if (bp->hide == 0) { short sel; - if (doswap) sel= swap_selection_bpoint(bp); - else sel= select_bpoint(bp, selstatus, 1, VISIBLE); + if (doswap) sel = swap_selection_bpoint(bp); + else sel = select_bpoint(bp, selstatus, 1, VISIBLE); - if (sel==1) break; + if (sel == 1) break; } } } @@ -2520,10 +2513,10 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, FIRST, 1, DESELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2540,15 +2533,15 @@ void CURVE_OT_de_select_first(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, LAST, 1, DESELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2565,7 +2558,7 @@ void CURVE_OT_de_select_last(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* de select all operator ***************/ @@ -2577,12 +2570,12 @@ static short nurb_has_selected_cps(ListBase *editnurb) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if (bezt->hide==0) { + if (bezt->hide == 0) { if ((bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT)) @@ -2594,10 +2587,10 @@ static short nurb_has_selected_cps(ListBase *editnurb) } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ((bp->hide==0) && (bp->f1 & SELECT)) return 1; + if ((bp->hide == 0) && (bp->f1 & SELECT)) return 1; bp++; } } @@ -2608,8 +2601,8 @@ static short nurb_has_selected_cps(ListBase *editnurb) static int de_select_all_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); int action = RNA_enum_get(op->ptr, "action"); if (action == SEL_TOGGLE) { @@ -2630,7 +2623,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op) break; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2647,7 +2640,7 @@ void CURVE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_select_all(ot); @@ -2657,55 +2650,55 @@ void CURVE_OT_select_all(wmOperatorType *ot) static int hide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; - int a, sel, invert= RNA_boolean_get(op->ptr, "unselected"); + int a, sel, invert = RNA_boolean_get(op->ptr, "unselected"); - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; - sel= 0; + bezt = nu->bezt; + a = nu->pntsu; + sel = 0; while (a--) { if (invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); - bezt->hide= 1; + bezt->hide = 1; } else if (invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); - bezt->hide= 1; + bezt->hide = 1; } if (bezt->hide) sel++; bezt++; } - if (sel==nu->pntsu) nu->hide= 1; + if (sel == nu->pntsu) nu->hide = 1; } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; - sel= 0; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; + sel = 0; while (a--) { - if (invert==0 && (bp->f1 & SELECT)) { + if (invert == 0 && (bp->f1 & SELECT)) { select_bpoint(bp, DESELECT, 1, HIDDEN); - bp->hide= 1; + bp->hide = 1; } - else if (invert && (bp->f1 & SELECT)==0) { + else if (invert && (bp->f1 & SELECT) == 0) { select_bpoint(bp, DESELECT, 1, HIDDEN); - bp->hide= 1; + bp->hide = 1; } if (bp->hide) sel++; bp++; } - if (sel==nu->pntsu*nu->pntsv) nu->hide= 1; + if (sel == nu->pntsu * nu->pntsv) nu->hide = 1; } } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2722,7 +2715,7 @@ void CURVE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -2732,33 +2725,33 @@ void CURVE_OT_hide(wmOperatorType *ot) static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - nu->hide= 0; + for (nu = editnurb->first; nu; nu = nu->next) { + nu->hide = 0; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (bezt->hide) { select_beztriple(bezt, SELECT, 1, HIDDEN); - bezt->hide= 0; + bezt->hide = 0; } bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->hide) { select_bpoint(bp, SELECT, 1, HIDDEN); - bp->hide= 0; + bp->hide = 0; } bp++; } @@ -2766,7 +2759,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2783,7 +2776,7 @@ void CURVE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** subdivide operator *********************/ @@ -2794,8 +2787,8 @@ void CURVE_OT_reveal(wmOperatorType *ot) */ static void subdividenurb(Object *obedit, int number_cuts) { - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; BezTriple *prevbezt, *bezt, *beztnew, *beztn; BPoint *bp, *prevbp, *bpnew, *bpn; @@ -2805,52 +2798,51 @@ static void subdividenurb(Object *obedit, int number_cuts) // printf("*** subdivideNurb: entering subdivide\n"); - for (nu= editnurb->nurbs.first; nu; nu= nu->next) { - amount= 0; + for (nu = editnurb->nurbs.first; nu; nu = nu->next) { + amount = 0; if (nu->type == CU_BEZIER) { - /* - * Insert a point into a 2D Bezier curve. - * Endpoints are preserved. Otherwise, all selected and inserted points are - * newly created. Old points are discarded. - */ + /* + * Insert a point into a 2D Bezier curve. + * Endpoints are preserved. Otherwise, all selected and inserted points are + * newly created. Old points are discarded. + */ /* count */ if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bezt= nu->bezt; - prevbezt= bezt+(a-1); + a = nu->pntsu; + bezt = nu->bezt; + prevbezt = bezt + (a - 1); } else { - a= nu->pntsu-1; - prevbezt= nu->bezt; - bezt= prevbezt+1; + a = nu->pntsu - 1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; } while (a--) { - if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts; - prevbezt= bezt; + if (BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount += number_cuts; + prevbezt = bezt; bezt++; } if (amount) { /* insert */ - beztnew = - (BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb"); - beztn= beztnew; + beztnew = (BezTriple *)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb"); + beztn = beztnew; if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bezt= nu->bezt; - prevbezt= bezt+(a-1); + a = nu->pntsu; + bezt = nu->bezt; + prevbezt = bezt + (a - 1); } else { - a= nu->pntsu-1; - prevbezt= nu->bezt; - bezt= prevbezt+1; + a = nu->pntsu - 1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; } while (a--) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); beztn++; - if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if (BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { float prevvec[3][3]; memcpy(prevvec, prevbezt->vec, sizeof(float) * 9); @@ -2862,93 +2854,92 @@ static void subdividenurb(Object *obedit, int number_cuts) /* midpoint subdividing */ interp_v3_v3v3(vec, prevvec[1], prevvec[2], factor); - interp_v3_v3v3(vec+3, prevvec[2], bezt->vec[0], factor); - interp_v3_v3v3(vec+6, bezt->vec[0], bezt->vec[1], factor); + interp_v3_v3v3(vec + 3, prevvec[2], bezt->vec[0], factor); + interp_v3_v3v3(vec + 6, bezt->vec[0], bezt->vec[1], factor); - interp_v3_v3v3(vec+9, vec, vec+3, factor); - interp_v3_v3v3(vec+12, vec+3, vec+6, factor); + interp_v3_v3v3(vec + 9, vec, vec + 3, factor); + interp_v3_v3v3(vec + 12, vec + 3, vec + 6, factor); /* change handle of prev beztn */ - copy_v3_v3((beztn-1)->vec[2], vec); + copy_v3_v3((beztn - 1)->vec[2], vec); /* new point */ - copy_v3_v3(beztn->vec[0], vec+9); - interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor); - copy_v3_v3(beztn->vec[2], vec+12); + copy_v3_v3(beztn->vec[0], vec + 9); + interp_v3_v3v3(beztn->vec[1], vec + 9, vec + 12, factor); + copy_v3_v3(beztn->vec[2], vec + 12); /* handle of next bezt */ - if (a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);} - else {copy_v3_v3(bezt->vec[0], vec+6);} + if (a == 0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) { copy_v3_v3(beztnew->vec[0], vec + 6); } + else { copy_v3_v3(bezt->vec[0], vec + 6); } - beztn->radius = (prevbezt->radius + bezt->radius)/2; - beztn->weight = (prevbezt->weight + bezt->weight)/2; + beztn->radius = (prevbezt->radius + bezt->radius) / 2; + beztn->weight = (prevbezt->weight + bezt->weight) / 2; memcpy(prevvec, beztn->vec, sizeof(float) * 9); beztn++; } } - prevbezt= bezt; + prevbezt = bezt; bezt++; } /* last point */ - if ((nu->flagu & CU_NURB_CYCLIC)==0) { + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); } MEM_freeN(nu->bezt); - nu->bezt= beztnew; - nu->pntsu+= amount; + nu->bezt = beztnew; + nu->pntsu += amount; BKE_nurb_handles_calc(nu); } } /* End of 'if (nu->type == CU_BEZIER)' */ - else if (nu->pntsv==1) { - /* - * All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves - * are handled together with the regular NURB plane division, as it - * should be. I split it off just now, let's see if it is - * stable... nzc 30-5-'00 - */ + else if (nu->pntsv == 1) { + /* + * All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves + * are handled together with the regular NURB plane division, as it + * should be. I split it off just now, let's see if it is + * stable... nzc 30-5-'00 + */ /* count */ if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bp= nu->bp; - prevbp= bp+(a-1); + a = nu->pntsu; + bp = nu->bp; + prevbp = bp + (a - 1); } else { - a= nu->pntsu-1; - prevbp= nu->bp; - bp= prevbp+1; + a = nu->pntsu - 1; + prevbp = nu->bp; + bp = prevbp + 1; } while (a--) { - if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts; - prevbp= bp; + if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount += number_cuts; + prevbp = bp; bp++; } if (amount) { /* insert */ - bpnew = - (BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2"); - bpn= bpnew; + bpnew = (BPoint *)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2"); + bpn = bpnew; if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bp= nu->bp; - prevbp= bp+(a-1); + a = nu->pntsu; + bp = nu->bp; + prevbp = bp + (a - 1); } else { - a= nu->pntsu-1; - prevbp= nu->bp; - bp= prevbp+1; + a = nu->pntsu - 1; + prevbp = nu->bp; + bp = prevbp + 1; } while (a--) { memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); bpn++; - if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) { - // printf("*** subdivideNurb: insert 'linear' point\n"); + if ((bp->f1 & SELECT) && (prevbp->f1 & SELECT)) { + // printf("*** subdivideNurb: insert 'linear' point\n"); for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); @@ -2958,17 +2949,17 @@ static void subdividenurb(Object *obedit, int number_cuts) } } - prevbp= bp; + prevbp = bp; bp++; } - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */ + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* last point */ memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu+= amount; + nu->bp = bpnew; + nu->pntsu += amount; if (nu->type & CU_NURBS) { BKE_nurb_knot_calc_u(nu); @@ -2976,57 +2967,57 @@ static void subdividenurb(Object *obedit, int number_cuts) } } /* End of 'else if (nu->pntsv==1)' */ else if (nu->type == CU_NURBS) { - /* This is a very strange test ... */ - /** - * Subdivide NURB surfaces - nzc 30-5-'00 - - * - * Subdivision of a NURB curve can be effected by adding a - * control point (insertion of a knot), or by raising the - * degree of the functions used to build the NURB. The - * expression - * - * degree = #knots - #controlpoints + 1 (J Walter piece) - * degree = #knots - #controlpoints (Blender - * implementation) - * ( this is confusing.... what is true? Another concern - * is that the JW piece allows the curve to become - * explicitly 1st order derivative discontinuous, while - * this is not what we want here... ) - * - * is an invariant for a single NURB curve. Raising the degree - * of the NURB is done elsewhere; the degree is assumed - * constant during this operation. Degree is a property shared - * by all controlpoints in a curve (even though it is stored - * per control point - this can be misleading). - * Adding a knot is done by searching for the place in the - * knot vector where a certain knot value must be inserted, or - * by picking an appropriate knot value between two existing - * ones. The number of controlpoints that is influenced by the - * insertion depends on the order of the curve. A certain - * minimum number of knots is needed to form high-order - * curves, as can be seen from the equation above. In Blender, - * currently NURBs may be up to 6th order, so we modify at - * most 6 points. One point is added. For an n-degree curve, - * n points are discarded, and n+1 points inserted - * (so effectively, n points are modified). (that holds for - * the JW piece, but it seems not for our NURBs) - * In practice, the knot spacing is copied, but the tail - * (the points following the insertion point) need to be - * offset to keep the knot series ascending. The knot series - * is always a series of monotonically ascending integers in - * Blender. When not enough control points are available to - * fit the order, duplicates of the endpoints are added as - * needed. - */ + /* This is a very strange test ... */ + /** + * Subdivide NURB surfaces - nzc 30-5-'00 - + * + * Subdivision of a NURB curve can be effected by adding a + * control point (insertion of a knot), or by raising the + * degree of the functions used to build the NURB. The + * expression + * + * degree = #knots - #controlpoints + 1 (J Walter piece) + * degree = #knots - #controlpoints (Blender + * implementation) + * ( this is confusing.... what is true? Another concern + * is that the JW piece allows the curve to become + * explicitly 1st order derivative discontinuous, while + * this is not what we want here... ) + * + * is an invariant for a single NURB curve. Raising the degree + * of the NURB is done elsewhere; the degree is assumed + * constant during this operation. Degree is a property shared + * by all controlpoints in a curve (even though it is stored + * per control point - this can be misleading). + * Adding a knot is done by searching for the place in the + * knot vector where a certain knot value must be inserted, or + * by picking an appropriate knot value between two existing + * ones. The number of controlpoints that is influenced by the + * insertion depends on the order of the curve. A certain + * minimum number of knots is needed to form high-order + * curves, as can be seen from the equation above. In Blender, + * currently NURBs may be up to 6th order, so we modify at + * most 6 points. One point is added. For an n-degree curve, + * n points are discarded, and n+1 points inserted + * (so effectively, n points are modified). (that holds for + * the JW piece, but it seems not for our NURBs) + * In practice, the knot spacing is copied, but the tail + * (the points following the insertion point) need to be + * offset to keep the knot series ascending. The knot series + * is always a series of monotonically ascending integers in + * Blender. When not enough control points are available to + * fit the order, duplicates of the endpoints are added as + * needed. + */ /* selection-arrays */ - usel= MEM_callocN(sizeof(int)*nu->pntsu, "subivideNurb3"); - vsel= MEM_callocN(sizeof(int)*nu->pntsv, "subivideNurb3"); - sel= 0; - - /* Count the number of selected points. */ - bp= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++) { + usel = MEM_callocN(sizeof(int) * nu->pntsu, "subivideNurb3"); + vsel = MEM_callocN(sizeof(int) * nu->pntsv, "subivideNurb3"); + sel = 0; + + /* Count the number of selected points. */ + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { if (bp->f1 & SELECT) { usel[b]++; vsel[a]++; @@ -3035,48 +3026,48 @@ static void subdividenurb(Object *obedit, int number_cuts) bp++; } } - if ( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */ + if (sel == (nu->pntsu * nu->pntsv) ) { /* subdivide entire nurb */ /* Global subdivision is a special case of partial * subdivision. Strange it is considered separately... */ /* count of nodes (after subdivision) along U axis */ - int countu= nu->pntsu + (nu->pntsu - 1) * number_cuts; + int countu = nu->pntsu + (nu->pntsu - 1) * number_cuts; /* total count of nodes after subdivision */ - int tot= ((number_cuts+1)*nu->pntsu-number_cuts)*((number_cuts+1)*nu->pntsv-number_cuts); + int tot = ((number_cuts + 1) * nu->pntsu - number_cuts) * ((number_cuts + 1) * nu->pntsv - number_cuts); - bpn=bpnew= MEM_mallocN(tot*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; + bpn = bpnew = MEM_mallocN(tot * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; /* first subdivide rows */ - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++) { - *bpn= *bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if (b<nu->pntsu-1) { - prevbp= bp-1; + if (b < nu->pntsu - 1) { + prevbp = bp - 1; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - *bpn= *bp; + *bpn = *bp; interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; } } } - bpn+= number_cuts * countu; + bpn += number_cuts * countu; } /* now insert new */ - bpn= bpnew+((number_cuts+1)*nu->pntsu - number_cuts); - bp= bpnew+(number_cuts+1)*((number_cuts+1)*nu->pntsu-number_cuts); - prevbp= bpnew; - for (a=1; a<nu->pntsv; a++) { + bpn = bpnew + ((number_cuts + 1) * nu->pntsu - number_cuts); + bp = bpnew + (number_cuts + 1) * ((number_cuts + 1) * nu->pntsu - number_cuts); + prevbp = bpnew; + for (a = 1; a < nu->pntsv; a++) { - for (b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) { - BPoint *tmp= bpn; + for (b = 0; b < (number_cuts + 1) * nu->pntsu - number_cuts; b++) { + BPoint *tmp = bpn; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - *tmp= *bp; + *tmp = *bp; interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); tmp += countu; } @@ -3084,81 +3075,81 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp++; bpn++; } - bp+= number_cuts * countu; - bpn+= number_cuts * countu; - prevbp+= number_cuts * countu; + bp += number_cuts * countu; + bpn += number_cuts * countu; + prevbp += number_cuts * countu; } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu= (number_cuts+1)*nu->pntsu-number_cuts; - nu->pntsv= (number_cuts+1)*nu->pntsv-number_cuts; + nu->bp = bpnew; + nu->pntsu = (number_cuts + 1) * nu->pntsu - number_cuts; + nu->pntsv = (number_cuts + 1) * nu->pntsv - number_cuts; BKE_nurb_knot_calc_u(nu); BKE_nurb_knot_calc_v(nu); } /* End of 'if (sel== nu->pntsu*nu->pntsv)' (subdivide entire NURB) */ else { /* subdivide in v direction? */ - sel= 0; - for (a=0; a<nu->pntsv-1; a++) { - if (vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts; + sel = 0; + for (a = 0; a < nu->pntsv - 1; a++) { + if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) sel += number_cuts; } if (sel) { /* V ! */ - bpn=bpnew= MEM_mallocN((sel+nu->pntsv)*nu->pntsu*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++) { - *bpn= *bp; + bpn = bpnew = MEM_mallocN((sel + nu->pntsv) * nu->pntsu * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; } - if ( (a<nu->pntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) { + if ( (a < nu->pntsv - 1) && vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) { for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - prevbp= bp- nu->pntsu; - for (b=0; b<nu->pntsu; b++) { - /* - * This simple bisection must be replaces by a - * subtle resampling of a number of points. Our - * task is made slightly easier because each - * point in our curve is a separate data - * node. (is it?) - */ - *bpn= *prevbp; - interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); - bpn++; + prevbp = bp - nu->pntsu; + for (b = 0; b < nu->pntsu; b++) { + /* + * This simple bisection must be replaces by a + * subtle resampling of a number of points. Our + * task is made slightly easier because each + * point in our curve is a separate data + * node. (is it?) + */ + *bpn = *prevbp; + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); + bpn++; prevbp++; bp++; } - bp-= nu->pntsu; + bp -= nu->pntsu; } } } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsv+= sel; + nu->bp = bpnew; + nu->pntsv += sel; BKE_nurb_knot_calc_v(nu); } else { /* or in u direction? */ - sel= 0; - for (a=0; a<nu->pntsu-1; a++) { - if (usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts; + sel = 0; + for (a = 0; a < nu->pntsu - 1; a++) { + if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) sel += number_cuts; } - if (sel) { /* U ! */ - /* Inserting U points is sort of 'default' Flat curves only get */ - /* U points inserted in them. */ - bpn=bpnew= MEM_mallocN((sel+nu->pntsu)*nu->pntsv*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++) { - *bpn= *bp; + if (sel) { /* U ! */ + /* Inserting U points is sort of 'default' Flat curves only get */ + /* U points inserted in them. */ + bpn = bpnew = MEM_mallocN((sel + nu->pntsu) * nu->pntsv * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if ( (b<nu->pntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { + if ( (b < nu->pntsu - 1) && usel[b] == nu->pntsv && usel[b + 1] == nu->pntsv) { /* * One thing that bugs me here is that the * orders of things are not the same as in @@ -3168,17 +3159,17 @@ static void subdividenurb(Object *obedit, int number_cuts) */ for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - prevbp= bp- 1; - *bpn= *prevbp; - interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); - bpn++; + prevbp = bp - 1; + *bpn = *prevbp; + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); + bpn++; } } } } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu+= sel; + nu->bp = bpnew; + nu->pntsu += sel; BKE_nurb_knot_calc_u(nu); /* shift knots forward */ } } @@ -3192,15 +3183,15 @@ static void subdividenurb(Object *obedit, int number_cuts) static int subdivide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - int number_cuts= RNA_int_get(op->ptr, "number_cuts"); + Object *obedit = CTX_data_edit_object(C); + int number_cuts = RNA_int_get(op->ptr, "number_cuts"); subdividenurb(obedit, number_cuts); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3220,7 +3211,7 @@ void CURVE_OT_subdivide(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of cuts", "", 1, 10); /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */ @@ -3240,10 +3231,10 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, flag = bp->f1; } else { - if (beztindex==0) { + if (beztindex == 0) { flag = bezt->f1; } - else if (beztindex==1) { + else if (beztindex == 1) { flag = bezt->f2; } else { @@ -3251,25 +3242,25 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, } } - temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); - if ((flag&1)==data->select) temp += 5; - if (bezt && beztindex==1) temp += 3; /* middle points get a small disadvantage */ + temp = abs(data->mval[0] - x) + abs(data->mval[1] - y); + if ((flag & 1) == data->select) temp += 5; + if (bezt && beztindex == 1) temp += 3; /* middle points get a small disadvantage */ - if (temp<data->dist) { + if (temp < data->dist) { data->dist = temp; data->bp = bp; data->bezt = bezt; data->nurb = nu; - data->hpoint = bezt?beztindex:0; + data->hpoint = bezt ? beztindex : 0; } } static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp) { - /* sel==1: selected gets a disadvantage */ - /* in nurb and bezt or bp the nearest is written */ - /* return 0 1 2: handlepunt */ + /* sel==1: selected gets a disadvantage */ + /* in nurb and bezt or bp the nearest is written */ + /* return 0 1 2: handlepunt */ struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } data = {NULL}; data.dist = 100; @@ -3297,51 +3288,51 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt BPoint *bp1; int a; - *nu= NULL; - *bezt= NULL; - *bp= NULL; - for (nu1= editnurb->first; nu1; nu1= nu1->next) { + *nu = NULL; + *bezt = NULL; + *bp = NULL; + for (nu1 = editnurb->first; nu1; nu1 = nu1->next) { if (nu1->type == CU_BEZIER) { - bezt1= nu1->bezt; - a= nu1->pntsu; + bezt1 = nu1->bezt; + a = nu1->pntsu; while (a--) { if ( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) { if (*nu != NULL && *nu != nu1) { - *nu= NULL; - *bp= NULL; - *bezt= NULL; + *nu = NULL; + *bp = NULL; + *bezt = NULL; return; } else if (*bezt || *bp) { - *bp= NULL; - *bezt= NULL; + *bp = NULL; + *bezt = NULL; } else { - *bezt= bezt1; - *nu= nu1; + *bezt = bezt1; + *nu = nu1; } } bezt1++; } } else { - bp1= nu1->bp; - a= nu1->pntsu*nu1->pntsv; + bp1 = nu1->bp; + a = nu1->pntsu * nu1->pntsv; while (a--) { - if ( bp1->f1 & 1 ) { + if (bp1->f1 & SELECT) { if (*nu != NULL && *nu != nu1) { - *bp= NULL; - *bezt= NULL; - *nu= NULL; + *bp = NULL; + *bezt = NULL; + *nu = NULL; return; } else if (*bezt || *bp) { - *bp= NULL; - *bezt= NULL; + *bp = NULL; + *bezt = NULL; } else { - *bp= bp1; - *nu= nu1; + *bp = bp1; + *nu = nu1; } } bp1++; @@ -3359,87 +3350,86 @@ static int convertspline(short type, Nurb *nu) int a, c, nr; if (nu->type == CU_POLY) { - if (type==CU_BEZIER) { /* to Bezier with vecthandles */ - nr= nu->pntsu; - bezt = - (BezTriple*)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt= bezt; - a= nr; - bp= nu->bp; + if (type == CU_BEZIER) { /* to Bezier with vecthandles */ + nr = nu->pntsu; + bezt = (BezTriple *)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); + nu->bezt = bezt; + a = nr; + bp = nu->bp; while (a--) { copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f1=bezt->f2=bezt->f3= bp->f1; - bezt->h1= bezt->h2= HD_VECT; - bezt->weight= bp->weight; - bezt->radius= bp->radius; + bezt->f1 = bezt->f2 = bezt->f3 = bp->f1; + bezt->h1 = bezt->h2 = HD_VECT; + bezt->weight = bp->weight; + bezt->radius = bp->radius; bp++; bezt++; } MEM_freeN(nu->bp); - nu->bp= NULL; - nu->pntsu= nr; + nu->bp = NULL; + nu->pntsu = nr; nu->type = CU_BEZIER; BKE_nurb_handles_calc(nu); } - else if (type==CU_NURBS) { + else if (type == CU_NURBS) { nu->type = CU_NURBS; - nu->orderu= 4; + nu->orderu = 4; nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ BKE_nurb_knot_calc_u(nu); - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->vec[3]= 1.0; + bp->vec[3] = 1.0; bp++; } } } - else if (nu->type == CU_BEZIER) { /* Bezier */ - if (type==CU_POLY || type==CU_NURBS) { - nr= 3*nu->pntsu; + else if (nu->type == CU_BEZIER) { /* Bezier */ + if (type == CU_POLY || type == CU_NURBS) { + nr = 3 * nu->pntsu; nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype"); - a= nu->pntsu; - bezt= nu->bezt; - bp= nu->bp; + a = nu->pntsu; + bezt = nu->bezt; + bp = nu->bp; while (a--) { - if (type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) { + if (type == CU_POLY && bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) { /* vector handle becomes 1 poly vertice */ copy_v3_v3(bp->vec, bezt->vec[1]); - bp->vec[3]= 1.0; - bp->f1= bezt->f2; - nr-= 2; - bp->radius= bezt->radius; - bp->weight= bezt->weight; + bp->vec[3] = 1.0; + bp->f1 = bezt->f2; + nr -= 2; + bp->radius = bezt->radius; + bp->weight = bezt->weight; bp++; } else { - for (c=0;c<3;c++) { + for (c = 0; c < 3; c++) { copy_v3_v3(bp->vec, bezt->vec[c]); - bp->vec[3]= 1.0; - if (c==0) bp->f1= bezt->f1; - else if (c==1) bp->f1= bezt->f2; - else bp->f1= bezt->f3; - bp->radius= bezt->radius; - bp->weight= bezt->weight; + bp->vec[3] = 1.0; + if (c == 0) bp->f1 = bezt->f1; + else if (c == 1) bp->f1 = bezt->f2; + else bp->f1 = bezt->f3; + bp->radius = bezt->radius; + bp->weight = bezt->weight; bp++; } } bezt++; } MEM_freeN(nu->bezt); - nu->bezt= NULL; - nu->pntsu= nr; - nu->pntsv= 1; - nu->orderu= 4; - nu->orderv= 1; + nu->bezt = NULL; + nu->pntsu = nr; + nu->pntsv = 1; + nu->orderu = 4; + nu->orderv = 1; nu->type = type; -#if 0 /* UNUSED */ - if (nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1; - else c= 0; +#if 0 /* UNUSED */ + if (nu->flagu & CU_NURB_CYCLIC) c = nu->orderu - 1; + else c = 0; #endif - if (type== CU_NURBS) { + if (type == CU_NURBS) { nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ nu->flagu |= CU_NURB_BEZIER; BKE_nurb_knot_calc_u(nu); @@ -3447,42 +3437,43 @@ static int convertspline(short type, Nurb *nu) } } else if (nu->type == CU_NURBS) { - if (type==CU_POLY) { + if (type == CU_POLY) { nu->type = CU_POLY; - if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ - nu->knotsu= NULL; + if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ + nu->knotsu = NULL; if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + nu->knotsv = NULL; } - else if (type==CU_BEZIER) { /* to Bezier */ - nr= nu->pntsu/3; + else if (type == CU_BEZIER) { /* to Bezier */ + nr = nu->pntsu / 3; - if (nr<2) - return 1; /* conversion impossible */ + if (nr < 2) { + return 1; /* conversion impossible */ + } else { bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt= bezt; - a= nr; - bp= nu->bp; + nu->bezt = bezt; + a = nr; + bp = nu->bp; while (a--) { copy_v3_v3(bezt->vec[0], bp->vec); - bezt->f1= bp->f1; + bezt->f1 = bp->f1; bp++; copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f2= bp->f1; + bezt->f2 = bp->f1; bp++; copy_v3_v3(bezt->vec[2], bp->vec); - bezt->f3= bp->f1; - bezt->radius= bp->radius; - bezt->weight= bp->weight; + bezt->f3 = bp->f1; + bezt->radius = bp->radius; + bezt->weight = bp->weight; bp++; bezt++; } MEM_freeN(nu->bp); - nu->bp= NULL; + nu->bp = NULL; MEM_freeN(nu->knotsu); - nu->knotsu= NULL; - nu->pntsu= nr; + nu->knotsu = NULL; + nu->pntsu = nr; nu->type = CU_BEZIER; } } @@ -3498,31 +3489,31 @@ void ED_nurb_set_spline_type(Nurb *nu, int type) static int set_spline_type_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int changed=0, type= RNA_enum_get(op->ptr, "type"); + int changed = 0, type = RNA_enum_get(op->ptr, "type"); - if (type==CU_CARDINAL || type==CU_BSPLINE) { + if (type == CU_CARDINAL || type == CU_BSPLINE) { BKE_report(op->reports, RPT_ERROR, "Not implemented yet"); return OPERATOR_CANCELLED; } - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { if (convertspline(type, nu)) BKE_report(op->reports, RPT_ERROR, "No conversion possible"); else - changed= 1; + changed = 1; } } if (changed) { if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -3533,7 +3524,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) void CURVE_OT_spline_type_set(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {CU_POLY, "POLY", 0, "Poly", ""}, {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, // {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, @@ -3552,7 +3543,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); @@ -3562,12 +3553,12 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) static int set_handle_type_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); BKE_nurbList_handles_set(editnurb, RNA_enum_get(op->ptr, "type")); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3576,7 +3567,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) void CURVE_OT_handle_type_set(wmOperatorType *ot) { /* keep in sync with graphkeys_handle_type_items */ - static EnumPropertyItem editcurve_handle_type_items[]= { + static EnumPropertyItem editcurve_handle_type_items[] = { {HD_AUTO, "AUTOMATIC", 0, "Automatic", ""}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {5, "ALIGNED", 0, "Aligned", ""}, @@ -3595,7 +3586,7 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type"); @@ -3610,36 +3601,36 @@ static void switchdirection_knots(float *base, int tot) float *fp1, *fp2, *tempf; int a; - if (base==NULL || tot==0) return; + if (base == NULL || tot == 0) return; /* reverse knots */ - a= tot; - fp1= base; - fp2= fp1+(a-1); - a/= 2; - while (fp1!=fp2 && a>0) { + a = tot; + fp1 = base; + fp2 = fp1 + (a - 1); + a /= 2; + while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; fp1++; fp2--; } /* and make in increasing order again */ - a= tot; - fp1= base; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + a = tot; + fp1 = base; + fp2 = tempf = MEM_mallocN(sizeof(float) * a, "switchdirect"); while (a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); + fp2[0] = fabs(fp1[1] - fp1[0]); fp1++; fp2++; } - a= tot-1; - fp1= base; - fp2= tempf; - fp1[0]= 0.0; + a = tot - 1; + fp1 = base; + fp2 = tempf; + fp1[0] = 0.0; fp1++; while (a--) { - fp1[0]= fp1[-1]+fp2[0]; + fp1[0] = fp1[-1] + fp2[0]; fp1++; fp2++; } @@ -3659,12 +3650,12 @@ static void rotate_direction_nurb(Nurb *nu) SWAP(float *, nu->knotsu, nu->knotsv); switchdirection_knots(nu->knotsv, KNOTSV(nu)); - temp= MEM_dupallocN(nu->bp); - bp1= nu->bp; - for (v=0; v<nu->pntsv; v++) { - for (u=0; u<nu->pntsu; u++, bp1++) { - bp2= temp + (nu->pntsu-u-1)*(nu->pntsv) + v; - *bp1= *bp2; + temp = MEM_dupallocN(nu->bp); + bp1 = nu->bp; + for (v = 0; v < nu->pntsv; v++) { + for (u = 0; u < nu->pntsu; u++, bp1++) { + bp2 = temp + (nu->pntsu - u - 1) * (nu->pntsv) + v; + *bp1 = *bp2; } } @@ -3677,8 +3668,8 @@ static int is_u_selected(Nurb *nu, int u) int v; /* what about resolu == 2? */ - bp= nu->bp+u; - for (v=0; v<nu->pntsv-1; v++, bp+=nu->pntsu) { + bp = &nu->bp[u]; + for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) { if (v) if (bp->f1 & SELECT) return 1; } @@ -3691,66 +3682,66 @@ typedef struct NurbSort { float vec[3]; } NurbSort; -static ListBase nsortbase= {NULL, NULL}; +static ListBase nsortbase = {NULL, NULL}; /* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */ static void make_selection_list_nurb(ListBase *editnurb) { - ListBase nbase= {NULL, NULL}; + ListBase nbase = {NULL, NULL}; NurbSort *nus, *nustest, *headdo, *taildo; Nurb *nu; BPoint *bp; float dist, headdist, taildist; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - if ( isNurbsel(nu) ) { + for (nu = editnurb->first; nu; nu = nu->next) { + if (isNurbsel(nu)) { - nus = (NurbSort*)MEM_callocN(sizeof(NurbSort), "sort"); + nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort"); BLI_addhead(&nbase, nus); - nus->nu= nu; + nus->nu = nu; - bp= nu->bp; - a= nu->pntsu; + bp = nu->bp; + a = nu->pntsu; while (a--) { add_v3_v3(nus->vec, bp->vec); bp++; } - mul_v3_fl(nus->vec, 1.0f/(float)nu->pntsu); + mul_v3_fl(nus->vec, 1.0f / (float)nu->pntsu); } } /* just add the first one */ - nus= nbase.first; + nus = nbase.first; BLI_remlink(&nbase, nus); BLI_addtail(&nsortbase, nus); /* now add, either at head or tail, the closest one */ while (nbase.first) { - headdist= taildist= 1.0e30; - headdo= taildo= NULL; + headdist = taildist = 1.0e30; + headdo = taildo = NULL; - nustest= nbase.first; + nustest = nbase.first; while (nustest) { - dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); - if (dist<headdist) { - headdist= dist; - headdo= nustest; + if (dist < headdist) { + headdist = dist; + headdo = nustest; } - dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); - if (dist<taildist) { - taildist= dist; - taildo= nustest; + if (dist < taildist) { + taildist = dist; + taildo = nustest; } - nustest= nustest->next; + nustest = nustest->next; } - if (headdist<taildist) { + if (headdist < taildist) { BLI_remlink(&nbase, headdo); BLI_addhead(&nsortbase, headdo); } @@ -3764,31 +3755,31 @@ static void make_selection_list_nurb(ListBase *editnurb) static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu2) { BPoint *bp, *bp1, *bp2, *temp; - float len1, len2; - int origu, u, v; + float len1, len2; + int origu, u, v; /* first nurbs will be changed to make u = resolu-1 selected */ /* 2nd nurbs will be changed to make u = 0 selected */ /* first nurbs: u = resolu-1 selected */ - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1) ) ; else { /* For 2D curves blender uses orderv=0. It doesn't make any sense mathematically. */ /* but after rotating orderu=0 will be confusing. */ - if (nu1->orderv == 0) nu1->orderv= 1; + if (nu1->orderv == 0) nu1->orderv = 1; rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { /* rotate again, now its OK! */ - if (nu1->pntsv!=1) rotate_direction_nurb(nu1); + if (nu1->pntsv != 1) rotate_direction_nurb(nu1); return; } } @@ -3796,28 +3787,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } /* 2nd nurbs: u = 0 selected */ - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0) ) ; else { - if (nu2->orderv == 0) nu2->orderv= 1; + if (nu2->orderv == 0) nu2->orderv = 1; rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { /* rotate again, now its OK! */ - if (nu1->pntsu==1) rotate_direction_nurb(nu1); - if (nu2->pntsv!=1) rotate_direction_nurb(nu2); + if (nu1->pntsu == 1) rotate_direction_nurb(nu1); + if (nu2->pntsv != 1) rotate_direction_nurb(nu2); return; } } } } - if ( nu1->pntsv != nu2->pntsv ) { + if (nu1->pntsv != nu2->pntsv) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); return; } @@ -3825,46 +3816,46 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu /* ok, now nu1 has the rightmost column and nu2 the leftmost column selected */ /* maybe we need a 'v' flip of nu2? */ - bp1= nu1->bp+nu1->pntsu-1; - bp2= nu2->bp; - len1= 0.0; + bp1 = &nu1->bp[nu1->pntsu - 1]; + bp2 = nu2->bp; + len1 = 0.0; - for (v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { - len1+= len_v3v3(bp1->vec, bp2->vec); + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 += nu2->pntsu) { + len1 += len_v3v3(bp1->vec, bp2->vec); } - bp1= nu1->bp + nu1->pntsu-1; - bp2= nu2->bp + nu2->pntsu*(nu2->pntsv-1); - len2= 0.0; + bp1 = &nu1->bp[nu1->pntsu - 1]; + bp2 = &nu2->bp[nu2->pntsu * (nu2->pntsv - 1)]; + len2 = 0.0; - for (v=0; v<nu1->pntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { - len2+= len_v3v3(bp1->vec, bp2->vec); + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 -= nu2->pntsu) { + len2 += len_v3v3(bp1->vec, bp2->vec); } /* merge */ - origu= nu1->pntsu; - nu1->pntsu+= nu2->pntsu; - if (nu1->orderu<3 && nu1->orderu<nu1->pntsu) nu1->orderu++; - if (nu1->orderv<3 && nu1->orderv<nu1->pntsv) nu1->orderv++; - temp= nu1->bp; - nu1->bp= MEM_mallocN(nu1->pntsu*nu1->pntsv*sizeof(BPoint), "mergeBP"); + origu = nu1->pntsu; + nu1->pntsu += nu2->pntsu; + if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) nu1->orderu++; + if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++; + temp = nu1->bp; + nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP"); - bp= nu1->bp; - bp1= temp; + bp = nu1->bp; + bp1 = temp; - for (v=0; v<nu1->pntsv; v++) { + for (v = 0; v < nu1->pntsv; v++) { /* switch direction? */ - if (len1<len2) bp2= nu2->bp + v*nu2->pntsu; - else bp2= nu2->bp + (nu1->pntsv-v-1)*nu2->pntsu; + if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu]; + else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu]; - for (u=0; u<nu1->pntsu; u++, bp++) { - if (u<origu) { - *bp= *bp1; bp1++; + for (u = 0; u < nu1->pntsu; u++, bp++) { + if (u < origu) { + *bp = *bp1; bp1++; select_bpoint(bp, SELECT, 1, HIDDEN); } else { - *bp= *bp2; bp2++; + *bp = *bp2; bp2++; } } } @@ -3884,10 +3875,10 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu static int merge_nurb(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); NurbSort *nus1, *nus2; - int ok= 1; + int ok = 1; make_selection_list_nurb(editnurb); @@ -3897,25 +3888,25 @@ static int merge_nurb(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - nus1= nsortbase.first; - nus2= nus1->next; + nus1 = nsortbase.first; + nus2 = nus1->next; /* resolution match, to avoid uv rotations */ - if (nus1->nu->pntsv==1) { - if (nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv); - else ok= 0; + if (nus1->nu->pntsv == 1) { + if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) ; + else ok = 0; } - else if (nus2->nu->pntsv==1) { - if (nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv); - else ok= 0; + else if (nus2->nu->pntsv == 1) { + if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) ; + else ok = 0; } - else if ( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv); - else if ( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu); + else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) ; + else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) ; else { - ok= 0; + ok = 0; } - if (ok==0) { + if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); BLI_freelistN(&nsortbase); return OPERATOR_CANCELLED; @@ -3923,14 +3914,14 @@ static int merge_nurb(bContext *C, wmOperator *op) while (nus2) { merge_2_nurb(op, editnurb, nus1->nu, nus2->nu); - nus2= nus2->next; + nus2 = nus2->next; } BLI_freelistN(&nsortbase); set_actNurb(obedit, NULL); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3939,91 +3930,91 @@ static int merge_nurb(bContext *C, wmOperator *op) static int make_segment_exec(bContext *C, wmOperator *op) { /* joins 2 curves */ - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *nubase= object_editcurve_get(obedit); - Nurb *nu, *nu1=NULL, *nu2=NULL; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *nubase = object_editcurve_get(obedit); + Nurb *nu, *nu1 = NULL, *nu2 = NULL; BPoint *bp; float *fp, offset; - int a, ok= 0; + int a, ok = 0; /* first decide if this is a surface merge! */ - if (obedit->type==OB_SURF) nu= nubase->first; - else nu= NULL; + if (obedit->type == OB_SURF) nu = nubase->first; + else nu = NULL; while (nu) { - if ( isNurbsel(nu) ) { + if (isNurbsel(nu)) { - if (nu->pntsu>1 && nu->pntsv>1) break; - if (isNurbsel_count(cu, nu)>1) break; - if (isNurbsel_count(cu, nu)==1) { + if (nu->pntsu > 1 && nu->pntsv > 1) break; + if (isNurbsel_count(cu, nu) > 1) break; + if (isNurbsel_count(cu, nu) == 1) { /* only 1 selected, not first or last, a little complex, but intuitive */ - if (nu->pntsv==1) { - if ( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT)); + if (nu->pntsv == 1) { + if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) ; else break; } } } - nu= nu->next; + nu = nu->next; } if (nu) return merge_nurb(C, op); /* find both nurbs and points, nu1 will be put behind nu2 */ - for (nu= nubase->first; nu; nu= nu->next) { + for (nu = nubase->first; nu; nu = nu->next) { if (nu->pntsu == 1) - nu->flagu&= ~CU_NURB_CYCLIC; + nu->flagu &= ~CU_NURB_CYCLIC; - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */ + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */ if (nu->type == CU_BEZIER) { - if (nu1==NULL) { - if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu; + if (nu1 == NULL) { + if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1 = nu; else { - if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { - nu1= nu; + if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1])) ) { + nu1 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if (nu2==NULL) { - if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { - nu2= nu; + else if (nu2 == NULL) { + if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { + nu2 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } else { - if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { - nu2= nu; + if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1])) ) { + nu2 = nu; } } } else break; } - else if (nu->pntsv==1) { - bp= nu->bp; - if (nu1==NULL) { - if ( bp->f1 & SELECT) nu1= nu; + else if (nu->pntsv == 1) { + bp = nu->bp; + if (nu1 == NULL) { + if (bp->f1 & SELECT) nu1 = nu; else { - bp= bp+(nu->pntsu-1); - if ( bp->f1 & SELECT ) { - nu1= nu; + bp = bp + (nu->pntsu - 1); + if (bp->f1 & SELECT) { + nu1 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if (nu2==NULL) { - if ( bp->f1 & SELECT ) { - nu2= nu; + else if (nu2 == NULL) { + if (bp->f1 & SELECT) { + nu2 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } else { - bp= bp+(nu->pntsu-1); - if ( bp->f1 & SELECT ) { - nu2= nu; + bp = bp + (nu->pntsu - 1); + if (bp->f1 & SELECT) { + nu2 = nu; } } } @@ -4032,75 +4023,74 @@ static int make_segment_exec(bContext *C, wmOperator *op) } } - if ((nu1 && nu2) && (nu1!=nu2)) { - if ( nu1->type==nu2->type) { + if ((nu1 && nu2) && (nu1 != nu2)) { + if (nu1->type == nu2->type) { if (nu1->type == CU_BEZIER) { - BezTriple *bezt = - (BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); + BezTriple *bezt = (BezTriple *)MEM_mallocN((nu1->pntsu + nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); ED_curve_beztcpy(cu->editnurb, bezt, nu2->bezt, nu2->pntsu); - ED_curve_beztcpy(cu->editnurb, bezt+nu2->pntsu, nu1->bezt, nu1->pntsu); + ED_curve_beztcpy(cu->editnurb, bezt + nu2->pntsu, nu1->bezt, nu1->pntsu); MEM_freeN(nu1->bezt); - nu1->bezt= bezt; - nu1->pntsu+= nu2->pntsu; + nu1->bezt = bezt; + nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); - BKE_nurb_free(nu2); nu2= NULL; + BKE_nurb_free(nu2); nu2 = NULL; BKE_nurb_handles_calc(nu1); } else { - bp = - (BPoint*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BPoint), "addsegmentN2"); + bp = (BPoint *)MEM_mallocN((nu1->pntsu + nu2->pntsu) * sizeof(BPoint), "addsegmentN2"); ED_curve_bpcpy(cu->editnurb, bp, nu2->bp, nu2->pntsu); - ED_curve_bpcpy(cu->editnurb, bp+nu2->pntsu, nu1->bp, nu1->pntsu); + ED_curve_bpcpy(cu->editnurb, bp + nu2->pntsu, nu1->bp, nu1->pntsu); MEM_freeN(nu1->bp); - nu1->bp= bp; + nu1->bp = bp; - a= nu1->pntsu+nu1->orderu; + a = nu1->pntsu + nu1->orderu; - nu1->pntsu+= nu2->pntsu; + nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); /* now join the knots */ if (nu1->type == CU_NURBS) { - if (nu1->knotsu==NULL) { + if (nu1->knotsu == NULL) { BKE_nurb_knot_calc_u(nu1); } else { - fp= MEM_mallocN(sizeof(float)*KNOTSU(nu1), "addsegment3"); - memcpy(fp, nu1->knotsu, sizeof(float)*a); + fp = MEM_mallocN(sizeof(float) * KNOTSU(nu1), "addsegment3"); + memcpy(fp, nu1->knotsu, sizeof(float) * a); MEM_freeN(nu1->knotsu); - nu1->knotsu= fp; + nu1->knotsu = fp; - offset= nu1->knotsu[a-1] + 1.0f; - fp= nu1->knotsu+a; - for (a=0; a<nu2->pntsu; a++, fp++) { + offset = nu1->knotsu[a - 1] + 1.0f; + fp = nu1->knotsu + a; + for (a = 0; a < nu2->pntsu; a++, fp++) { if (nu2->knotsu) - *fp= offset+nu2->knotsu[a+1]; + *fp = offset + nu2->knotsu[a + 1]; else *fp = offset; } } } - BKE_nurb_free(nu2); nu2= NULL; + BKE_nurb_free(nu2); nu2 = NULL; } - set_actNurb(obedit, nu1); /* for selected */ - ok= 1; + set_actNurb(obedit, nu1); /* for selected */ + ok = 1; } } else if (nu1 && !nu2) { - if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu>1) { + if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu > 1) { if (nu1->type == CU_BEZIER && BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt) && - BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt+(nu1->pntsu-1))) { - nu1->flagu|= CU_NURB_CYCLIC; + BEZSELECTED_HIDDENHANDLES(cu, &nu1->bezt[nu1->pntsu - 1])) + { + nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_handles_calc(nu1); - ok= 1; + ok = 1; } - else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) { - nu1->flagu|= CU_NURB_CYCLIC; + else if (nu1->type == CU_NURBS && nu1->bp->f1 & SELECT && (nu1->bp[nu1->pntsu - 1].f1 & SELECT)) { + nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu1); - ok= 1; + ok = 1; } } } @@ -4111,9 +4101,9 @@ static int make_segment_exec(bContext *C, wmOperator *op) } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4131,67 +4121,67 @@ void CURVE_OT_make_segment(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** pick select from 3d view **********************/ int mouse_nurb(bContext *C, const int mval[2], int extend) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); ViewContext vc; Nurb *nu; - BezTriple *bezt=NULL; - BPoint *bp=NULL; + BezTriple *bezt = NULL; + BPoint *bp = NULL; int location[2]; short hand; view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - location[0]= mval[0]; - location[1]= mval[1]; - hand= findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); + location[0] = mval[0]; + location[1] = mval[1]; + hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); if (bezt || bp) { - if (extend==0) { + if (extend == 0) { setflagsNurb(editnurb, 0); if (bezt) { - if (hand==1) { + if (hand == 1) { select_beztriple(bezt, SELECT, 1, HIDDEN); - cu->lastsel= bezt; + cu->lastsel = bezt; } else { - if (hand==0) bezt->f1|= SELECT; - else bezt->f3|= SELECT; + if (hand == 0) bezt->f1 |= SELECT; + else bezt->f3 |= SELECT; - cu->lastsel= NULL; + cu->lastsel = NULL; } } else { - cu->lastsel= bp; + cu->lastsel = bp; select_bpoint(bp, SELECT, 1, HIDDEN); } } else { if (bezt) { - if (hand==1) { + if (hand == 1) { if (bezt->f2 & SELECT) { select_beztriple(bezt, DESELECT, 1, HIDDEN); if (bezt == cu->lastsel) cu->lastsel = NULL; } else { select_beztriple(bezt, SELECT, 1, HIDDEN); - cu->lastsel= bezt; + cu->lastsel = bezt; } } - else if (hand==0) { + else if (hand == 0) { bezt->f1 ^= SELECT; } else { @@ -4205,16 +4195,16 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) } else { select_bpoint(bp, SELECT, 1, HIDDEN); - cu->lastsel= bp; + cu->lastsel = bp; } } } - if (nu!=get_actNurb(obedit)) + if (nu != get_actNurb(obedit)) set_actNurb(obedit, nu); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return 1; } @@ -4228,13 +4218,13 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) */ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cent) { - Curve *cu= (Curve*)obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Curve *cu = (Curve *)obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; float si, phi, n[3], q[4], cmat[3][3], tmat[3][3], imat[3][3]; float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; float persmat[3][3], persinv[3][3]; - short a, ok, changed= 0; + short a, ok, changed = 0; copy_m3_m4(persmat, viewmat); invert_m3_m3(persinv, persmat); @@ -4244,20 +4234,20 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen invert_m3_m3(imat, bmat); normalize_v3_v3(n, axis); - - phi= M_PI/8.0; - q[0]= cos(phi); - si= sin(phi); - q[1]= n[0]*si; - q[2]= n[1]*si; - q[3]= n[2]*si; + /* TODO - use math func */ + phi = M_PI / 8.0; + q[0] = cos(phi); + si = sin(phi); + q[1] = n[0] * si; + q[2] = n[1] * si; + q[3] = n[2] * si; quat_to_mat3(cmat, q); mul_m3_m3m3(tmat, cmat, bmat); mul_m3_m3m3(rotmat, imat, tmat); unit_m3(scalemat1); - scalemat1[0][0]= M_SQRT2; - scalemat1[1][1]= M_SQRT2; + scalemat1[0][0] = M_SQRT2; + scalemat1[1][1] = M_SQRT2; mul_m3_m3m3(tmat, persmat, bmat); mul_m3_m3m3(cmat, scalemat1, tmat); @@ -4273,32 +4263,32 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen mul_m3_m3m3(tmat, persinv, cmat); mul_m3_m3m3(scalemat2, imat, tmat); - ok= 1; + ok = 1; - for (a=0;a<7;a++) { - ok= extrudeflagNurb(cu->editnurb, 1); + for (a = 0; a < 7; a++) { + ok = extrudeflagNurb(cu->editnurb, 1); - if (ok==0) + if (ok == 0) return changed; - changed= 1; + changed = 1; rotateflagNurb(editnurb, SELECT, cent, rotmat); - if ( (a & SELECT)==0 ) { + if ((a & SELECT) == 0) { rotateflagNurb(editnurb, SELECT, cent, scalemat1); - weightflagNurb(editnurb, SELECT, 0.25*M_SQRT2); + weightflagNurb(editnurb, SELECT, 0.25 * M_SQRT2); } else { rotateflagNurb(editnurb, SELECT, cent, scalemat2); - weightflagNurb(editnurb, SELECT, 4.0/M_SQRT2); + weightflagNurb(editnurb, SELECT, 4.0 / M_SQRT2); } } if (ok) { - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { - nu->orderv= 4; + nu->orderv = 4; nu->flagv |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_v(nu); } @@ -4310,8 +4300,8 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen static int spin_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + Object *obedit = CTX_data_edit_object(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); float cent[3], axis[3], viewmat[4][4]; RNA_float_get_array(op->ptr, "center", cent); @@ -4331,9 +4321,9 @@ static int spin_exec(bContext *C, wmOperator *op) } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4343,8 +4333,8 @@ static int spin_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); - float axis[3]= {0.0f, 0.0f, 1.0f}; + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + float axis[3] = {0.0f, 0.0f, 1.0f}; if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); @@ -4368,7 +4358,7 @@ void CURVE_OT_spin(wmOperatorType *ot) ot->poll = ED_operator_editsurf; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX); RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX); @@ -4378,47 +4368,47 @@ void CURVE_OT_spin(wmOperatorType *ot) static int addvert_Nurb(bContext *C, short mode, float location[3]) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - Nurb *nu, *newnu= NULL; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + Nurb *nu, *newnu = NULL; BezTriple *bezt, *newbezt = NULL; BPoint *bp, *newbp = NULL; float imat[4][4], temp[3]; - int ok= 0; + int ok = 0; BezTriple *bezt_recalc[3] = {NULL}; invert_m4_m4(imat, obedit->obmat); findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); - if ((nu == NULL) || (nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) { - if (mode!='e') { + if ((nu == NULL) || (nu->type == CU_BEZIER && bezt == NULL) || (nu->type != CU_BEZIER && bp == NULL)) { + if (mode != 'e') { if (cu->actnu >= 0) - nu= BLI_findlink(&editnurb->nurbs, cu->actnu); + nu = BLI_findlink(&editnurb->nurbs, cu->actnu); - if (!nu || nu->type==CU_BEZIER) { - newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); - newbezt->radius= 1; - newbezt->alfa= 0; + if (!nu || nu->type == CU_BEZIER) { + newbezt = (BezTriple *)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); + newbezt->radius = 1; + newbezt->alfa = 0; BEZ_SEL(newbezt); - newbezt->h2= newbezt->h1= HD_AUTO; + newbezt->h2 = newbezt->h1 = HD_AUTO; - newnu= (Nurb*)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu"); if (!nu) { /* no selected segment -- create new one which is BEZIER type * type couldn't be determined from Curve bt could be changed * in the future, so shouldn't make much headache */ - newnu->type= CU_BEZIER; - newnu->resolu= cu->resolu; + newnu->type = CU_BEZIER; + newnu->resolu = cu->resolu; newnu->flag |= CU_SMOOTH; } else memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bezt= newbezt; - newnu->pntsu= 1; + newnu->bezt = newbezt; + newnu->pntsu = 1; temp[0] = 1; temp[1] = 0; @@ -4432,32 +4422,32 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) mul_m4_v3(imat, newbezt->vec[1]); mul_m4_v3(imat, newbezt->vec[2]); - ok= 1; - nu= newnu; + ok = 1; + nu = newnu; } else if (nu->pntsv == 1) { - newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); - newbp->radius= 1; - newbp->alfa= 0; - newbp->f1|= SELECT; - cu->lastsel= newbp; + newbp = (BPoint *)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); + newbp->radius = 1; + newbp->alfa = 0; + newbp->f1 |= SELECT; + cu->lastsel = newbp; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bp= newbp; - newnu->orderu= 2; - newnu->pntsu= 1; + newnu->bp = newbp; + newnu->orderu = 2; + newnu->pntsu = 1; mul_v3_m4v3(newbp->vec, imat, location); - newbp->vec[3]= 1.0; + newbp->vec[3] = 1.0; - newnu->knotsu= newnu->knotsv= NULL; + newnu->knotsu = newnu->knotsv = NULL; BKE_nurb_knot_calc_u(newnu); - ok= 1; - nu= newnu; + ok = 1; + nu = newnu; } } @@ -4468,73 +4458,71 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) if (!ok && nu->type == CU_BEZIER) { /* which bezpoint? */ - if (bezt== (nu->bezt+nu->pntsu-1)) { /* last */ + if (bezt == &nu->bezt[nu->pntsu - 1]) { /* last */ BEZ_DESEL(bezt); - newbezt = - (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); + newbezt = (BezTriple *)MEM_callocN((nu->pntsu + 1) * sizeof(BezTriple), "addvert_Nurb"); ED_curve_beztcpy(editnurb, newbezt, nu->bezt, nu->pntsu); - *(newbezt+nu->pntsu)= *bezt; + newbezt[nu->pntsu] = *bezt; copy_v3_v3(temp, bezt->vec[1]); MEM_freeN(nu->bezt); - nu->bezt= newbezt; - newbezt+= nu->pntsu; + nu->bezt = newbezt; + newbezt += nu->pntsu; BEZ_SEL(newbezt); - cu->lastsel= newbezt; + cu->lastsel = newbezt; newbezt->h1 = newbezt->h2; - bezt= nu->bezt+nu->pntsu-1; - ok= 1; + bezt = &nu->bezt[nu->pntsu - 1]; + ok = 1; if (nu->pntsu > 1) { bezt_recalc[1] = newbezt; bezt_recalc[0] = newbezt - 1; } } - else if (bezt== nu->bezt) { /* first */ + else if (bezt == nu->bezt) { /* first */ BEZ_DESEL(bezt); - newbezt = - (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); - ED_curve_beztcpy(editnurb, newbezt+1, bezt, nu->pntsu); - *newbezt= *bezt; + newbezt = (BezTriple *)MEM_callocN((nu->pntsu + 1) * sizeof(BezTriple), "addvert_Nurb"); + ED_curve_beztcpy(editnurb, newbezt + 1, bezt, nu->pntsu); + *newbezt = *bezt; BEZ_SEL(newbezt); - cu->lastsel= newbezt; - newbezt->h2= newbezt->h1; + cu->lastsel = newbezt; + newbezt->h2 = newbezt->h1; copy_v3_v3(temp, bezt->vec[1]); MEM_freeN(nu->bezt); - nu->bezt= newbezt; - bezt= newbezt+1; - ok= 1; + nu->bezt = newbezt; + bezt = newbezt + 1; + ok = 1; if (nu->pntsu > 1) { bezt_recalc[1] = newbezt; bezt_recalc[2] = newbezt + 1; } } - else if (mode!='e') { + else if (mode != 'e') { BEZ_DESEL(bezt); - newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); - *newbezt= *bezt; + newbezt = (BezTriple *)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); + *newbezt = *bezt; BEZ_SEL(newbezt); - newbezt->h2= newbezt->h1; + newbezt->h2 = newbezt->h1; copy_v3_v3(temp, bezt->vec[1]); - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bezt= newbezt; - newnu->pntsu= 1; + newnu->bezt = newbezt; + newnu->pntsu = 1; - cu->lastsel= newbezt; + cu->lastsel = newbezt; - bezt= newbezt; - ok= 1; + bezt = newbezt; + ok = 1; } - else bezt= NULL; + else bezt = NULL; if (bezt) { if (!newnu) nu->pntsu++; - if (mode=='e') { + if (mode == 'e') { copy_v3_v3(newbezt->vec[0], bezt->vec[0]); copy_v3_v3(newbezt->vec[1], bezt->vec[1]); copy_v3_v3(newbezt->vec[2], bezt->vec[2]); @@ -4561,65 +4549,63 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } } } - else if (!ok && nu->pntsv==1) { + else if (!ok && nu->pntsv == 1) { /* which b-point? */ - if (bp== (nu->bp+nu->pntsu-1)) { /* last */ - bp->f1= 0; - newbp = - (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb4"); + if (bp == &nu->bp[nu->pntsu - 1]) { /* last */ + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN((nu->pntsu + 1) * sizeof(BPoint), "addvert_Nurb4"); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - *(newbp+nu->pntsu)= *bp; + newbp[nu->pntsu] = *bp; MEM_freeN(nu->bp); - nu->bp= newbp; - newbp+= nu->pntsu; - newbp->f1|= SELECT; - cu->lastsel= newbp; - bp= newbp - 1; - ok= 1; - } - else if (bp== nu->bp) { /* first */ - bp->f1= 0; - newbp = - (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb3"); - ED_curve_bpcpy(editnurb, newbp+1, bp, nu->pntsu); - *newbp= *bp; - newbp->f1|= SELECT; - cu->lastsel= newbp; + nu->bp = newbp; + newbp += nu->pntsu; + newbp->f1 |= SELECT; + cu->lastsel = newbp; + bp = newbp - 1; + ok = 1; + } + else if (bp == nu->bp) { /* first */ + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN((nu->pntsu + 1) * sizeof(BPoint), "addvert_Nurb3"); + ED_curve_bpcpy(editnurb, newbp + 1, bp, nu->pntsu); + *newbp = *bp; + newbp->f1 |= SELECT; + cu->lastsel = newbp; MEM_freeN(nu->bp); - nu->bp= newbp; - bp= newbp + 1; - ok= 1; - } - else if (mode!='e') { - bp->f1= 0; - newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); - *newbp= *bp; - newbp->f1|= SELECT; - cu->lastsel= newbp; - - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + nu->bp = newbp; + bp = newbp + 1; + ok = 1; + } + else if (mode != 'e') { + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); + *newbp = *bp; + newbp->f1 |= SELECT; + cu->lastsel = newbp; + + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bp= newbp; - newnu->orderu= 2; - newnu->pntsu= 1; - newnu->knotsu= newnu->knotsv= NULL; + newnu->bp = newbp; + newnu->orderu = 2; + newnu->pntsu = 1; + newnu->knotsu = newnu->knotsv = NULL; - bp= newbp; - ok= 1; + bp = newbp; + ok = 1; } - else bp= NULL; + else bp = NULL; if (bp) { - if (mode=='e') { + if (mode == 'e') { copy_v3_v3(newbp->vec, bp->vec); } else { mul_v3_m4v3(newbp->vec, imat, location); - newbp->vec[3]= 1.0; + newbp->vec[3] = 1.0; - if (!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu) + if (!newnu && nu->orderu < 4 && nu->orderu <= nu->pntsu) nu->orderu++; } @@ -4635,9 +4621,9 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) BKE_nurb_test2D(nu); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4656,7 +4642,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { Curve *cu; @@ -4669,7 +4655,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) view3d_set_viewcontext(C, &vc); - cu= vc.obedit->data; + cu = vc.obedit->data; findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp); @@ -4703,7 +4689,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location to add new vertex at", -1e4, 1e4); @@ -4713,25 +4699,25 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; /* first test: curve? */ - for (nu= editnurb->nurbs.first; nu; nu= nu->next) - if (nu->pntsv==1 && isNurbsel_count(cu, nu)==1) + for (nu = editnurb->nurbs.first; nu; nu = nu->next) + if (nu->pntsv == 1 && isNurbsel_count(cu, nu) == 1) break; - if (obedit->type==OB_CURVE || nu) { + if (obedit->type == OB_CURVE || nu) { addvert_Nurb(C, 'e', NULL); } else { if (extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } @@ -4751,7 +4737,7 @@ void CURVE_OT_extrude(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -4761,21 +4747,21 @@ void CURVE_OT_extrude(wmOperatorType *ot) static int toggle_cyclic_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - int a, direction= RNA_enum_get(op->ptr, "direction"); + int a, direction = RNA_enum_get(op->ptr, "direction"); - for (nu= editnurb->first; nu; nu= nu->next) { - if ( nu->pntsu>1 || nu->pntsv>1) { + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->pntsu > 1 || nu->pntsv > 1) { if (nu->type == CU_POLY) { - a= nu->pntsu; - bp= nu->bp; + a = nu->pntsu; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT ) { + if (bp->f1 & SELECT) { nu->flagu ^= CU_NURB_CYCLIC; break; } @@ -4783,10 +4769,10 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } } else if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { nu->flagu ^= CU_NURB_CYCLIC; break; } @@ -4794,31 +4780,31 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } BKE_nurb_handles_calc(nu); } - else if (nu->pntsv==1 && nu->type == CU_NURBS) { + else if (nu->pntsv == 1 && nu->type == CU_NURBS) { if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */ - a= nu->pntsu; - bp= nu->bp; + a = nu->pntsu; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT ) { + if (bp->f1 & SELECT) { nu->flagu ^= CU_NURB_CYCLIC; - BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ + BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ break; } bp++; } } } - else if (nu->type==CU_NURBS) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + else if (nu->type == CU_NURBS) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT) { - if (direction==0 && nu->pntsu>1) { + if (bp->f1 & SELECT) { + if (direction == 0 && nu->pntsu > 1) { nu->flagu ^= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ } - if (direction==1 && nu->pntsv>1) { + if (direction == 1 && nu->pntsv > 1) { nu->flagv ^= CU_NURB_CYCLIC; BKE_nurb_knot_calc_v(nu); /* 2==v type is ignored for cyclic curves */ } @@ -4831,7 +4817,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4839,18 +4825,18 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); uiPopupMenu *pup; uiLayout *layout; Nurb *nu; if (obedit->type == OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - if (nu->pntsu>1 || nu->pntsv>1) { - if (nu->type==CU_NURBS) { - pup= uiPupMenuBegin(C, "Direction", ICON_NONE); - layout= uiPupMenuLayout(pup); + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->pntsu > 1 || nu->pntsv > 1) { + if (nu->type == CU_NURBS) { + pup = uiPupMenuBegin(C, "Direction", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "direction"); uiPupMenuEnd(C, pup); return OPERATOR_CANCELLED; @@ -4864,7 +4850,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve void CURVE_OT_cyclic_toggle(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {0, "CYCLIC_U", 0, "Cyclic U", ""}, {1, "CYCLIC_V", 0, "Cyclic V", ""}, {0, NULL, 0, NULL, NULL}}; @@ -4880,7 +4866,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to make surface cyclic in"); @@ -4890,23 +4876,23 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - ListBase *nurbs= &editnurb->nurbs; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + ListBase *nurbs = &editnurb->nurbs; Nurb *nu; BezTriple *bezt; BPoint *bp; int a; - for (nu= nurbs->first; nu; nu= nu->next) { + for (nu = nurbs->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; @@ -4917,12 +4903,12 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if ( bp->f1 & 1 ) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + if (bp->f1 & SELECT) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { select_bpoint(bp, SELECT, 1, VISIBLE); bp++; @@ -4934,7 +4920,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -4957,7 +4943,7 @@ void CURVE_OT_select_linked(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ } @@ -4967,14 +4953,14 @@ void CURVE_OT_select_linked(wmOperatorType *ot) static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); ViewContext vc; Nurb *nu; BezTriple *bezt; BPoint *bp; int a, deselect; - deselect= RNA_boolean_get(op->ptr, "deselect"); + deselect = RNA_boolean_get(op->ptr, "deselect"); view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); @@ -4982,8 +4968,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp); if (bezt) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { if (deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE); else select_beztriple(bezt, SELECT, 1, VISIBLE); @@ -4991,8 +4977,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event } } else if (bp) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (deselect) select_bpoint(bp, DESELECT, 1, VISIBLE); else select_bpoint(bp, SELECT, 1, VISIBLE); @@ -5000,7 +4986,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5017,7 +5003,7 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve_region_view3d; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked control points rather than selecting them"); @@ -5027,28 +5013,28 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot) static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); - static BPoint *last= NULL; - static int direction=0; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); + static BPoint *last = NULL; + static int direction = 0; Nurb *nu; BPoint *bp; - int u = 0, v = 0, a, b, ok=0; + int u = 0, v = 0, a, b, ok = 0; if (editnurb->first == NULL) return OPERATOR_CANCELLED; - if (cu->lastsel==NULL) + if (cu->lastsel == NULL) return OPERATOR_CANCELLED; /* find the correct nurb and toggle with u of v */ - for (nu= editnurb->first; nu; nu= nu->next) { - bp= nu->bp; - for (v=0; v<nu->pntsv; v++) { - for (u=0; u<nu->pntsu; u++, bp++) { - if (bp==cu->lastsel) { + for (nu = editnurb->first; nu; nu = nu->next) { + bp = nu->bp; + for (v = 0; v < nu->pntsv; v++) { + for (u = 0; u < nu->pntsu; u++, bp++) { + if (bp == cu->lastsel) { if (bp->f1 & SELECT) { - ok= 1; + ok = 1; break; } } @@ -5057,20 +5043,20 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) } if (ok) { - if (last==cu->lastsel) { - direction= 1-direction; + if (last == cu->lastsel) { + direction = 1 - direction; setflagsNurb(editnurb, 0); } - last= cu->lastsel; + last = cu->lastsel; - bp= nu->bp; - for (a=0; a<nu->pntsv; a++) { - for (b=0; b<nu->pntsu; b++, bp++) { + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp++) { if (direction) { - if (a==v) select_bpoint(bp, SELECT, 1, VISIBLE); + if (a == v) select_bpoint(bp, SELECT, 1, VISIBLE); } else { - if (b==u) select_bpoint(bp, SELECT, 1, VISIBLE); + if (b == u) select_bpoint(bp, SELECT, 1, VISIBLE); } } } @@ -5079,7 +5065,7 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5096,18 +5082,18 @@ void CURVE_OT_select_row(wmOperatorType *ot) ot->poll = ED_operator_editsurf; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select next operator **********************/ static int select_next_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, 1, 0, SELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5124,18 +5110,18 @@ void CURVE_OT_select_next(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select previous operator **********************/ static int select_previous_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, -1, 0, SELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5152,58 +5138,58 @@ void CURVE_OT_select_previous(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select more operator **********************/ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp, *tempbp; int a; - short sel= 0; + short sel = 0; short *selbpoints; /* note that NURBS surface is a special case because we mimic */ /* the behavior of "select more" of mesh tools. */ /* The algorithm is designed to work in planar cases so it */ /* may not be optimal always (example: end of NURBS sphere) */ - if (obedit->type==OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - selbpoints= MEM_callocN(sizeof(short)*a-nu->pntsu, "selectlist"); + if (obedit->type == OB_SURF) { + for (nu = editnurb->first; nu; nu = nu->next) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + selbpoints = MEM_callocN(sizeof(short) * a - nu->pntsu, "selectlist"); while (a > 0) { - if ((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) { + if ((selbpoints[a] != 1) && (bp->hide == 0) && (bp->f1 & SELECT)) { /* upper control point */ - if (a%nu->pntsu != 0) { - tempbp= bp-1; + if (a % nu->pntsu != 0) { + tempbp = bp - 1; if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* left control point. select only if it is not selected already */ - if (a-nu->pntsu > 0) { - sel= 0; - tempbp= bp+nu->pntsu; - if (!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (a - nu->pntsu > 0) { + sel = 0; + tempbp = bp + nu->pntsu; + if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE); /* make sure selected bpoint is discarded */ - if (sel == 1) selbpoints[a-nu->pntsu]= 1; + if (sel == 1) selbpoints[a - nu->pntsu] = 1; } /* right control point */ - if (a+nu->pntsu < nu->pntsu*nu->pntsv) { - tempbp= bp-nu->pntsu; + if (a + nu->pntsu < nu->pntsu * nu->pntsv) { + tempbp = bp - nu->pntsu; if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* lower control point. skip next bp in case selection was made */ - if (a%nu->pntsu != 1) { - sel= 0; - tempbp= bp+1; - if (!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (a % nu->pntsu != 1) { + sel = 0; + tempbp = bp + 1; + if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE); if (sel) { bp++; a--; @@ -5223,7 +5209,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) select_adjacent_cp(editnurb, -1, 0, SELECT); } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5233,14 +5219,14 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "CURVE_OT_select_more"; - ot->description = "Select control points linked to already selected ones"; + ot->description = "Select control points directly linked to already selected ones"; /* api callbacks */ ot->exec = select_more_exec; ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** select less operator *****************/ @@ -5248,60 +5234,60 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* basic method: deselect if control point doesn't have all neighbors selected */ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - short sel= 0, lastsel= 0; + short sel = 0, lastsel = 0; short *selbpoints; - if (obedit->type==OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - selbpoints= MEM_callocN(sizeof(short)*a, "selectlist"); + if (obedit->type == OB_SURF) { + for (nu = editnurb->first; nu; nu = nu->next) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + selbpoints = MEM_callocN(sizeof(short) * a, "selectlist"); while (a--) { - if ((bp->hide==0) && (bp->f1 & SELECT)) { - sel= 0; + if ((bp->hide == 0) && (bp->f1 & SELECT)) { + sel = 0; /* check if neighbors have been selected */ /* edges of surface are an exception */ - if ((a+1)%nu->pntsu==0) sel++; + if ((a + 1) % nu->pntsu == 0) sel++; else { bp--; - if ((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; + if ((selbpoints[a + 1] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; bp++; } - if ((a+1)%nu->pntsu==1) sel++; + if ((a + 1) % nu->pntsu == 1) sel++; else { bp++; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp--; } - if (a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++; + if (a + 1 > nu->pntsu * nu->pntsv - nu->pntsu) sel++; else { - bp-=nu->pntsu; - if ((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; - bp+=nu->pntsu; + bp -= nu->pntsu; + if ((selbpoints[a + nu->pntsu] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; + bp += nu->pntsu; } if (a < nu->pntsu) sel++; else { - bp+=nu->pntsu; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; - bp-=nu->pntsu; + bp += nu->pntsu; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; + bp -= nu->pntsu; } - if (sel!=4) { + if (sel != 4) { select_bpoint(bp, DESELECT, 1, VISIBLE); - selbpoints[a]= 1; + selbpoints[a] = 1; } } - else lastsel= 0; + else lastsel = 0; bp++; } @@ -5310,74 +5296,74 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } else { - for (nu= editnurb->first; nu; nu= nu->next) { - lastsel=0; + for (nu = editnurb->first; nu; nu = nu->next) { + lastsel = 0; /* check what type of curve/nurb it is */ if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if ((bezt->hide==0) && (bezt->f2 & SELECT)) { - if (lastsel==1) sel= 1; - else sel= 0; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) { + if (lastsel == 1) sel = 1; + else sel = 0; /* check if neighbors have been selected */ /* first and last are exceptions */ - if (a==nu->pntsu-1) sel++; + if (a == nu->pntsu - 1) sel++; else { bezt--; - if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; bezt++; } - if (a==0) sel++; + if (a == 0) sel++; else { bezt++; - if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; bezt--; } - if (sel!=2) { + if (sel != 2) { select_beztriple(bezt, DESELECT, 1, VISIBLE); - lastsel= 1; + lastsel = 1; } - else lastsel= 0; + else lastsel = 0; } - else lastsel= 0; + else lastsel = 0; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) { - if (lastsel!=0) sel= 1; - else sel= 0; + if ((lastsel == 0) && (bp->hide == 0) && (bp->f1 & SELECT)) { + if (lastsel != 0) sel = 1; + else sel = 0; /* first and last are exceptions */ - if (a==nu->pntsu*nu->pntsv-1) sel++; + if (a == nu->pntsu * nu->pntsv - 1) sel++; else { bp--; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp++; } - if (a==0) sel++; + if (a == 0) sel++; else { bp++; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp--; } - if (sel!=2) { + if (sel != 2) { select_bpoint(bp, DESELECT, 1, VISIBLE); - lastsel= 1; + lastsel = 1; } - else lastsel= 0; + else lastsel = 0; } - else lastsel= 0; + else lastsel = 0; bp++; } @@ -5385,7 +5371,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5402,7 +5388,7 @@ void CURVE_OT_select_less(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** select random *********************/ @@ -5416,10 +5402,10 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) BLI_srand(BLI_rand()); /* random seed */ - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (BLI_frand() < randfac) select_beztriple(bezt, SELECT, 1, VISIBLE); @@ -5427,8 +5413,8 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (BLI_frand() < randfac) @@ -5441,15 +5427,15 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) static int select_random_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); if (!RNA_boolean_get(op->ptr, "extend")) CU_deselect_all(obedit); - selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent")/100.0f); + selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent") / 100.0f); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5466,7 +5452,7 @@ void CURVE_OT_select_random(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); @@ -5478,19 +5464,19 @@ void CURVE_OT_select_random(wmOperatorType *ot) static int point_on_nurb(Nurb *nu, void *point) { if (nu->bezt) { - BezTriple *bezt= (BezTriple*)point; - return bezt >= nu->bezt && bezt < nu->bezt + nu->pntsu; + BezTriple *bezt = (BezTriple *)point; + return bezt >= nu->bezt && bezt < &nu->bezt[nu->pntsu]; } else { - BPoint *bp= (BPoint*)point; - return bp >= nu->bp && bp < nu->bp + nu->pntsu * nu->pntsv; + BPoint *bp = (BPoint *)point; + return bp >= nu->bp && bp < &nu->bp[nu->pntsu * nu->pntsv]; } } static Nurb *get_lastsel_nurb(Curve *cu) { - ListBase *nubase= BKE_curve_editNurbs_get(cu); - Nurb *nu= nubase->first; + ListBase *nubase = BKE_curve_editNurbs_get(cu); + Nurb *nu = nubase->first; if (!cu->lastsel) return NULL; @@ -5499,7 +5485,7 @@ static Nurb *get_lastsel_nurb(Curve *cu) if (point_on_nurb(nu, cu->lastsel)) return nu; - nu= nu->next; + nu = nu->next; } return NULL; @@ -5509,9 +5495,9 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth) { int a, start; - start= bezt - nu->bezt; - a= nu->pntsu; - bezt= nu->bezt + a - 1; + start = bezt - nu->bezt; + a = nu->pntsu; + bezt = &nu->bezt[a - 1]; while (a--) { if (abs(start - a) % nth) { @@ -5527,23 +5513,23 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth) int a, startrow, startpnt; int dist, row, pnt; - startrow= (bp - nu->bp) / nu->pntsu; - startpnt= (bp - nu->bp) % nu->pntsu; + startrow = (bp - nu->bp) / nu->pntsu; + startpnt = (bp - nu->bp) % nu->pntsu; - a= nu->pntsu * nu->pntsv; - bp= nu->bp + a - 1; + a = nu->pntsu * nu->pntsv; + bp = &nu->bp[a - 1]; row = nu->pntsv - 1; pnt = nu->pntsu - 1; while (a--) { - dist= abs(pnt - startpnt) + abs(row - startrow); + dist = abs(pnt - startpnt) + abs(row - startrow); if (dist % nth) { select_bpoint(bp, DESELECT, 1, HIDDEN); } pnt--; if (pnt < 0) { - pnt= nu->pntsu - 1; + pnt = nu->pntsu - 1; row--; } @@ -5553,10 +5539,10 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth) int CU_select_nth(Object *obedit, int nth) { - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; Nurb *nu; - nu= get_lastsel_nurb(cu); + nu = get_lastsel_nurb(cu); if (!nu) return 0; @@ -5572,8 +5558,8 @@ int CU_select_nth(Object *obedit, int nth) static int select_nth_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - int nth= RNA_int_get(op->ptr, "nth"); + Object *obedit = CTX_data_edit_object(C); + int nth = RNA_int_get(op->ptr, "nth"); if (!CU_select_nth(obedit, nth)) { if (obedit->type == OB_SURF) { @@ -5586,7 +5572,7 @@ static int select_nth_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5603,7 +5589,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "nth", 2, 2, 100, "Nth Selection", "", 1, INT_MAX); } @@ -5612,10 +5598,10 @@ void CURVE_OT_select_nth(wmOperatorType *ot) static int duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); adduplicateflagNurb(obedit, 1); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5632,25 +5618,25 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** delete operator *********************/ static int delete_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; - ListBase *nubase= &editnurb->nurbs; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; + ListBase *nubase = &editnurb->nurbs; Nurb *nu, *nu1; BezTriple *bezt, *bezt1, *bezt2; BPoint *bp, *bp1, *bp2; - int a, cut= 0, type= RNA_enum_get(op->ptr, "type"); - int nuindex= 0; + int a, cut = 0, type = RNA_enum_get(op->ptr, "type"); + int nuindex = 0; - if (obedit->type==OB_SURF) { - if (type==0) { + if (obedit->type == OB_SURF) { + if (type == 0) { deleteflagNurb(C, op, 1); } else { @@ -5658,58 +5644,58 @@ static int delete_exec(bContext *C, wmOperator *op) BKE_nurbList_free(nubase); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } - if (type==0) { + if (type == 0) { /* first loop, can we remove entire pieces? */ Nurb *next; - nu= nubase->first; + nu = nubase->first; while (nu) { - next= nu->next; + next = nu->next; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; if (a) { while (a) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ); + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) ; else break; a--; bezt++; } - if (a==0) { + if (a == 0) { if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; if (a) { while (a) { - if (bp->f1 & SELECT); + if (bp->f1 & SELECT) ; else break; a--; bp++; } - if (a==0) { + if (a == 0) { if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } } } @@ -5717,55 +5703,54 @@ static int delete_exec(bContext *C, wmOperator *op) /* Never allow the order to exceed the number of points * - note, this is ok but changes unselected nurbs, disable for now */ #if 0 - if ((nu!= NULL) && (nu->type == CU_NURBS)) { + if ((nu != NULL) && (nu->type == CU_NURBS)) { clamp_nurb_order_u(nu); } #endif - nu= next; + nu = next; nuindex++; } /* 2nd loop, delete small pieces: just for curves */ - nu= nubase->first; + nu = nubase->first; while (nu) { - next= nu->next; - type= 0; + next = nu->next; + type = 0; if (nu->type == CU_BEZIER) { - int delta= 0; - bezt= nu->bezt; - for (a=0;a<nu->pntsu;a++) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { - memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple)); + int delta = 0; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu; a++) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple)); keyIndex_delBezt(editnurb, bezt + delta); - keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu-a-1); + keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1); nu->pntsu--; a--; - type= 1; + type = 1; delta++; } else bezt++; } if (type) { - bezt1 = - (BezTriple*)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); - memcpy(bezt1, nu->bezt, (nu->pntsu)*sizeof(BezTriple)); + bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); + memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple)); keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu); MEM_freeN(nu->bezt); - nu->bezt= bezt1; + nu->bezt = bezt1; BKE_nurb_handles_calc(nu); } } - else if (nu->pntsv==1) { - int delta= 0; - bp= nu->bp; - - for (a=0;a<nu->pntsu;a++) { - if ( bp->f1 & SELECT ) { - memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint)); + else if (nu->pntsv == 1) { + int delta = 0; + bp = nu->bp; + + for (a = 0; a < nu->pntsu; a++) { + if (bp->f1 & SELECT) { + memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint)); keyIndex_delBP(editnurb, bp + delta); - keyIndex_updateBP(editnurb, bp+1, bp, nu->pntsu-a-1); + keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1); nu->pntsu--; a--; - type= 1; + type = 1; delta++; } else { @@ -5773,11 +5758,11 @@ static int delete_exec(bContext *C, wmOperator *op) } } if (type) { - bp1 = (BPoint*)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); - memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint)); + bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); + memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint)); keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu); MEM_freeN(nu->bp); - nu->bp= bp1; + nu->bp = bp1; /* Never allow the order to exceed the number of points * - note, this is ok but changes unselected nurbs, disable for now */ @@ -5790,68 +5775,68 @@ static int delete_exec(bContext *C, wmOperator *op) BKE_nurb_order_clamp_u(nu); BKE_nurb_knot_calc_u(nu); } - nu= next; + nu = next; } } - else if (type==1) { /* erase segment */ + else if (type == 1) { /* erase segment */ /* find the 2 selected points */ - bezt1= bezt2= NULL; - bp1= bp2= NULL; - nu1= NULL; - nuindex= 0; - for (nu= nubase->first; nu; nu= nu->next) { + bezt1 = bezt2 = NULL; + bp1 = bp2 = NULL; + nu1 = NULL; + nuindex = 0; + for (nu = nubase->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - for (a=0; a<nu->pntsu-1; a++) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { - bezt1= bezt; - bezt2= bezt+1; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu - 1; a++) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + bezt1 = bezt; + bezt2 = bezt + 1; if ((bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT)) { /* pass */ } - else { /* maybe do not make cyclic */ - if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { - bezt2= bezt+(nu->pntsu-1); + else { /* maybe do not make cyclic */ + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) ) { + bezt2 = bezt + (nu->pntsu - 1); if ( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { nu->flagu &= ~CU_NURB_CYCLIC; BKE_nurb_handles_calc(nu); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } return OPERATOR_FINISHED; } - cut= a; - nu1= nu; + cut = a; + nu1 = nu; break; } bezt++; } } - else if (nu->pntsv==1) { - bp= nu->bp; - for (a=0; a<nu->pntsu-1; a++) { - if ( bp->f1 & SELECT ) { - bp1= bp; - bp2= bp+1; - if (bp2->f1 & 1) { + else if (nu->pntsv == 1) { + bp = nu->bp; + for (a = 0; a < nu->pntsu - 1; a++) { + if (bp->f1 & SELECT) { + bp1 = bp; + bp2 = bp + 1; + if (bp2->f1 & SELECT) { /* pass */ } - else { /* maybe do not make cyclic */ - if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { - bp2= bp+(nu->pntsu-1); - if ( bp2->f1 & SELECT ) { + else { /* maybe do not make cyclic */ + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) ) { + bp2 = bp + (nu->pntsu - 1); + if (bp2->f1 & SELECT) { nu->flagu &= ~CU_NURB_CYCLIC; - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } return OPERATOR_FINISHED; } - cut= a; - nu1= nu; + cut = a; + nu1 = nu; break; } bp++; @@ -5862,45 +5847,41 @@ static int delete_exec(bContext *C, wmOperator *op) } if (nu1) { if (bezt1) { - if (nu1->pntsu==2) { /* remove completely */ + if (nu1->pntsu == 2) { /* remove completely */ if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); BKE_nurb_free(nu); nu = NULL; } - else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ - bezt = - (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1"); - ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut+1); - a= nu1->pntsu-cut-1; + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + bezt = (BezTriple *)MEM_mallocN((cut + 1) * sizeof(BezTriple), "delNurb1"); + ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut + 1); + a = nu1->pntsu - cut - 1; ED_curve_beztcpy(editnurb, nu1->bezt, bezt2, a); - ED_curve_beztcpy(editnurb, nu1->bezt+a, bezt, cut+1); + ED_curve_beztcpy(editnurb, &nu1->bezt[a], bezt, cut + 1); nu1->flagu &= ~CU_NURB_CYCLIC; MEM_freeN(bezt); BKE_nurb_handles_calc(nu); } - else { /* add new curve */ + else { /* add new curve */ /* seems to be an error here... but where? (a can become zero) */ - nu = - (Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb2"); + nu = (Nurb *)MEM_mallocN(sizeof(Nurb), "delNurb2"); memcpy(nu, nu1, sizeof(Nurb)); BLI_addtail(nubase, nu); - nu->bezt = - (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb3"); - ED_curve_beztcpy(editnurb, nu->bezt, nu1->bezt, cut+1); - a= nu1->pntsu-cut-1; - - bezt = - (BezTriple*)MEM_mallocN(a * sizeof(BezTriple), "delNurb4"); - ED_curve_beztcpy(editnurb, bezt, nu1->bezt+cut+1, a); + nu->bezt = (BezTriple *)MEM_mallocN((cut + 1) * sizeof(BezTriple), "delNurb3"); + ED_curve_beztcpy(editnurb, nu->bezt, nu1->bezt, cut + 1); + a = nu1->pntsu - cut - 1; + + bezt = (BezTriple *)MEM_mallocN(a * sizeof(BezTriple), "delNurb4"); + ED_curve_beztcpy(editnurb, bezt, &nu1->bezt[cut + 1], a); MEM_freeN(nu1->bezt); - nu1->bezt= bezt; - nu1->pntsu= a; - nu->pntsu= cut+1; + nu1->bezt = bezt; + nu1->pntsu = a; + nu->pntsu = cut + 1; BKE_nurb_handles_calc(nu); @@ -5908,40 +5889,37 @@ static int delete_exec(bContext *C, wmOperator *op) } } else if (bp1) { - if (nu1->pntsu==2) { /* remove completely */ + if (nu1->pntsu == 2) { /* remove completely */ if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } - else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ - bp = - (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5"); - ED_curve_bpcpy(editnurb, bp, nu1->bp, cut+1); - a= nu1->pntsu-cut-1; + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + bp = (BPoint *)MEM_mallocN((cut + 1) * sizeof(BPoint), "delNurb5"); + ED_curve_bpcpy(editnurb, bp, nu1->bp, cut + 1); + a = nu1->pntsu - cut - 1; ED_curve_bpcpy(editnurb, nu1->bp, bp2, a); - ED_curve_bpcpy(editnurb, nu1->bp+a, bp, cut+1); + ED_curve_bpcpy(editnurb, &nu1->bp[a], bp, cut + 1); nu1->flagu &= ~CU_NURB_CYCLIC; MEM_freeN(bp); } - else { /* add new curve */ - nu = (Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb6"); + else { /* add new curve */ + nu = (Nurb *)MEM_mallocN(sizeof(Nurb), "delNurb6"); memcpy(nu, nu1, sizeof(Nurb)); BLI_addtail(nubase, nu); - nu->bp = - (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb7"); - ED_curve_bpcpy(editnurb, nu->bp, nu1->bp, cut+1); - a= nu1->pntsu-cut-1; - bp = - (BPoint*)MEM_mallocN(a * sizeof(BPoint), "delNurb8"); - ED_curve_bpcpy(editnurb, bp, nu1->bp+cut+1, a); + nu->bp = (BPoint *)MEM_mallocN((cut + 1) * sizeof(BPoint), "delNurb7"); + ED_curve_bpcpy(editnurb, nu->bp, nu1->bp, cut + 1); + a = nu1->pntsu - cut - 1; + bp = (BPoint *)MEM_mallocN(a * sizeof(BPoint), "delNurb8"); + ED_curve_bpcpy(editnurb, bp, &nu1->bp[cut + 1], a); MEM_freeN(nu1->bp); - nu1->bp= bp; - nu1->pntsu= a; - nu1->knotsu= NULL; - nu->pntsu= cut+1; + nu1->bp = bp; + nu1->pntsu = a; + nu1->knotsu = NULL; + nu->pntsu = cut + 1; BKE_nurb_order_clamp_u(nu); BKE_nurb_knot_calc_u(nu); @@ -5952,16 +5930,16 @@ static int delete_exec(bContext *C, wmOperator *op) } } } - else if (type==2) { - cu->actnu= -1; + else if (type == 2) { + cu->actnu = -1; keyIndex_delNurbList(editnurb, nubase); BKE_nurbList_free(nubase); } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -5969,20 +5947,20 @@ static int delete_exec(bContext *C, wmOperator *op) static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); uiPopupMenu *pup; uiLayout *layout; - if (obedit->type==OB_SURF) { - pup= uiPupMenuBegin(C, "Delete", ICON_NONE); - layout= uiPupMenuLayout(pup); + if (obedit->type == OB_SURF) { + pup = uiPupMenuBegin(C, "Delete", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0); uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2); uiPupMenuEnd(C, pup); } else { - pup= uiPupMenuBegin(C, "Delete", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Delete", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "type"); uiPupMenuEnd(C, pup); } @@ -6009,7 +5987,7 @@ void CURVE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Which elements to delete"); @@ -6019,22 +5997,22 @@ void CURVE_OT_delete(wmOperatorType *ot) static int shade_smooth_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int clear= (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); + int clear = (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { if (!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -6052,7 +6030,7 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void CURVE_OT_shade_flat(wmOperatorType *ot) @@ -6067,16 +6045,16 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************** join operator, to be used externally? ****************/ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); Curve *cu; Nurb *nu, *newnu; BezTriple *bezt; @@ -6085,33 +6063,33 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) float imat[4][4], cmat[4][4]; int a; - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - if (base->object->type==ob->type) { + if (base->object->type == ob->type) { if (base->object != ob) { - cu= base->object->data; + cu = base->object->data; if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ mult_m4_m4m4(cmat, imat, base->object->obmat); - nu= cu->nurb.first; + nu = cu->nurb.first; while (nu) { - newnu= BKE_nurb_duplicate(nu); + newnu = BKE_nurb_duplicate(nu); if (ob->totcol) { /* TODO, merge material lists */ - CLAMP(newnu->mat_nr, 0, ob->totcol-1); + CLAMP(newnu->mat_nr, 0, ob->totcol - 1); } - else newnu->mat_nr= 0; + else newnu->mat_nr = 0; BLI_addtail(&tempbase, newnu); - if ( (bezt= newnu->bezt) ) { - a= newnu->pntsu; + if ( (bezt = newnu->bezt) ) { + a = newnu->pntsu; while (a--) { mul_m4_v3(cmat, bezt->vec[0]); mul_m4_v3(cmat, bezt->vec[1]); @@ -6120,14 +6098,14 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } BKE_nurb_handles_calc(newnu); } - if ( (bp= newnu->bp) ) { - a= newnu->pntsu*nu->pntsv; + if ( (bp = newnu->bp) ) { + a = newnu->pntsu * nu->pntsv; while (a--) { mul_m4_v3(cmat, bp->vec); bp++; } } - nu= nu->next; + nu = nu->next; } } @@ -6137,15 +6115,15 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - cu= ob->data; + cu = ob->data; BLI_movelisttolist(&cu->nurb, &tempbase); - DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! + DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); return OPERATOR_FINISHED; } @@ -6154,9 +6132,9 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) static const char *get_curve_defname(int type) { - int stype= type & CU_PRIMITIVE; + int stype = type & CU_PRIMITIVE; - if ((type & CU_TYPE)==CU_BEZIER) { + if ((type & CU_TYPE) == CU_BEZIER) { switch (stype) { case CU_PRIM_CURVE: return "BezierCurve"; case CU_PRIM_CIRCLE: return "BezierCircle"; @@ -6178,7 +6156,7 @@ static const char *get_curve_defname(int type) static const char *get_surf_defname(int type) { - int stype= type & CU_PRIMITIVE; + int stype = type & CU_PRIMITIVE; switch (stype) { case CU_PRIM_CURVE: return "SurfCurve"; @@ -6194,22 +6172,22 @@ static const char *get_surf_defname(int type) Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) { - static int xzproj= 0; /* this function calls itself... */ - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + static int xzproj = 0; /* this function calls itself... */ + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); Nurb *nu = NULL; BezTriple *bezt; BPoint *bp; - Curve *cu= (Curve*)obedit->data; - float vec[3], zvec[3]= {0.0f, 0.0f, 1.0f}; - float umat[4][4]= MAT4_UNITY, viewmat[4][4]= MAT4_UNITY; + Curve *cu = (Curve *)obedit->data; + float vec[3], zvec[3] = {0.0f, 0.0f, 1.0f}; + float umat[4][4] = MAT4_UNITY, viewmat[4][4] = MAT4_UNITY; float fac; int a, b; - const float grid= v3d ? v3d->grid : 1.0f; - const int cutype= (type & CU_TYPE); // poly, bezier, nurbs, etc - const int stype= (type & CU_PRIMITIVE); + const float grid = v3d ? v3d->grid : 1.0f; + const int cutype = (type & CU_TYPE); // poly, bezier, nurbs, etc + const int stype = (type & CU_PRIMITIVE); const int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ if (rv3d) { @@ -6220,328 +6198,325 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) setflagsNurb(editnurb, 0); /* these types call this function to return a Nurb */ - if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) { - nu = (Nurb*)MEM_callocN(sizeof(Nurb), "addNurbprim"); - nu->type= cutype; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; + if (stype != CU_PRIM_TUBE && stype != CU_PRIM_DONUT) { + nu = (Nurb *)MEM_callocN(sizeof(Nurb), "addNurbprim"); + nu->type = cutype; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; } switch (stype) { - case CU_PRIM_CURVE: /* curve */ - nu->resolu= cu->resolu; - if (cutype==CU_BEZIER) { - if (!force_3d) nu->flag |= CU_2D; - nu->pntsu= 2; - nu->bezt = - (BezTriple*)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1"); - bezt= nu->bezt; - bezt->h1= bezt->h2= HD_ALIGN; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->radius = 1.0; - - bezt->vec[1][0]+= -grid; - bezt->vec[0][0]+= -1.5f*grid; - bezt->vec[0][1]+= -0.5f*grid; - bezt->vec[2][0]+= -0.5f*grid; - bezt->vec[2][1]+= 0.5f*grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + case CU_PRIM_CURVE: /* curve */ + nu->resolu = cu->resolu; + if (cutype == CU_BEZIER) { + if (!force_3d) nu->flag |= CU_2D; + nu->pntsu = 2; + nu->bezt = (BezTriple *)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1"); + bezt = nu->bezt; + bezt->h1 = bezt->h2 = HD_ALIGN; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->radius = 1.0; + + bezt->vec[1][0] += -grid; + bezt->vec[0][0] += -1.5f * grid; + bezt->vec[0][1] += -0.5f * grid; + bezt->vec[2][0] += -0.5f * grid; + bezt->vec[2][1] += 0.5f * grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); - bezt++; - bezt->h1= bezt->h2= HD_ALIGN; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->radius = bezt->weight = 1.0; - - bezt->vec[0][0] = 0; - bezt->vec[0][1] = 0; - bezt->vec[1][0] = grid; - bezt->vec[1][1] = 0; - bezt->vec[2][0] = grid*2; - bezt->vec[2][1] = 0; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + bezt++; + bezt->h1 = bezt->h2 = HD_ALIGN; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->radius = bezt->weight = 1.0; + + bezt->vec[0][0] = 0; + bezt->vec[0][1] = 0; + bezt->vec[1][0] = grid; + bezt->vec[1][1] = 0; + bezt->vec[2][0] = grid * 2; + bezt->vec[2][1] = 0; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); - BKE_nurb_handles_calc(nu); - } - else { + BKE_nurb_handles_calc(nu); + } + else { + + nu->pntsu = 4; + nu->pntsv = 1; + nu->orderu = 4; + nu->bp = callocstructN(BPoint, 4, "addNurbprim3"); + + bp = nu->bp; + for (a = 0; a < 4; a++, bp++) { + bp->vec[3] = 1.0; + bp->f1 = SELECT; + bp->radius = bp->weight = 1.0; + } + + bp = nu->bp; + bp->vec[0] += -1.5f * grid; + bp++; + bp->vec[0] += -grid; + bp->vec[1] += grid; + bp++; + bp->vec[0] += grid; + bp->vec[1] += grid; + bp++; + bp->vec[0] += 1.5f * grid; + + bp = nu->bp; + for (a = 0; a < 4; a++, bp++) mul_m4_v3(mat, bp->vec); + + if (cutype == CU_NURBS) { + nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */ + BKE_nurb_knot_calc_u(nu); + } - nu->pntsu= 4; - nu->pntsv= 1; - nu->orderu= 4; - nu->bp= callocstructN(BPoint, 4, "addNurbprim3"); - - bp= nu->bp; - for (a=0;a<4;a++, bp++) { - bp->vec[3]= 1.0; - bp->f1= SELECT; + } + break; + case CU_PRIM_PATH: /* 5 point path */ + nu->pntsu = 5; + nu->pntsv = 1; + nu->orderu = 5; + nu->flagu = CU_NURB_ENDPOINT; /* endpoint */ + nu->resolu = cu->resolu; + nu->bp = callocstructN(BPoint, 5, "addNurbprim3"); + + bp = nu->bp; + for (a = 0; a < 5; a++, bp++) { + bp->vec[3] = 1.0; + bp->f1 = SELECT; bp->radius = bp->weight = 1.0; } - bp= nu->bp; - bp->vec[0]+= -1.5f*grid; + bp = nu->bp; + bp->vec[0] += -2.0f * grid; bp++; - bp->vec[0]+= -grid; - bp->vec[1]+= grid; + bp->vec[0] += -grid; + bp++; bp++; + bp->vec[0] += grid; bp++; - bp->vec[0]+= grid; - bp->vec[1]+= grid; - bp++; - bp->vec[0]+= 1.5f*grid; + bp->vec[0] += 2.0f * grid; - bp= nu->bp; - for (a=0;a<4;a++, bp++) mul_m4_v3(mat, bp->vec); + bp = nu->bp; + for (a = 0; a < 5; a++, bp++) mul_m4_v3(mat, bp->vec); - if (cutype==CU_NURBS) { - nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ + if (cutype == CU_NURBS) { + nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */ BKE_nurb_knot_calc_u(nu); } - } - break; - case CU_PRIM_PATH: /* 5 point path */ - nu->pntsu= 5; - nu->pntsv= 1; - nu->orderu= 5; - nu->flagu= CU_NURB_ENDPOINT; /* endpoint */ - nu->resolu= cu->resolu; - nu->bp= callocstructN(BPoint, 5, "addNurbprim3"); - - bp= nu->bp; - for (a=0;a<5;a++, bp++) { - bp->vec[3]= 1.0; - bp->f1= SELECT; - bp->radius = bp->weight = 1.0; - } - - bp= nu->bp; - bp->vec[0]+= -2.0f*grid; - bp++; - bp->vec[0]+= -grid; - bp++; bp++; - bp->vec[0]+= grid; - bp++; - bp->vec[0]+= 2.0f*grid; - - bp= nu->bp; - for (a=0;a<5;a++, bp++) mul_m4_v3(mat, bp->vec); - - if (cutype==CU_NURBS) { - nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ - BKE_nurb_knot_calc_u(nu); - } - - break; - case CU_PRIM_CIRCLE: /* circle */ - nu->resolu= cu->resolu; - - if (cutype==CU_BEZIER) { - if (!force_3d) nu->flag |= CU_2D; - nu->pntsu= 4; - nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1"); - nu->flagu= CU_NURB_CYCLIC; - bezt= nu->bezt; - - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][0]+= -grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + break; + case CU_PRIM_CIRCLE: /* circle */ + nu->resolu = cu->resolu; - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][1]+= grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; - - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][0]+= grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + if (cutype == CU_BEZIER) { + if (!force_3d) nu->flag |= CU_2D; + nu->pntsu = 4; + nu->bezt = callocstructN(BezTriple, 4, "addNurbprim1"); + nu->flagu = CU_NURB_CYCLIC; + bezt = nu->bezt; + + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][0] += -grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][1]+= -grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][1] += grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - BKE_nurb_handles_calc(nu); - } - else if ( cutype==CU_NURBS ) { /* nurb */ - nu->pntsu= 8; - nu->pntsv= 1; - nu->orderu= 4; - nu->bp= callocstructN(BPoint, 8, "addNurbprim6"); - nu->flagu= CU_NURB_CYCLIC; - bp= nu->bp; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][0] += grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - for (a=0; a<8; a++) { - bp->f1= SELECT; - if (xzproj==0) { - bp->vec[0]+= nurbcircle[a][0]*grid; - bp->vec[1]+= nurbcircle[a][1]*grid; - } - else { - bp->vec[0]+= 0.25f*nurbcircle[a][0]*grid-0.75f*grid; - bp->vec[2]+= 0.25f*nurbcircle[a][1]*grid; - } - if (a & 1) bp->vec[3]= 0.25*M_SQRT2; - else bp->vec[3]= 1.0; - mul_m4_v3(mat, bp->vec); - bp->radius = bp->weight = 1.0; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][1] += -grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - bp++; + BKE_nurb_handles_calc(nu); } - - BKE_nurb_knot_calc_u(nu); - } - break; - case CU_PRIM_PATCH: /* 4x4 patch */ - if ( cutype==CU_NURBS ) { /* nurb */ - - nu->pntsu= 4; - nu->pntsv= 4; - nu->orderu= 4; - nu->orderv= 4; - nu->flag= CU_SMOOTH; - nu->bp= callocstructN(BPoint, 4*4, "addNurbprim6"); - nu->flagu= 0; - nu->flagv= 0; - bp= nu->bp; - - for (a=0; a<4; a++) { - for (b=0; b<4; b++) { - bp->f1= SELECT; - fac= (float)a -1.5f; - bp->vec[0]+= fac*grid; - fac= (float)b -1.5f; - bp->vec[1]+= fac*grid; - if (a==1 || a==2) if (b==1 || b==2) { - bp->vec[2]+= grid; + else if (cutype == CU_NURBS) { /* nurb */ + nu->pntsu = 8; + nu->pntsv = 1; + nu->orderu = 4; + nu->bp = callocstructN(BPoint, 8, "addNurbprim6"); + nu->flagu = CU_NURB_CYCLIC; + bp = nu->bp; + + for (a = 0; a < 8; a++) { + bp->f1 = SELECT; + if (xzproj == 0) { + bp->vec[0] += nurbcircle[a][0] * grid; + bp->vec[1] += nurbcircle[a][1] * grid; } + else { + bp->vec[0] += 0.25f * nurbcircle[a][0] * grid - 0.75f * grid; + bp->vec[2] += 0.25f * nurbcircle[a][1] * grid; + } + if (a & 1) bp->vec[3] = 0.25 * M_SQRT2; + else bp->vec[3] = 1.0; mul_m4_v3(mat, bp->vec); - bp->vec[3]= 1.0; + bp->radius = bp->weight = 1.0; + bp++; } - } - BKE_nurb_knot_calc_u(nu); - BKE_nurb_knot_calc_v(nu); - } - break; - case CU_PRIM_TUBE: /* Cylinder */ - if ( cutype==CU_NURBS ) { - nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ - nu->resolu= cu->resolu; - nu->flag= CU_SMOOTH; - BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ - vec[0]=vec[1]= 0.0; - vec[2]= -grid; - - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { - /* pass */ - } - else { - mul_mat3_m4_v3(mat, vec); + BKE_nurb_knot_calc_u(nu); } + break; + case CU_PRIM_PATCH: /* 4x4 patch */ + if (cutype == CU_NURBS) { /* nurb */ + + nu->pntsu = 4; + nu->pntsv = 4; + nu->orderu = 4; + nu->orderv = 4; + nu->flag = CU_SMOOTH; + nu->bp = callocstructN(BPoint, 4 * 4, "addNurbprim6"); + nu->flagu = 0; + nu->flagv = 0; + bp = nu->bp; + + for (a = 0; a < 4; a++) { + for (b = 0; b < 4; b++) { + bp->f1 = SELECT; + fac = (float)a - 1.5f; + bp->vec[0] += fac * grid; + fac = (float)b - 1.5f; + bp->vec[1] += fac * grid; + if (a == 1 || a == 2) if (b == 1 || b == 2) { + bp->vec[2] += grid; + } + mul_m4_v3(mat, bp->vec); + bp->vec[3] = 1.0; + bp++; + } + } - translateflagNurb(editnurb, 1, vec); - extrudeflagNurb(cu->editnurb, 1); - vec[0]= -2*vec[0]; - vec[1]= -2*vec[1]; - vec[2]= -2*vec[2]; - translateflagNurb(editnurb, 1, vec); - - BLI_remlink(editnurb, nu); - - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; - } - } - break; - case CU_PRIM_SPHERE: /* sphere */ - if ( cutype==CU_NURBS ) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; - - nu->pntsu= 5; - nu->pntsv= 1; - nu->orderu= 3; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; - nu->flag= CU_SMOOTH; - nu->bp= callocstructN(BPoint, 5, "addNurbprim6"); - nu->flagu= 0; - bp= nu->bp; - - for (a=0; a<5; a++) { - bp->f1= SELECT; - bp->vec[0]+= nurbcircle[a][0]*grid; - bp->vec[2]+= nurbcircle[a][1]*grid; - if (a & 1) bp->vec[3]= 0.5*M_SQRT2; - else bp->vec[3]= 1.0; - mul_m4_v3(mat, bp->vec); - bp++; + BKE_nurb_knot_calc_u(nu); + BKE_nurb_knot_calc_v(nu); } - nu->flagu= CU_NURB_BEZIER; - BKE_nurb_knot_calc_u(nu); - - BLI_addtail(editnurb, nu); /* temporal for spin */ + break; + case CU_PRIM_TUBE: /* Cylinder */ + if (cutype == CU_NURBS) { + nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + nu->resolu = cu->resolu; + nu->flag = CU_SMOOTH; + BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ + vec[0] = vec[1] = 0.0; + vec[2] = -grid; + + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { + /* pass */ + } + else { + mul_mat3_m4_v3(mat, vec); + } - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); - else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); - else spin_nurb(umat, obedit, tmp_vec, mat[3]); + translateflagNurb(editnurb, 1, vec); + extrudeflagNurb(cu->editnurb, 1); + mul_v3_fl(vec, -2.0f); + translateflagNurb(editnurb, 1, vec); - BKE_nurb_knot_calc_v(nu); + BLI_remlink(editnurb, nu); - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; + bp++; + } } - BLI_remlink(editnurb, nu); - } - break; - case CU_PRIM_DONUT: /* torus */ - if ( cutype==CU_NURBS ) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; - - xzproj= 1; - nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ - xzproj= 0; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; - nu->flag= CU_SMOOTH; - BLI_addtail(editnurb, nu); /* temporal for spin */ + break; + case CU_PRIM_SPHERE: /* sphere */ + if (cutype == CU_NURBS) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 1.f}; + + nu->pntsu = 5; + nu->pntsv = 1; + nu->orderu = 3; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; + nu->flag = CU_SMOOTH; + nu->bp = callocstructN(BPoint, 5, "addNurbprim6"); + nu->flagu = 0; + bp = nu->bp; + + for (a = 0; a < 5; a++) { + bp->f1 = SELECT; + bp->vec[0] += nurbcircle[a][0] * grid; + bp->vec[2] += nurbcircle[a][1] * grid; + if (a & 1) bp->vec[3] = 0.5 * M_SQRT2; + else bp->vec[3] = 1.0; + mul_m4_v3(mat, bp->vec); + bp++; + } + nu->flagu = CU_NURB_BEZIER; + BKE_nurb_knot_calc_u(nu); - /* same as above */ - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); - else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); - else spin_nurb(umat, obedit, tmp_vec, mat[3]); + BLI_addtail(editnurb, nu); /* temporal for spin */ + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); + else spin_nurb(umat, obedit, tmp_vec, mat[3]); - BLI_remlink(editnurb, nu); + BKE_nurb_knot_calc_v(nu); - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; + bp++; + } + BLI_remlink(editnurb, nu); } + break; + case CU_PRIM_DONUT: /* torus */ + if (cutype == CU_NURBS) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 1.f}; + + xzproj = 1; + nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + xzproj = 0; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; + nu->flag = CU_SMOOTH; + BLI_addtail(editnurb, nu); /* temporal for spin */ + + /* same as above */ + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); + else spin_nurb(umat, obedit, tmp_vec, mat[3]); + + + BLI_remlink(editnurb, nu); + + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; + bp++; + } - } - break; + } + break; - default: /* should never happen */ - BLI_assert(!"invalid nurbs type"); - return NULL; + default: /* should never happen */ + BLI_assert(!"invalid nurbs type"); + return NULL; } BLI_assert(nu != NULL); @@ -6557,10 +6532,10 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); ListBase *editnurb; Nurb *nu; - int newob= 0; + int newob = 0; int enter_editmode, is_aligned; unsigned int layer; float loc[3], rot[3]; @@ -6570,23 +6545,23 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) return OPERATOR_CANCELLED; if (!isSurf) { /* adding curve */ - if (obedit==NULL || obedit->type!=OB_CURVE) { + if (obedit == NULL || obedit->type != OB_CURVE) { Curve *cu; - obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); + obedit = ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); newob = 1; - cu= (Curve*)obedit->data; + cu = (Curve *)obedit->data; cu->flag |= CU_DEFORM_FILL; if (type & CU_PRIM_PATH) - cu->flag |= CU_PATH|CU_3D; + cu->flag |= CU_PATH | CU_3D; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } else { /* adding surface */ - if (obedit==NULL || obedit->type!=OB_SURF) { - obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); + if (obedit == NULL || obedit->type != OB_SURF) { + obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); newob = 1; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -6595,7 +6570,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) /* rename here, the undo stack checks name for valid undo pushes */ if (newob) { - if (obedit->type==OB_CURVE) { + if (obedit->type == OB_CURVE) { rename_id((ID *)obedit, get_curve_defname(type)); rename_id((ID *)obedit->data, get_curve_defname(type)); } @@ -6611,8 +6586,8 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - nu= add_nurbs_primitive(C, mat, type, newob); - editnurb= object_editcurve_get(obedit); + nu = add_nurbs_primitive(C, mat, type, newob); + editnurb = object_editcurve_get(obedit); BLI_addtail(editnurb, nu); /* userdef */ @@ -6620,7 +6595,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) ED_object_exit_editmode(C, EM_FREEDATA); } - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); return OPERATOR_FINISHED; } @@ -6639,7 +6614,7 @@ static int surf_prim_add(bContext *C, wmOperator *op, int type) static int add_primitive_bezier_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_BEZIER|CU_PRIM_CURVE); + return curve_prim_add(C, op, CU_BEZIER | CU_PRIM_CURVE); } void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) @@ -6655,14 +6630,14 @@ void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_bezier_circle_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_BEZIER|CU_PRIM_CIRCLE); + return curve_prim_add(C, op, CU_BEZIER | CU_PRIM_CIRCLE); } void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) @@ -6678,14 +6653,14 @@ void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_curve_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_CURVE); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_CURVE); } void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) @@ -6701,14 +6676,14 @@ void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_circle_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_CIRCLE); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_CIRCLE); } void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) @@ -6724,14 +6699,14 @@ void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_curve_path_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_PATH); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_PATH); } void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) @@ -6747,7 +6722,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -6755,7 +6730,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) /* **************** NURBS surfaces ********************** */ static int add_primitive_nurbs_surface_curve_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CURVE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) @@ -6771,14 +6746,14 @@ void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_circle_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CIRCLE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) @@ -6794,14 +6769,14 @@ void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_surface_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_PATCH | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) @@ -6817,14 +6792,14 @@ void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_cylinder_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_TUBE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) @@ -6840,14 +6815,14 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_sphere_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_SPHERE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) @@ -6863,14 +6838,14 @@ void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_torus_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_DONUT | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) @@ -6886,7 +6861,7 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -6895,34 +6870,34 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - if ( nu->bezt ) { - bezt= nu->bezt; - a= nu->pntsu; + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->bezt) { + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0; + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa = 0.0; bezt++; } } else if (nu->bp) { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if (bp->f1 & SELECT) bp->alfa= 0.0; + if (bp->f1 & SELECT) bp->alfa = 0.0f; bp++; } } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -6940,7 +6915,7 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************** undo for curves ****************/ @@ -6948,15 +6923,15 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu) { if (nu->bezt) { - BezTriple *lastbezt= (BezTriple*)lastsel; - if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) { - return newnu->bezt + (lastbezt - nu->bezt); + BezTriple *lastbezt = (BezTriple *)lastsel; + if (lastbezt >= nu->bezt && lastbezt < &nu->bezt[nu->pntsu]) { + return &newnu->bezt[lastbezt - nu->bezt]; } } else { - BPoint *lastbp= (BPoint*)lastsel; - if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) { - return newnu->bp + (lastbp - nu->bp); + BPoint *lastbp = (BPoint *)lastsel; + if (lastbp >= nu->bp && lastbp < &nu->bp[nu->pntsu * nu->pntsv]) { + return &newnu->bp[lastbp - nu->bp]; } } @@ -6965,20 +6940,20 @@ static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu) static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) { - Curve *cu= cu_v; - UndoCurve *undoCurve= ucu; - ListBase *undobase= &undoCurve->nubase; - ListBase *editbase= BKE_curve_editNurbs_get(cu); + Curve *cu = cu_v; + UndoCurve *undoCurve = ucu; + ListBase *undobase = &undoCurve->nubase; + ListBase *editbase = BKE_curve_editNurbs_get(cu); Nurb *nu, *newnu; - EditNurb *editnurb= cu->editnurb; - void *lastsel= NULL; - AnimData *ad= BKE_animdata_from_id(&cu->id); + EditNurb *editnurb = cu->editnurb; + void *lastsel = NULL; + AnimData *ad = BKE_animdata_from_id(&cu->id); BKE_nurbList_free(editbase); if (undoCurve->undoIndex) { BLI_ghash_free(editnurb->keyindex, NULL, (GHashValFreeFP)MEM_freeN); - editnurb->keyindex= dupli_keyIndexHash(undoCurve->undoIndex); + editnurb->keyindex = dupli_keyIndexHash(undoCurve->undoIndex); } if (ad) { @@ -6992,11 +6967,11 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) } /* copy */ - for (nu= undobase->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = undobase->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); if (lastsel == NULL) { - lastsel= undo_check_lastsel(undoCurve->lastsel, nu, newnu); + lastsel = undo_check_lastsel(undoCurve->lastsel, nu, newnu); } if (editnurb->keyindex) { @@ -7006,26 +6981,26 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) BLI_addtail(editbase, newnu); } - cu->lastsel= lastsel; - cu->actnu= undoCurve->actnu; + cu->lastsel = lastsel; + cu->actnu = undoCurve->actnu; ED_curve_updateAnimPaths(cu); } static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) { - Curve *cu= cu_v; - ListBase *nubase= BKE_curve_editNurbs_get(cu); + Curve *cu = cu_v; + ListBase *nubase = BKE_curve_editNurbs_get(cu); UndoCurve *undoCurve; - EditNurb *editnurb= cu->editnurb, tmpEditnurb; + EditNurb *editnurb = cu->editnurb, tmpEditnurb; Nurb *nu, *newnu; - void *lastsel= NULL; - AnimData *ad= BKE_animdata_from_id(&cu->id); + void *lastsel = NULL; + AnimData *ad = BKE_animdata_from_id(&cu->id); - undoCurve= MEM_callocN(sizeof(UndoCurve), "undoCurve"); + undoCurve = MEM_callocN(sizeof(UndoCurve), "undoCurve"); if (editnurb->keyindex) { - undoCurve->undoIndex= dupli_keyIndexHash(editnurb->keyindex); - tmpEditnurb.keyindex= undoCurve->undoIndex; + undoCurve->undoIndex = dupli_keyIndexHash(editnurb->keyindex); + tmpEditnurb.keyindex = undoCurve->undoIndex; } if (ad) { @@ -7036,11 +7011,11 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) } /* copy */ - for (nu= nubase->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = nubase->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); if (lastsel == NULL) { - lastsel= undo_check_lastsel(cu->lastsel, nu, newnu); + lastsel = undo_check_lastsel(cu->lastsel, nu, newnu); } if (undoCurve->undoIndex) { @@ -7050,15 +7025,15 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) BLI_addtail(&undoCurve->nubase, newnu); } - undoCurve->lastsel= lastsel; - undoCurve->actnu= cu->actnu; + undoCurve->lastsel = lastsel; + undoCurve->actnu = cu->actnu; return undoCurve; } static void free_undoCurve(void *ucv) { - UndoCurve *undoCurve= ucv; + UndoCurve *undoCurve = ucv; BKE_nurbList_free(&undoCurve->nubase); @@ -7073,7 +7048,7 @@ static void free_undoCurve(void *ucv) static void *get_data(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); return obedit; } @@ -7085,30 +7060,30 @@ void undo_push_curve(bContext *C, const char *name) void ED_curve_beztcpy(EditNurb *editnurb, BezTriple *dst, BezTriple *src, int count) { - memcpy(dst, src, count*sizeof(BezTriple)); + memcpy(dst, src, count * sizeof(BezTriple)); keyIndex_updateBezt(editnurb, src, dst, count); } void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count) { - memcpy(dst, src, count*sizeof(BPoint)); + memcpy(dst, src, count * sizeof(BPoint)); keyIndex_updateBP(editnurb, src, dst, count); } int ED_curve_actSelection(Curve *cu, float center[3]) { - Nurb *nu= get_lastsel_nurb(cu); + Nurb *nu = get_lastsel_nurb(cu); if (!nu) return 0; if (nu->bezt) { - BezTriple *bezt= cu->lastsel; + BezTriple *bezt = cu->lastsel; copy_v3_v3(center, bezt->vec[1]); } else { - BPoint *bp= cu->lastsel; + BPoint *bp = cu->lastsel; copy_v3_v3(center, bp->vec); } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 0a976e6ed6b..83f6b1d1824 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -74,135 +74,135 @@ #include "curve_intern.h" -#define MAXTEXT 32766 +#define MAXTEXT 32766 /************************* utilities ******************************/ static char findaccent(char char1, unsigned int code) { - char new= 0; - - if (char1=='a') { - if (code=='`') new= 224; - else if (code==39) new= 225; - else if (code=='^') new= 226; - else if (code=='~') new= 227; - else if (code=='"') new= 228; - else if (code=='o') new= 229; - else if (code=='e') new= 230; - else if (code=='-') new= 170; + char new = 0; + + if (char1 == 'a') { + if (code == '`') new = 224; + else if (code == 39) new = 225; + else if (code == '^') new = 226; + else if (code == '~') new = 227; + else if (code == '"') new = 228; + else if (code == 'o') new = 229; + else if (code == 'e') new = 230; + else if (code == '-') new = 170; } - else if (char1=='c') { - if (code==',') new= 231; - if (code=='|') new= 162; + else if (char1 == 'c') { + if (code == ',') new = 231; + if (code == '|') new = 162; } - else if (char1=='e') { - if (code=='`') new= 232; - else if (code==39) new= 233; - else if (code=='^') new= 234; - else if (code=='"') new= 235; + else if (char1 == 'e') { + if (code == '`') new = 232; + else if (code == 39) new = 233; + else if (code == '^') new = 234; + else if (code == '"') new = 235; } - else if (char1=='i') { - if (code=='`') new= 236; - else if (code==39) new= 237; - else if (code=='^') new= 238; - else if (code=='"') new= 239; + else if (char1 == 'i') { + if (code == '`') new = 236; + else if (code == 39) new = 237; + else if (code == '^') new = 238; + else if (code == '"') new = 239; } - else if (char1=='n') { - if (code=='~') new= 241; + else if (char1 == 'n') { + if (code == '~') new = 241; } - else if (char1=='o') { - if (code=='`') new= 242; - else if (code==39) new= 243; - else if (code=='^') new= 244; - else if (code=='~') new= 245; - else if (code=='"') new= 246; - else if (code=='/') new= 248; - else if (code=='-') new= 186; - else if (code=='e') new= 143; + else if (char1 == 'o') { + if (code == '`') new = 242; + else if (code == 39) new = 243; + else if (code == '^') new = 244; + else if (code == '~') new = 245; + else if (code == '"') new = 246; + else if (code == '/') new = 248; + else if (code == '-') new = 186; + else if (code == 'e') new = 143; } - else if (char1=='s') { - if (code=='s') new= 167; + else if (char1 == 's') { + if (code == 's') new = 167; } - else if (char1=='u') { - if (code=='`') new= 249; - else if (code==39) new= 250; - else if (code=='^') new= 251; - else if (code=='"') new= 252; + else if (char1 == 'u') { + if (code == '`') new = 249; + else if (code == 39) new = 250; + else if (code == '^') new = 251; + else if (code == '"') new = 252; } - else if (char1=='y') { - if (code==39) new= 253; - else if (code=='"') new= 255; + else if (char1 == 'y') { + if (code == 39) new = 253; + else if (code == '"') new = 255; } - else if (char1=='A') { - if (code=='`') new= 192; - else if (code==39) new= 193; - else if (code=='^') new= 194; - else if (code=='~') new= 195; - else if (code=='"') new= 196; - else if (code=='o') new= 197; - else if (code=='e') new= 198; + else if (char1 == 'A') { + if (code == '`') new = 192; + else if (code == 39) new = 193; + else if (code == '^') new = 194; + else if (code == '~') new = 195; + else if (code == '"') new = 196; + else if (code == 'o') new = 197; + else if (code == 'e') new = 198; } - else if (char1=='C') { - if (code==',') new= 199; + else if (char1 == 'C') { + if (code == ',') new = 199; } - else if (char1=='E') { - if (code=='`') new= 200; - else if (code==39) new= 201; - else if (code=='^') new= 202; - else if (code=='"') new= 203; + else if (char1 == 'E') { + if (code == '`') new = 200; + else if (code == 39) new = 201; + else if (code == '^') new = 202; + else if (code == '"') new = 203; } - else if (char1=='I') { - if (code=='`') new= 204; - else if (code==39) new= 205; - else if (code=='^') new= 206; - else if (code=='"') new= 207; + else if (char1 == 'I') { + if (code == '`') new = 204; + else if (code == 39) new = 205; + else if (code == '^') new = 206; + else if (code == '"') new = 207; } - else if (char1=='N') { - if (code=='~') new= 209; + else if (char1 == 'N') { + if (code == '~') new = 209; } - else if (char1=='O') { - if (code=='`') new= 210; - else if (code==39) new= 211; - else if (code=='^') new= 212; - else if (code=='~') new= 213; - else if (code=='"') new= 214; - else if (code=='/') new= 216; - else if (code=='e') new= 141; + else if (char1 == 'O') { + if (code == '`') new = 210; + else if (code == 39) new = 211; + else if (code == '^') new = 212; + else if (code == '~') new = 213; + else if (code == '"') new = 214; + else if (code == '/') new = 216; + else if (code == 'e') new = 141; } - else if (char1=='U') { - if (code=='`') new= 217; - else if (code==39) new= 218; - else if (code=='^') new= 219; - else if (code=='"') new= 220; + else if (char1 == 'U') { + if (code == '`') new = 217; + else if (code == 39) new = 218; + else if (code == '^') new = 219; + else if (code == '"') new = 220; } - else if (char1=='Y') { - if (code==39) new= 221; + else if (char1 == 'Y') { + if (code == 39) new = 221; } - else if (char1=='1') { - if (code=='4') new= 188; - if (code=='2') new= 189; + else if (char1 == '1') { + if (code == '4') new = 188; + if (code == '2') new = 189; } - else if (char1=='3') { - if (code=='4') new= 190; + else if (char1 == '3') { + if (code == '4') new = 190; } - else if (char1==':') { - if (code=='-') new= 247; + else if (char1 == ':') { + if (code == '-') new = 247; } - else if (char1=='-') { - if (code==':') new= 247; - if (code=='|') new= 135; - if (code=='+') new= 177; + else if (char1 == '-') { + if (code == ':') new = 247; + if (code == '|') new = 135; + if (code == '+') new = 177; } - else if (char1=='|') { - if (code=='-') new= 135; - if (code=='=') new= 136; + else if (char1 == '|') { + if (code == '-') new = 135; + if (code == '=') new = 136; } - else if (char1=='=') { - if (code=='|') new= 136; + else if (char1 == '=') { + if (code == '|') new = 136; } - else if (char1=='+') { - if (code=='-') new= 177; + else if (char1 == '+') { + if (code == '-') new = 177; } if (new) return new; @@ -212,7 +212,7 @@ static char findaccent(char char1, unsigned int code) static void update_string(Curve *cu) { - EditFont *ef= cu->editfont; + EditFont *ef = cu->editfont; int len; // Free the old curve string @@ -230,22 +230,22 @@ static void update_string(Curve *cu) static int insert_into_textbuf(Object *obedit, uintptr_t c) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; - if (cu->len<MAXTEXT-1) { - EditFont *ef= cu->editfont; + if (cu->len < MAXTEXT - 1) { + EditFont *ef = cu->editfont; int x; - for (x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1]; - for (x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1]; - ef->textbuf[cu->pos]= c; + for (x = cu->len; x > cu->pos; x--) ef->textbuf[x] = ef->textbuf[x - 1]; + for (x = cu->len; x > cu->pos; x--) ef->textbufinfo[x] = ef->textbufinfo[x - 1]; + ef->textbuf[cu->pos] = c; ef->textbufinfo[cu->pos] = cu->curinfo; ef->textbufinfo[cu->pos].kern = 0; ef->textbufinfo[cu->pos].mat_nr = obedit->actcol; cu->pos++; cu->len++; - ef->textbuf[cu->len]='\0'; + ef->textbuf[cu->len] = '\0'; update_string(cu); @@ -257,63 +257,63 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int recalc, int mode) { - struct Main *bmain= CTX_data_main(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0]; + struct Main *bmain = CTX_data_main(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + cu->curinfo = ef->textbufinfo[cu->pos ? cu->pos - 1 : 0]; if (obedit->totcol > 0) { - obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr; + obedit->actcol = ef->textbufinfo[cu->pos ? cu->pos - 1 : 0].mat_nr; /* since this array is calloc'd, it can be 0 even though we try ensure * (mat_nr > 0) almost everywhere */ if (obedit->actcol < 1) { - obedit->actcol= 1; + obedit->actcol = 1; } } if (mode == FO_EDIT) update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, mode); + BKE_vfont_to_curve(bmain, scene, obedit, mode); if (recalc) DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); } /********************** insert lorem operator *********************/ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); const char *p, *p2; int i; static const char *lastlorem; if (lastlorem) - p= lastlorem; + p = lastlorem; else - p= ED_lorem; + p = ED_lorem; - i= rand()/(RAND_MAX/6)+4; + i = rand() / (RAND_MAX / 6) + 4; - for (p2=p; *p2 && i; p2++) { + for (p2 = p; *p2 && i; p2++) { insert_into_textbuf(obedit, *p2); - if (*p2=='.') + if (*p2 == '.') i--; } - lastlorem = p2+1; - if (strlen(lastlorem)<5) + lastlorem = p2 + 1; + if (strlen(lastlorem) < 5) lastlorem = ED_lorem; insert_into_textbuf(obedit, '\n'); insert_into_textbuf(obedit, '\n'); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -330,7 +330,7 @@ void FONT_OT_insert_lorem(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* paste file operator ********************/ @@ -340,15 +340,15 @@ void FONT_OT_insert_lorem(wmOperatorType *ot) static int paste_file(bContext *C, ReportList *reports, const char *filename) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; FILE *fp; int filelen; char *strp; - fp= BLI_fopen(filename, "r"); + fp = BLI_fopen(filename, "r"); if (!fp) { if (reports) @@ -360,22 +360,22 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) filelen = ftell(fp); fseek(fp, 0L, SEEK_SET); - strp= MEM_callocN(filelen+4, "tempstr"); + strp = MEM_callocN(filelen + 4, "tempstr"); // fread() instead of read(), because windows read() converts text // to DOS \r\n linebreaks, causing double linebreaks in the 3d text filelen = fread(strp, 1, filelen, fp); fclose(fp); - strp[filelen]= 0; + strp[filelen] = 0; - if (cu->len+filelen<MAXTEXT) { + if (cu->len + filelen < MAXTEXT) { int tmplen; - wchar_t *mem = MEM_callocN((sizeof(wchar_t)*filelen)+(4*sizeof(wchar_t)), "temporary"); + wchar_t *mem = MEM_callocN((sizeof(wchar_t) * filelen) + (4 * sizeof(wchar_t)), "temporary"); tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1); wcscat(ef->textbuf, mem); MEM_freeN(mem); cu->len += tmplen; - cu->pos= cu->len; + cu->pos = cu->len; } MEM_freeN(strp); @@ -389,8 +389,8 @@ static int paste_file_exec(bContext *C, wmOperator *op) char *path; int retval; - path= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); - retval= paste_file(C, op->reports, path); + path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); + retval = paste_file(C, op->reports, path); MEM_freeN(path); return retval; @@ -419,17 +419,17 @@ void FONT_OT_file_paste(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } /******************* text to object operator ********************/ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float offset[3]) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Curve *cu; Object *obedit; Base *base; @@ -437,60 +437,60 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float int nchars = 0, a; float rot[3] = {0.f, 0.f, 0.f}; - obedit= add_object(scene, OB_FONT); - base= scene->basact; + obedit = BKE_object_add(scene, OB_FONT); + base = scene->basact; ED_object_base_init_transform(C, base, NULL, rot); /* seems to assume view align ? TODO - look into this, could be an operator option */ - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); obedit->loc[0] += offset[0]; obedit->loc[1] += offset[1]; obedit->loc[2] += offset[2]; - cu= obedit->data; - cu->vfont= get_builtin_font(); + cu = obedit->data; + cu->vfont = BKE_vfont_builtin_get(); cu->vfont->id.us++; - for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++) + for (tmp = firstline, a = 0; cu->len < MAXTEXT && a < totline; tmp = tmp->next, a++) nchars += strlen(tmp->line) + 1; if (cu->str) MEM_freeN(cu->str); if (cu->strinfo) MEM_freeN(cu->strinfo); - cu->str= MEM_callocN(nchars+4, "str"); - cu->strinfo= MEM_callocN((nchars+4)*sizeof(CharInfo), "strinfo"); + cu->str = MEM_callocN(nchars + 4, "str"); + cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo"); - cu->str[0]= '\0'; - cu->len= 0; - cu->pos= 0; + cu->str[0] = '\0'; + cu->len = 0; + cu->pos = 0; - for (tmp=firstline, a=0; cu->len<MAXTEXT && a<totline; tmp=tmp->next, a++) { + for (tmp = firstline, a = 0; cu->len < MAXTEXT && a < totline; tmp = tmp->next, a++) { strcat(cu->str, tmp->line); - cu->len+= strlen(tmp->line); + cu->len += strlen(tmp->line); if (tmp->next) { strcat(cu->str, "\n"); cu->len++; } - cu->pos= cu->len; + cu->pos = cu->len; } - WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, obedit); + WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, obedit); } void ED_text_to_object(bContext *C, Text *text, int split_lines) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); TextLine *line; float offset[3]; - int linenum= 0; + int linenum = 0; if (!text || !text->lines.first) return; if (split_lines) { - for (line=text->lines.first; line; line=line->next) { + for (line = text->lines.first; line; line = line->next) { /* skip lines with no text, but still make space for them */ if (line->line[0] == '\0') { linenum++; @@ -511,9 +511,9 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) } } else { - offset[0]= 0.0f; - offset[1]= 0.0f; - offset[2]= 0.0f; + offset[0] = 0.0f; + offset[1] = 0.0f; + offset[2] = 0.0f; txt_add_object(C, text->lines.first, BLI_countlist(&text->lines), offset); } @@ -523,8 +523,8 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) static short next_word(Curve *cu) { short s; - for (s=cu->pos; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && - (cu->str[s] != 1) && (cu->str[s] != '\r')); + for (s = cu->pos; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && + (cu->str[s] != 1) && (cu->str[s] != '\r')); s++) { /* pass */ @@ -537,7 +537,7 @@ static short prev_word(Curve *cu) { short s; - if (cu->pos==0) return(0); + if (cu->pos == 0) return(0); for (s = cu->pos - 2; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && (cu->str[s] != 1) && (cu->str[s] != '\r')); s--) @@ -548,29 +548,29 @@ static short prev_word(Curve *cu) return cu->str[s] ? (s + 1) : s; } -static int kill_selection(Object *obedit, int ins) /* 1 == new character */ +static int kill_selection(Object *obedit, int ins) /* 1 == new character */ { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; int selend, selstart, direction; int offset = 0; int getfrom; - direction = BKE_font_getselection(obedit, &selstart, &selend); + direction = BKE_vfont_select_get(obedit, &selstart, &selend); if (direction) { int size; if (ins) offset = 1; - if (cu->pos >= selstart) cu->pos = selstart+offset; + if (cu->pos >= selstart) cu->pos = selstart + offset; if ((direction == -1) && ins) { selstart++; selend++; } - getfrom = selend+offset; - if (ins==0) getfrom++; - size = (cu->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset*sizeof(wchar_t)); - memmove(ef->textbuf+selstart, ef->textbuf+getfrom, size); - memmove(ef->textbufinfo+selstart, ef->textbufinfo+getfrom, ((cu->len-selstart)+offset)*sizeof(CharInfo)); - cu->len -= (selend-selstart)+offset; + getfrom = selend + offset; + if (ins == 0) getfrom++; + size = (cu->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t)); + memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size); + memmove(ef->textbufinfo + selstart, ef->textbufinfo + getfrom, ((cu->len - selstart) + offset) * sizeof(CharInfo)); + cu->len -= (selend - selstart) + offset; cu->selstart = cu->selend = 0; } @@ -579,24 +579,25 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ /******************* set style operator ********************/ -static EnumPropertyItem style_items[]= { +static EnumPropertyItem style_items[] = { {CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""}, {CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""}, {CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, {CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int set_style(bContext *C, const int style, const int clear) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; int i, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - for (i=selstart; i<=selend; i++) { + for (i = selstart; i <= selend; i++) { if (clear) ef->textbufinfo[i].flag &= ~style; else @@ -604,15 +605,15 @@ static int set_style(bContext *C, const int style, const int clear) } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } static int set_style_exec(bContext *C, wmOperator *op) { - const int style= RNA_enum_get(op->ptr, "style"); - const int clear= RNA_boolean_get(op->ptr, "clear"); + const int style = RNA_enum_get(op->ptr, "style"); + const int clear = RNA_boolean_get(op->ptr, "clear"); return set_style(C, style, clear); } @@ -629,7 +630,7 @@ void FONT_OT_style_set(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to"); @@ -640,17 +641,17 @@ void FONT_OT_style_set(wmOperatorType *ot) static int toggle_style_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; int style, clear, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - style= RNA_enum_get(op->ptr, "style"); + style = RNA_enum_get(op->ptr, "style"); cu->curinfo.flag ^= style; - clear= (cu->curinfo.flag & style) == 0; + clear = (cu->curinfo.flag & style) == 0; return set_style(C, style, clear); } @@ -667,7 +668,7 @@ void FONT_OT_style_toggle(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to"); @@ -679,19 +680,19 @@ static void copy_selection(Object *obedit) { int selstart, selend; - if (BKE_font_getselection(obedit, &selstart, &selend)) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; - memcpy(ef->copybuf, ef->textbuf+selstart, ((selend-selstart)+1)*sizeof(wchar_t)); - ef->copybuf[(selend-selstart)+1]=0; - memcpy(ef->copybufinfo, ef->textbufinfo+selstart, ((selend-selstart)+1)*sizeof(CharInfo)); + memcpy(ef->copybuf, ef->textbuf + selstart, ((selend - selstart) + 1) * sizeof(wchar_t)); + ef->copybuf[(selend - selstart) + 1] = 0; + memcpy(ef->copybufinfo, ef->textbufinfo + selstart, ((selend - selstart) + 1) * sizeof(CharInfo)); } } static int copy_text_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); copy_selection(obedit); @@ -714,11 +715,11 @@ void FONT_OT_text_copy(wmOperatorType *ot) static int cut_text_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); int selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; copy_selection(obedit); @@ -741,26 +742,26 @@ void FONT_OT_text_cut(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* paste text operator ********************/ static int paste_selection(Object *obedit, ReportList *reports) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int len= wcslen(ef->copybuf); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int len = wcslen(ef->copybuf); // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT if (cu->len + len <= MAXTEXT) { if (len) { - int size = (cu->len * sizeof(wchar_t)) - (cu->pos*sizeof(wchar_t)) + sizeof(wchar_t); - memmove(ef->textbuf+cu->pos+len, ef->textbuf+cu->pos, size); - memcpy(ef->textbuf+cu->pos, ef->copybuf, len * sizeof(wchar_t)); + int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); + memmove(ef->textbuf + cu->pos + len, ef->textbuf + cu->pos, size); + memcpy(ef->textbuf + cu->pos, ef->copybuf, len * sizeof(wchar_t)); - memmove(ef->textbufinfo+cu->pos+len, ef->textbufinfo+cu->pos, (cu->len-cu->pos+1)*sizeof(CharInfo)); - memcpy(ef->textbufinfo+cu->pos, ef->copybufinfo, len*sizeof(CharInfo)); + memmove(ef->textbufinfo + cu->pos + len, ef->textbufinfo + cu->pos, (cu->len - cu->pos + 1) * sizeof(CharInfo)); + memcpy(ef->textbufinfo + cu->pos, ef->copybufinfo, len * sizeof(CharInfo)); cu->len += len; cu->pos += len; @@ -776,8 +777,8 @@ static int paste_selection(Object *obedit, ReportList *reports) static int paste_text_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); if (!paste_selection(obedit, op->reports)) return OPERATOR_CANCELLED; @@ -799,12 +800,12 @@ void FONT_OT_text_paste(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************************ move operator ************************/ -static EnumPropertyItem move_type_items[]= { +static EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -819,77 +820,77 @@ static EnumPropertyItem move_type_items[]= { static int move_cursor(bContext *C, int type, int select) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int cursmove= -1; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int cursmove = -1; switch (type) { case LINE_BEGIN: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while (cu->pos>0) { - if (ef->textbuf[cu->pos-1]=='\n') break; - if (ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + while (cu->pos > 0) { + if (ef->textbuf[cu->pos - 1] == '\n') break; + if (ef->textbufinfo[cu->pos - 1].flag & CU_CHINFO_WRAP) break; cu->pos--; } - cursmove=FO_CURS; + cursmove = FO_CURS; break; case LINE_END: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while (cu->pos<cu->len) { - if (ef->textbuf[cu->pos]==0) break; - if (ef->textbuf[cu->pos]=='\n') break; - if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + while (cu->pos < cu->len) { + if (ef->textbuf[cu->pos] == 0) break; + if (ef->textbuf[cu->pos] == '\n') break; + if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP) break; cu->pos++; } - cursmove=FO_CURS; + cursmove = FO_CURS; break; case PREV_WORD: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cu->pos= prev_word(cu); - cursmove= FO_CURS; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cu->pos = prev_word(cu); + cursmove = FO_CURS; break; case NEXT_WORD: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cu->pos= next_word(cu); - cursmove= FO_CURS; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cu->pos = next_word(cu); + cursmove = FO_CURS; break; case PREV_CHAR: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; cu->pos--; - cursmove=FO_CURS; + cursmove = FO_CURS; break; case NEXT_CHAR: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; cu->pos++; - cursmove= FO_CURS; + cursmove = FO_CURS; break; case PREV_LINE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_CURSUP; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_CURSUP; break; case NEXT_LINE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove= FO_CURSDOWN; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_CURSDOWN; break; case PREV_PAGE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_PAGEUP; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_PAGEUP; break; case NEXT_PAGE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_PAGEDOWN; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_PAGEDOWN; break; } @@ -898,16 +899,16 @@ static int move_cursor(bContext *C, int type, int select) if (select == 0) { if (cu->selstart) { - struct Main *bmain= CTX_data_main(C); + struct Main *bmain = CTX_data_main(C); cu->selstart = cu->selend = 0; update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, FO_SELCHANGE); + BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE); } } - if (cu->pos>cu->len) cu->pos= cu->len; - else if (cu->pos>=MAXTEXT) cu->pos= MAXTEXT; - else if (cu->pos<0) cu->pos= 0; + if (cu->pos > cu->len) cu->pos = cu->len; + else if (cu->pos >= MAXTEXT) cu->pos = MAXTEXT; + else if (cu->pos < 0) cu->pos = 0; text_update_edited(C, scene, obedit, select, cursmove); @@ -919,7 +920,7 @@ static int move_cursor(bContext *C, int type, int select) static int move_exec(bContext *C, wmOperator *op) { - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); return move_cursor(C, type, 0); } @@ -936,7 +937,7 @@ void FONT_OT_move(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to"); @@ -946,7 +947,7 @@ void FONT_OT_move(wmOperatorType *ot) static int move_select_exec(bContext *C, wmOperator *op) { - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); return move_cursor(C, type, 1); } @@ -963,7 +964,7 @@ void FONT_OT_move_select(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to, to make a selection"); @@ -973,20 +974,20 @@ void FONT_OT_move_select(wmOperatorType *ot) static int change_spacing_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int kern, delta= RNA_int_get(op->ptr, "delta"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int kern, delta = RNA_int_get(op->ptr, "delta"); - kern = ef->textbufinfo[cu->pos-1].kern; + kern = ef->textbufinfo[cu->pos - 1].kern; kern += delta; CLAMP(kern, -20, 20); - if (ef->textbufinfo[cu->pos-1].kern == kern) + if (ef->textbufinfo[cu->pos - 1].kern == kern) return OPERATOR_CANCELLED; - ef->textbufinfo[cu->pos-1].kern = kern; + ef->textbufinfo[cu->pos - 1].kern = kern; text_update_edited(C, scene, obedit, 1, FO_EDIT); @@ -1005,7 +1006,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "delta", 1, -20, 20, "Delta", "Amount to decrease or increase character spacing with", -20, 20); @@ -1015,23 +1016,23 @@ void FONT_OT_change_spacing(wmOperatorType *ot) static int change_character_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int character, delta= RNA_int_get(op->ptr, "delta"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int character, delta = RNA_int_get(op->ptr, "delta"); if (cu->pos <= 0) return OPERATOR_CANCELLED; - character= ef->textbuf[cu->pos - 1]; + character = ef->textbuf[cu->pos - 1]; character += delta; CLAMP(character, 0, 255); if (character == ef->textbuf[cu->pos - 1]) return OPERATOR_CANCELLED; - ef->textbuf[cu->pos - 1]= character; + ef->textbuf[cu->pos - 1] = character; text_update_edited(C, scene, obedit, 1, FO_EDIT); @@ -1050,7 +1051,7 @@ void FONT_OT_change_character(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "delta", 1, -255, 255, "Delta", "Number to increase or decrease character code with", -255, 255); @@ -1060,15 +1061,15 @@ void FONT_OT_change_character(wmOperatorType *ot) static int line_break_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - const int ctrl= RNA_boolean_get(op->ptr, "ctrl"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + const int ctrl = RNA_boolean_get(op->ptr, "ctrl"); if (ctrl) { insert_into_textbuf(obedit, 1); - if (ef->textbuf[cu->pos]!='\n') + if (ef->textbuf[cu->pos] != '\n') insert_into_textbuf(obedit, '\n'); } else @@ -1093,7 +1094,7 @@ void FONT_OT_line_break(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "ctrl", 0, "Ctrl", ""); // XXX what is this? @@ -1101,7 +1102,7 @@ void FONT_OT_line_break(wmOperatorType *ot) /******************* delete operator **********************/ -static EnumPropertyItem delete_type_items[]= { +static EnumPropertyItem delete_type_items[] = { {DEL_ALL, "ALL", 0, "All", ""}, {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -1112,55 +1113,55 @@ static EnumPropertyItem delete_type_items[]= { static int delete_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int x, selstart, selend, type= RNA_enum_get(op->ptr, "type"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int x, selstart, selend, type = RNA_enum_get(op->ptr, "type"); if (cu->len == 0) return OPERATOR_CANCELLED; - if (BKE_font_getselection(obedit, &selstart, &selend)) { - if (type == DEL_NEXT_SEL) type= DEL_SELECTION; - else if (type == DEL_PREV_SEL) type= DEL_SELECTION; + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { + if (type == DEL_NEXT_SEL) type = DEL_SELECTION; + else if (type == DEL_PREV_SEL) type = DEL_SELECTION; } else { - if (type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR; - else if (type == DEL_PREV_SEL) type= DEL_PREV_CHAR; + if (type == DEL_NEXT_SEL) type = DEL_NEXT_CHAR; + else if (type == DEL_PREV_SEL) type = DEL_PREV_CHAR; } switch (type) { case DEL_ALL: cu->len = cu->pos = 0; - ef->textbuf[0]= 0; + ef->textbuf[0] = 0; break; case DEL_SELECTION: if (!kill_selection(obedit, 0)) return OPERATOR_CANCELLED; break; case DEL_PREV_CHAR: - if (cu->pos<=0) + if (cu->pos <= 0) return OPERATOR_CANCELLED; - for (x=cu->pos;x<=cu->len;x++) - ef->textbuf[x-1]= ef->textbuf[x]; - for (x=cu->pos;x<=cu->len;x++) - ef->textbufinfo[x-1]= ef->textbufinfo[x]; + for (x = cu->pos; x <= cu->len; x++) + ef->textbuf[x - 1] = ef->textbuf[x]; + for (x = cu->pos; x <= cu->len; x++) + ef->textbufinfo[x - 1] = ef->textbufinfo[x]; cu->pos--; - ef->textbuf[--cu->len]='\0'; + ef->textbuf[--cu->len] = '\0'; break; case DEL_NEXT_CHAR: - if (cu->pos>=cu->len) + if (cu->pos >= cu->len) return OPERATOR_CANCELLED; - for (x=cu->pos;x<cu->len;x++) - ef->textbuf[x]= ef->textbuf[x+1]; - for (x=cu->pos;x<cu->len;x++) - ef->textbufinfo[x]= ef->textbufinfo[x+1]; + for (x = cu->pos; x < cu->len; x++) + ef->textbuf[x] = ef->textbuf[x + 1]; + for (x = cu->pos; x < cu->len; x++) + ef->textbufinfo[x] = ef->textbufinfo[x + 1]; - ef->textbuf[--cu->len]='\0'; + ef->textbuf[--cu->len] = '\0'; break; default: return OPERATOR_CANCELLED; @@ -1183,7 +1184,7 @@ void FONT_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", delete_type_items, DEL_ALL, "Type", "Which part of the text to delete"); @@ -1193,8 +1194,8 @@ void FONT_OT_delete(wmOperatorType *ot) static int insert_text_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); char *inserted_utf8; wchar_t *inserted_text; int a, len; @@ -1202,13 +1203,13 @@ static int insert_text_exec(bContext *C, wmOperator *op) if (!RNA_struct_property_is_set(op->ptr, "text")) return OPERATOR_CANCELLED; - inserted_utf8= RNA_string_get_alloc(op->ptr, "text", NULL, 0); - len= BLI_strlen_utf8(inserted_utf8); + inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0); + len = BLI_strlen_utf8(inserted_utf8); - inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text"); - BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len+1); + inserted_text = MEM_callocN(sizeof(wchar_t) * (len + 1), "FONT_insert_text"); + BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len + 1); - for (a=0; a<len; a++) + for (a = 0; a < len; a++) insert_into_textbuf(obedit, inserted_text[a]); MEM_freeN(inserted_text); @@ -1222,81 +1223,81 @@ static int insert_text_exec(bContext *C, wmOperator *op) static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - static int accentcode= 0; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + static int accentcode = 0; uintptr_t ascii = evt->ascii; - int alt= evt->alt, shift= evt->shift, ctrl= evt->ctrl; - int event= evt->type, val= evt->val; - wchar_t inserted_text[2]= {0}; + int alt = evt->alt, shift = evt->shift, ctrl = evt->ctrl; + int event = evt->type, val = evt->val; + wchar_t inserted_text[2] = {0}; if (RNA_struct_property_is_set(op->ptr, "text")) return insert_text_exec(C, op); if (RNA_struct_property_is_set(op->ptr, "accent")) { - if (cu->len!=0 && cu->pos>0) - accentcode= 1; + if (cu->len != 0 && cu->pos > 0) + accentcode = 1; return OPERATOR_FINISHED; } /* tab should exit editmode, but we allow it to be typed using modifier keys */ - if (event==TABKEY) { - if ((alt||ctrl||shift) == 0) + if (event == TABKEY) { + if ((alt || ctrl || shift) == 0) return OPERATOR_PASS_THROUGH; else - ascii= 9; + ascii = 9; } - else if (event==BACKSPACEKEY) - ascii= 0; + else if (event == BACKSPACEKEY) + ascii = 0; if (val && (ascii || evt->utf8_buf[0])) { /* handle case like TAB (== 9) */ if ( (ascii > 31 && ascii < 254 && ascii != 127) || - (ascii==13) || - (ascii==10) || - (ascii==8) || - (evt->utf8_buf[0])) + (ascii == 13) || + (ascii == 10) || + (ascii == 8) || + (evt->utf8_buf[0])) { if (evt->utf8_buf[0]) { BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1); - ascii= inserted_text[0]; + ascii = inserted_text[0]; insert_into_textbuf(obedit, ascii); - accentcode= 0; + accentcode = 0; } else if (accentcode) { - if (cu->pos>0) { - inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii); - ef->textbuf[cu->pos-1]= inserted_text[0]; + if (cu->pos > 0) { + inserted_text[0] = findaccent(ef->textbuf[cu->pos - 1], ascii); + ef->textbuf[cu->pos - 1] = inserted_text[0]; } - accentcode= 0; + accentcode = 0; } - else if (cu->len<MAXTEXT-1) { + else if (cu->len < MAXTEXT - 1) { if (alt) { /* might become obsolete, apple has default values for this, other OS's too? */ - if (ascii=='t') ascii= 137; - else if (ascii=='c') ascii= 169; - else if (ascii=='f') ascii= 164; - else if (ascii=='g') ascii= 176; - else if (ascii=='l') ascii= 163; - else if (ascii=='r') ascii= 174; - else if (ascii=='s') ascii= 223; - else if (ascii=='y') ascii= 165; - else if (ascii=='.') ascii= 138; - else if (ascii=='1') ascii= 185; - else if (ascii=='2') ascii= 178; - else if (ascii=='3') ascii= 179; - else if (ascii=='%') ascii= 139; - else if (ascii=='?') ascii= 191; - else if (ascii=='!') ascii= 161; - else if (ascii=='x') ascii= 215; - else if (ascii=='>') ascii= 187; - else if (ascii=='<') ascii= 171; + if (ascii == 't') ascii = 137; + else if (ascii == 'c') ascii = 169; + else if (ascii == 'f') ascii = 164; + else if (ascii == 'g') ascii = 176; + else if (ascii == 'l') ascii = 163; + else if (ascii == 'r') ascii = 174; + else if (ascii == 's') ascii = 223; + else if (ascii == 'y') ascii = 165; + else if (ascii == '.') ascii = 138; + else if (ascii == '1') ascii = 185; + else if (ascii == '2') ascii = 178; + else if (ascii == '3') ascii = 179; + else if (ascii == '%') ascii = 139; + else if (ascii == '?') ascii = 191; + else if (ascii == '!') ascii = 161; + else if (ascii == 'x') ascii = 215; + else if (ascii == '>') ascii = 187; + else if (ascii == '<') ascii = 171; } - inserted_text[0]= ascii; + inserted_text[0] = ascii; insert_into_textbuf(obedit, ascii); } @@ -1304,14 +1305,14 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) text_update_edited(C, scene, obedit, 1, FO_EDIT); } else { - inserted_text[0]= ascii; + inserted_text[0] = ascii; insert_into_textbuf(obedit, ascii); text_update_edited(C, scene, obedit, 1, FO_EDIT); } } else if (val && event == BACKSPACEKEY) { - if (alt && cu->len!=0 && cu->pos>0) - accentcode= 1; + if (alt && cu->len != 0 && cu->pos > 0) + accentcode = 1; return OPERATOR_PASS_THROUGH; } @@ -1327,7 +1328,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) } /* reset property? */ - accentcode= 0; + accentcode = 0; return OPERATOR_FINISHED; } @@ -1345,7 +1346,7 @@ void FONT_OT_text_insert(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); @@ -1356,18 +1357,18 @@ void FONT_OT_text_insert(wmOperatorType *ot) /*********************** textbox add operator *************************/ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_active_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_active_object(C); + Curve *cu = obedit->data; int i; if (cu->totbox < 256) { - for (i = cu->totbox; i>cu->actbox; i--) cu->tb[i]= cu->tb[i-1]; - cu->tb[cu->actbox]= cu->tb[cu->actbox-1]; + for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1]; + cu->tb[cu->actbox] = cu->tb[cu->actbox - 1]; cu->actbox++; cu->totbox++; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1383,7 +1384,7 @@ void FONT_OT_textbox_add(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable_font; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1396,20 +1397,20 @@ void FONT_OT_textbox_add(wmOperatorType *ot) static int textbox_remove_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_active_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_active_object(C); + Curve *cu = obedit->data; int i; int index = RNA_int_get(op->ptr, "index"); if (cu->totbox > 1) { - for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1]; + for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1]; cu->totbox--; if (cu->actbox >= index) cu->actbox--; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1426,7 +1427,7 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable_font; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX); } @@ -1437,33 +1438,33 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) void make_editText(Object *obedit) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; - if (ef==NULL) { - ef= cu->editfont= MEM_callocN(sizeof(EditFont), "editfont"); + if (ef == NULL) { + ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont"); - ef->textbuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditbuf"); - ef->textbufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditbufinfo"); - ef->copybuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditcopybuf"); - ef->copybufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditcopybufinfo"); - ef->oldstr= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf"); - ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "oldstrbuf"); + ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf"); + ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); + ef->copybuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditcopybuf"); + ef->copybufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditcopybufinfo"); + ef->oldstr = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "oldstrbuf"); + ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf"); } // Convert the original text to wchar_t - BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT+4); /* length is bogus */ + BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */ wcscpy(ef->oldstr, ef->textbuf); - cu->len= wcslen(ef->textbuf); + cu->len = wcslen(ef->textbuf); - memcpy(ef->textbufinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); - memcpy(ef->oldstrinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); + memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); + memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); - if (cu->pos>cu->len) cu->pos= cu->len; + if (cu->pos > cu->len) cu->pos = cu->len; if (cu->pos) - cu->curinfo = ef->textbufinfo[cu->pos-1]; + cu->curinfo = ef->textbufinfo[cu->pos - 1]; else cu->curinfo = ef->textbufinfo[0]; @@ -1473,28 +1474,28 @@ void make_editText(Object *obedit) void load_editText(Object *obedit) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; MEM_freeN(ef->oldstr); - ef->oldstr= NULL; + ef->oldstr = NULL; MEM_freeN(ef->oldstrinfo); - ef->oldstrinfo= NULL; + ef->oldstrinfo = NULL; update_string(cu); if (cu->strinfo) MEM_freeN(cu->strinfo); - cu->strinfo= MEM_callocN((cu->len+4)*sizeof(CharInfo), "texteditinfo"); - memcpy(cu->strinfo, ef->textbufinfo, (cu->len)*sizeof(CharInfo)); + cu->strinfo = MEM_callocN((cu->len + 4) * sizeof(CharInfo), "texteditinfo"); + memcpy(cu->strinfo, ef->textbufinfo, (cu->len) * sizeof(CharInfo)); - cu->len= strlen(cu->str); + cu->len = strlen(cu->str); /* this memory system is weak... */ if (cu->selboxes) { MEM_freeN(cu->selboxes); - cu->selboxes= NULL; + cu->selboxes = NULL; } } @@ -1505,35 +1506,35 @@ void free_editText(Object *obedit) /********************** set case operator *********************/ -static EnumPropertyItem case_items[]= { +static EnumPropertyItem case_items[] = { {CASE_LOWER, "LOWER", 0, "Lower", ""}, {CASE_UPPER, "UPPER", 0, "Upper", ""}, {0, NULL, 0, NULL, NULL}}; static int set_case(bContext *C, int ccase) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; wchar_t *str; int len; - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='a' && *str<='z') - *str-= 32; + if (*str >= 'a' && *str <= 'z') + *str -= 32; len--; str++; } if (ccase == CASE_LOWER) { - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='A' && *str<='Z') { - *str+= 32; + if (*str >= 'A' && *str <= 'Z') { + *str += 32; } len--; str++; @@ -1562,7 +1563,7 @@ void FONT_OT_case_set(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "case", case_items, CASE_LOWER, "Case", "Lower or upper case"); @@ -1572,17 +1573,17 @@ void FONT_OT_case_set(wmOperatorType *ot) static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; wchar_t *str; - int len, ccase= CASE_UPPER; + int len, ccase = CASE_UPPER; - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='a' && *str<='z') { - ccase= CASE_LOWER; + if (*str >= 'a' && *str <= 'z') { + ccase = CASE_LOWER; break; } @@ -1605,7 +1606,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** Open Font ************** */ @@ -1614,27 +1615,27 @@ static void font_ui_template_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } static int font_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } static int font_open_exec(bContext *C, wmOperator *op) { - struct Main *bmain= CTX_data_main(C); + struct Main *bmain = CTX_data_main(C); VFont *font; PropertyPointerRNA *pprop; PointerRNA idptr; char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - font= load_vfont(bmain, filepath); + font = BKE_vfont_load(bmain, filepath); if (!font) { if (op->customdata) MEM_freeN(op->customdata); @@ -1645,7 +1646,7 @@ static int font_open_exec(bContext *C, wmOperator *op) font_ui_template_init(C, op); /* hook into UI */ - pprop= op->customdata; + pprop = op->customdata; if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA @@ -1664,7 +1665,7 @@ static int font_open_exec(bContext *C, wmOperator *op) static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - VFont *font=NULL; + VFont *font = NULL; char *path; PointerRNA idptr; @@ -1673,14 +1674,14 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) font_ui_template_init(C, op); /* hook into UI */ - pprop= op->customdata; + pprop = op->customdata; if (pprop->prop) { - idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop); - font= idptr.id.data; + idptr = RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop); + font = idptr.id.data; } - path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir; + path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0) ? font->name : U.fontdir; if (RNA_struct_property_is_set(op->ptr, "filepath")) return font_open_exec(C, op); @@ -1704,10 +1705,10 @@ void FONT_OT_open(wmOperatorType *ot) ot->cancel = font_open_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* delete operator *********************/ @@ -1721,12 +1722,12 @@ static int font_unlink_exec(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop.ptr, &pprop.prop); - if (pprop.prop==NULL) { + if (pprop.prop == NULL) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink"); return OPERATOR_CANCELLED; } - builtin_font = get_builtin_font(); + builtin_font = BKE_vfont_builtin_get(); RNA_id_pointer_create(&builtin_font->id, &idptr); RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr); @@ -1751,15 +1752,15 @@ void FONT_OT_unlink(wmOperatorType *ot) static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata)) { - Curve *cu= (Curve *)ecu; - EditFont *ef= cu->editfont; - char *str= strv; + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; + char *str = strv; - cu->pos= *((short *)str); - cu->len= *((short *)(str+2)); + cu->pos = *((short *)str); + cu->len = *((short *)(str + 2)); - memcpy(ef->textbuf, str+4, (cu->len+1)*sizeof(wchar_t)); - memcpy(ef->textbufinfo, str+4 + (cu->len+1)*sizeof(wchar_t), cu->len*sizeof(CharInfo)); + memcpy(ef->textbuf, str + 4, (cu->len + 1) * sizeof(wchar_t)); + memcpy(ef->textbufinfo, str + 4 + (cu->len + 1) * sizeof(wchar_t), cu->len * sizeof(CharInfo)); cu->selstart = cu->selend = 0; @@ -1768,19 +1769,19 @@ static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata)) static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) { - Curve *cu= (Curve *)ecu; - EditFont *ef= cu->editfont; + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; char *str; // The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo - str= MEM_callocN((MAXTEXT+6)*sizeof(wchar_t) + (MAXTEXT+4)*sizeof(CharInfo), "string undo"); + str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); // Copy the string and string information - memcpy(str+4, ef->textbuf, (cu->len+1)*sizeof(wchar_t)); - memcpy(str+4 + (cu->len+1)*sizeof(wchar_t), ef->textbufinfo, cu->len*sizeof(CharInfo)); + memcpy(str + 4, ef->textbuf, (cu->len + 1) * sizeof(wchar_t)); + memcpy(str + 4 + (cu->len + 1) * sizeof(wchar_t), ef->textbufinfo, cu->len * sizeof(CharInfo)); - *((short *)str)= cu->pos; - *((short *)(str+2))= cu->len; + *((short *)str) = cu->pos; + *((short *)(str + 2)) = cu->len; return str; } @@ -1792,8 +1793,8 @@ static void free_undoFont(void *strv) static void *get_undoFont(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_FONT) { + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_FONT) { return obedit->data; } return NULL; diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index b27901c2667..dc441c41664 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -64,6 +64,7 @@ if(WITH_BLENDER) inflate.png.c layer.png.c lighten.png.c + mask.png.c mix.png.c multiply.png.c nudge.png.c diff --git a/source/blender/editors/datafiles/mask.png.c b/source/blender/editors/datafiles/mask.png.c new file mode 100644 index 00000000000..78a2e1a0352 --- /dev/null +++ b/source/blender/editors/datafiles/mask.png.c @@ -0,0 +1,400 @@ +/* DataToC output of file <mask_png> */ + +int datatoc_mask_png_size= 12593; +char datatoc_mask_png[]= { +137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, + 0, 0, 96, 0, 0, 0, 96, 8, 2, 0, 0, 0,109,250,224,111, 0, 0, 0, 1,115, 82, 71, 66, 0,174,206, 28,233, 0, 0, 0, + 6, 98, 75, 71, 68, 0,255, 0,255, 0,255,160,189,167,147, 0, 0, 0, 9,112, 72, 89,115, 0, 0, 11, 19, 0, 0, 11, 19, 1, + 0,154,156, 24, 0, 0, 0, 7,116, 73, 77, 69, 7,220, 3, 25, 18, 46, 48,241,229, 90,175, 0, 0, 32, 0, 73, 68, 65, 84,120, +218,237,189, 89,172,101,217,113, 37, 22, 17,123,159,115,231,225, 13,249,114,100,101, 85,102,205, 44, 22,103, 82,148,186, 53,160, +219,114, 55,220,238, 54, 96,160, 1, 15,253, 39,209,128, 13,201, 18,108,195, 48,208,147, 97,255,248,195,250, 51, 12,248,211, 31, +254, 50, 96, 3, 22, 4, 75,178,196,110, 81, 18, 41,137, 44,146, 53,207, 89, 85, 57,231, 27,239,124,206,217, 59, 34,252, 17,123, +159,251,146,173,238, 22, 69,181,236, 6, 58,137,202,122,204,151,239,189,123,227,196,142, 88,177,214,138, 93, 0,255,230,215,191, +249,245,231,254, 69, 0,254, 47,246, 59, 94, 57,216,255,155, 63,247, 83, 63,245,197,207, 58, 71,239,124,240,241,111,125,243,143, +190,243,218,155,255,250, 6,168, 68,196, 31,255,187,116, 59,229,115, 55,174,255,221,127,231,223,250, 15,255,189,191,113,176,191, +171, 12, 77,108,132, 5,145, 8,225,206,131,195, 63,252,238, 15,254,239,223,251,214, 43,175,191, 61, 91, 44,215,155,170, 9,225, + 95,139,232, 56, 4, 5,248,113, 3,244,210,179, 55,255,135,255,230,151,127,250,203,159, 39,162,170,170, 69, 21, 16, 16, 0, 17, + 68, 85, 4, 64, 21, 16, 68,228,240,228,236,225,209,241, 15,222,122,239,221, 15, 63,126,227,189, 91,175,190,253,238, 98,185, 38, + 68, 81,253,255,103,128, 60, 66,212, 31,251,136,125,238,211,207,254,252, 95,249,234,186,170, 81,165, 44, 10, 86, 81, 85, 85, 5, + 0, 79, 32, 4,202,202, 42, 34, 58, 30,244,203,194, 95,218,223,251,185,175,126,113, 85,109,142, 79,231,179,229,242,209,225,113, +217, 41,189, 35, 22, 93, 44, 86, 15, 14,143,155, 16,126,240,214,123, 39,103,179, 15, 62,185, 43, 34,255, 31, 6, 8, 1, 17,244, +199,205,160, 95,251,251,191,250,111,255,204,215, 28,225,160, 55, 24,244, 58,190,240,222, 57, 21,101, 21, 21, 5, 85, 1, 80, 80, +142, 28,133, 67, 19,171,186, 14, 33, 70,230, 58,132, 16, 34,139,212, 77,216,108,170,251,135,135,227,225,176,137, 81,132,189, 47, + 8,177,105,194,163,211,179,183,223,251,240,253,143,238,188,255,241,237,249,114, 85,213, 53,243, 95, 94,200, 10,196,168,250,227, +102,144,130, 30,159,206,155, 80, 75,228, 94,175, 51, 28,244,167,163,209,112, 56,232, 20, 37, 17, 1, 0,168,138, 48, 18, 57, 0, +245,208, 1,116, 46,132, 24,137,200,145,107, 66, 32,194,126,183, 51,157,142,234,186, 9, 33,206,150,203,208,196,154,163, 34, 93, +220,221,185,244,147, 95,250,217,175,125,105,189,169, 30, 30,157,124,248,201,157,143,238,220,127,255,163,219,247, 30, 30,254, 37, + 4, 72, 65,127,220, 26, 84,120,255,255,252,111,255, 51, 33,174,215,235, 38, 4, 21, 65, 66, 36, 44,156,159,142, 71, 7,251,123, +163,193,192, 17, 17, 33, 34, 54,129, 3, 71, 17,101, 97,142, 28, 66, 12, 49,134, 16,152, 37, 8,139,168,136, 48, 51,179,136, 74, + 93, 55,103,139,165,136, 32,145,138,198,200,145,153,133,171,186, 89,173, 54,143,142,143,191,247,230, 59,175,188,246,206,114,189, +254, 87, 91,164,245,207, 21,160,126,175,251,196,149, 75,255,217,223,251,187, 63,255,211, 63, 1, 42,145,229,232,248,100,181, 89, + 51,139,168,130, 10, 32,136,168,170, 14, 7,253,253,221,157,157,201,100,216,239,119,202, 82, 68,154, 16,154,200,194, 18,153,153, + 99,136, 49,178,216, 97, 99, 17, 97, 86, 80, 17,101, 22,102,110, 98, 92,172,214, 42, 28, 35, 43, 40,179,178, 8,139,196, 16, 99, +140,171,205,230,187,175,189,253,135,175,188,122,116,122, 22, 66,252, 87,115,202,126,196, 0,245, 58,157,191,243,243, 63,243,183, +255,250, 79,127,233, 51, 47, 14,135,253,162, 40,188,115,170, 50, 95,172, 14,143,142,207,206,102,117,180,108, 0, 5, 5, 80,102, +142, 28,157,243,163, 65,127,111,103,186,191,179, 51, 29,143, 89, 53, 70,110, 66,104, 66, 96, 22, 97, 14,145, 67, 12, 44, 18, 34, + 3, 64,136, 49,215,122, 21,213, 24, 67, 85, 55, 44, 50, 95, 44, 3, 51,179, 16, 33,139,138,112, 12,188, 90,111,222,185,245,241, +235,111,127,240,254,199,183, 23,171,191,224,132,242, 63,210, 17,251,143,255,206,223,252, 79,254,163,127,255,226,133,221,162,240, +222, 57,231, 92,225,189, 35, 42,138,162, 44,156,170,206, 22,171, 7, 15, 31, 29,159,158,213,117, 19, 56, 10,139,128, 10,139,168, +138,176, 34, 56,162,209, 96,112,237,242,229,131,253, 93, 71,142,133,215,155,166,174,235,200, 28, 35, 71,142,129, 69, 85,153, 57, +198, 40, 98,136, 1, 1, 0, 9, 17, 32, 50, 87,117,243,201,221,251, 31,220,190, 55, 25, 15, 7,189, 94,233, 41, 68,174,235,176, + 92,173, 14,143, 79, 95,125,251,189, 63,121,245, 45,254, 11,237,125,238,207, 82,104,254,234,151, 63,247,191,254,218,127,251, 31, +252,237,191, 49, 28,244, 58,101,217, 43, 59,157,178, 44, 75,239,156, 35, 34, 80, 21, 81, 64, 28,244,187, 23, 47,236, 95,184,176, +215,235,118, 61, 17, 2,168,193, 34, 68, 4, 36, 0, 17, 93, 87,155,251,143, 30, 61, 60, 60,226, 40,157, 78,217,239,118,187,221, +210,130, 34, 42,106, 85, 93, 65, 21,136,208,226,131, 8,133,247,138, 72,136,101, 81, 92,185,120,240,189, 55,222,123,243,131,187, +203,229,154,136,122,221, 78, 81,250,194, 23,253, 94,247,242,193,222, 51, 79,125,234,108,190, 88,174, 55, 34,250,151, 17,160,159, +252,194,203,127,255,151,126,225, 31,252,242, 47,236, 77, 39, 44,210, 41,203, 94,183,219, 41, 11,239,124,225,157,119,228,200, 57, + 34,116,132, 0,204,202, 44,142,220,100, 52,220,223,219,221,157, 76, 7,131,129, 67,140, 81,132, 89, 84, 9,145, 16, 17,176, 9, +225,232,228,244,209,209,241,106,179, 70,194,241,104, 56, 26,244,189,243,160, 26, 89, 84, 5, 16,136, 44, 62, 10, 0, 68,148,122, + 34, 0,139,120, 71,127,252,131,183,215, 13,156, 45, 86, 77, 19,250,101,209,235,117, 11,239,188,247,253,110,231,169,171,151,167, +227,225,166,170,255, 66, 78,220,191, 40, 64,255,248, 87,191,254,223,255, 87,255,233,139,207,222, 96, 22,116,212,237,116,122,157, +162,244,222,121,231,136,156, 35, 76, 15, 25, 17,192,158, 87,219,140,132,197,123, 63, 26, 14, 47,238,239,237,239,239, 2,226,102, +179, 9, 33, 32, 17,145, 35, 0,203,154,229,106,125,116,122,122,120,116,196, 34,211,241,100, 52, 26,140,122, 3, 34,140,204, 25, +147,131,115,132,136,136,132,132,150,100,139,229,250,251,111,190,227,203,126, 8, 50, 91,110,230,171,181, 39, 28, 13,123,190, 40, +156, 67, 95,248,201,104,112,241,194,206,160,223,187,247,232, 72,127, 60,164,238,254,212,113,236,197,103,158,250, 63,255,151,255, +241,223,253,235, 63,163,160, 8,232,189,235,149,101, 89,122,239, 28,165,255, 33, 0, 64,142,140, 77, 20,246, 82, 84, 5, 0, 20, +193, 58,142,136,118,139,242, 96,127,111,127,119, 39,196,184,217,108,212,106, 4, 17,139, 48,115, 8,177,106,234,163,227,211, 7, +135,143, 98,148,178, 44, 38,163,225,100, 60,244, 68,145,197,219,147, 0, 34,239, 64, 84, 85, 64,245,116,190,248,254, 91,239,249, +162, 71,100,199, 54,158, 45,215,132, 48, 25,116,189,243, 68, 72,132,165, 47, 38,195,193,181,203, 23,142, 78,102,235,170,254,243, + 7,232,215,254,225,127,113,253,137,107, 79, 94,187,226, 9,143, 78,206,188,119,255,229,215,255,222,255,244,223,253,215, 87, 46, + 29,196,200, 4,232,156, 43,156, 47, 82,218,144, 35, 71,132, 86,221,109,168, 72,205,198, 42, 17,168, 69, 7, 84, 21, 17, 1, 4, +145, 35,139,106,183,211, 61,216,223,223,155, 78, 17,161, 14, 33,132, 64,136,142, 40,229, 29,115,213, 52, 39,167,167, 71,199, 39, +179,197, 66, 68,119,166,227,221,233,164, 44, 11, 68, 68, 4, 67,230,162, 10, 10, 15,143, 79, 94,123,251,195,178,219,107, 39,129, + 16,101,185,169, 75,143,147, 97,151, 28, 2, 32, 32, 16,162,247,238,234,193,133,194,187,163,211,217,159,111,232, 67,253,232, 59, + 77,136,204, 92,133,112,120, 54,155,205, 22,220,196,253,233,100,127,111,167, 91,250, 38,114,100, 86, 21, 68, 44,138,162,244,222, + 59,135, 4,170, 32, 6,122, 84, 69, 68,196, 94,186,168,130,162,170, 42,138,178, 77,162, 8, 42,160,168,168,160, 8, 4,132,168, + 85, 93, 29, 30, 30,223,185,119,255,108,177, 4, 0, 68, 20, 73,200,200, 57, 71,228,188,247,189,178,188,124,233,226,181, 43,151, +139,162,136,145, 87,171,213,201,124,217, 52, 13, 34,126,227, 91,127,242,141,111,191,218, 29,140, 69, 84, 68,115, 89,135,241,160, +243,194,147, 23, 15,118, 71,145,185,105,194,166,106,150,235,213,114,181,158, 47, 86,199,179,197,239,127,231,213,170,254,145,137, + 4,247,143,255,243, 95, 36, 66,239, 92,233,253,238,120,120,237,224,194,181, 43, 23, 59,157,114,190, 88,204, 87, 27,239,208, 59, +135,136,162,192,145,155, 24, 34, 11, 88,166, 67,206, 29, 59, 94,246,112, 1, 44, 68, 66,136,144, 43, 19, 2,170,253, 63,101,225, +200,140,232,198,227,241,254,222,238,100, 60,138, 49,134, 24, 1,208, 17,121,231, 17, 73, 69, 16, 49,114, 60,155,205, 30, 28, 30, +198, 24,250,189, 94,127,208,159, 14,250, 68, 24, 99,252,245,223,253,102,132, 18,209, 65,198, 41, 10, 10,170,117,224, 16,227,184, +223,233, 90,222,217,184,160, 64,132,158,232,210,133,189,179,197,234, 71, 61,110,238, 31,253,202,215, 49,195, 13,123, 63,162,236, +200,141,134,131, 94,167,136, 44,136,168, 2,136, 72,206, 17,162,136,132, 40,204, 81, 1, 16,208,158,161,106, 62, 93, 0, 32,170, +132, 0,160,162,168, 10, 22,169,246,219,171, 42,128,136,196, 16, 85,180, 44,203,233,100, 50, 26, 14,156,163, 24,153, 69,156, 53, + 44, 4,102, 97,225, 58,132,147,179,217,225,209, 73, 85, 53,174,240, 23,118,119,231,203,213,111,252,147,111,117,186, 35, 5,177, + 16,164,111,141, 8, 10,117, 19, 17, 97, 58,234, 23,158, 0, 65, 85, 81,237,147, 74, 72,211,209,128,153,103,139,213,143, 18,160, + 95,253, 58, 2, 40, 32, 40, 16, 18, 37,150, 8, 69,212, 57, 87, 22, 69, 89,248,162,240, 10,200,145, 53, 63, 22, 80, 96,102, 11, +138,170, 68, 81,102, 86,145, 92, 19, 16, 64, 17, 84, 9, 1,183,121,148, 2,164, 96,167, 81, 88, 89,152, 69,200,185, 94,183, 59, + 25,141, 60,185,170,174, 68,132,136,114,121, 18,142,177, 9, 97, 54,155, 61, 60, 58, 90, 46, 87,223,252,147,239, 31, 45,106, 69, +159,242, 21, 83,169, 64, 64, 4, 16,149, 38, 72,191,231,199,253,126,226,165, 64, 21, 64, 24, 0,212, 17,142, 6, 61, 66, 60,153, + 45,254,204, 71,236, 87,190,174,130,144,135, 3,201,111,144,136, 88, 4, 17, 16, 81, 21,188,195,162,112, 32, 18, 36,218,160,160, +104, 71,199, 90,151, 48, 75, 84, 54,244, 12,170, 8,104,121,100,245, 90, 45, 76,185, 78, 10,231, 83,169, 54,237, 91, 41,131,110, +167, 59, 29,143, 17,145, 99, 20, 21, 0,116,206, 57,231,197,176, 67,228, 15, 62,185,253,221, 55,222,163, 98,160, 10, 10, 98, 49, + 71,235, 25,168,136, 0, 64, 10,136,174, 24,247,138,110,199,111, 19, 95, 5, 80,173, 41,247,186, 69,100,158, 45,254, 76, 40,201, +171,164,145, 21, 17, 65, 21, 53,189,103, 5, 1, 85, 64, 4, 0, 81, 81, 81, 34,232,148,157, 78,217,169, 67, 88,173,214, 85, 85, + 7, 23, 74,239,189, 47, 12,166, 32,163,168,130,168,160, 58,114, 4,132,136,160,160,136,160,106, 72, 32, 85, 5,220, 6, 75,211, + 59, 68, 34,136,172, 10, 56,158, 76,167,147, 73, 93,215,203,213,106,190, 92,104,132, 78,167,195, 28, 79, 78,103,111,127,120, 7, +253, 0, 0, 9, 65,137, 4, 0, 65, 64,132, 0, 21, 64, 64, 17,129, 57, 10,116,119, 46, 92,190,121,101,119, 60, 24,140,199,163, + 77, 85,253,246, 55,255,240,222,195,135,221, 78,135, 89, 68,251, 79, 63,113, 89, 68,239, 60, 56,250,151,103,208, 63,252,229,175, + 35, 42,171, 88,111, 20, 20, 64, 0,123, 71,160,136, 8,136,204, 18, 57,178,218, 35,130,210,251,110,167,116,206,213,117, 8, 28, +153, 25,144,108, 60,179, 20, 68, 36, 1, 5, 67,122, 68,233,123,105,142,142,164,118,151, 32, 66,250, 64, 82, 14,131,138,104, 20, + 1,128,110,183,187, 55,157,122,143,171,213,230,248,116,254,198,251,159,172, 2, 81,209, 71, 32, 53,174,230, 49, 12,135,136,136, +138,136, 80,215,245, 19, 79, 60,245,181,207, 62,255,252,211, 79,142,135,131, 65,183,123,229,226,193,157, 7, 15, 23,203, 37, 33, + 8, 40, 42,244,123, 37, 0,252, 75,243,200,253,163, 95,249, 5, 80,112, 68,169, 25,229, 39,110, 96,198,248,101, 3,124, 4,168, +138, 77,140,222,185, 16,195,173,247,223,186,117,235,221,201,100,119, 83, 55, 77, 19, 12, 79,251,194, 39,248, 75,132, 72,138, 96, +236, 7,110,115,242,241,246,151,161,148,228,194,148,195,136,170, 26, 88, 86,235,245,253,135, 15, 23,155,230, 7,239,126,188,137, +206,151, 67,109,171, 28,218,247, 86, 64, 68, 36,235,150, 96, 79, 52, 70,162,226,230,245, 43,251, 59, 35, 66,138, 49,246,187,221, +213,122, 29, 35,175, 18, 82, 85, 80, 44,189, 99,150,197,186,250, 23,102,208, 47,253, 98, 10,141, 42, 40,160, 34, 42,168,181,132, +116,184,149, 69, 85,149,144,236, 51,143, 30,220,249,157,223,249,141,223,255,131,127,250,250, 59,239,124,239,141,183, 30, 29, 29, +158,204,102, 49, 74,183,215, 85,171,244,132,169, 58,180,228, 28,128, 64, 30, 69, 19, 21,171,118,236, 84, 18,148,201, 88, 1,236, + 3,102, 94,173,215, 15,142, 78,222,189,253,232,253, 59,199, 88, 12,193,119, 53,149,101,235, 76,154, 19, 7,242, 56, 96,179, 15, + 32,185,200,124, 97,239,194,147,151,118, 59,133, 51,114, 10, 17, 15, 79,142, 39,195, 97, 19,226,122,179,177,147,221, 41,125, 19, +194,186,106,254,185, 1,250, 7,191,244,139,144,169, 51, 67, 43,219,188, 85,171,208,202, 34, 8, 64,132,170,240,222, 59,175,255, + 95,191,254,191,223,190,123,103,190,137,117,132, 16,195,201,201,201,189,123,247, 94,121,245, 7,155,170,222,155,238,218,240, 14, +128, 41, 49, 0, 16, 49, 1, 36, 27, 70,164,205,155,116,214, 64, 64, 64, 85, 84, 84, 67,140,155, 77,117,124, 58,191,251,224,240, +131, 59, 15, 62,186,127, 54,223,168,186,142, 0,165, 18,150,184,208,156, 47, 96, 49, 1, 66, 11, 89,250, 19,102, 30, 12, 39, 55, +175,237, 79, 70,125, 80,136,204,206,209,221,251, 15, 68,101, 50,234,139,192,114,181, 68, 84,102,233,150,197,186,170,235, 38,254, +243,142,216, 47,146, 29,102,205, 71,218, 78, 68,234,232,168,168, 42,106,104,230,173,183, 95,253,141,223,248, 63, 22,171,205,217, + 38,134,104,233, 5,145, 35,115,172,155,205, 27,111,189,245,224,240,112, 58, 25,151,101,199,158,171,136, 72,238,249,169,176,137, +138,170,128,178,176,209,105, 54,139,173,214,155,179,249,226,225,209,201,237,251,135, 31,220,126,120,235,222,209,189,227,213,108, + 45, 81,157,228,142,158,128, 58,100,228,131,104, 51, 15, 34, 34, 80,122,197,246, 15,130,136, 32,186,167,175, 95,189,180, 59, 34, +162, 24,153, 16, 31, 29,159,204, 23, 11, 64, 24, 15,135, 72,116,114, 58, 35, 68, 22,233,117,203,249,114, 29,255, 52, 69,192,163, +162,216, 19, 4,104,219, 22,166, 15, 17, 64,129,129, 28, 34,224,107,175,126,231, 55,127,235,215,231,235,106, 89, 9,171, 2,160, + 67, 66,194,200, 12, 0,157,162, 51, 30,234,155,111,191,246,232,232,225,207,124,237,175,124,249, 11, 95,212, 94, 79, 85,137, 80, +156, 71, 66,102,174,234,176,169,170,170,110,154, 38,212, 77,168,154, 80,213,205,166,110, 54, 85,179,174,194,166, 14, 85, 19,155, +168, 81,144,161, 16, 42, 20, 20, 68, 16, 69,137,128, 21, 9, 81, 72, 81, 17, 41,209, 75, 10, 68,168, 32,130,130, 72, 32,224, 64, +144,196,224,237,108,177,184,123, 56,251,204,141, 75,221,110,137,136,206,185,241,104,120,231,129,101,159, 94,187,120,224, 29,189, +243,193,199, 77,136,145,195,213,131,157, 91,119,143,254,217,121,205, 91,134,219,121, 86,177, 49, 43, 33,107,205, 40,149,128,222, +125,247,181,223,249,221,223,156,175,235, 69,165, 34,138,136,228, 8,145, 16,212, 38, 53, 68,236,117,251,136,184,152,159,125,235, + 79,190, 85,150,238,211,207,191,216,233,244, 68,117,185, 62, 59,157, 45,207,150,171,229,186,217,212, 49,176, 6, 22,102,136, 34, + 42,192,150, 83,130,162, 5,171, 87, 50, 81,156, 65, 88, 80, 21, 9,193,224, 24,161, 42,162, 32, 17,169,168,245, 71, 0, 16, 5, + 68, 2, 4, 82, 1, 84, 1, 4, 32, 82, 6, 93,173,151, 15, 79, 22,139, 77,211,237,150,142,136,153,119, 38,227, 68, 49, 33,176, +240,238,100,252,252,205, 39, 95,127,231,195, 16,155,241,160,119,121,111,124,247,104,246,207, 4, 72,117, 59, 37,144, 10, 32,106, +130, 38, 22, 53,116,238,238,157,143,190,241, 79,126,251,116,190,152,109,216,162,131, 8, 42,194,194,228,200,123,175, 98, 24, 27, +250,189, 62, 2,108,214,171, 87,223,120,141, 89,118,247, 14, 78, 23,155,227, 89, 85, 51, 50, 56, 1,175, 90, 88, 30, 39, 60,141, +162,100, 69, 73, 0, 5, 84,129, 5,208, 42, 19, 90, 63, 69, 80,131,171,152,187,148, 69, 68, 82, 15, 17, 16, 1, 36, 18, 1, 66, + 1, 2, 1, 4, 38, 4,142,124,124,182, 60, 91, 86,123,211,129,247,174, 9, 97,103, 50,113,206,133, 16,140,132, 67,196, 97,191, +251,185, 79, 63,253, 71,223,123,189, 14,113,111, 50,156,175,171,197,250,177, 97,141,196, 90,170, 0, 38,188,168,153,202, 0, 69, +112,228,142, 15,239,255,246,111,253,250,221, 7, 15,102,107, 22, 27, 54, 82, 43, 6, 52, 38,203,200, 44, 66, 36,116,206,247,122, + 3,239,203,135,143, 78,222,249,240,246, 91,183, 30,220, 61,174,215,220,139, 52, 84, 26,130,235, 40, 21, 72, 78,193, 41, 32, 0, +129,149,222,196,181, 98,254,225,248,152, 60,149,123, 84,170,201, 96,188, 36,145, 1, 31,227, 51, 17,173,121,230,151,100, 51,142, +156,206, 23,199,243,141,205, 46,136, 56,232,247,247,119,118, 34,139,170,138, 48, 17, 25,193,245,153,231,158,222, 25,143,201,193, +165,189, 81,233,233,113,131, 7,218,147,178,246, 10, 54, 57,128, 2,145, 18,210, 98, 53,251,221,111,252,230,199,119,110, 47, 42, + 97,201,120, 15, 1,200,130,226,136,200, 57,135, 8, 72,142,136, 68,121,179,169,231,171, 64,229,180, 59,249, 20, 23, 83,245, 35, +112, 93, 64,159,200,181, 68,240,181, 40, 72,218, 97, 83,236,243,162, 86,211, 13,221, 67, 26, 35,172,232, 3, 2, 18, 32, 26,150, +160, 54, 26, 54, 68,218,169, 67, 36, 50, 16,143,132,243,249,252,209,201,178, 9,146,120, 91,196, 27,215,159, 16,137, 34,169,232, + 18, 82, 81,184,178,244,207, 92,191, 54, 26, 14, 75,239,119, 70,253,199, 2,148, 49, 33,138,162, 72, 26,203, 5, 84, 20,153,229, +123,223,253,163,247, 63,252, 96,182,225, 38,170,136, 1, 61,123, 31,144,232, 46,251,152,188,170, 10,235,201,233,106,213,224,149, +167, 94,124,250,165,159, 40, 6,123, 64, 29,116, 30, 0,182, 19,125,251, 68, 0,108, 56,202, 29, 95,114,159,202,236, 69, 27, 25, + 72, 37, 40,145, 96,246,108, 16, 16, 93,138, 17, 16,218,168, 66,214,210,210, 41, 36,164,229,106,113,182, 14,243,213,198,178, 6, + 16,246,119,119,203,162,100, 97,251,177,228, 8, 1, 10,231, 58,101,241,252,205,235,101, 89, 78, 6,157,110,185,101,162, 73, 5, +243,120,169,138, 96,152, 13, 81, 29,209,131,251,119, 94,249,222,119,102,171,170, 10,146, 30,188,253,120,178, 17, 34,209,181,162, +138, 8, 49,198,227,211,121,209,155,188,248,217,159,186,246,212,103, 92,103,128,232, 0, 16, 68,129, 82, 76, 53, 5, 55, 13, 97, +154,138, 29,182, 4, 0,160, 98, 14, 25,180,163, 90, 14, 48, 16, 81,154, 73, 91,134,198,114,200,190, 77, 26,233, 18, 96, 65, 4, + 36, 85, 57, 91, 86,103,203,106, 83,109, 66, 12, 10, 64, 8,189,110, 23, 84, 89, 88, 84,237, 75,139,194, 59, 79,157,162,120,225, +230,245, 78,183,115,176, 51, 56, 39,141, 33, 96, 70,247,249,177, 42, 40, 53,161,249,214, 31,126,227,232,228,116, 85,177, 61, 88, +103, 47,133,128,192,164,118,200,209,193,166, 14,103,139,245, 96,122,241,233, 23,190,212, 29,236, 8,230,153,194, 10,172,102,106, + 84,209, 10,112, 62,104,231, 70, 48, 1, 61,231,171,104, 99, 9, 9,186, 42, 25,242, 68, 74, 99,139, 53, 19, 76,104,150, 0, 24, + 17,136, 64, 4,128, 0, 25, 21,136, 32,132,250,116,190,120,112,124, 54,238,193,199,119,238,188,254,198,155,235,170,218,153,238, +150,101,167,170,107,145, 8,228, 16,144, 8, 11,239,188,119,189,110,241,228,213, 75,111,190,255,225,238,176,115,178,172, 83, 23, +203, 61, 69,236,172, 41,128, 3,122,231,173,239,189,253,222, 59,235, 70, 76,195, 68, 74,133, 16,115,102, 3,128,138, 16, 98, 8, + 97,190,170,250,227,131,231, 62,253,149,162, 55, 81, 36, 4, 32, 84,117,100,143,168,213, 21,176, 29, 47,242, 56,140,128,134,162, + 21,100, 11,145, 21, 53,227,202,156,110,152, 38,103,181, 79,167,176,137,161, 53,235,172, 9, 94, 43, 18,102,214, 6, 84,228,244, +228,240,149, 31,156,125,251,247,238,220,250,228,147,186,105, 16,113,119,103,122,227,198,211, 69,225, 66, 35,145,163, 35, 23, 57, + 58,242,142,160,240,126, 50, 26, 60,113,229, 82, 8,119, 23, 85, 19,162,146, 81,202,170, 10,138,204, 42, 34, 8, 48,159, 29,127, +231,187,223,174,234,176,174, 35,171,154,104,151, 11,159,133, 7, 65, 0, 0, 69,120,179,105, 38,187, 23,159,255,204, 87,202,193, + 14, 32, 97,126,234, 9, 63,232,214, 44,145,206,151, 90, 45, 78, 84,127,166,137,180,157,114,236, 11, 19,243, 14,231, 40,183,182, +106, 19,110, 11, 26,108,203, 78, 26,204,206,215, 60,132,179,211,135, 77, 61,103,137,227,241,168, 40, 60,128, 30,159,156,190,247, +222,187, 32,210,233,116, 16,144,133,173, 24, 19,146, 47, 60, 33,236, 78, 70, 87, 46,236, 14,187, 37, 0, 16, 11, 88,241,117,142, + 76,204, 9,129,223,126,231,245, 7, 15, 31, 44,106,177, 49,213, 89,197, 3, 32, 68,231,236,152,171,253,190, 90, 87, 69,111,114, +227,217,207,119,250, 83,176, 46,123,174, 61,195,246,253,106, 30, 51,108,114,149, 31, 98, 59,172, 8,230, 65, 43, 59, 79,172,222, + 65, 59,151,230,225, 52, 75,102, 89,148, 75,177,200, 31,183, 51, 7, 0,128,196, 64, 0, 23,246,247,171,122,227,189,183,220, 63, +155,205,222,122,251, 45,142, 77,175,215, 67, 36,208,164, 77,122, 34,239,136,136, 38,147,225,213,139, 83, 71, 72,153,171,227, 24, + 25,146,152, 55,123,247,157, 55, 23,171,122, 83,179,149, 24,218, 2,142,246,116, 41,168,174, 55,155,168,197,213, 39, 95,232, 12, +246,144, 60, 42,130,149,193,148, 65,210,118, 37, 61, 31, 39,115, 85,101,181, 72, 68, 64,243, 63,170, 91, 60,152,248, 0, 36,200, + 47,193, 10, 78,206, 20, 74,163, 88, 74,151, 54, 78,143,177, 68, 10,136, 16, 66, 64, 87, 76, 70,163,205,122, 9, 32,246,101,171, +245,250,181, 55,222,168, 54,235, 78, 89, 58, 71,128, 88,118, 74, 66,240,206,121,194,194,185, 75,251,211,189,201,128, 68, 88, 85, +140,132,110, 66, 0,132,143, 62,124,239,254,131,251,139, 42,170, 10, 32, 58,139, 13,128,115,206, 25,103,157, 11,243,170,138,151, +175,221,188,112,233, 41, 36,223,102, 76,139, 4,242, 75,180,122, 43,128, 2, 91, 38, 46, 27,245,180, 21, 28, 33,171, 94, 54, 40, +111, 99,164, 91,105, 51,255,249, 54, 85, 8,206,253, 9,230, 67,217,178,226,144, 80,129, 46, 87,155,203,151,175, 93,189,114,181, +174,106, 81,182,191,221, 52,245, 91,239,188,181, 92,206,187,221,174, 61,254,162, 44,157,119, 68,228, 29,129,226,205,107,123,148, +135, 82, 8, 49, 40,226,114,181,124,255,189, 55, 79, 23,171, 16,197,140,194,228, 8, 17, 28,145, 35, 66, 75, 18, 85, 85,157,175, +235,201,238,149,235, 55, 63, 67,190, 67,153,126,222,106, 35,144,186, 49, 32, 42, 40,182, 52,143, 49,134, 40,106,172, 62, 40,160, + 90,182,165,225,194,206, 26, 88, 37,126,252, 36,217, 55, 76,228, 3,225, 99,132, 71, 27, 83,204,173, 47,149, 63, 34, 35,238,181, +110,194,165,203, 87, 94,120,254,185,170,174, 57, 70, 80, 97,142,139,229,226,141, 55,223,184,127,255, 30,106,162,206, 13,153,123, +231,136,192,123, 67,151, 68, 65, 25, 16, 8,240,147,143,222,189,123,255, 94, 21, 68,218,218,156, 74,143, 81,167, 42,160, 72,184, + 88,109,168,232,223,120,238,101,215, 29,166, 44,223, 82, 15, 70,125,146,230,198,101,129,201,186,177, 40,136,242, 86,144, 77,111, + 3, 83, 85, 23, 52, 54, 17, 21, 91,247,139,106,134, 60,233, 41, 24, 32,180, 63, 49,204,152, 19, 24,183,124, 49, 24, 14,232,120, + 34, 66,211, 55,235, 42, 76,199,187,159,123,233, 37, 5,105,154, 42,114,108, 98, 88,174, 22, 31,220,122,255,193,195,251,161,169, + 69, 4, 53,149, 90,231, 28, 1,146,130,134, 24, 81, 1, 17,103,243,179,219,183, 63, 58,157,205,155, 8,162,169, 95, 16,128, 79, +199, 61,113, 45,155,170, 94,172,195,229, 79, 61, 51,154, 94, 74, 13, 85,206, 29, 42, 4,123,159,208,146,100,118,156, 12,167,139, +182,230,168, 45,107,159,186,214, 22, 25,106,202,132,124,220, 0, 64,145,218,115,148, 19, 42,231,145,185,107,218, 47,215, 86,129, + 43, 28,141,122,142,208,100, 38, 21,213,117, 85,119,123,195,231,158,121,166,219,233,198, 24, 29, 0,139,172, 55,155,187,247,239, +158,156, 28, 54,205,198,202,158,185, 73,144,144, 68, 1, 8,152,185, 14,225,225,195,187,247,239,223, 91, 53, 34, 34,154,136, 40, +176,137, 46,177,130,128,194,114,114,182, 30, 78, 15, 46, 63,241, 28,144,183, 34, 35,231,102,204,115,125, 41,199, 67,212,212,197, +196,182,110, 57, 23,221,150,239, 68, 45,131, 97,115, 72,180,180,133,202, 10, 77,150,120,182,236, 94,155, 81,127,138,162,174,170, +128, 56,234, 22,147,190, 7, 5, 81,105, 31, 78,221, 52,131,222,240,169, 39,175,239, 76,198,166, 42,199, 24, 23,203,229,221,251, + 15,142,143,143, 29, 1, 2, 58, 66,231,200, 33,250,200,204,204, 10,202, 49, 62,186,127,247,248,228,180, 9,233, 29, 16,168, 67, +114,137,221, 72, 63,114,185,170, 3,184,235, 55, 62, 93,118, 71,204, 2, 96,102,141,220,162, 50,182,177,174,174,208,198, 70, 90, +193, 48, 71, 49, 79,118,144, 38, 84,216, 10, 21, 63,252,150, 17, 77,219, 7,204,198,243, 45,173,215, 14, 34, 8, 38,181,230, 7, +132,221, 14, 29, 76,138,194, 17, 11,139, 50,108,231, 23,168, 26, 25, 12, 70, 87, 46, 95, 22,145,147,179, 51, 80, 97,209,245,102, + 85, 55, 53,130,150,157, 30,128, 85, 34, 36,243,153,170,232,106,181,120,240,224,238,124, 93,219, 3, 37, 85, 27,153,157, 51,201, + 9, 0,129,163,156, 45, 55, 7, 87,110, 78, 15,158,136, 44, 34,202, 54,200,137,136,114,238,219,233, 48,217, 99,147, 86, 78,133, + 45,239,164, 45, 25,151, 16, 16,180,172, 56,180,157, 27,243, 95,196, 76,205, 3, 2, 40,181,125, 92,173,139,164, 26,165, 0,128, + 98, 18,177,130,150,142, 46, 78,186,227,126,161, 41,119, 44,147,173, 28,138,136,108,170,166,215, 27, 28, 92, 60, 48,235,132, 57, + 71,155,208,220,127,244,104,181, 90, 58, 76,250, 21,153,227, 18,144,238,223,253,228,228,244,100,211, 8,156, 47,204,212, 22, 61, + 69,192,179,229, 26,252,224,218, 83, 47, 40,146,228,159,165,156,206, 15, 75,155, 44,108,137,147, 95,151,108, 43, 67,254, 23,158, + 3,216,208,146,201,122,142, 16,210,164,202, 65,102,207, 18,174,209,243, 98,137,180, 85, 39,155, 37, 68, 85, 61,193,254,164,220, +159,116, 8,204,133, 34, 54, 49,137,176,136,249,105, 69, 68,154, 16,135,253,225,179, 55,111,118,202, 78,182,240,104, 8,225,225, +225,163,249, 98, 1, 18, 8,109,246, 35,136,161, 62,122,112,123, 85, 5, 77, 16, 30,208, 33,102, 25,197,134,167,117, 21,142,103, +155,253, 75,215,203,254, 36,154,143, 87, 88,148, 89,133,133,217,204, 82, 49,114, 50, 51,216,107, 74, 98, 23,106,139,143,255, 84, +211, 63, 0, 8,228,214,127, 78,220, 85, 80, 65, 64, 76,250,175,158,195,232,249, 27,166,239,189, 85,221, 8, 97,103,212,185,188, +211, 43, 29, 90,233, 17,102, 17,142,230,124, 99, 97, 17, 78,175,152,235, 58,118,187,253,103,159,185, 57,232,247, 9, 49,187,121, +100, 54,159,113, 12,189, 14,145, 67, 71, 68, 71,143, 30,156, 45, 22,155,134,205, 33,133, 68,118,190,146, 89, 30, 80, 85, 79,102, + 75,245,189,253,203, 55, 84,192,126,100, 50, 32,112,122, 34, 42, 44,233, 92, 73,155, 63,146,243, 63, 77,168,143,161, 72, 61,247, +111,204,191,101, 63, 70, 43,252,139,158,155, 90,245,220, 25,109, 37,114, 67,230, 2, 42, 8,186, 51, 44,174,237, 14,122,165, 75, + 73,156, 82, 72,149, 37, 55,208, 54,251, 69, 65,234, 16,189, 47,175, 93,185, 82,148,133, 21, 52,123, 3,171,205, 38, 52, 53,173, +215,107, 66,124,244,232,193, 39,247, 30,174,234, 16, 35, 3,180,240, 62, 81,128,136, 80,213,113,190,110,118, 15, 62,213, 31,237, +112,202, 84,145,200, 34, 81,211, 83,145,200,194,194,105,250, 21,205,239, 44, 87,210, 54, 3,126, 40, 68,104,178,129, 34,230,118, +118,254,244,181, 26, 90, 30,199,180, 21,128, 65, 19,181,151,148, 89, 17,145,241,176,247,196,197,201,120,216, 69, 34, 48, 79,186, +136,136,176, 50,171,178, 50,107, 84, 21, 81,182,210,100,131, 78,100,118, 69,121,229,210,165,178,240,109,150,199, 24,151,235,141, +171,170,249, 27,239,188,247,234,155,111, 30,157,205,153, 53,187,235,208, 81,242,199,217,139, 62, 91,172,151, 1,158,121,225,203, +157,238, 32,137,161, 34, 2, 57, 87,204,154,170,201, 44,148,251,217, 99,188,114,219,228, 17,160,253,164, 10,180,189,199,254, 14, +226, 57, 0,144,254, 76, 16,219,113, 85,179, 43, 42,185,213, 69,185,197, 90, 59,211,233,151, 95,122,230, 11, 47,222,232,117, 59, +243,197,122,211, 52, 77, 29,146,165,180, 69, 97,230,161,148,172,116,131, 40, 40,139,198,192,162,226,157,159, 47, 87,185,105,171, + 2,248,143, 62,186,245,250, 91,111,151,158, 58,101, 57,238,119,198,195,158,115, 70,232,144, 34,130, 10, 0,178,200, 98, 93,239, + 29, 60, 49, 28,237, 49, 51,104,130,112,105, 40, 79,125, 74,218, 78,189, 69, 35,109,254,180,188,252,182, 88,107,219,119, 53, 55, +184, 52,199,164,218,171,173,225,209,136,159,115, 25,245, 67,230, 72, 70,160,103,110, 62,247,179, 63,241,185, 23,159, 24, 21, 78, + 99,228,221,157,157,111,252,254,183,231,235,181, 71,195, 6,231,127, 4,234,150, 32,215,212, 90, 16, 68,128,156,247, 69, 55,134, +141,167, 20, 67,119,243,218,133,178,240,206, 57, 81,219, 4,208,174,243,100,253, 43,179,172,213, 38, 44, 42,121,242,185, 47,116, +186, 3, 59,216,121,176,218, 30,105,248,161, 42, 1,184,237,197,150, 54,169,149,107,219,229,181, 13, 43,232,185,221, 26, 60, 55, +195,234,227, 4,108, 59,224,178,213, 29, 91,239,240,190,120,249,229, 47,252,244,151, 62,243,242,205, 93, 2,102, 17, 79,238, 96, +111,103,103, 58,125,229,181, 55,207,230,115,181,249, 14, 19, 74,205,179,158, 81, 81,162,106, 37, 53,181, 26, 80, 88,174, 27, 36, +112,164, 0,224,110, 94,187,128,105,190,113, 10, 26, 3, 40,112,225, 8, 50, 65, 6, 0,243,229,166, 51,218,187,112,229,102,130, +168, 34,208,186, 55,173,103,229, 14,159, 94,128,149, 31,132,140, 74,210,251,222, 10, 70,143,141,250, 45, 66,122,220,247,145,186, +126,251, 5,250,195,104, 84, 69, 65,119,119,246,191,242,229,175,252,228, 75, 55, 94,120, 98,236,137, 61,145, 3,231,157,115,142, + 46, 31,236,221,188,254,196, 31,127,239,213,163,211, 83, 97,241,142,172,244, 43, 0,110,171,117, 66,252,204,202,137,167, 22, 81, +174, 54,209, 17, 16,161,187,118, 48, 53,193, 0, 49, 53,144,192,162, 34, 14, 83, 27,139, 33,174,170,184,123,233, 70,111,184,155, + 72, 47,200,137, 41, 86,119,210,252,189, 53,196,101,207,133,197, 4, 91, 35, 92,203,108,108, 81,245,150,157,182,118,221, 82,214, +104,159,183,211,161, 91,130,205,190,148, 37,146,163,167,111, 62,243,179, 95,251,210, 87, 95,184,122,237, 66,215,161, 24,215,208, + 50,179,160,184, 55,157,124,234,242,165,219,247,238,223,123,240,176,105, 66,225, 61, 57,196,109, 43,205, 22, 55,211,201, 68, 36, + 74,148,168, 10, 49, 4,102, 44, 28,120,116,190, 9,145, 80,188, 39,163,212, 89, 96,190, 86, 17,157, 18, 34, 64, 19,162,146, 31, +141,247, 84, 20,128,211, 97, 70,176, 9, 3,178, 55, 35,243, 51,106, 40, 10,204,190,169, 91,151,138,129, 57,220,106, 26,153,156, +199,124,154, 32,255, 46,134,189,116, 11,193, 83, 97,106, 31, 77,220,223,221,255,234, 23, 62,251,185,231,174, 95,154,118, 29, 70, + 51,245, 37, 71,177, 17, 23,154,252,109,215,174, 92,190,121,253,202,209,209,163,217,124,121,124,122,182,183, 51,237, 20,222,200, +218,182,155,180,182, 8,160, 52,129,250,210,111,214,117,100,244, 23, 47,236,110,214,155,117, 85,109,170,198, 17, 16, 57, 17,102, + 66,168, 21,136,118,134, 20, 34,247,250, 83, 87,116, 68,248,156,146,177,109, 38,237,243, 64, 36, 16, 52,239, 37, 2,129,181,159, + 92, 94,209,242,179,141, 4,110, 53,111,205,154, 88, 22,198, 18, 63,155,198,180,115,135, 1, 17,134,131,222, 75,207, 63,247,181, +207,191,240,228,149,105,137,218,212,213,150,181, 4,101,102,211, 88,205,201, 93, 55,245, 59, 31,188,127,114,122,178,183, 51,142, + 33,108,234,230,228,236,108,111, 58, 41,202, 2, 77,224, 63,103,225,202,112,196,100, 18,244, 30,234,168,126,111, 58,137,195, 97, +136,177,170, 67, 85,215, 33,132,186,169, 99,100, 22, 88, 85,193, 19, 21,222,239,236, 95,142, 12,201,118,171,186,173, 13,233,205, + 97, 70,183, 2, 64,170, 2, 64, 0, 2,232, 18, 99,145,109, 52,217,149,219,170,143,146, 42, 64,130, 76,219,153, 36,157,182, 92, +201,153, 89, 85,166,227,241,115, 55,159,250,202,103,159,191,113,237, 66,191, 68, 14,161,137,161,237, 3, 22, 90,231,140, 1,165, +245,102,115,235,147,143,127,240,198,235, 31,124,116, 75, 84, 71,131, 97,220,229, 71,135, 71, 77,148,163,211,179,157,201,184,219, +241,231,220,239, 89, 95,104,203, 1,161,115,142, 37,250,201,104,104,242,164, 2,196,200, 85, 19, 86,155,106,179,217, 84,213,198, +182,184,202, 78,191,211, 29,137,176,125,117, 58, 13,231,138, 74, 82,102, 17,173, 46,171, 38,119, 90,170,215,152,181,177, 45,175, +209,110, 49,164,179,149, 89,145, 54, 60,210, 54, 97, 27, 89, 70,163,225,231, 94,120,254,243, 47,222,120,242,202,126,191, 67,220, + 84, 77,197,230,235,104,201, 19,123, 23, 70, 31,190,253,193,251,255,244, 15,254,224,228,236, 84, 84,201,249,166,106,152,155,126, +191, 55, 26, 15,103,243,133,178,158,158,158, 77, 39,163,178, 83,166, 12, 18,209,196,125, 66,162,105, 1,136,200, 59,240,189,110, +199, 57, 95,250,194, 57, 2, 34, 21,169, 3,111,170, 42, 52,141,115, 84,173, 22,141,150, 12,148,156,226,153,248,200, 50, 84,110, +191, 8, 10, 98, 49, 50, 35, 88, 98,182, 84, 53, 57,105, 52, 89,140,207,131,152,243, 92, 90, 42,206,169,206,216,134, 1, 17,237, +142,198, 47, 60,247,244, 87, 62,243,252,245, 75,147,110, 65, 28,234,102, 19,146,200,137,100,101, 77,179, 19,174,110,234,135, 71, +135,223,249,254,247,223,253,240, 3, 68,138, 44, 57,133, 85, 20, 28, 97,191,223, 19,142,203,213, 58, 4, 57, 60, 57,155,140, 70, +189,110,153, 43,169, 36,101,101,219,102,136,200,123,239,124, 81, 20,101, 89,122,239,189,115, 68,168, 2,145,135,129, 99,225, 60, +208,149, 59, 15,231,203,192,232, 57, 65, 27,139,120,203,224, 65,106,126,152,172, 25,106,123, 97,170, 0,192, 86,185,165,181, 21, + 38,240, 43,217,182, 96, 15,143, 85, 36,103,146,253,226,126,127,112,245,210,193,179, 79,125,234,165,231,158,186,186, 63, 46, 29, +112,108,234, 77,180,124,105, 55,148,236, 95, 68,168,170, 31,221,190,253,221, 87,127,240,209,237,219, 77,104, 0, 72, 53,198,200, + 42,172, 0,102,130, 12, 77, 84,133,178,211, 25, 33, 45,151,203,186,110,206,102,179, 38,244, 6,189,142, 35, 58,223, 80, 91, 27, +155,115,206,147,115,222, 57,135,228,189,243,206,118, 85,200,164, 34,239,105,185,105, 66, 76,104,122,235,164, 3, 0,101,104,137, +180,246, 37, 39, 1,192,170, 95, 18, 25,182, 88, 89,183,240, 79,179, 81, 51,129,255, 84, 67, 4, 65, 15, 46,236,189,248,244,141, +231,111, 94,251,212,197,221,241,168, 71,192, 92,215, 77,224, 31, 10, 77,171, 74, 34,226,124,185,252,254,235,175,191,250,198, 91, +179,229, 92, 68, 89,162,216, 80, 8,140,130,198, 80,165,164, 20, 16,129,210,187,209,104, 4,184,168,170,122,185, 90,133,166, 25, + 12,250,222,187,180,202,133,217,183,143, 2,136,190,244,190, 40,138,162, 40,188, 43,188, 39,239,189, 39,219, 72,117,206,185,158, +151, 72,166, 0, 0, 16,165, 73, 68, 65, 84,213, 38, 68, 85, 17, 32,180,113,241,220,242, 28,170,249,166,140,207, 18, 85, 52,127, +154,149,106,155,119,240,156, 7, 97,187, 77,150,200, 34,201,151, 15,148,158,134,253,254,213, 75,123, 95,252,244,243, 55,158,184, + 60, 25,117,137, 72, 56,114,181,110,132, 91,185, 71,219,202, 37, 10, 0,204,188,174,214, 31,220,250,248,143,190,255,202,201,233, +220,134,229,200, 44,108,251,174,166,165,107, 59,234, 8, 72,238,171, 84,120, 26, 13,134,136,180, 92, 46,171,166,142,204,131, 65, +183,116,222,176, 4, 38,211, 62, 34,160,159, 76,166,133,109,131, 57,231, 8, 41,101,147,119,142, 20, 40,176, 4,123, 8, 40, 9, + 6,106,134,163, 98,246, 9,200,200,140, 82,109,202,114,130,154, 89, 3,207, 19,101, 70,209, 26, 10,103, 2,217,157, 12,111, 92, +187,244,220,141,107, 79, 92, 61, 56,184,176, 79, 30, 32,114,108,234, 24, 66, 46,156,233, 88, 99,162,111, 69, 84,154,166, 57, 58, + 57,190,117,251,206,237,123,247,110,223,189,107, 43,251, 45,213,147, 64, 77,122, 90,168, 32,182, 11, 41, 0, 42,140, 42,138,137, +234,239,245,122,132, 48,155,175, 66,140,203,197,186,219, 45,189,247, 89,220, 4, 82, 66, 82, 63,157,238, 56, 34,114, 73, 69, 49, + 10,209,116, 76, 22, 89, 87,117,140,162, 36, 40, 64,136, 98, 2, 79, 59, 75,129,152, 21, 14, 21, 8, 84, 17, 69,149,160, 45,220, +231,135,213,116, 22, 69, 68, 69,202,194, 93,189,122,241, 43,159,121,246,153,235, 23,167,147,161,239,148,168,194, 77, 21,214,193, + 22, 55,178,119, 21, 84, 85,152, 99,228,192,177,137,113,185, 92,221,121,112,255,214, 71, 31, 61, 60, 62,218, 84, 85,228, 24,109, + 95,154,163,173,197, 38, 14, 13, 16,148,179,113, 55,137, 6,168,102, 27, 20, 4, 16, 84, 17, 64,229,178, 83, 14, 6, 50,155, 45, +213,137, 86,224, 92,116,158,146, 88,137, 0,138,190, 44, 10,115,250,180,171, 39,136,102, 52, 65,102,222,212,129, 85, 65,192,172, +166,164, 98, 62, 74,204, 99,118,234, 34,132,121, 32, 5, 54,241, 89, 64,208, 12,153,201, 35,170,170,206,209,116, 60,186,241,196, +213, 47,190,116,243,230,213,253,110,215, 1,162,196, 24,151,115,137, 81,183,251, 4,160, 2, 81,184, 9, 77, 85, 55,155,170, 90, +111,214,143, 14, 15, 63,190,115,247,209,241,225,114,181, 50, 50,211,102,192, 40,204, 49,166, 81, 16,196,214,104,210,189, 36, 72, + 12, 2, 2, 34, 10, 32,137, 25, 22, 64,100, 2, 66,132, 40,132, 32,221,110,209, 52,101,211,132, 24,131,170, 99,110,117, 1, 4, +167, 62,109,159,152,235, 11, 19,242,135,220,106, 91,203, 25, 33, 90,156, 80, 85, 73,200,172,255,154, 11, 83, 2,234,105,107, 75, + 50,209, 46, 25,248,216,138,229,167,159,189,241,242,179, 79, 92,191, 56,237,149, 40,194, 97, 83, 75,140,246,183,179, 13, 10, 69, +164,106,154,229,114,121, 54, 95,156,206,102,199,167, 39,199, 39, 39,167,179,179,197,106, 21, 99, 72, 83,183, 38, 26,147,141, 11, + 59, 55,118, 34, 42, 8, 42,136,113, 53,104,102,225,116, 52, 19, 34, 4, 54, 73, 73, 33,211, 87,253,126, 7, 17, 67,224,200, 33, +165, 65,110, 50, 94, 68,204,120,156,153,243,115,194, 93,218,116, 18, 37, 1, 48,229, 5,237,102, 32, 33, 32,164,243, 64,173, 53, + 27,108, 71, 44,149,214, 28,244,244,147,215,126,246, 43, 47, 63,125,109,175, 32,209,184,217,172,132,146,173, 7,144,176, 61,125, + 71,199, 39, 31,223,187,247,232,240,240,108,190, 88, 85,155,205,102, 93, 85, 85,176,219, 28,192,110,246, 96, 53,115, 88, 76,146, + 74,110,131,201,167, 0,146,132, 35, 67, 96, 98,127,153,165, 5,180, 9,242,183,241, 82,230, 40,190, 40,134, 3, 90,174, 43, 12, + 16, 66,216,106,186,136,158, 85, 29, 0,176, 10, 34,210,121,155, 73,166, 53, 68, 68,197,184, 15, 77, 46, 56, 32, 86,113, 66, 64, +233,248,144,102,237,217,146, 42, 45,212, 9, 96,167,240, 47,191,240,204, 95,251,234, 75,151,119,251,177,174, 56, 68, 1, 32, 68, + 51,123, 91, 92,234,166,249,228,238,253,119, 63,252,240,225,209,113, 85,175, 99,100,230, 24,154, 38,112,228, 92,116, 19,241,173, +194, 28,173, 7,202, 57,187,131,182, 32, 29,197,252, 87,132,160,154,181, 4, 81, 49, 25,174, 93,186, 72, 40, 86, 44, 79,204, 6, +219,237,148, 27,173, 1,124,140, 17, 24,148,128, 20,188,205, 66,212, 46, 81,226,227, 6,220, 68, 41,169, 40, 32, 41,146,130, 16, + 17, 9, 10, 9, 9, 10, 33,165, 83, 15,170, 9,212,106,203,140, 77, 71,195,159,251,137,207,127,249,165, 27,131, 18,234,205, 42, +117,122,209, 8, 54,107, 67,136,241,195, 79,110,191,253,254,135,143,142,143, 66, 8, 33, 52, 33, 6,102, 14, 33,164, 64, 36,243, +155, 88, 96,140,175,177,192,100,161,176,221,180,198,214,238,103,112, 63,154,124,145,165,204, 45,142, 7, 68, 73,116,191, 57,126, +152,217, 78,119, 89,250, 0, 0,160, 17, 80, 68, 20,213,139, 8, 32,130,160,105, 96,250,184, 64,110,170, 54, 67, 36, 34, 18,155, +211, 5, 69,145,156, 36, 15,149, 32, 56, 64,123, 24,138,173, 61, 6,116,119, 60,252, 91, 63,247,165,207,191,120,131,148,171,213, + 74, 85, 9, 33,154,229, 92, 69,145, 78,230,243, 87, 94,123,227,238,253, 7, 85, 83, 53, 77,211,132, 38, 70, 86,230,192,193, 78, + 69,203,137, 70, 97,230,216,170,182,219,133,129, 45, 67,135,121, 47, 19, 64,213, 54,242, 37, 45, 54,110, 49,124,139, 88, 69, 21, + 12, 17,112,218,216, 70, 68, 81, 33,197, 78, 89,136,136,247, 24,130,128,130, 23, 81, 36, 67,154,217,250,180,101,199, 5, 1,197, +150,125, 84,128,148, 4,193, 81, 36, 36, 1, 66,167,170,202,102,191, 53,143, 37, 42,171, 81,145, 59,227,193, 79,190,124,243,233, +107,251,205,122, 37,161, 49, 35, 22, 3,196, 24, 89,216,145,187,243,224,193,171,111,190,125, 54,155, 53,193, 54, 55, 66,150,214, + 82,135,202,116, 51,199, 92,137, 33,141,149,233, 29, 99,106,121, 8,173,163, 15,147,204, 99,223,234, 49, 3,146,205,209, 25,182, + 26,189,202,170,104, 80, 21,128, 0,109, 74, 18,150,210,251, 16, 99, 68, 20, 81, 47,170,168, 64, 10, 64, 34, 91,115, 77, 42,241, + 73, 36,210, 8,226, 84, 65,157, 35, 22, 84, 18, 18, 32, 32,177,205, 98,225,196, 52, 37, 82,124, 52, 40, 95,184,190, 63, 40,225, +155,223,254,227,170,170, 46,238,237,140,135,253,157,233,216,121, 31,154,112, 58, 95,220,189,255,224,240,228,100,179,217,212, 77, +101,137,195,182,244,154, 77,122, 73,238,203, 21,228,156,187, 81,211,146,121,182, 39,158, 95, 77, 79,154,147, 69,231,113,246,178, +221, 60,177, 80, 70,110,251, 90,235,130,204,243, 15, 58, 91, 35,143,142,154, 24,188,136,152,129,221, 44,169,231, 23,173, 85,149, + 16,193,180,101, 2, 34, 2,142, 74, 68,170, 36, 78, 84,192, 1, 2, 34, 19,162, 8, 37, 11, 83,175,244, 79, 92, 24, 13, 10,248, +248,238,189, 59,247,238,127,239,181,215,231,139,179, 43, 7, 23, 62,253,220,211,207,220,120,170,105,194,195,227, 19, 83, 22, 66, + 12, 33, 90,161,201,206,139, 76,145,217,166,148, 36, 87,158, 49,225,153,137,176,199,141, 0,128,172,220,234, 6,169,237,171, 72, +171, 32,156, 59, 91,152,104, 57, 81,212,104,144, 27, 36, 89,187,140, 0, 76, 70,113,178,251, 83, 68,217, 59,116, 68, 94,132, 17, + 72, 81, 5,145, 30, 91,166, 51,175, 20,168, 70, 97,187,107, 33,109, 29,130,170,146, 18, 58, 80, 69,103,203, 90, 8,130,138,232, +157, 59,152,116,247,198,157,200, 97,189, 94, 45, 55,107, 34,220,108,170,247,110,221,186,115,239,238,239,252,222, 31,244,251,189, + 39, 63,245,169,157,157, 73,167,236, 24,250,223, 58, 97, 13, 64,164, 3,149, 81, 49,180,117, 55, 23, 0, 74,181, 39,165, 64,146, +116,165,229,220, 91, 25, 73, 91,238,106,235,188, 1, 97,181,107,249,172,117,183, 70, 1,132,164,201,165,171, 34, 20, 16,160, 83, +160, 55,143, 62,153,204,131,136,143,153,118,149,192, 54, 14, 89, 1, 5,217,129,221,219, 66,182, 33, 10,228,136, 65,137,129, 8, +129, 16,116,212,239, 94,217, 27,150,158,236, 36,247,202, 98,111,103,167,110,170,217,236,172,106, 26,144,122,185, 94,205, 23,203, +107, 87, 46, 93,190,120,177,219,235,166,185, 53, 87,147,150,193, 69, 68,231, 72,240, 60,177, 38, 91,135, 95, 66,126, 41,154, 86, +183, 84, 88, 91, 86, 55,147, 85,104,149,197,156, 56,220,222, 49,194,231,242, 74,207,217,134, 45,130, 98,215, 23,169, 48, 34,185, +191,245,215,254,234,246, 22, 23, 67, 22,154, 87,147, 5, 54, 85,117,239,240,172, 10,143, 57,158,243, 74, 98,114,129, 97,134,134, +165,119,215, 47,142, 15,118, 7,201,182, 76,128, 0, 33, 4, 5, 17,145,208, 68,219, 44, 11, 33,206,230,243,197,114,229, 8,243, +221, 37, 54, 9,170,137, 83, 96,196,127, 91,130,177,181,163,109,213, 66, 43, 33,173, 79,195,138, 78,166,245, 83,233, 49,216,159, + 40, 93, 22,101,213,243, 78,227, 22,218, 42,230,123, 52,242, 5, 26,109,170,168,248, 24, 35, 56,167,128, 36, 32, 6,135,218,149, + 89,181,165, 42, 85, 97, 1, 82,178, 60, 37, 85, 80,167,206,168, 91, 2, 48, 7, 53,105,191,235,247, 70,221, 84, 49, 0, 28,185, + 97,191,191, 59, 29,213,245, 38, 6,174,155, 48,155, 55,168,201, 29,112, 58,155,213, 77,115,241,194,254,254,222, 78,175,219,119, +132, 42, 91,106, 24, 20,137, 64, 5, 36,205, 64,152, 24,108,209, 86,129,203,228, 90,178,255,192, 57, 75,127,162,162, 36,159, 44, + 78,146,136,110,151, 93, 33,149,251,188,129,145,132, 56,123, 30,108,118, 13, 96, 85, 31,153, 85,213, 41, 18, 18, 26,246, 79,171, + 0, 22, 72, 69, 0,150,136,224, 73, 17, 72,149,212, 73, 58,182,100,127,201,129, 10,120,132, 73,191,236,118,252, 22,113, 0,122, +239,135,131,193,116, 60, 78,151,148, 49,159,205,102, 0,226,201,145, 66,181,169,238, 63,124, 52, 95, 44,167,147,241,100, 60, 44, +203, 82,207,175, 59,230,214,181,245,185,234,150, 25, 48, 66,236,252, 50, 96,170, 89,152, 27,141,108,239,137,107, 63,108, 13,104, +105,139, 60, 91, 63, 91, 23, 23, 36, 59, 59, 64,150, 16,124, 72,144,193,145, 83,218,174, 88,167, 51, 73, 72,142,144, 69, 73, 25, +136, 64,137, 84,196, 89, 73, 6, 5, 5, 2,100, 85,212,178,112,163, 65, 73, 68,137,181,151,228,128, 42,203,114, 48,232, 87,117, +197, 34, 14,177,240,197,201,217, 89, 29,106, 34, 50, 13, 59,196, 88, 85,245, 98,185,220,153, 76,198,163, 1,218, 54,106,230, 99, +211,131, 70,243,190, 38,195,175,164,103,189, 69,140,173, 89,130, 82,227,207, 89,198, 91,230,251, 28,229,166,231,214,139,210,138, + 74, 27, 30, 75, 10, 84, 49,157,202, 51, 51, 16, 1, 40, 9, 58,243, 20, 35, 32, 80,246, 97, 67,233,201, 86,136, 21, 4, 8, 84, + 72,129,129, 40,213,111, 16, 66, 34,148,194,209,160, 83,164,113, 72,160,165, 98,189, 47, 6,189,126, 61,168,155, 38,196,126,216, +211,177,247,110,182, 88,172, 55, 27,187,156,200, 59, 39, 44, 33,132,170,105, 54,117, 53, 25, 14,124,225,179,144,111,175, 71, 25, + 4, 34,146,195,220,193, 53,235, 15,153,154, 72,173, 20,219, 3, 8, 57, 58,143,221,172,185,157, 57,208, 12, 87,218,114, 27,219, + 41, 9,192, 74, 33, 0,160,250,116,181,136,154,227, 85, 40,237, 90, 11,106,178,214, 22,133, 19, 21, 80, 34, 0, 6, 33, 2, 84, +226,116,219,148,146,217, 0,200,117, 10,234,148,190,245,176,182,207,159, 16,139,178, 24, 14,134, 33,196, 24, 66, 44,227,168,223, +117, 4,221,178, 88,215, 85, 93, 55, 77,140, 70, 6, 6,230,186, 14,203,229,102, 50, 25, 78,134, 3,231,201,142,191, 71, 7,136, +224, 84,132, 20, 37, 13,238,182, 38,212,198, 8,225,188,156,156,101, 36,105,243,203,238, 63, 75,165,138, 20, 24,179,143,182,109, + 80, 8,237, 56,171,105,155,157, 0,188,180, 59, 37,105, 81,140, 76, 54, 37, 68, 96, 0, 0,239, 93,162,116,149,200, 54,200, 1, +137, 32,155, 88,211,162, 84,183,227, 11,243, 67,156, 99,230,243,149, 7,212,233,148,227,241, 48,114,140, 9,170,128,119,174, 83, + 20, 43, 95,173, 55, 85,211, 52, 28, 27, 95, 8, 51, 55, 77,179, 92,175,231,195,254,206,100,210,235,149, 8, 26, 57, 66,186, 61, + 69, 91, 79, 98,222, 88, 0, 72,251,122,182, 43,223,230,142,232, 57,123,141,149, 47,201, 78, 18,100, 84,201,148, 16,108, 73,144, + 12,107,210, 13,131, 86,251,188,205, 19,108,201,102, 67, 39,217, 99, 65,163,124, 58,222, 35,164,251,201,140,125, 22, 16, 80, 27, + 52,136,145, 69,137,156,235, 21, 5, 18,164,135,214, 10, 21,185,233, 32, 82, 81,148,163,225, 48,166, 91,181, 4,146, 57,194, 57, +231,214, 27,170,154, 38,132, 32, 34,196, 92, 55,205, 98,181,186,123,255,112, 58, 30, 94,185,180,223,239,117,243, 77, 14,208,218, +181,179,213, 21,133,132,192,229,169, 65,193, 48, 81, 59,117,181, 87, 13,102, 5,193,116,123,160,115, 90,106,206, 30, 68,108,103, +189, 68,137, 40,250, 45, 91,156, 82, 87, 89,208, 17, 0, 40, 10, 42, 81,217,241, 68,164, 81,237, 62, 50,180, 73,140, 18, 33, 71, +152,210,190, 83, 58, 56,223,108,181,181,184,165, 95, 8, 88, 22,197,168,223, 87, 22, 64, 34,221, 4, 80, 66, 37,215, 45, 28, 20, + 27, 87,213,117, 8, 77, 20, 99,116, 49, 70,126,116,116,122, 58, 95, 94,188,176,123,113,127, 90, 22, 37, 36, 77, 24,193,185,244, +152, 17, 32, 2, 3, 27,115, 40, 42,102,240, 1, 60,151, 59, 9,216,100, 43,146,213, 94,187, 86, 45, 15, 14, 89,128, 84, 99,170, +183,200, 17,213, 99,186,132, 13,208, 80, 6, 2, 81,226,250,204, 30,209, 45, 59,101,225, 54,117, 0, 17, 33, 68, 65, 64, 37, 16, + 86, 34, 66, 69, 35,218,168, 44, 40,111, 58,109, 85, 83,201,179, 99,146, 28, 0,188, 43, 6,253, 65,250, 97,154,252,252,132,228, +188, 47,189,219,212, 84, 53,129, 89, 16,212, 19, 70,213,166,105,238,220,125,120,122, 54,191,122,249,194,116, 52,116,132,228, 60, +144,237, 78,137, 68, 17, 20, 36,148,104, 70,100,109,133,166,188,234,130, 34,130,130, 66,146, 47, 50,210,243,152, 55, 91,225, 48, +185,185, 18,179,142,104,131, 7, 98,186, 79, 26, 5,212,105,242,100,107,187, 1, 4,170,216,235,150,131,110, 57, 91,134, 52,141, + 1,176, 93,226, 70, 2,233,146, 1,114, 14, 11, 71,153, 97,200,138,233,185, 8,113,154, 8,172,202, 97,183,236,240,128, 5, 84, +171, 13, 40, 20, 5, 56,236,120, 36,239,169, 40,154, 77, 85, 55, 49, 34,131,163,180,215,184,169,234, 91,159,220, 59,216,223,189, +176, 59,233,118, 74, 2, 71,164, 42, 32, 36, 16,179, 97, 76, 4, 72,137, 73, 41,221,185, 7,237,204, 65,219,237,141,212,240,183, + 34, 67, 91, 54, 5, 84,242, 5, 68,146, 45,172,232,147,202,165,166, 16,163,160,221,113,165,153,214,149,210,251,157, 81,239,254, +241, 42,219,157, 16, 77,177, 16, 96, 51,225, 32,148,158,188, 67,179, 47,202, 54, 66,146, 39,201,116,143,116,180, 88,169, 32, 82, + 89,118,250,172,160, 90,105,165,141, 32, 33,148,158, 72,237,218,198,186,105,234, 38,132, 24, 85,129, 85,148,129,153,239, 61, 56, + 92, 46,215, 23,246,167,211,241,208,123,167,233, 70, 6, 72,218,169,105,224, 78,172,183,156,219,238, 76, 3, 84,158,240,179, 87, + 39,195,234,188,165,165,148,175,217, 49,178,192, 68, 12,159,177,125, 86, 5, 8, 5,157, 57,214,109, 9, 1,137,166,227,126, 89, +224,186, 86, 67,133,206,248, 94, 2, 4, 96, 69, 34, 45, 29, 34,130, 93, 96,166,219,246,149,102, 43, 21,149, 68, 49,100,171,187, + 42, 34, 22,133,239,105,207,212,154,134, 3, 41, 0,185, 78, 73,222, 81,167, 40, 67, 39,212, 77, 88,215, 85,213,196,100,139, 17, +153,205, 23,139,213,106,208,239, 29,236,239, 76,199, 3, 66, 50,147, 96,222, 23, 82, 66, 84, 7,105, 79, 56, 45,112,180,150,189, + 92,152, 90, 53,113,219,114,165,149, 44,204, 70,101, 53, 7, 17,253, 57,163,133,169, 2, 32, 32,230,176, 79, 89,136, 58, 26,244, + 70,189,114, 83, 87,102, 14,138,130,136, 72,108,115,170, 32, 18, 57, 84,149, 40, 81, 90, 47, 82,114,145, 39,151,112, 76,150,119, + 43, 70,246,161, 0, 18, 57,234,116,186,170,160,149,134,168,130,138,170,206, 57, 34,245, 5, 21,133, 47, 59,126,189,105, 54, 85, + 29, 56,253, 7, 5, 36,242,108,190, 90, 44,214,163,209,224,194,238,104,208,233,166, 94, 96, 34,138, 49,120,102, 18,182,228, 17, + 77,172,106,203,153,217,118,190,245,197,212,157, 41,183, 71, 56,191,198, 7, 8, 94,183,130, 26,160, 2,181,215, 58, 17,129, 0, + 16,144, 72,183, 44,118,198,189,195,179, 74,210,162, 91, 54,196,153, 53, 51,203,151, 12,231,230,159, 20, 31,219,218, 72,106,150, + 93, 10, 44, 45, 75, 33,138,128, 68, 84, 20, 5,100, 27,149,180, 67, 19,162,115,212,193,130, 16, 11, 79,235, 77, 93, 55, 33,138, +182,166,189,217,108, 62, 95,172, 6,189,206,116, 52,232,117, 93,186,167, 96, 91,121, 64, 32,211,139,146,111, 6, 75,109, 13, 91, +247, 81,126, 3, 89, 56, 34,108,123,159, 29, 51,223,132,144, 61,147, 10, 0,146,168,230,188,232,167,168, 68,136,176, 59, 30,148, +229,217,122,147, 38, 21,204,214, 94, 69,171, 73,204,202, 42,152,140, 44,105, 93, 35, 45,178,180, 84, 95,203,135,110, 57, 10, 51, +117, 16, 58,239, 59,170, 0,208, 64, 45,145, 53,111,141, 33,162,119,142, 58,232,136, 10,239,214,117, 19, 35, 39,149, 5, 80, 68, +230,171,205,186,218, 76,134,131,241,160, 99, 23,184,217, 45,135,246, 92, 98,140,178, 93,122,197,180, 26,154,111, 8,201, 55,121, +231,141,189, 45, 26,202,252, 49,170,175,155,166, 5, 83,182,141, 40, 14, 29, 57, 99,209, 0, 72, 20, 28,194,100,212,155,244, 59, +235,205, 90, 5,243,253,118,173, 8,162,145, 69, 34, 43, 98,123,193,171,230, 45, 58, 57, 15,135,140, 53, 78,240,145, 83,134,137, +128, 8, 0,146,163,162,112,170, 37,104, 19, 99, 20,144,150, 6, 2, 4,239,169,171,158, 8, 54, 85,186, 0,223, 84,118, 80,136, + 17,142,103,203,245,166, 30, 13, 58,221,210, 59, 71,166,136, 69,142, 44,146,198, 57, 0, 32,115,123,156,187, 6,156, 32,223, 84, +144, 45, 24, 9,128,102,230, 27,209,125,233,229, 23,146, 83,223,238,210,148,173, 28, 0,237,242,132,130,119, 20, 66, 56,154,173, + 34, 75,134, 87, 6,251, 5, 1,166,163,238,254,164,111,216,134, 69, 52, 49,124,146, 9,188,214,103,203,109,107, 19, 86,201,174, +228,156, 74,249, 78, 6,108, 23,207, 31,139,112,123,143,155,141, 67,152, 61,108, 10,160,138, 33,114, 19, 34, 0, 18,161,154,217, +197,240,117,118,232,192,118,155, 38, 45,163,160,182,123,140,152, 87,168, 83,245, 33, 77, 30, 33,247,185,231,159,177, 87,202, 38, +184, 36, 57, 36,187, 1, 32,253,151, 67, 0,176,112,116,182, 88, 47, 54,141, 42, 60,118,193,159,234,176, 87,236, 79,250,105, 12, + 78,215,143, 51, 39,202,207, 8,245,237,209,226,150, 11,212,148, 70,146,229,207,124, 7, 68,234,169, 9, 28,199,196,232,216,237, +248,198,246,184,124, 61, 78,126, 79,182,210, 39,117, 19,171, 38, 42,128, 67, 32,135,137, 24, 58,199,111,152,216,151,210, 37, 25, + 54, 48,211,221,237,182,121,187,193,135,255, 47,141, 49,219,167,190,145,191,220, 0, 0, 0, 0, 73, 69, 78, 68,174, 66, 96,130, + 0}; + diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 12a54658f90..8d771f0dc58 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -74,23 +74,23 @@ /* flags for sflag */ typedef enum eDrawStrokeFlags { - GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */ - GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */ - GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ - GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */ - GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ - GP_DRAWDATA_NO_XRAY = (1<<5), /* don't draw xray in 3D view (which is default) */ + GP_DRAWDATA_NOSTATUS = (1 << 0), /* don't draw status info */ + GP_DRAWDATA_ONLY3D = (1 << 1), /* only draw 3d-strokes */ + GP_DRAWDATA_ONLYV2D = (1 << 2), /* only draw 'canvas' strokes */ + GP_DRAWDATA_ONLYI2D = (1 << 3), /* only draw 'image' strokes */ + GP_DRAWDATA_IEDITHACK = (1 << 4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ + GP_DRAWDATA_NO_XRAY = (1 << 5), /* don't draw xray in 3D view (which is default) */ } eDrawStrokeFlags; /* thickness above which we should use special drawing */ -#define GP_DRAWTHICKNESS_SPECIAL 3 +#define GP_DRAWTHICKNESS_SPECIAL 3 /* ----- Tool Buffer Drawing ------ */ /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ -static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) +static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) { tGPspoint *pt; int i; @@ -100,14 +100,14 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick return; /* check if buffer can be drawn */ - if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D)) + if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; /* if drawing a single point, draw it larger */ if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); - glVertex2iv(&points->x); + glVertex2iv(&points->x); glEnd(); } else if (sflag & GP_STROKE_ERASER) { @@ -122,7 +122,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick glLineWidth(oldpressure * thickness); glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -154,12 +154,12 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) { /* draw point */ if (sflag & GP_STROKE_3DSPACE) { glBegin(GL_POINTS); - glVertex3fv(&points->x); + glVertex3fv(&points->x); glEnd(); } else { @@ -167,26 +167,26 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl /* get coordinates of point */ if (sflag & GP_STROKE_2DSPACE) { - co[0]= points->x; - co[1]= points->y; + co[0] = points->x; + co[1] = points->y; } else if (sflag & GP_STROKE_2DIMAGE) { - co[0]= (points->x * winx) + offsx; - co[1]= (points->y * winy) + offsy; + co[0] = (points->x * winx) + offsx; + co[1] = (points->y * winy) + offsy; } else { - co[0]= (points->x / 100 * winx) + offsx; - co[1]= (points->y / 100 * winy) + offsy; + co[0] = (points->x / 100 * winx) + offsx; + co[1] = (points->y / 100 * winy) + offsy; } /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok - * - also mandatory in if Image Editor 'image-based' dot + * - also mandatory in if Image Editor 'image-based' dot */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) { glBegin(GL_POINTS); - glVertex2fv(co); + glVertex2fv(co); glEnd(); } else { @@ -206,7 +206,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl } /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ -static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short debug) +static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug) { bGPDspoint *pt; float oldpressure = 0.0f; @@ -214,7 +214,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw stroke curve */ glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -240,7 +240,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw debug points of curve on top? */ if (debug) { glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) glVertex3fv(&pt->x); glEnd(); } @@ -249,35 +249,35 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* ----- Fancy 2D-Stroke Drawing ------ */ /* draw a given stroke in 2d */ -static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, - short debug, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, + short debug, int offsx, int offsy, int winx, int winy) { /* otherwise thickness is twice that of the 3D view */ - float thickness= (float)thickness_s * 0.5f; + float thickness = (float)thickness_s * 0.5f; /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better - * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke + * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) { bGPDspoint *pt; int i; glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2f(pt->x, pt->y); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (pt->x * winx) + offsx; - const float y= (pt->y * winy) + offsy; + const float x = (pt->x * winx) + offsx; + const float y = (pt->y * winy) + offsy; glVertex2f(x, y); } else { - const float x= (pt->x / 100 * winx) + offsx; - const float y= (pt->y / 100 * winy) + offsy; + const float x = (pt->x / 100 * winx) + offsx; + const float y = (pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -296,67 +296,67 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s glShadeModel(GL_FLAT); glBegin(GL_QUADS); - for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) { - float s0[2], s1[2]; /* segment 'center' points */ - float t0[2], t1[2]; /* tessellated coordinates */ - float m1[2], m2[2]; /* gradient and normal */ - float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ - float pthick; /* thickness at segment point */ + for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) { + float s0[2], s1[2]; /* segment 'center' points */ + float t0[2], t1[2]; /* tessellated coordinates */ + float m1[2], m2[2]; /* gradient and normal */ + float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ + float pthick; /* thickness at segment point */ /* get x and y coordinates from points */ if (sflag & GP_STROKE_2DSPACE) { - s0[0]= pt1->x; s0[1]= pt1->y; - s1[0]= pt2->x; s1[1]= pt2->y; + s0[0] = pt1->x; s0[1] = pt1->y; + s1[0] = pt2->x; s1[1] = pt2->y; } else if (sflag & GP_STROKE_2DIMAGE) { - s0[0]= (pt1->x * winx) + offsx; - s0[1]= (pt1->y * winy) + offsy; - s1[0]= (pt2->x * winx) + offsx; - s1[1]= (pt2->y * winy) + offsy; + s0[0] = (pt1->x * winx) + offsx; + s0[1] = (pt1->y * winy) + offsy; + s1[0] = (pt2->x * winx) + offsx; + s1[1] = (pt2->y * winy) + offsy; } else { - s0[0]= (pt1->x / 100 * winx) + offsx; - s0[1]= (pt1->y / 100 * winy) + offsy; - s1[0]= (pt2->x / 100 * winx) + offsx; - s1[1]= (pt2->y / 100 * winy) + offsy; + s0[0] = (pt1->x / 100 * winx) + offsx; + s0[1] = (pt1->y / 100 * winy) + offsy; + s1[0] = (pt2->x / 100 * winx) + offsx; + s1[1] = (pt2->y / 100 * winy) + offsy; } /* calculate gradient and normal - 'angle'=(ny/nx) */ - m1[1]= s1[1] - s0[1]; - m1[0]= s1[0] - s0[0]; + m1[1] = s1[1] - s0[1]; + m1[0] = s1[0] - s0[0]; normalize_v2(m1); - m2[1]= -m1[0]; - m2[0]= m1[1]; + m2[1] = -m1[0]; + m2[0] = m1[1]; /* always use pressure from first point here */ - pthick= (pt1->pressure * thickness); + pthick = (pt1->pressure * thickness); /* if the first segment, start of segment is segment's normal */ if (i == 0) { /* draw start cap first * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s0[0] - (m1[0] * pthick * 0.75f); - sc[1]= s0[1] - (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s0[0] - (m1[0] * pthick * 0.75f); + sc[1] = s0[1] - (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t0); glVertex2fv(t1); /* calculate points for start of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (first to finish off start cap, then for stroke) */ glVertex2fv(t1); @@ -366,33 +366,33 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if not the first segment, use bisector of angle between segments */ else { - float mb[2]; /* bisector normal */ - float athick, dfac; /* actual thickness, difference between thicknesses */ + float mb[2]; /* bisector normal */ + float athick, dfac; /* actual thickness, difference between thicknesses */ /* calculate gradient of bisector (as average of normals) */ - mb[0]= (pm[0] + m2[0]) / 2; - mb[1]= (pm[1] + m2[1]) / 2; + mb[0] = (pm[0] + m2[0]) / 2; + mb[1] = (pm[1] + m2[1]) / 2; normalize_v2(mb); /* calculate gradient to apply - * - as basis, use just pthick * bisector gradient + * - as basis, use just pthick * bisector gradient * - if cross-section not as thick as it should be, add extra padding to fix it */ - mt[0]= mb[0] * pthick; - mt[1]= mb[1] * pthick; - athick= len_v2(mt); - dfac= pthick - (athick * 2); + mt[0] = mb[0] * pthick; + mt[1] = mb[1] * pthick; + athick = len_v2(mt); + dfac = pthick - (athick * 2); - if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0)) { + if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); } /* calculate points for start of segment */ - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (once for end of current segment, and once for start of next) */ glVertex2fv(t1); @@ -402,18 +402,18 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if last segment, also draw end of segment (defined as segment's normal) */ - if (i == totpoints-2) { + if (i == totpoints - 2) { /* for once, we use second point's pressure (otherwise it won't be drawn) */ - pthick= (pt2->pressure * thickness); + pthick = (pt2->pressure * thickness); /* calculate points for end of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s1[0] - mt[0]; - t0[1]= s1[1] - mt[1]; - t1[0]= s1[0] + mt[0]; - t1[1]= s1[1] + mt[1]; + t0[0] = s1[0] - mt[0]; + t0[1] = s1[1] - mt[1]; + t1[0] = s1[0] + mt[0]; + t1[1] = s1[1] + mt[1]; /* draw this line twice (once for end of stroke, and once for endcap)*/ glVertex2fv(t1); @@ -425,15 +425,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* draw end cap as last step * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s1[0] + (m1[0] * pthick * 0.75f); - sc[1]= s1[1] + (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s1[0] + (m1[0] * pthick * 0.75f); + sc[1] = s1[1] + (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t1); glVertex2fv(t0); @@ -452,19 +452,19 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s int i; glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2fv(&pt->x); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (float)((pt->x * winx) + offsx); - const float y= (float)((pt->y * winy) + offsy); + const float x = (float)((pt->x * winx) + offsx); + const float y = (float)((pt->y * winy) + offsy); glVertex2f(x, y); } else { - const float x= (float)(pt->x / 100 * winx) + offsx; - const float y= (float)(pt->y / 100 * winy) + offsy; + const float x = (float)(pt->x / 100 * winx) + offsx; + const float y = (float)(pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -476,15 +476,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* ----- General Drawing ------ */ /* draw a set of strokes */ -static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, - short debug, short lthick, float color[4]) +static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, + short debug, short lthick, float color[4]) { bGPDstroke *gps; /* set color first (may need to reset it again later too) */ glColor4fv(color); - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { /* check if stroke can be drawn - checks here generally fall into pairs */ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) continue; @@ -505,7 +505,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int if (gps->totpoints == 1) gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy); else if (dflag & GP_DRAWDATA_ONLY3D) { - const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY); + const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY); int mask_orig = 0; if (no_xray) { @@ -540,7 +540,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int } /* draw grease-pencil datablock */ -static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) +static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { bGPDlayer *gpl; @@ -555,11 +555,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glEnable(GL_BLEND); /* loop over layers, drawing them */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf; short debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? 1 : 0; - short lthick= gpl->thickness; + short lthick = gpl->thickness; float color[4], tcolor[4]; /* don't draw layer if hidden */ @@ -567,7 +567,7 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy continue; /* get frame to draw */ - gpf= gpencil_layer_getframe(gpl, cfra, 0); + gpf = gpencil_layer_getframe(gpl, cfra, 0); if (gpf == NULL) continue; @@ -579,8 +579,8 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glPointSize((float)(gpl->thickness + 2)); /* apply xray layer setting */ - if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; - else dflag &= ~GP_DRAWDATA_NO_XRAY; + if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; + else dflag &= ~GP_DRAWDATA_NO_XRAY; /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { @@ -590,11 +590,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy float fac; /* draw previous frames first */ - for (gf=gpf->prev; gf; gf=gf->prev) { + for (gf = gpf->prev; gf; gf = gf->prev) { /* check if frame is drawable */ if ((gpf->framenum - gf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -603,11 +603,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* now draw next frames */ - for (gf= gpf->next; gf; gf=gf->next) { + for (gf = gpf->next; gf; gf = gf->next) { /* check if frame is drawable */ if ((gf->framenum - gpf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -636,14 +636,14 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* draw the strokes already in active frame */ - tcolor[3]= color[3]; + tcolor[3] = color[3]; gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); /* Check if may need to draw the active stroke cache, only if this layer is the active layer * that is being edited. (Stroke buffer is currently stored in gp-data) */ if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) && - (gpf->flag & GP_FRAME_PAINT)) + (gpf->flag & GP_FRAME_PAINT)) { /* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */ gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag); @@ -671,16 +671,16 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int offsx, offsy, sizex, sizey; int dflag = GP_DRAWDATA_NOSTATUS; /* check that we have grease-pencil stuff to draw */ if (ELEM(NULL, sa, ibuf)) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* calculate rect */ @@ -691,24 +691,24 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) /* just draw using standard scaling (settings here are currently ignored anyways) */ // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); - dflag |= GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_IEDITHACK; + dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; } - break; -#if 0 /* removed since 2.5x, needs to be added back */ + break; +#if 0 /* removed since 2.5x, needs to be added back */ case SPACE_SEQ: /* sequence */ { - SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; float zoom, zoomx, zoomy; /* calculate accessory values */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { /* XXX sequencer zoom should store it? */ zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp); @@ -718,20 +718,20 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) zoomx = zoomy = zoom; /* calculate transforms (Note: we use ibuf here, as we have it) */ - sizex= (int)(zoomx * ibuf->x); - sizey= (int)(zoomy * ibuf->y); - offsx= (int)( (ar->winx-sizex)/2 + sseq->xof ); - offsy= (int)( (ar->winy-sizey)/2 + sseq->yof ); + sizex = (int)(zoomx * ibuf->x); + sizey = (int)(zoomy * ibuf->y); + offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof); + offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof); dflag |= GP_DRAWDATA_ONLYI2D; } - break; + break; #endif default: /* for spacetype not yet handled */ - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; dflag |= GP_DRAWDATA_ONLYI2D; break; @@ -747,15 +747,15 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) */ void draw_gpencil_view2d(bContext *C, short onlyv2d) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int dflag = 0; /* check that we have grease-pencil stuff to draw */ if (sa == NULL) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* special hack for Image Editor */ @@ -764,7 +764,7 @@ void draw_gpencil_view2d(bContext *C, short onlyv2d) dflag |= GP_DRAWDATA_IEDITHACK; /* draw it! */ - if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_NOSTATUS); + if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag); } @@ -777,10 +777,10 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) bGPdata *gpd; int dflag = 0; rcti rect; - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* check that we have grease-pencil stuff to draw */ - gpd= gpencil_data_get_active_v3d(scene); // XXX + gpd = gpencil_data_get_active_v3d(scene); // XXX if (gpd == NULL) return; /* when rendering to the offscreen buffer we don't want to @@ -798,7 +798,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) } /* draw it! */ - if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS); + if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, rect.xmin, rect.ymin, rect.xmax, rect.ymax, CFRA, dflag); } diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index b79516ed25e..9cc738b016e 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -54,9 +54,9 @@ /* ***************************************** */ /* NOTE ABOUT THIS FILE: - * This file contains code for editing Grease Pencil data in the Action Editor - * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. - * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. + * This file contains code for editing Grease Pencil data in the Action Editor + * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. + * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. */ /* ***************************************** */ /* Generics - Loopers */ @@ -71,7 +71,7 @@ short gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDfr return 0; /* do loop */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* execute callback */ if (gpf_cb(gpf, scene)) return 1; @@ -95,12 +95,12 @@ void gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel) return; /* loop through gp-frames, adding */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) { - ce= MEM_callocN(sizeof(CfraElem), "CfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "CfraElem"); - ce->cfra= (float)gpf->framenum; - ce->sel= (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; + ce->cfra = (float)gpf->framenum; + ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; BLI_addtail(elems, ce); } @@ -120,7 +120,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) return 0; /* stop at the first one found */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->flag & GP_FRAME_SELECT) return 1; } @@ -130,7 +130,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) } /* helper function - select gp-frame based on SELECT_* mode */ -static void gpframe_select (bGPDframe *gpf, short select_mode) +static void gpframe_select(bGPDframe *gpf, short select_mode) { if (gpf == NULL) return; @@ -158,7 +158,7 @@ void select_gpencil_frames(bGPDlayer *gpl, short select_mode) return; /* handle according to mode */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { gpframe_select(gpf, select_mode); } } @@ -183,7 +183,7 @@ void select_gpencil_frame(bGPDlayer *gpl, int selx, short select_mode) return; /* search through frames for a match */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* there should only be one frame with this frame-number */ if (gpf->framenum == selx) { gpframe_select(gpf, select_mode); @@ -201,7 +201,7 @@ void borderselect_gplayer_frames(bGPDlayer *gpl, float min, float max, short sel return; /* only select those frames which are in bounds */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (IN_RANGE(gpf->framenum, min, max)) gpframe_select(gpf, select_mode); } @@ -220,8 +220,8 @@ void delete_gplayer_frames(bGPDlayer *gpl) return; /* check for frames to delete */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; if (gpf->flag & GP_FRAME_SELECT) gpencil_layer_delframe(gpl, gpf); @@ -238,15 +238,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) return; /* duplicate selected frames */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; /* duplicate this frame */ if (gpf->flag & GP_FRAME_SELECT) { bGPDframe *gpfd; /* duplicate frame, and deselect self */ - gpfd= gpencil_frame_duplicate(gpf); + gpfd = gpencil_frame_duplicate(gpf); gpf->flag &= ~GP_FRAME_SELECT; BLI_insertlinkafter(&gpl->frames, gpf, gpfd); @@ -267,15 +267,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) /* globals for copy/paste data (like for other copy/paste buffers) */ ListBase gpcopybuf = {NULL, NULL}; -static int gpcopy_firstframe= 999999999; +static int gpcopy_firstframe = 999999999; /* This function frees any MEM_calloc'ed copy/paste buffer data */ void free_gpcopybuf() { free_gpencil_layers(&gpcopybuf); - gpcopybuf.first= gpcopybuf.last= NULL; - gpcopy_firstframe= 999999999; + gpcopybuf.first = gpcopybuf.last = NULL; + gpcopy_firstframe = 999999999; } /* This function adds data to the copy/paste buffer, freeing existing data first @@ -293,39 +293,39 @@ void copy_gpdata() free_gpcopybuf(); /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL); actdata_filter(&act_data, filter, data, datatype); /* assume that each of these is an ipo-block */ - for (ale= act_data.first; ale; ale= ale->next) { + for (ale = act_data.first; ale; ale = ale->next) { bGPDlayer *gpls, *gpln; bGPDframe *gpf, *gpfn; /* get new layer to put into buffer */ - gpls= (bGPDlayer *)ale->data; - gpln= MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); + gpls = (bGPDlayer *)ale->data; + gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); - gpln->frames.first= gpln->frames.last= NULL; + gpln->frames.first = gpln->frames.last = NULL; BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info)); BLI_addtail(&gpcopybuf, gpln); /* loop over frames, and copy only selected frames */ - for (gpf= gpls->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpls->frames.first; gpf; gpf = gpf->next) { /* if frame is selected, make duplicate it and its strokes */ if (gpf->flag & GP_FRAME_SELECT) { /* add frame to buffer */ - gpfn= gpencil_frame_duplicate(gpf); + gpfn = gpencil_frame_duplicate(gpf); BLI_addtail(&gpln->frames, gpfn); /* check if this is the earliest frame encountered so far */ if (gpf->framenum < gpcopy_firstframe) - gpcopy_firstframe= gpf->framenum; + gpcopy_firstframe = gpf->framenum; } } } @@ -347,7 +347,7 @@ void paste_gpdata(Scene *scene) short datatype; const int offset = (CFRA - gpcopy_firstframe); - short no_name= 0; + short no_name = 0; /* check if buffer is empty */ if (ELEM(NULL, gpcopybuf.first, gpcopybuf.last)) { @@ -356,27 +356,27 @@ void paste_gpdata(Scene *scene) } /* check if single channel in buffer (disregard names if so) */ if (gpcopybuf.first == gpcopybuf.last) - no_name= 1; + no_name = 1; /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); actdata_filter(&act_data, filter, data, datatype); /* from selected channels */ - for (ale= act_data.first; ale; ale= ale->next) { - bGPDlayer *gpld= (bGPDlayer *)ale->data; - bGPDlayer *gpls= NULL; + for (ale = act_data.first; ale; ale = ale->next) { + bGPDlayer *gpld = (bGPDlayer *)ale->data; + bGPDlayer *gpls = NULL; bGPDframe *gpfs, *gpf; /* find suitable layer from buffer to use to paste from */ - for (gpls= gpcopybuf.first; gpls; gpls= gpls->next) { + for (gpls = gpcopybuf.first; gpls; gpls = gpls->next) { /* check if layer name matches */ - if ((no_name) || (strcmp(gpls->info, gpld->info)==0)) + if ((no_name) || (strcmp(gpls->info, gpld->info) == 0)) break; } @@ -385,12 +385,12 @@ void paste_gpdata(Scene *scene) continue; /* add frames from buffer */ - for (gpfs= gpls->frames.first; gpfs; gpfs= gpfs->next) { + for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) { /* temporarily apply offset to buffer-frame while copying */ gpfs->framenum += offset; /* get frame to copy data into (if no frame returned, then just ignore) */ - gpf= gpencil_layer_getframe(gpld, gpfs->framenum, 1); + gpf = gpencil_layer_getframe(gpld, gpfs->framenum, 1); if (gpf) { bGPDstroke *gps, *gpsn; ScrArea *sa; @@ -404,12 +404,12 @@ void paste_gpdata(Scene *scene) * - we cannot just add a duplicate frame, as that would cause errors * - need to check for compatible types to minimise memory usage (copying 'junk' over) */ - for (gps= gpfs->strokes.first; gps; gps= gps->next) { + for (gps = gpfs->strokes.first; gps; gps = gps->next) { short stroke_ok; /* if there's an area, check that it supports this type of stroke */ if (sa) { - stroke_ok= 0; + stroke_ok = 0; /* check if spacetype supports this type of stroke * - NOTE: must sync this with gp_paint_initstroke() in gpencil.c @@ -417,30 +417,30 @@ void paste_gpdata(Scene *scene) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View: either screen-aligned or 3d-space */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_3DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */ case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */ case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_SEQ: /* Sequence Editor: either screen-aligned or view-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DIMAGE)) - stroke_ok= 1; + stroke_ok = 1; break; } } else - stroke_ok= 1; + stroke_ok = 1; /* if stroke is ok, we make a copy of this stroke and add to frame */ if (stroke_ok) { /* make a copy of stroke, then of its points array */ - gpsn= MEM_dupallocN(gps); - gpsn->points= MEM_dupallocN(gps->points); + gpsn = MEM_dupallocN(gps); + gpsn->points = MEM_dupallocN(gps->points); /* append stroke to frame */ BLI_addtail(&gpf->strokes, gpsn); @@ -467,32 +467,32 @@ void paste_gpdata(Scene *scene) /* -------------------------------------- */ /* Snap Tools */ -static short snap_gpf_nearest (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearest(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum+0.5)); + gpf->framenum = (int)(floor(gpf->framenum + 0.5)); return 0; } -static short snap_gpf_nearestsec (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene) { float secf = (float)FPS; if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum/secf + 0.5f) * secf); + gpf->framenum = (int)(floor(gpf->framenum / secf + 0.5f) * secf); return 0; } -static short snap_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)CFRA; + gpf->framenum = (int)CFRA; return 0; } -static short snap_gpf_nearmarker (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); + gpf->framenum = (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); return 0; } @@ -522,43 +522,43 @@ void snap_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode) /* -------------------------------------- */ /* Mirror Tools */ -static short mirror_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= CFRA - gpf->framenum; - gpf->framenum= CFRA; + diff = CFRA - gpf->framenum; + gpf->framenum = CFRA; } return 0; } -static short mirror_gpf_yaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_xaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) { static TimeMarker *marker; static short initialized = 0; @@ -575,8 +575,8 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) if (gpf) { /* mirroring time */ if ((gpf->flag & GP_FRAME_SELECT) && (marker)) { - diff= (marker->frame - gpf->framenum); - gpf->framenum= (marker->frame + diff); + diff = (marker->frame - gpf->framenum); + gpf->framenum = (marker->frame + diff); } } else { @@ -588,9 +588,9 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) } else { /* try to find a marker */ - marker= ED_markers_get_first_selected(&scene->markers); + marker = ED_markers_get_first_selected(&scene->markers); if (marker) { - initialized= 1; + initialized = 1; } } } diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 263c842ed08..3a7e806c2ed 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -74,7 +74,7 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl) /* make sure the layer we want to remove is the active one */ gpencil_layer_setactive(gpd, gpl); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } /* delete 'active' layer */ @@ -84,7 +84,7 @@ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl) gpencil_layer_setactive(gpd, gpl); gpencil_layer_delactive(gpd); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } @@ -133,7 +133,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons uiItemR(sub, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ - if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) { + if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) { char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */ /* visibility button (only if hidden but not locked!) */ @@ -197,8 +197,8 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* color */ sub = uiLayoutColumn(col, 1); - uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); - uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); + uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* stroke thickness */ uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -251,8 +251,8 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); row = uiLayoutRow(col, 1); - uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); - uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); + uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); + uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); /* sanity checks... */ if (gpd == NULL) @@ -266,29 +266,29 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw gpd drawing settings first ------------------------------------- */ col = uiLayoutColumn(layout, 1); - /* label */ - uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); + /* label */ + uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); - /* check whether advanced 3D-View drawing space options can be used */ - if (is_v3d) { - if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW)) - v3d_stroke_opts = STROKE_OPTS_V3D_ON; - else - v3d_stroke_opts = STROKE_OPTS_V3D_OFF; - } - - /* drawing space options */ - row= uiLayoutRow(col, 1); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); - row= uiLayoutRow(col, 1); - uiLayoutSetActive(row, v3d_stroke_opts); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); + /* check whether advanced 3D-View drawing space options can be used */ + if (is_v3d) { + if (gpd->flag & (GP_DATA_DEPTH_STROKE | GP_DATA_DEPTH_VIEW)) + v3d_stroke_opts = STROKE_OPTS_V3D_ON; + else + v3d_stroke_opts = STROKE_OPTS_V3D_OFF; + } - row= uiLayoutRow(col, 0); - uiLayoutSetActive(row, v3d_stroke_opts==STROKE_OPTS_V3D_ON); - uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); + /* drawing space options */ + row = uiLayoutRow(col, 1); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); + row = uiLayoutRow(col, 1); + uiLayoutSetActive(row, v3d_stroke_opts); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); + + row = uiLayoutRow(col, 0); + uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); + uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 34a95cd89bf..9250d48a20c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -77,10 +77,10 @@ /* Context Wrangling... */ /* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */ -bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) +bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); /* if there's an active area, check if the particular editor may * have defined any special Grease Pencil context for editing... @@ -89,7 +89,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View */ { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); // TODO: we can include other data-types such as bones later if need be... @@ -100,11 +100,11 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &ob->gpd; } } - break; + break; case SPACE_NODE: /* Nodes Editor */ { - SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C); + SpaceNode *snode = (SpaceNode *)CTX_wm_space_data(C); /* return the GP data for the active node block/node */ if (snode && snode->nodetree) { @@ -117,7 +117,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return NULL; } } - break; + break; case SPACE_SEQ: /* Sequencer */ { @@ -125,23 +125,23 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) /* return the GP data for the active strips/image/etc. */ } - break; + break; case SPACE_IMAGE: /* Image/UV Editor */ { - SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); + SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space... */ // XXX our convention for everything else is to link to data though... if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } - break; + break; case SPACE_CLIP: /* Nodes Editor */ { - SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); + MovieClip *clip = ED_space_clip(sc); if (clip) { /* for now, as long as there's a clip, default to using that in Clip Editor */ @@ -149,7 +149,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &clip->gpd; } } - break; + break; default: /* unsupported space */ return NULL; @@ -162,16 +162,16 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) } /* Get the active Grease Pencil datablock */ -bGPdata *gpencil_data_get_active (bContext *C) +bGPdata *gpencil_data_get_active(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; } /* needed for offscreen rendering */ -bGPdata *gpencil_data_get_active_v3d (Scene *scene) +bGPdata *gpencil_data_get_active_v3d(Scene *scene) { - bGPdata *gpd= scene->basact ? scene->basact->object->gpd : NULL; + bGPdata *gpd = scene->basact ? scene->basact->object->gpd : NULL; return gpd ? gpd : scene->gpd; } @@ -179,7 +179,7 @@ bGPdata *gpencil_data_get_active_v3d (Scene *scene) /* Panel Operators */ /* poll callback for adding data/layers - special */ -static int gp_add_poll (bContext *C) +static int gp_add_poll(bContext *C) { /* the base line we have is that we have somewhere to add Grease Pencil data */ return gpencil_data_get_pointers(C, NULL) != NULL; @@ -188,9 +188,9 @@ static int gp_add_poll (bContext *C) /* ******************* Add New Data ************************ */ /* add new datablock - wrapper around API */ -static int gp_data_add_exec (bContext *C, wmOperator *op) +static int gp_data_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -198,14 +198,14 @@ static int gp_data_add_exec (bContext *C, wmOperator *op) } else { /* decrement user count and add new datablock */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -216,7 +216,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) ot->name = "Grease Pencil Add New"; ot->idname = "GPENCIL_OT_data_add"; ot->description = "Add new Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_add_exec; @@ -226,9 +226,9 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) /* ******************* Unlink Data ************************ */ /* poll callback for adding data/layers - special */ -static int gp_data_unlink_poll (bContext *C) +static int gp_data_unlink_poll(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if we have access to some active data, make sure there's a datablock before enabling this */ return (gpd_ptr && *gpd_ptr); @@ -236,9 +236,9 @@ static int gp_data_unlink_poll (bContext *C) /* unlink datablock - wrapper around API */ -static int gp_data_unlink_exec (bContext *C, wmOperator *op) +static int gp_data_unlink_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -246,14 +246,14 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op) } else { /* just unlink datablock now, decreasing its user count */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= NULL; + *gpd_ptr = NULL; } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -264,7 +264,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) ot->name = "Grease Pencil Unlink"; ot->idname = "GPENCIL_OT_data_unlink"; ot->description = "Unlink active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_unlink_exec; @@ -274,9 +274,9 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) /* ******************* Add New Layer ************************ */ /* add new layer - wrapper around API */ -static int gp_layer_add_exec (bContext *C, wmOperator *op) +static int gp_layer_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if there's no existing Grease-Pencil data there, add some */ if (gpd_ptr == NULL) { @@ -284,13 +284,13 @@ static int gp_layer_add_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); /* add new layer now */ gpencil_layer_addnew(*gpd_ptr); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -301,7 +301,7 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) ot->name = "Add New Layer"; ot->idname = "GPENCIL_OT_layer_add"; ot->description = "Add new Grease Pencil layer for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_layer_add_exec; @@ -310,22 +310,22 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) /* ******************* Delete Active Frame ************************ */ -static int gp_actframe_delete_poll (bContext *C) +static int gp_actframe_delete_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); /* only if there's an active layer with an active frame */ return (gpl && gpl->actframe); } /* delete active frame - wrapper around API calls */ -static int gp_actframe_delete_exec (bContext *C, wmOperator *op) +static int gp_actframe_delete_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); /* if there's no existing Grease-Pencil data there, add some */ if (gpd == NULL) { @@ -341,7 +341,7 @@ static int gp_actframe_delete_exec (bContext *C, wmOperator *op) gpencil_layer_delframe(gpl, gpf); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -352,7 +352,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) ot->name = "Delete Active Frame"; ot->idname = "GPENCIL_OT_active_frame_delete"; ot->description = "Delete the active frame for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_actframe_delete_exec; @@ -380,35 +380,35 @@ static EnumPropertyItem prop_gpencil_convertmodes[] = { /* convert the coordinates from the given stroke point into 3d-coordinates * - assumes that the active space is the 3D-View */ -static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) +static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (gps->flag & GP_STROKE_3DSPACE) { /* directly use 3d-coordinates */ copy_v3_v3(p3d, &pt->x); } else { - float *fp= give_cursor(scene, v3d); + float *fp = give_cursor(scene, v3d); float mvalf[2]; /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { int mvali[2]; - View2D *v2d= &ar->v2d; - UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1); + View2D *v2d = &ar->v2d; + UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1); VECCOPY2D(mvalf, mvali); } 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) * (subrect->xmax - subrect->xmin)) + subrect->xmin; + mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; } else { - mvalf[0]= (float)pt->x / 100.0f * ar->winx; - mvalf[1]= (float)pt->y / 100.0f * ar->winy; + mvalf[0] = (float)pt->x / 100.0f * ar->winx; + mvalf[1] = (float)pt->y / 100.0f * ar->winy; } } @@ -422,7 +422,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi /* --- */ /* convert stroke to 3d path */ -static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -432,16 +432,16 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)"); - nu->pntsu= gps->totpoints; - nu->pntsv= 1; - nu->orderu= gps->totpoints; - nu->flagu= CU_NURB_ENDPOINT; - nu->resolu= 32; + nu->pntsu = gps->totpoints; + nu->pntsv = 1; + nu->orderu = gps->totpoints; + nu->flagu = CU_NURB_ENDPOINT; + nu->resolu = 32; - nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*gps->totpoints, "bpoints"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * gps->totpoints, "bpoints"); /* add points */ - for (i=0, pt=gps->points, bp=nu->bp; i < gps->totpoints; i++, pt++, bp++) { + for (i = 0, pt = gps->points, bp = nu->bp; i < gps->totpoints; i++, pt++, bp++) { float p3d[3]; /* get coordinates to add at */ @@ -449,7 +449,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur copy_v3_v3(bp->vec, p3d); /* set settings */ - bp->f1= SELECT; + bp->f1 = SELECT; bp->radius = bp->weight = pt->pressure * gpl->thickness; } @@ -459,15 +459,15 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur static int gp_camera_view_subrect(bContext *C, rctf *subrect) { - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, TRUE); /* no shift */ return 1; } @@ -477,7 +477,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) } /* convert stroke to 3d bezier */ -static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -488,31 +488,31 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)"); - nu->pntsu= gps->totpoints; - nu->resolu= 12; - nu->resolv= 12; - nu->type= CU_BEZIER; - nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints*sizeof(BezTriple), "bezts"); + nu->pntsu = gps->totpoints; + nu->resolu = 12; + nu->resolv = 12; + nu->type = CU_BEZIER; + nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints * sizeof(BezTriple), "bezts"); - tot= gps->totpoints; + tot = gps->totpoints; /* get initial coordinates */ - pt=gps->points; + pt = gps->points; if (tot) { gp_strokepoint_convertcoords(C, gps, pt, p3d_cur, subrect); if (tot > 1) { - gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect); + gp_strokepoint_convertcoords(C, gps, pt + 1, p3d_next, subrect); } } /* add points */ - for (i=0, bezt=nu->bezt; i < tot; i++, pt++, bezt++) { + for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) { float h1[3], h2[3]; if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3); else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3); - if (i < tot-1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); + if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3); copy_v3_v3(bezt->vec[0], h1); @@ -520,8 +520,8 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C copy_v3_v3(bezt->vec[2], h2); /* set settings */ - bezt->h1= bezt->h2= HD_FREE; - bezt->f1= bezt->f2= bezt->f3= SELECT; + bezt->h1 = bezt->h2 = HD_FREE; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f; /* shift coord vects */ @@ -541,16 +541,16 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C } /* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */ -static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) +static void gp_layer_to_curve(bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) { - Scene *scene= CTX_data_scene(C); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); bGPDstroke *gps; Object *ob; Curve *cu; /* camera framing */ - rctf subrect, *subrect_ptr= NULL; + rctf subrect, *subrect_ptr = NULL; /* error checking */ if (ELEM3(NULL, gpd, gpl, gpf)) @@ -562,16 +562,16 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* initialize camera framing */ if (gp_camera_view_subrect(C, &subrect)) { - subrect_ptr= &subrect; + subrect_ptr = &subrect; } /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ - ob= add_object(scene, OB_CURVE); + ob = BKE_object_add(scene, OB_CURVE); zero_v3(ob->loc); zero_v3(ob->rot); - cu= ob->data; + cu = ob->data; cu->flag |= CU_3D; /* rename object and curve to layer name */ @@ -579,7 +579,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short rename_id((ID *)cu, gpl->info); /* add points to curve */ - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { switch (mode) { case GP_STROKECONVERT_PATH: gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr); @@ -596,22 +596,22 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* --- */ -static int gp_convert_poll (bContext *C) +static int gp_convert_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - ScrArea *sa= CTX_wm_area(C); - Scene *scene= CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); /* only if there's valid data, and the current view is 3D View */ return ((sa && sa->spacetype == SPACE_VIEW3D) && gpencil_layer_getactive(gpd) && (scene->obedit == NULL)); } -static int gp_convert_layer_exec (bContext *C, wmOperator *op) +static int gp_convert_layer_exec(bContext *C, wmOperator *op) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - Scene *scene= CTX_data_scene(C); - int mode= RNA_enum_get(op->ptr, "type"); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + Scene *scene = CTX_data_scene(C); + int mode = RNA_enum_get(op->ptr, "type"); /* check if there's data to work with */ if (gpd == NULL) { @@ -622,8 +622,8 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op) gp_layer_to_curve(C, gpd, gpl, mode); /* notifiers */ - WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); /* done */ return OPERATOR_FINISHED; @@ -635,7 +635,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->name = "Convert Grease Pencil"; ot->idname = "GPENCIL_OT_convert"; ot->description = "Convert the active Grease Pencil layer to a new Object"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->invoke = WM_menu_invoke; @@ -643,7 +643,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->poll = gp_convert_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", ""); diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index b88723d8a3c..28eb1355caf 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -77,18 +77,18 @@ void gpencil_undo_finish(void); typedef struct bActListElem { struct bActListElem *next, *prev; - void *data; /* source data this elem represents */ - int type; /* one of the ACTTYPE_* values */ - int flag; /* copy of elem's flags for quick access */ - int index; /* copy of adrcode where applicable */ + void *data; /* source data this elem represents */ + int type; /* one of the ACTTYPE_* values */ + int flag; /* copy of elem's flags for quick access */ + int index; /* copy of adrcode where applicable */ - void *key_data; /* motion data - ipo or ipo-curve */ - short datatype; /* type of motion data to expect */ + void *key_data; /* motion data - ipo or ipo-curve */ + short datatype; /* type of motion data to expect */ - struct bActionGroup *grp; /* action group that owns the channel */ + struct bActionGroup *grp; /* action group that owns the channel */ - void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ - short ownertype; /* type of owner */ + void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ + short ownertype; /* type of owner */ } bActListElem; /******************************************************* */ @@ -96,14 +96,14 @@ typedef struct bActListElem { /* filtering flags - under what circumstances should a channel be added */ typedef enum ACTFILTER_FLAGS { - ACTFILTER_VISIBLE = (1<<0), /* should channels be visible */ - ACTFILTER_SEL = (1<<1), /* should channels be selected */ - ACTFILTER_FOREDIT = (1<<2), /* does editable status matter */ - ACTFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */ - ACTFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */ - ACTFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */ - ACTFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */ - ACTFILTER_ACTGROUPED = (1<<7) /* belongs to the active group */ + ACTFILTER_VISIBLE = (1 << 0), /* should channels be visible */ + ACTFILTER_SEL = (1 << 1), /* should channels be selected */ + ACTFILTER_FOREDIT = (1 << 2), /* does editable status matter */ + ACTFILTER_CHANNELS = (1 << 3), /* do we only care that it is a channel */ + ACTFILTER_IPOKEYS = (1 << 4), /* only channels referencing ipo's */ + ACTFILTER_ONLYICU = (1 << 5), /* only reference ipo-curves */ + ACTFILTER_FORDRAWING = (1 << 6), /* make list for interface drawing */ + ACTFILTER_ACTGROUPED = (1 << 7) /* belongs to the active group */ } ACTFILTER_FLAGS; /* Action Editor - Main Data types */ diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index baa6999f552..7055eb3ee1b 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -54,18 +54,22 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Draw */ - /* draw */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); - /* draw - straight lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); - /* draw - poly lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); - /* erase */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); + + /* draw */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); + + /* draw - straight lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); + + /* draw - poly lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); + + /* erase */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); } /* ****************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 9f9d941f523..b79c510efce 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -71,38 +71,38 @@ typedef struct tGPsdata { Scene *scene; /* current scene from context */ - wmWindow *win; /* window where painting originated */ - ScrArea *sa; /* area where painting originated */ + wmWindow *win; /* window where painting originated */ + ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ - View2D *v2d; /* needed for GP_STROKE_2DSPACE */ - rctf *subrect; /* for using the camera rect within the 3d view */ + View2D *v2d; /* needed for GP_STROKE_2DSPACE */ + rctf *subrect; /* for using the camera rect within the 3d view */ rctf subrect_data; #if 0 // XXX review this 2d image stuff... - ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ + ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ struct IBufViewSettings { - int offsx, offsy; /* offsets */ - int sizex, sizey; /* dimensions to use as scale-factor */ - } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ + int offsx, offsy; /* offsets */ + int sizex, sizey; /* dimensions to use as scale-factor */ + } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ #endif - PointerRNA ownerPtr;/* pointer to owner of gp-datablock */ - bGPdata *gpd; /* gp-datablock layer comes from */ - bGPDlayer *gpl; /* layer we're working on */ - bGPDframe *gpf; /* frame we're working on */ - - short status; /* current status of painting */ - short paintmode; /* mode for painting */ + PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ + bGPdata *gpd; /* gp-datablock layer comes from */ + bGPDlayer *gpl; /* layer we're working on */ + bGPDframe *gpf; /* frame we're working on */ + + short status; /* current status of painting */ + short paintmode; /* mode for painting */ - int mval[2]; /* current mouse-position */ - int mvalo[2]; /* previous recorded mouse-position */ + int mval[2]; /* current mouse-position */ + int mvalo[2]; /* previous recorded mouse-position */ - float pressure; /* current stylus pressure */ - float opressure; /* previous stylus pressure */ + float pressure; /* current stylus pressure */ + float opressure; /* previous stylus pressure */ - short radius; /* radius of influence for eraser */ - short flags; /* flags that can get set during runtime */ + short radius; /* radius of influence for eraser */ + short flags; /* flags that can get set during runtime */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space * to region space */ @@ -112,36 +112,36 @@ typedef struct tGPsdata { /* values for tGPsdata->status */ enum { - GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ - GP_STATUS_PAINTING, /* a stroke is in progress */ - GP_STATUS_ERROR, /* something wasn't correctly set up */ - GP_STATUS_DONE /* painting done */ + GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ + GP_STATUS_PAINTING, /* a stroke is in progress */ + GP_STATUS_ERROR, /* something wasn't correctly set up */ + GP_STATUS_DONE /* painting done */ }; /* Return flags for adding points to stroke buffer */ enum { - GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ - GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ - GP_STROKEADD_NORMAL, /* point was successfully added */ - GP_STROKEADD_FULL /* cannot add any more points to buffer */ + GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ + GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ + GP_STROKEADD_NORMAL, /* point was successfully added */ + GP_STROKEADD_FULL /* cannot add any more points to buffer */ }; /* Runtime flags */ enum { - GP_PAINTFLAG_FIRSTRUN = (1<<0), /* operator just started */ - GP_PAINTFLAG_STROKEADDED = (1<<1) /* stroke was already added during draw session */ + GP_PAINTFLAG_FIRSTRUN = (1 << 0), /* operator just started */ + GP_PAINTFLAG_STROKEADDED = (1 << 1) /* stroke was already added during draw session */ }; /* ------ */ /* maximum sizes of gp-session buffer */ -#define GP_STROKE_BUFFER_MAX 5000 +#define GP_STROKE_BUFFER_MAX 5000 /* Macros for accessing sensitivity thresholds... */ - /* minimum number of pixels mouse should move before new point created */ -#define MIN_MANHATTEN_PX (U.gp_manhattendist) - /* minimum length of new segment before new point can be added */ -#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) +/* minimum number of pixels mouse should move before new point created */ +#define MIN_MANHATTEN_PX (U.gp_manhattendist) +/* minimum length of new segment before new point can be added */ +#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) /* ------ */ /* Forward defines for some functions... */ @@ -152,7 +152,7 @@ static void gp_session_validatebuffer(tGPsdata *p); /* Context Wrangling... */ /* check if context is suitable for drawing */ -static int gpencil_draw_poll (bContext *C) +static int gpencil_draw_poll(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ @@ -175,9 +175,9 @@ static int gpencil_draw_poll (bContext *C) } /* check if projecting strokes into 3d-geometry in the 3D-View */ -static int gpencil_project_check (tGPsdata *p) +static int gpencil_project_check(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE))); } @@ -187,18 +187,18 @@ static int gpencil_project_check (tGPsdata *p) /* Utilities --------------------------------- */ /* get the reference point for stroke-point conversions */ -static void gp_get_3d_reference (tGPsdata *p, float vec[3]) +static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { - View3D *v3d= p->sa->spacedata.first; - float *fp= give_cursor(p->scene, v3d); + View3D *v3d = p->sa->spacedata.first; + float *fp = give_cursor(p->scene, v3d); /* the reference point used depends on the owner... */ #if 0 // XXX: disabled for now, since we can't draw relative to the owner yet if (p->ownerPtr.type == &RNA_Object) { - Object *ob= (Object *)p->ownerPtr.data; + Object *ob = (Object *)p->ownerPtr.data; /* active Object - * - use relative distance of 3D-cursor from object center + * - use relative distance of 3D-cursor from object center */ sub_v3_v3v3(vec, fp, ob->loc); } @@ -213,10 +213,10 @@ static void gp_get_3d_reference (tGPsdata *p, float vec[3]) /* Stroke Editing ---------------------------- */ /* check if the current mouse position is suitable for adding a new point */ -static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) +static short gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) { - int dx= abs(mval[0] - pmval[0]); - int dy= abs(mval[1] - pmval[1]); + int dx = abs(mval[0] - pmval[0]); + int dy = abs(mval[1] - pmval[1]); /* if buffer is empty, just let this go through (i.e. so that dots will work) */ if (p->gpd->sbuffer_size == 0) @@ -232,7 +232,7 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) * - prevents points being added too densely * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though */ - else if ((dx*dx + dy*dy) > MIN_EUCLIDEAN_PX*MIN_EUCLIDEAN_PX) + else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) return 1; /* mouse 'didn't move' */ @@ -242,9 +242,9 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) { @@ -292,14 +292,14 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3 /* get stored settings * - assume that these have been set already (there are checks that set sane 'defaults' just in case) */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - out[0]= (float)(mval[0] - offsx) / (float)sizex; - out[1]= (float)(mval[1] - offsy) / (float)sizey; + out[0] = (float)(mval[0] - offsx) / (float)sizex; + out[1] = (float)(mval[1] - offsy) / (float)sizey; } #endif @@ -310,16 +310,16 @@ 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) / ((p->subrect->xmax - p->subrect->xmin))) * 100; + out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; } } } /* add current stroke-point to buffer (returns whether point was successfully added) */ -static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) +static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGPspoint *pt; /* check painting mode */ @@ -327,11 +327,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* straight lines only - i.e. only store start and end point in buffer */ if (gpd->sbuffer_size == 0) { /* first point in buffer (start point) */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment buffer size */ gpd->sbuffer_size++; @@ -340,18 +340,18 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* normally, we just reset the endpoint to the latest value * - assume that pointers for this are always valid... */ - pt= ((tGPspoint *)(gpd->sbuffer) + 1); + pt = ((tGPspoint *)(gpd->sbuffer) + 1); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if this is just the second point we've added, increment the buffer size * so that it will be drawn properly... * otherwise, just leave it alone, otherwise we get problems */ if (gpd->sbuffer_size != 2) - gpd->sbuffer_size= 2; + gpd->sbuffer_size = 2; } /* can keep carrying on this way :) */ @@ -363,11 +363,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) return GP_STROKEADD_OVERFLOW; /* get pointer to destination point */ - pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); + pt = ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment counters */ gpd->sbuffer_size++; @@ -380,43 +380,43 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* get pointer to destination point */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, i.e.) */ if (p->flags & GP_PAINTFLAG_STROKEADDED) { - bGPDstroke *gps= p->gpf->strokes.last; + bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->sbuffer_size == 0) { - gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint)*(gps->totpoints+1)); + gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } - pts = &gps->points[gps->totpoints-1]; + pts = &gps->points[gps->totpoints - 1]; /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); /* copy pressure */ - pts->pressure= pt->pressure; + pts->pressure = pt->pressure; } /* increment counters */ @@ -438,11 +438,11 @@ typedef struct tGpSmoothCo { } tGpSmoothCo; /* smooth a stroke (in buffer) before storing it */ -static void gp_stroke_smooth (tGPsdata *p) +static void gp_stroke_smooth(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGpSmoothCo *smoothArray, *spc; - int i=0, cmx=gpd->sbuffer_size; + int i = 0, cmx = gpd->sbuffer_size; /* only smooth if smoothing is enabled, and we're not doing a straight line */ if (!(U.gp_settings & GP_PAINT_DOSMOOTH) || ELEM(p->paintmode, GP_PAINTMODE_DRAW_STRAIGHT, GP_PAINTMODE_DRAW_POLY)) @@ -453,23 +453,23 @@ static void gp_stroke_smooth (tGPsdata *p) return; /* create a temporary smoothing coordinates buffer, use to store calculated values to prevent sequential error */ - smoothArray = MEM_callocN(sizeof(tGpSmoothCo)*cmx, "gp_stroke_smooth smoothArray"); + smoothArray = MEM_callocN(sizeof(tGpSmoothCo) * cmx, "gp_stroke_smooth smoothArray"); /* first pass: calculate smoothing coordinates using weighted-averages */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - const tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); - const tGPspoint *pb= (i-1 > 0)?(pc-1):(pc); - const tGPspoint *pa= (i-2 > 0)?(pc-2):(pb); - const tGPspoint *pd= (i+1 < cmx)?(pc+1):(pc); - const tGPspoint *pe= (i+2 < cmx)?(pc+2):(pd); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + const tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); + const tGPspoint *pb = (i - 1 > 0) ? (pc - 1) : (pc); + const tGPspoint *pa = (i - 2 > 0) ? (pc - 2) : (pb); + const tGPspoint *pd = (i + 1 < cmx) ? (pc + 1) : (pc); + const tGPspoint *pe = (i + 2 < cmx) ? (pc + 2) : (pd); - spc->x= (int)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - spc->y= (int)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); + spc->x = (int)(0.1 * pa->x + 0.2 * pb->x + 0.4 * pc->x + 0.2 * pd->x + 0.1 * pe->x); + spc->y = (int)(0.1 * pa->y + 0.2 * pb->y + 0.4 * pc->y + 0.2 * pd->y + 0.1 * pe->y); } /* second pass: apply smoothed coordinates */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); copy_v2_v2_int(&pc->x, &spc->x); } @@ -482,12 +482,12 @@ static void gp_stroke_smooth (tGPsdata *p) * - applies a reverse Chaikin filter * - code adapted from etch-a-ton branch (editarmature_sketch.c) */ -static void gp_stroke_simplify (tGPsdata *p) +static void gp_stroke_simplify(tGPsdata *p) { - bGPdata *gpd= p->gpd; - tGPspoint *old_points= (tGPspoint *)gpd->sbuffer; - short num_points= gpd->sbuffer_size; - short flag= gpd->sbuffer_sflag; + bGPdata *gpd = p->gpd; + tGPspoint *old_points = (tGPspoint *)gpd->sbuffer; + short num_points = gpd->sbuffer_size; + short flag = gpd->sbuffer_sflag; short i, j; /* only simplify if simplification is enabled, and we're not doing a straight line */ @@ -502,7 +502,7 @@ static void gp_stroke_simplify (tGPsdata *p) * - firstly set sbuffer to NULL, so a new one is allocated * - secondly, reset flag after, as it gets cleared auto */ - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; gp_session_validatebuffer(p); gpd->sbuffer_sflag = flag; @@ -522,19 +522,19 @@ static void gp_stroke_simplify (tGPsdata *p) int mco[2]; /* initialize values */ - co[0]= 0; - co[1]= 0; + co[0] = 0; + co[1] = 0; pressure = 0; /* using macro, calculate new point */ GP_SIMPLIFY_AVPOINT(j, -0.25f); - GP_SIMPLIFY_AVPOINT(j+1, 0.75f); - GP_SIMPLIFY_AVPOINT(j+2, 0.75f); - GP_SIMPLIFY_AVPOINT(j+3, -0.25f); + GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); /* set values for adding */ - mco[0]= (int)co[0]; - mco[1]= (int)co[1]; + mco[0] = (int)co[0]; + mco[1] = (int)co[1]; /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure); @@ -549,9 +549,9 @@ static void gp_stroke_simplify (tGPsdata *p) /* make a new stroke from the buffer data */ -static void gp_stroke_newfrombuffer (tGPsdata *p) +static void gp_stroke_newfrombuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; @@ -563,7 +563,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) * - drawing straight-lines only requires the endpoints */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) - totelem = (gpd->sbuffer_size >= 2) ? 2: gpd->sbuffer_size; + totelem = (gpd->sbuffer_size >= 2) ? 2 : gpd->sbuffer_size; else totelem = gpd->sbuffer_size; @@ -583,77 +583,77 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } /* allocate memory for a new stroke */ - gps= MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); /* copy appropriate settings for stroke */ - gps->totpoints= totelem; - gps->thickness= p->gpl->thickness; - gps->flag= gpd->sbuffer_sflag; + gps->totpoints = totelem; + gps->thickness = p->gpl->thickness; + gps->flag = gpd->sbuffer_sflag; /* allocate enough memory for a continuous array for storage points */ - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); /* set pointer to first non-initialized point */ - pt= gps->points + (gps->totpoints - totelem); + pt = gps->points + (gps->totpoints - totelem); /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only -> only endpoints */ { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; pt++; } if (totelem == 2) { /* last point if applicable */ - ptc= ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); + ptc = ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } else { - float *depth_arr= NULL; + float *depth_arr = NULL; /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - int mval[2], mval_prev[2]= {0}; + int mval[2], mval_prev[2] = {0}; int interp_depth = 0; int found_depth = 0; - depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); + depth_arr = MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { copy_v2_v2_int(mval, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0)) - ) { - interp_depth= TRUE; + if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { + interp_depth = TRUE; } else { - found_depth= TRUE; + found_depth = TRUE; } copy_v2_v2_int(mval_prev, mval); @@ -661,7 +661,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) if (found_depth == FALSE) { /* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */ - for (i=gpd->sbuffer_size-1; i >= 0; i--) + for (i = gpd->sbuffer_size - 1; i >= 0; i--) depth_arr[i] = 0.9999f; } else { @@ -670,23 +670,23 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) int first_valid = 0; int last_valid = 0; - for (i=0; i < gpd->sbuffer_size; i++) { + for (i = 0; i < gpd->sbuffer_size; i++) { if (depth_arr[i] != FLT_MAX) break; } - first_valid= i; + first_valid = i; - for (i=gpd->sbuffer_size-1; i >= 0; i--) { + for (i = gpd->sbuffer_size - 1; i >= 0; i--) { if (depth_arr[i] != FLT_MAX) break; } - last_valid= i; + last_valid = i; /* invalidate non-endpoints, so only blend between first and last */ - for (i=first_valid+1; i < last_valid; i++) - depth_arr[i]= FLT_MAX; + for (i = first_valid + 1; i < last_valid; i++) + depth_arr[i] = FLT_MAX; - interp_depth= TRUE; + interp_depth = TRUE; } if (interp_depth) { @@ -696,15 +696,15 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } - pt= gps->points; + pt = gps->points; /* convert all points (normal behavior) */ - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ - gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr+i:NULL); + gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } if (depth_arr) @@ -720,9 +720,9 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* --- 'Eraser' for 'Paint' Tool ------ */ /* eraser tool - remove segment from stroke/split stroke (after lasso inside) */ -static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) +static short gp_stroke_eraser_splitdel(bGPDframe *gpf, bGPDstroke *gps, int i) { - bGPDspoint *pt_tmp= gps->points; + bGPDspoint *pt_tmp = gps->points; bGPDstroke *gsn = NULL; /* if stroke only had two points, get rid of stroke */ @@ -739,8 +739,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == gps->totpoints - 2) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -753,8 +753,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == 0) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -766,18 +766,18 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) /* segment occurs in 'middle' of stroke, so split */ else { /* duplicate stroke, and assign 'later' data to that stroke */ - gsn= MEM_dupallocN(gps); - gsn->prev= gsn->next= NULL; + gsn = MEM_dupallocN(gps); + gsn->prev = gsn->next = NULL; BLI_insertlinkafter(&gpf->strokes, gps, gsn); - gsn->totpoints= gps->totpoints - i; - gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); - memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); + gsn->totpoints = gps->totpoints - i; + gsn->points = MEM_callocN(sizeof(bGPDspoint) * gsn->totpoints, "gp_stroke_points"); + memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint) * gsn->totpoints); /* adjust existing stroke */ - gps->totpoints= i; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); + gps->totpoints = i; + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * i); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -788,7 +788,7 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) } /* eraser tool - check if part of stroke occurs within last segment drawn by eraser */ -static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) +static short gp_stroke_eraser_strokeinside(int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) { /* simple within-radius check for now */ if (edge_inside_circle(mval[0], mval[1], rad, x0, y0, x1, y1)) @@ -800,10 +800,10 @@ static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), sho /* eraser tool - evaluation per stroke */ // TODO: this could really do with some optimization (KD-Tree/BVH?) -static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) +static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) { bGPDspoint *pt1, *pt2; - int x0=0, y0=0, x1=0, y1=0; + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int xyval[2]; int i; @@ -817,8 +817,8 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &gps->points->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0); @@ -828,31 +828,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((gps->points->x * sizex) + offsx); - y0= (int)((gps->points->y * sizey) + offsy); + x0 = (int)((gps->points->x * sizex) + offsx); + y0 = (int)((gps->points->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(gps->points->x / 100 * p->ar->winx); - y0= (int)(gps->points->y / 100 * p->ar->winy); + x0 = (int)(gps->points->x / 100 * p->ar->winx); + 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) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; } } /* do boundbox check first */ if (BLI_in_rcti(rect, x0, y0)) { /* only check if point is inside */ - if ( ((x0-mval[0])*(x0-mval[0]) + (y0-mval[1])*(y0-mval[1])) <= rad*rad ) { + if ( ((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ MEM_freeN(gps->points); BLI_freelinkN(&gpf->strokes, gps); @@ -861,22 +861,22 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } else { /* loop over the points in the stroke, checking for intersections - * - an intersection will require the stroke to be split + * - an intersection will require the stroke to be split */ - for (i=0; (i+1) < gps->totpoints; i++) { + for (i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ - pt1= gps->points + i; - pt2= gps->points + i + 1; + pt1 = gps->points + i; + pt2 = gps->points + i + 1; /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &pt1->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; project_int(p->ar, &pt2->x, xyval); - x1= xyval[0]; - y1= xyval[1]; + x1 = xyval[0]; + y1 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0); @@ -888,31 +888,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((pt1->x * sizex) + offsx); - y0= (int)((pt1->y * sizey) + offsy); + x0 = (int)((pt1->x * sizex) + offsx); + y0 = (int)((pt1->y * sizey) + offsy); - x1= (int)((pt2->x * sizex) + offsx); - y1= (int)((pt2->y * sizey) + offsy); + x1 = (int)((pt2->x * sizex) + offsx); + y1 = (int)((pt2->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(pt1->x / 100 * p->ar->winx); - y0= (int)(pt1->y / 100 * p->ar->winy); - x1= (int)(pt2->x / 100 * p->ar->winx); - y1= (int)(pt2->y / 100 * p->ar->winy); + x0 = (int)(pt1->x / 100 * p->ar->winx); + y0 = (int)(pt1->y / 100 * p->ar->winy); + x1 = (int)(pt2->x / 100 * p->ar->winx); + 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) * (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; } } @@ -920,7 +920,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(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 + * - this assumes that linewidth is irrelevant */ if (gp_stroke_eraser_strokeinside(mval, mvalo, rad, x0, y0, x1, y1)) { /* if function returns true, break this loop (as no more point to check) */ @@ -933,9 +933,9 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } /* erase strokes which fall under the eraser strokes */ -static void gp_stroke_doeraser (tGPsdata *p) +static void gp_stroke_doeraser(tGPsdata *p) { - bGPDframe *gpf= p->gpf; + bGPDframe *gpf = p->gpf; bGPDstroke *gps, *gpn; rcti rect; @@ -946,8 +946,8 @@ static void gp_stroke_doeraser (tGPsdata *p) rect.ymax = p->mval[1] + p->radius; /* loop over strokes, checking segments for intersections */ - for (gps= gpf->strokes.first; gps; gps= gpn) { - gpn= gps->next; + for (gps = gpf->strokes.first; gps; gps = gpn) { + gpn = gps->next; gp_stroke_eraser_dostroke(p, p->mval, p->mvalo, p->radius, &rect, gpf, gps); } } @@ -956,45 +956,45 @@ static void gp_stroke_doeraser (tGPsdata *p) /* Sketching Operator */ /* clear the session buffers (call this before AND after a paint operation) */ -static void gp_session_validatebuffer (tGPsdata *p) +static void gp_session_validatebuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* clear memory of buffer (or allocate it if starting a new session) */ if (gpd->sbuffer) { //printf("\t\tGP - reset sbuffer\n"); - memset(gpd->sbuffer, 0, sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX); + memset(gpd->sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX); } else { //printf("\t\tGP - allocate sbuffer\n"); - gpd->sbuffer= MEM_callocN(sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); + gpd->sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); } /* reset indices */ gpd->sbuffer_size = 0; /* reset flags */ - gpd->sbuffer_sflag= 0; + gpd->sbuffer_sflag = 0; } /* (re)init new painting data */ -static int gp_session_initdata (bContext *C, tGPsdata *p) +static int gp_session_initdata(bContext *C, tGPsdata *p) { bGPdata **gpd_ptr = NULL; - ScrArea *curarea= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *curarea = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No active view for painting\n"); return 0; } /* pass on current scene and window */ - p->scene= CTX_data_scene(C); - p->win= CTX_wm_window(C); + p->scene = CTX_data_scene(C); + p->win = CTX_wm_window(C); unit_m4(p->imat); @@ -1008,11 +1008,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) /* set current area * - must verify that region data is 3D-view (and not something else) */ - p->sa= curarea; - p->ar= ar; + p->sa = curarea; + p->ar = ar; if (ar->regiondata == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable\n"); return 0; @@ -1020,118 +1020,118 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((v3d->flag2 & V3D_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((v3d->flag2 & V3D_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_NODE: { //SpaceNode *snode= curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((snode->flag & SNODE_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((snode->flag & SNODE_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; #if 0 // XXX these other spaces will come over time... case SPACE_SEQ: { - SpaceSeq *sseq= curarea->spacedata.first; + SpaceSeq *sseq = curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; /* check that gpencil data is allowed to be drawn */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); return 0; } - if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) { - p->status= GP_STATUS_ERROR; + if ((sseq->flag & SEQ_DRAW_GPENCIL) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } } - break; + break; #endif case SPACE_IMAGE: { //SpaceImage *sima= curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); #if 0 // XXX disabled for now /* check that gpencil data is allowed to be drawn */ - if ((sima->flag & SI_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((sima->flag & SI_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_CLIP: { - SpaceClip *sc= curarea->spacedata.first; + SpaceClip *sc = curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); invert_m4_m4(p->imat, sc->unistabmat); /* custom color for new layer */ - p->custom_color[0]= 1.0f; - p->custom_color[1]= 0.0f; - p->custom_color[2]= 0.5f; - p->custom_color[3]= 0.9f; + p->custom_color[0] = 1.0f; + p->custom_color[1] = 0.0f; + p->custom_color[2] = 0.5f; + p->custom_color[3] = 0.9f; } - break; + break; /* unsupported views */ default: { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Active view not appropriate for Grease Pencil drawing\n"); return 0; } - break; + break; } /* get gp-data */ - gpd_ptr= gpencil_data_get_pointers(C, &p->ownerPtr); + gpd_ptr = gpencil_data_get_pointers(C, &p->ownerPtr); if (gpd_ptr == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Current context doesn't allow for any Grease Pencil data\n"); return 0; @@ -1139,11 +1139,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) else { /* if no existing GPencil block exists, add one */ if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); - p->gpd= *gpd_ptr; + *gpd_ptr = gpencil_data_addnew("GPencil"); + p->gpd = *gpd_ptr; } - if (ED_gpencil_session_active()==0) { + if (ED_gpencil_session_active() == 0) { /* initialize undo stack, * also, existing undo stack would make buffer drawn */ gpencil_undo_init(p->gpd); @@ -1154,20 +1154,20 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 /* set 'default' im2d_settings just in case something that uses this doesn't set it */ - p->im2d_settings.sizex= 1; - p->im2d_settings.sizey= 1; + p->im2d_settings.sizex = 1; + p->im2d_settings.sizey = 1; #endif return 1; } /* init new painting session */ -static tGPsdata *gp_session_initpaint (bContext *C) +static tGPsdata *gp_session_initpaint(bContext *C) { tGPsdata *p = NULL; /* create new context data */ - p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); + p = MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); gp_session_initdata(C, p); @@ -1176,9 +1176,9 @@ static tGPsdata *gp_session_initpaint (bContext *C) } /* cleanup after a painting session */ -static void gp_session_cleanup (tGPsdata *p) +static void gp_session_cleanup(tGPsdata *p) { - bGPdata *gpd= (p) ? p->gpd : NULL; + bGPdata *gpd = (p) ? p->gpd : NULL; /* error checking */ if (gpd == NULL) @@ -1188,36 +1188,36 @@ static void gp_session_cleanup (tGPsdata *p) if (gpd->sbuffer) { //printf("\t\tGP - free sbuffer\n"); MEM_freeN(gpd->sbuffer); - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; } /* clear flags */ - gpd->sbuffer_size= 0; - gpd->sbuffer_sflag= 0; + gpd->sbuffer_size = 0; + gpd->sbuffer_sflag = 0; } /* init new stroke */ -static void gp_paint_initstroke (tGPsdata *p, short paintmode) +static void gp_paint_initstroke(tGPsdata *p, short paintmode) { /* get active layer (or add a new one if non-existent) */ - p->gpl= gpencil_layer_getactive(p->gpd); + p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { - p->gpl= gpencil_layer_addnew(p->gpd); + p->gpl = gpencil_layer_addnew(p->gpd); if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } if (p->gpl->flag & GP_LAYER_LOCKED) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Cannot paint on locked layer\n"); return; } /* get active frame (add a new one if not matching frame) */ - p->gpf= gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); + p->gpf = gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); if (p->gpf == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No frame created (gpencil_paint_init)\n"); return; @@ -1226,7 +1226,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpf->flag |= GP_FRAME_PAINT; /* set 'eraser' for this stroke if using eraser */ - p->paintmode= paintmode; + p->paintmode = paintmode; if (p->paintmode == GP_PAINTMODE_ERASER) p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; @@ -1237,13 +1237,13 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* when drawing in the camera view, in 2D space, set the subrect */ if (!(p->gpd->flag & GP_DATA_VIEWALIGN)) { if (p->sa->spacetype == SPACE_VIEW3D) { - View3D *v3d= p->sa->spacedata.first; - RegionView3D *rv3d= p->ar->regiondata; + View3D *v3d = p->sa->spacedata.first; + RegionView3D *rv3d = p->ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */ - p->subrect= &p->subrect_data; + p->subrect = &p->subrect_data; } } } @@ -1253,7 +1253,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) switch (p->sa->spacetype) { case SPACE_VIEW3D: { - RegionView3D *rv3d= p->ar->regiondata; + RegionView3D *rv3d = p->ar->regiondata; float rvec[3]; /* get reference point for 3d space placement */ @@ -1262,17 +1262,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_3DSPACE; } - break; + break; case SPACE_NODE: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; #if 0 // XXX other spacetypes to be restored in due course case SPACE_SEQ: { - SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)p->sa->spacedata.first; int rectx, recty; float zoom, zoomx, zoomy; @@ -1280,7 +1280,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE; /* calculate zoom factor */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { zoomx = zoom * (p->scene->r.xasp / p->scene->r.yasp); zoomy = zoom; @@ -1293,20 +1293,20 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) * as it is too messy getting the ibuf (and could be too slow). This should be * a reasonable for most cases anyway. */ - rectx= (p->scene->r.size * p->scene->r.xsch) / 100; - recty= (p->scene->r.size * p->scene->r.ysch) / 100; + rectx = (p->scene->r.size * p->scene->r.xsch) / 100; + recty = (p->scene->r.size * p->scene->r.ysch) / 100; /* set offset and scale values for opertations to use */ - p->im2d_settings.sizex= (int)(zoomx * rectx); - p->im2d_settings.sizey= (int)(zoomy * recty); - p->im2d_settings.offsx= (int)((p->sa->winx-p->im2d_settings.sizex)/2 + sseq->xof); - p->im2d_settings.offsy= (int)((p->sa->winy-p->im2d_settings.sizey)/2 + sseq->yof); + p->im2d_settings.sizex = (int)(zoomx * rectx); + p->im2d_settings.sizey = (int)(zoomy * recty); + p->im2d_settings.offsx = (int)((p->sa->winx - p->im2d_settings.sizex) / 2 + sseq->xof); + p->im2d_settings.offsy = (int)((p->sa->winy - p->im2d_settings.sizey) / 2 + sseq->yof); } - break; + break; #endif case SPACE_IMAGE: { - SpaceImage *sima= (SpaceImage *)p->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first; /* only set these flags if the image editor doesn't have an image active, * otherwise user will be confused by strokes not appearing after they're drawn @@ -1321,29 +1321,29 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) else p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; case SPACE_CLIP: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; } } } /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ -static void gp_paint_strokeend (tGPsdata *p) +static void gp_paint_strokeend(tGPsdata *p) { /* for surface sketching, need to set the right OpenGL context stuff so that * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ @@ -1363,7 +1363,7 @@ static void gp_paint_strokeend (tGPsdata *p) } /* finish off stroke painting operation */ -static void gp_paint_cleanup (tGPsdata *p) +static void gp_paint_cleanup(tGPsdata *p) { /* p->gpd==NULL happens when stroke failed to initialize, * for example. when GP is hidden in current space (sergey) */ @@ -1379,9 +1379,9 @@ static void gp_paint_cleanup (tGPsdata *p) /* ------------------------------- */ -static void gpencil_draw_exit (bContext *C, wmOperator *op) +static void gpencil_draw_exit(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* clear undo stack */ gpencil_undo_finish(); @@ -1405,10 +1405,10 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) MEM_freeN(p); } - op->customdata= NULL; + op->customdata = NULL; } -static int gpencil_draw_cancel (bContext *C, wmOperator *op) +static int gpencil_draw_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ gpencil_draw_exit(C, op); @@ -1418,13 +1418,13 @@ static int gpencil_draw_cancel (bContext *C, wmOperator *op) /* ------------------------------- */ -static int gpencil_draw_init (bContext *C, wmOperator *op) +static int gpencil_draw_init(bContext *C, wmOperator *op) { tGPsdata *p; - int paintmode= RNA_enum_get(op->ptr, "mode"); + int paintmode = RNA_enum_get(op->ptr, "mode"); /* check context */ - p= op->customdata= gp_session_initpaint(C); + p = op->customdata = gp_session_initpaint(C); if ((p == NULL) || (p->status == GP_STATUS_ERROR)) { /* something wasn't set correctly in context */ gpencil_draw_exit(C, op); @@ -1439,7 +1439,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) } /* radius for eraser circle is defined in userprefs now */ - p->radius= U.gp_eraser; + p->radius = U.gp_eraser; /* everything is now setup ok */ return 1; @@ -1448,7 +1448,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) /* ------------------------------- */ /* update UI indicators of status, including cursor and header prints */ -static void gpencil_draw_status_indicators (tGPsdata *p) +static void gpencil_draw_status_indicators(tGPsdata *p) { /* header prints */ switch (p->status) { @@ -1488,7 +1488,7 @@ static void gpencil_draw_status_indicators (tGPsdata *p) /* ------------------------------- */ /* create a new stroke point at the point indicated by the painting context */ -static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) +static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) { /* handle drawing/erasing -> test for erasing first */ if (p->paintmode == GP_PAINTMODE_ERASER) { @@ -1496,14 +1496,14 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) gp_stroke_doeraser(p); /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* only add current point to buffer if mouse moved (even though we got an event, it might be just noise) */ else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ - short ok= gp_stroke_addpoint(p, p->mval, p->pressure); + short ok = gp_stroke_addpoint(p, p->mval, p->pressure); /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { @@ -1525,43 +1525,43 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) } /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } } /* handle draw event */ -static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) +static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; PointerRNA itemptr; float mousef[2]; - int tablet=0; + int tablet = 0; /* convert from window-space to area-space mouse coordintes */ // NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... - p->mval[0]= event->mval[0] + 1; - p->mval[1]= event->mval[1] + 1; + p->mval[0] = event->mval[0] + 1; + p->mval[1] = event->mval[1] + 1; /* handle pressure sensitivity (which is supplied by tablets) */ if (event->custom == EVT_DATA_TABLET) { - wmTabletData *wmtab= event->customdata; + wmTabletData *wmtab = event->customdata; - tablet= (wmtab->Active != EVT_TABLET_NONE); - p->pressure= wmtab->Pressure; + tablet = (wmtab->Active != EVT_TABLET_NONE); + p->pressure = wmtab->Pressure; //if (wmtab->Active == EVT_TABLET_ERASER) - // TODO... this should get caught by the keymaps which call drawing in the first place + // TODO... this should get caught by the keymaps which call drawing in the first place } else - p->pressure= 1.0f; + p->pressure = 1.0f; /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ RNA_collection_add(op->ptr, "stroke", &itemptr); - mousef[0]= p->mval[0]; - mousef[1]= p->mval[1]; + mousef[0] = p->mval[0]; + mousef[1] = p->mval[1]; RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "pressure", p->pressure); RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN)); @@ -1570,9 +1570,9 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch .. @@ -1591,7 +1591,7 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) /* ------------------------------- */ /* operator 'redo' (i.e. after changing some properties, but also for repeat last) */ -static int gpencil_draw_exec (bContext *C, wmOperator *op) +static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; @@ -1604,14 +1604,14 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; //printf("\tGP - Start redrawing stroke\n"); /* loop over the stroke RNA elements recorded (i.e. progress of mouse movement), * setting the relevant values in context at each step, then applying */ - RNA_BEGIN (op->ptr, itemptr, "stroke") + RNA_BEGIN(op->ptr, itemptr, "stroke") { float mousef[2]; @@ -1621,7 +1621,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) RNA_float_get_array(&itemptr, "mouse", mousef); p->mval[0] = (int)mousef[0]; p->mval[1] = (int)mousef[1]; - p->pressure= RNA_float_get(&itemptr, "pressure"); + p->pressure = RNA_float_get(&itemptr, "pressure"); if (RNA_boolean_get(&itemptr, "is_start")) { /* if first-run flag isn't set already (i.e. not true first stroke), @@ -1638,9 +1638,9 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* apply this data as necessary now (as per usual) */ @@ -1654,7 +1654,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) gpencil_draw_exit(C, op); /* refreshes */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work /* done */ return OPERATOR_FINISHED; @@ -1663,10 +1663,10 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) /* ------------------------------- */ /* start of interactive drawing part of operator */ -static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p = NULL; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); @@ -1680,7 +1680,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; // TODO: set any additional settings that we can take from the events? // TODO? if tablet is erasing, force eraser to be on? @@ -1694,7 +1694,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* set cursor */ if (p->paintmode == GP_PAINTMODE_ERASER) - WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor + WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor else WM_cursor_modal(win, BC_PAINTBRUSHCURSOR); @@ -1705,7 +1705,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) if (event->type) { /* hotkey invoked - start drawing */ //printf("\tGP - set first spot\n"); - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ gpencil_draw_apply_event(op, event); @@ -1715,7 +1715,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) //printf("\tGP - hotkey invoked... waiting for click-drag\n"); } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -1724,11 +1724,11 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ static int gpencil_area_exists(bContext *C, ScrArea *satest) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - if (sa==satest) + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (sa == satest) return 1; } @@ -1737,14 +1737,14 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest) static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ if (CTX_wm_area(C) != p->sa) { printf("\t\t\tGP - wrong area execution abort!\n"); - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; } //printf("\t\tGP - start stroke\n"); @@ -1757,14 +1757,14 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) gp_paint_initstroke(p, p->paintmode); if (p->status != GP_STATUS_ERROR) - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; return op->customdata; } static void gpencil_stroke_end(wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; gp_paint_cleanup(p); @@ -1772,17 +1772,17 @@ static void gpencil_stroke_end(wmOperator *op) gp_session_cleanup(p); - p->status= GP_STATUS_IDLING; + p->status = GP_STATUS_IDLING; - p->gpd= NULL; - p->gpl= NULL; - p->gpf= NULL; + p->gpd = NULL; + p->gpl = NULL; + p->gpf = NULL; } /* events handling during interactive drawing part of operator */ -static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ // if (event->type == NDOF_MOTION) @@ -1803,7 +1803,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) { /* exit() ends the current stroke before cleaning up */ //printf("\t\tGP - end of paint op + end of stroke\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } @@ -1811,7 +1811,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) { /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { - int sketch= 0; + int sketch = 0; /* basically, this should be mouse-button up = end stroke * BUT what happens next depends on whether we 'painting sessions' is enabled */ @@ -1828,17 +1828,17 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; /* stroke could be smoothed, send notifier to refresh screen */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); } else { //printf("\t\tGP - end of stroke + op\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } } else if (event->val == KM_PRESS) { /* not painting, so start stroke (this should be mouse-button down) */ - p= gpencil_stroke_begin(C, op); + p = gpencil_stroke_begin(C, op); if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; @@ -1878,8 +1878,8 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ - if (0==gpencil_area_exists(C, p->sa)) - estate= OPERATOR_CANCELLED; + if (0 == gpencil_area_exists(C, p->sa)) + estate = OPERATOR_CANCELLED; else /* update status indicators - cursor, header, etc. */ gpencil_draw_status_indicators(p); @@ -1889,14 +1889,14 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_FINISHED: /* one last flush before we're done */ gpencil_draw_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work break; case OPERATOR_CANCELLED: gpencil_draw_exit(C, op); break; - case OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH: + case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); break; @@ -1931,7 +1931,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot) ot->poll = gpencil_draw_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* settings for drawing */ RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements"); diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 36624b88a9f..61f7e1bb86f 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -46,7 +46,7 @@ #include "gpencil_intern.h" -#define MAXUNDONAME 64 +#define MAXUNDONAME 64 typedef struct bGPundonode { struct bGPundonode *next, *prev; @@ -65,25 +65,25 @@ int ED_gpencil_session_active(void) int ED_undo_gpencil_step(bContext *C, int step, const char *name) { - bGPdata **gpd_ptr= NULL, *new_gpd= NULL; + bGPdata **gpd_ptr = NULL, *new_gpd = NULL; - gpd_ptr= gpencil_data_get_pointers(C, NULL); + gpd_ptr = gpencil_data_get_pointers(C, NULL); - if (step==1) { /* undo */ + if (step == 1) { /* undo */ //printf("\t\tGP - undo step\n"); if (cur_node->prev) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->prev; - new_gpd= cur_node->gpd; + cur_node = cur_node->prev; + new_gpd = cur_node->gpd; } } } - else if (step==-1) { + else if (step == -1) { //printf("\t\tGP - redo step\n"); if (cur_node->next) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->next; - new_gpd= cur_node->gpd; + cur_node = cur_node->next; + new_gpd = cur_node->gpd; } } } @@ -91,24 +91,24 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) if (new_gpd) { if (gpd_ptr) { if (*gpd_ptr) { - bGPdata *gpd= *gpd_ptr; + bGPdata *gpd = *gpd_ptr; bGPDlayer *gpl, *gpld; free_gpencil_layers(&gpd->layers); /* copy layers */ - gpd->layers.first= gpd->layers.last= NULL; + gpd->layers.first = gpd->layers.last = NULL; - for (gpl= new_gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ - gpld= gpencil_layer_duplicate(gpl); + gpld = gpencil_layer_duplicate(gpl); BLI_addtail(&gpd->layers, gpld); } } } } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -126,41 +126,41 @@ void gpencil_undo_push(bGPdata *gpd) if (cur_node) { /* remove all un-done nodes from stack */ - undo_node= cur_node->next; + undo_node = cur_node->next; while (undo_node) { - bGPundonode *next_node= undo_node->next; + bGPundonode *next_node = undo_node->next; - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); BLI_freelinkN(&undo_nodes, undo_node); - undo_node= next_node; + undo_node = next_node; } } /* create new undo node */ - undo_node= MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); - undo_node->gpd= gpencil_data_duplicate(gpd); + undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); + undo_node->gpd = gpencil_data_duplicate(gpd); - cur_node= undo_node; + cur_node = undo_node; BLI_addtail(&undo_nodes, undo_node); } void gpencil_undo_finish(void) { - bGPundonode *undo_node= undo_nodes.first; + bGPundonode *undo_node = undo_nodes.first; while (undo_node) { - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); - undo_node= undo_node->next; + undo_node = undo_node->next; } BLI_freelistN(&undo_nodes); - cur_node= NULL; + cur_node = NULL; } diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h index 9b20553e0cc..64b57f6858b 100644 --- a/source/blender/editors/include/ED_datafiles.h +++ b/source/blender/editors/include/ED_datafiles.h @@ -102,6 +102,9 @@ extern char datatoc_layer_png[]; extern int datatoc_lighten_png_size; extern char datatoc_lighten_png[]; +extern int datatoc_mask_png_size; +extern char datatoc_mask_png[]; + extern int datatoc_mix_png_size; extern char datatoc_mix_png[]; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index afb14191797..490a8830d3a 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -190,7 +190,7 @@ int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[]); /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); +KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]); /* for RNA type registrations... */ void ANIM_keyingset_info_register(KeyingSetInfo *ksi); @@ -292,7 +292,7 @@ short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); * Checks whether a keyframe exists for the given ID-block one the given frame. * - It is recommended to call this method over the other keyframe-checkers directly, * in case some detail of the implementation changes... - * - frame: the value of this is quite often result of BKE_curframe() + * - frame: the value of this is quite often result of BKE_scene_frame_get() */ short id_frame_has_keyframe(struct ID *id, float frame, short filter); diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index 2df699255be..e8593e9b60d 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -32,6 +32,7 @@ struct ARegion; struct bContext; +struct MultiresModifierData; struct Object; struct RegionView3D; struct wmKeyConfig; @@ -44,14 +45,16 @@ void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar, void ED_sculpt_force_update(struct bContext *C); float *ED_sculpt_get_last_stroke(struct Object *ob); int ED_sculpt_minmax(struct bContext *C, float *min, float *max); +void ED_sculpt_mask_layers_ensure(struct Object *ob, + struct MultiresModifierData *mmd); /* paint_ops.c */ void ED_operatortypes_paint(void); void ED_keymap_paint(struct wmKeyConfig *keyconf); /* paint_undo.c */ -#define UNDO_PAINT_IMAGE 0 -#define UNDO_PAINT_MESH 1 +#define UNDO_PAINT_IMAGE 0 +#define UNDO_PAINT_MESH 1 int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name); void ED_undo_paint_free(void); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 4b614085f8e..e3759ef5fde 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -304,6 +304,8 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); +void ED_view3D_lock_clear(struct View3D *v3d); + struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); void ED_view3D_background_image_clear(struct View3D *v3d); diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index c1fa45a10a1..cdc4c492d56 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -974,6 +974,7 @@ DEF_ICON(BRUSH_GRAB) DEF_ICON(BRUSH_INFLATE) DEF_ICON(BRUSH_LAYER) DEF_ICON(BRUSH_LIGHTEN) +DEF_ICON(BRUSH_MASK) DEF_ICON(BRUSH_MIX) DEF_ICON(BRUSH_MULTIPLY) DEF_ICON(BRUSH_NUDGE) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c7fb523dcba..0c13b5de02e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -509,9 +509,9 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; - if(line->flag & UI_SELECT) - glColor3ub(100,100,100); - else if(hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) + if (line->flag & UI_SELECT) + glColor3ub(100, 100, 100); + else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else glColor3ub(0, 0, 0); @@ -528,9 +528,9 @@ static void ui_draw_links(uiBlock *block) // As we go, remember if we see any active or selected lines. int foundselectline = 0; int foundactiveline = 0; - 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) { + 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 @@ -545,9 +545,9 @@ static void ui_draw_links(uiBlock *block) // Draw any active lines (lines with either button being hovered over). // Do this last so they appear on top of inactive lines. if (foundactiveline) { - 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) { + 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, !foundselectline); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4cc478aa7c4..94ebdb7c0b9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4557,7 +4557,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); /* XXX inactive option, not for public! */ #if 0 @@ -4573,7 +4573,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); WM_operator_properties_create(&ptr_props, "WM_OT_doc_edit"); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index e20b60cd77e..e9186aff666 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -491,6 +491,7 @@ static void init_brush_icons(void) INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate); INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer); INIT_BRUSH_ICON(ICON_BRUSH_LIGHTEN, lighten); + INIT_BRUSH_ICON(ICON_BRUSH_MASK, mask); INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix); INIT_BRUSH_ICON(ICON_BRUSH_MULTIPLY, multiply); INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a0935e7abdd..9e073055fc3 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -99,48 +99,48 @@ typedef enum { } uiWidgetTypeEnum; /* panel limits */ -#define UI_PANEL_MINX 100 -#define UI_PANEL_MINY 70 +#define UI_PANEL_MINX 100 +#define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 /* use when the button is pressed */ -#define UI_SCROLLED 2 /* temp hidden, scrolled away */ -#define UI_ACTIVE 4 -#define UI_HAS_ICON 8 -#define UI_TEXTINPUT 16 -#define UI_HIDDEN 32 +#define UI_SELECT 1 /* use when the button is pressed */ +#define UI_SCROLLED 2 /* temp hidden, scrolled away */ +#define UI_ACTIVE 4 +#define UI_HAS_ICON 8 +#define UI_TEXTINPUT 16 +#define UI_HIDDEN 32 /* warn: rest of uiBut->flag in UI_interface.h */ /* internal panel drawing defines */ -#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ -#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ +#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ +#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ /* panel->flag */ -#define PNL_SELECT 1 -#define PNL_CLOSEDX 2 -#define PNL_CLOSEDY 4 -#define PNL_CLOSED 6 +#define PNL_SELECT 1 +#define PNL_CLOSEDX 2 +#define PNL_CLOSEDY 4 +#define PNL_CLOSED 6 /*#define PNL_TABBED 8*/ /*UNUSED*/ -#define PNL_OVERLAP 16 +#define PNL_OVERLAP 16 /* Button text selection: * extension direction, selextend, inside ui_do_but_TEX */ -#define EXTEND_LEFT 1 -#define EXTEND_RIGHT 2 +#define EXTEND_LEFT 1 +#define EXTEND_RIGHT 2 /* for scope resize zone */ -#define SCOPE_RESIZE_PAD 9 +#define SCOPE_RESIZE_PAD 9 -typedef struct uiLinkLine { /* only for draw/edit */ +typedef struct uiLinkLine { /* only for draw/edit */ struct uiLinkLine *next, *prev; struct uiBut *from, *to; short flag, pad; } uiLinkLine; typedef struct { - void **poin; /* pointer to original pointer */ - void ***ppoin; /* pointer to original pointer-array */ - short *totlink; /* if pointer-array, here is the total */ + void **poin; /* pointer to original pointer */ + void ***ppoin; /* pointer to original pointer-array */ + short *totlink; /* if pointer-array, here is the total */ short maxlink, pad; short fromcode, tocode; @@ -178,8 +178,8 @@ struct uiBut { /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */ #if 0 - void (*embossfunc)(int , int , float, float, float, float, float, int); - void (*sliderfunc)(int , float, float, float, float, float, float, int); + void (*embossfunc)(int, int, float, float, float, float, float, int); + void (*sliderfunc)(int, float, float, float, float, float, float, int); #endif uiButCompleteFunc autocomplete_func; @@ -245,7 +245,7 @@ struct uiBut { void *editcoba; void *editcumap; - /* pointer back */ + /* pointer back */ uiBlock *block; }; @@ -268,7 +268,7 @@ struct uiBlock { float minx, miny, maxx, maxy; float aspect; - int puphash; // popup menu hash for memory + int puphash; /* popup menu hash for memory */ uiButHandleFunc func; void *func_arg1; @@ -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? + 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 + float xofs, yofs; // offset to parent button + int dobounds, mx, my; // for doing delayed + int bounds, minbounds; // for doing delayed - rctf safety; // pulldowns, to detect outside, can differ per case how it is created - ListBase saferct; // uiSafetyRct list + rctf safety; // pulldowns, to detect outside, can differ per case how it is created + ListBase saferct; // uiSafetyRct list - uiPopupBlockHandle *handle; // handle + uiPopupBlockHandle *handle; // handle - struct wmOperator *ui_operator;// use so presets can find the operator, - // across menus and from nested popups which fail for operator context. + struct wmOperator *ui_operator; // use so presets can find the operator, + // across menus and from nested popups which fail for operator context. - void *evil_C; // XXX hack for dynamic operator enums + 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 + 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 { @@ -425,12 +425,12 @@ void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); void ui_but_search_test(uiBut *but); -typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); +typedef uiBlock * (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); + uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiMenuCreateFunc create_func, void *arg, char *str); + uiMenuCreateFunc create_func, void *arg, char *str); void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); @@ -466,14 +466,14 @@ extern int ui_button_is_active(struct ARegion *ar); void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); -uiWidgetColors* ui_tooltip_get_theme(void); -void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +uiWidgetColors *ui_tooltip_get_theme(void); +void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); -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); void ui_draw_link_bezier(rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); - /* theme color init */ +/* theme color init */ struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3c913b26dec..958ee9f5420 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -857,7 +857,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char PointerRNA ptr; PropertyRNA *prop; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -888,7 +888,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char EnumPropertyItem *item; int value, free; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -926,7 +926,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); @@ -939,7 +939,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); @@ -952,7 +952,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); @@ -965,7 +965,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); @@ -1611,7 +1611,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); if (!ot->srna) { ui_item_disabled(layout, opname); @@ -1776,12 +1776,12 @@ static void ui_litem_layout_row(uiLayout *litem) /* align right/center */ offset = 0; if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { - if (freew > 0 && freew < w - fixedw) - offset = (w - fixedw) - freew; + if (freew + fixedw > 0 && freew + fixedw < w) + offset = w - (fixedw + freew); } else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) { - if (freew > 0 && freew < w - fixedw) - offset = ((w - fixedw) - freew) / 2; + if (freew + fixedw > 0 && freew + fixedw < w) + offset = (w - (fixedw + freew)) / 2; } /* position item */ @@ -2726,8 +2726,8 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p void uiLayoutContextCopy(uiLayout *layout, bContextStore *context) { - uiBlock *block= layout->root->block; - layout->context= CTX_store_add_all(&block->contexts, context); + uiBlock *block = layout->root->block; + layout->context = CTX_store_add_all(&block->contexts, context); } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 93546d74c1b..6d2ac388374 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -234,12 +234,32 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot) /* Copy Data Path Operator ------------------------ */ +static int copy_data_path_button_poll(bContext *C) +{ + PointerRNA ptr; + PropertyRNA *prop; + char *path; + int index; + + uiContextActiveProperty(C, &ptr, &prop, &index); + + if (ptr.id.data && ptr.data && prop) { + path = RNA_path_from_ID_to_property(&ptr, prop); + + if (path) { + MEM_freeN(path); + return 1; + } + } + + return 0; +} + static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr; PropertyRNA *prop; char *path; - int success = 0; int index; /* try to create driver using property retrieved from UI */ @@ -251,11 +271,11 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) if (path) { WM_clipboard_text_set(path, FALSE); MEM_freeN(path); + return OPERATOR_FINISHED; } } - /* since we're just copying, we don't really need to do anything else...*/ - return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } static void UI_OT_copy_data_path_button(wmOperatorType *ot) @@ -267,7 +287,7 @@ static void UI_OT_copy_data_path_button(wmOperatorType *ot) /* callbacks */ ot->exec = copy_data_path_button_exec; - //op->poll= ??? // TODO: need to have some valid property before this can be done + ot->poll = copy_data_path_button_poll; /* flags */ ot->flag = OPTYPE_REGISTER; @@ -507,7 +527,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) char *str; /* create new text-block to write to */ - txt = add_empty_text("Recent Reports"); + txt = BKE_text_add("Recent Reports"); /* convert entire list to a display string, and add this to the text-block * - if commandline debug option enabled, show debug reports too @@ -516,7 +536,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO); if (str) { - write_text(txt, str); + BKE_text_write(txt, str); MEM_freeN(str); return OPERATOR_FINISHED; @@ -652,7 +672,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, } if (text == NULL) { - text = add_text(filepath, bmain->name); + text = BKE_text_load(filepath, bmain->name); } if (text == NULL) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 36e8dedee97..e4ea8bf08c5 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -836,7 +836,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ - uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + uiBlockSetButLock(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; @@ -954,7 +954,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) // if there are problems because of this, then rna needs changed update functions. // // object_test_constraints(ob); - // if (ob->pose) update_pose_constraint_flags(ob->pose); + // if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -970,7 +970,7 @@ static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v) /* draw panel showing settings for a constraint */ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraintTypeInfo *cti; uiBlock *block; uiLayout *result = NULL, *col, *box, *row; @@ -2151,7 +2151,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); ma = give_current_material(ob, index + 1); - if (ma && !scene_use_new_shading_nodes(scene)) { + if (ma && !BKE_scene_use_new_shading_nodes(scene)) { manode = give_node_material(ma); if (manode) { char str[MAX_ID_NAME + 12]; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cfc9e11879e..5f6384d6b24 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -67,7 +67,7 @@ * use in object mode when selecting faces (while painting) */ void paintface_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MPoly *polys, *mp_orig; MFace *faces; @@ -166,7 +166,7 @@ void paintface_hide(Object *ob, const int unselected) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -195,7 +195,7 @@ void paintface_reveal(Object *ob) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -325,7 +325,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] Mesh *me; unsigned int index = 0; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (mode == 0 || mode == 1) { @@ -347,7 +347,7 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { @@ -410,7 +410,7 @@ int paintface_minmax(Object *ob, float r_min[3], float r_max[3]) int a, b, ok = FALSE; float vec[3], bmat[3][3]; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!me || !me->mtpoly) return ok; copy_m3_m4(bmat, ob->obmat); @@ -459,7 +459,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) MEdge *med; int a, b; - me = get_mesh(OBACT); + me = BKE_mesh_from_object(OBACT); if (me == 0 || me->totpoly == 0) return; if (mode == 0) @@ -516,7 +516,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in unsigned int a, index; /* Get the face under the cursor */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!facesel_face_pick(C, me, ob, mval, &index, 1)) return 0; @@ -567,7 +567,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) int sx = rect->xmax - rect->xmin + 1; int sy = rect->ymax - rect->ymin + 1; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0 || sx * sy <= 0) return OPERATOR_CANCELLED; @@ -629,7 +629,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) * use in object mode when selecting vertices (while painting) */ void paintvert_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MVert *dm_mvert, *dm_mv; int *index_array = NULL; @@ -668,7 +668,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) MVert *mvert; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 57d7869d3db..5a99ddb9332 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2785,7 +2785,7 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut)) DerivedMesh *cage, *final; SmallHash shash; void *data[3]; - const short only_select = RNA_boolean_get(op->ptr, "only_select"); + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); /* alloc new customdata */ kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), "knifetool Modal Op Data"); @@ -3086,5 +3086,5 @@ void MESH_OT_knife_tool(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "use_occlude_geometry", TRUE, "Occlude Geometry", "Only cut the front most geometry"); - RNA_def_boolean(ot->srna, "only_select", FALSE, "Only Selected", "Only cut selected geometry"); + RNA_def_boolean(ot->srna, "only_selected", FALSE, "Only Selected", "Only cut selected geometry"); } diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 0b65cce20d7..7298153791e 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -492,7 +492,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->val == KM_RELEASE) break; - cuts = MAX2(cuts - 1, 1); + cuts = MAX2(cuts - 1, 0); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); show_cuts = TRUE; @@ -519,12 +519,15 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) /* using the keyboard to input the number of cuts */ if (event->val == KM_PRESS) { - float value; + /* init as zero so backspace clears */ + float value = 0.0f; if (handleNumInput(&lcd->num, event)) { applyNumInput(&lcd->num, &value); - cuts = CLAMPIS(value, 1, 130); + /* allow zero so you can backspace and type in a value + * otherwise 1 as minimum would make more sense */ + cuts = CLAMPIS(value, 0, 130); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7e89025d528..538087b8e46 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -150,7 +150,7 @@ static void draw_triangulated(int mcords[][2], short tot) } /* do the fill */ - filldisplist(&lb, &lb, 0); + BKE_displist_fill(&lb, &lb, 0); /* do the draw */ dl = lb.first; /* filldisplist adds in head of list */ @@ -170,7 +170,7 @@ static void draw_triangulated(int mcords[][2], short tot) glEnd(); } - freedisplist(&lb); + BKE_displist_free(&lb); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 533b2ca12de..645b2d9cb68 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -66,6 +66,8 @@ #include "RE_render_ext.h" +#include "UI_interface.h" + #include "mesh_intern.h" /* allow accumulated normals to form a new direction but don't @@ -485,7 +487,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe * automatically building this data if invalid. Or something. */ // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - object_handle_update(scene, obedit); + BKE_object_handle_update(scene, obedit); /* individual faces? */ // BIF_TransformSetUndo("Extrude"); @@ -614,7 +616,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); + EDBM_update_generic(C, em, TRUE); return OPERATOR_FINISHED; } @@ -1251,6 +1253,7 @@ void MESH_OT_edge_split(wmOperatorType *ot) /* identifiers */ ot->name = "Edge Split"; ot->idname = "MESH_OT_edge_split"; + ot->description = "Split selected edges so that each neighbor face gets its own copy"; /* api callbacks */ ot->exec = edbm_edge_split_exec; @@ -3060,6 +3063,7 @@ void MESH_OT_beautify_fill(wmOperatorType *ot) /* identifiers */ ot->name = "Beautify Fill"; ot->idname = "MESH_OT_beautify_fill"; + ot->description = "Rearrange some faces to try to get less degenerated geometry"; /* api callbacks */ ot->exec = edbm_beautify_fill_exec; @@ -3657,393 +3661,577 @@ void MESH_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); } -/* qsort routines. not sure how to make these - * work, since we aren't using linked lists for - * geometry anymore. might need a sort of "swap" - * function for bmesh elements. */ - -/* TODO All this section could probably use a refresh... - * face code works in object mode, does everything in one op, while vert uses several... - */ - -typedef struct xvertsort { - int x; /* X screen-coordinate */ - int org_idx; /* Original index of this vertex _in the mempool_ */ -} xvertsort; - +/****************************************************************************** + * qsort routines. + * Now unified, for vertices/edges/faces. */ -static int vergxco(const void *v1, const void *v2) -{ - const xvertsort *x1 = v1, *x2 = v2; +enum { + SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */ + SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */ + SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */ + SRT_MATERIAL, /* Face only: use mat number. */ + SRT_SELECTED, /* Move selected elements in first, without modifying + * relative order of selected and unselected elements. */ + SRT_RANDOMIZE, /* Randomize selected elements. */ + SRT_REVERSE, /* Reverse current order of selected elements. */ +}; - /* We move unchanged vertices (org_idx < 0) at the begining of the sorted list. */ - if (x1->org_idx >= 0 && x2->org_idx >= 0) - return (x1->x > x2->x) - (x1->x < x2->x); - return (x2->org_idx < 0) - (x1->org_idx < 0); -} +typedef struct bmelemsort { + float srt; /* Sort factor */ + int org_idx; /* Original index of this element _in its mempool_ */ +} bmelemsort; -static void xsortvert_flag__doSetX(void *userData, BMVert *UNUSED(eve), int x, int UNUSED(y), int index) +static int bmelemsort_comp(const void *v1, const void *v2) { - xvertsort *sortblock = userData; + const bmelemsort *x1 = v1, *x2 = v2; - sortblock[index].x = x; + return (x1->srt > x2->srt) - (x1->srt < x2->srt); } -/* all verts with (flag & 'flag') are sorted */ -static void xsortvert_flag(bContext *C, int flag) +/* Reorders vertices/edges/faces using a given methods. Loops are not supported. */ +static void sort_bmelem_flag(bContext *C, const int types, const int flag, const int action, + const int reverse, const unsigned int seed) { + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_edit_object(C); ViewContext vc; BMEditMesh *em; BMVert *ve; + BMEdge *ed; + BMFace *fa; BMIter iter; - xvertsort *sortblock; - int *unchangedblock, *vmap; - int totvert, sorted = 0, unchanged = 0, i; + + /* In all five elements below, 0 = vertices, 1 = edges, 2 = faces. */ + /* Just to mark protected elements. */ + char *pblock[3] = {NULL, NULL, NULL}, *pb; + bmelemsort *sblock[3] = {NULL, NULL, NULL}, *sb; + int *map[3] = {NULL, NULL, NULL}, *mp; + int totelem[3] = {0, 0, 0}, tot; + int affected[3] = {0, 0, 0}, aff; + int i, j; + + if (!(types && flag && action)) + return; em_setup_viewcontext(C, &vc); em = vc.em; - totvert = em->bm->totvert; + if (types & BM_VERT) + totelem[0] = em->bm->totvert; + if (types & BM_EDGE) + totelem[1] = em->bm->totedge; + if (types & BM_FACE) + totelem[2] = em->bm->totface; - sortblock = MEM_callocN(sizeof(xvertsort) * totvert, "xsort sorted"); - /* Stores unchanged verts, will be reused as final old2new vert mapping... */ - unchangedblock = MEM_callocN(sizeof(int) * totvert, "xsort unchanged"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - sortblock[i].org_idx = i; - sorted++; - } - else { - unchangedblock[unchanged++] = i; - sortblock[i].org_idx = -1; - } - } -/* printf("%d verts: %d to be sorted, %d unchanged…\n", totvert, sorted, unchanged);*/ - if (sorted == 0) { - MEM_freeN(sortblock); - MEM_freeN(unchangedblock); - return; - } + if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) { + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; + int coidx = (action == SRT_VIEW_ZAXIS) ? 2 : 0; - ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - mesh_foreachScreenVert(&vc, xsortvert_flag__doSetX, sortblock, V3D_CLIP_TEST_OFF); + mult_m4_m4m4(mat, rv3d->viewmat, ob->obmat); /* Apply the view matrix to the object matrix. */ - qsort(sortblock, totvert, sizeof(xvertsort), vergxco); + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); - /* Convert sortblock into an array mapping old idx to new. */ - vmap = unchangedblock; - unchangedblock = NULL; - if (unchanged) { - unchangedblock = MEM_mallocN(sizeof(int) * unchanged, "xsort unchanged"); - memcpy(unchangedblock, vmap, unchanged * sizeof(int)); - } - for (i = totvert; i--; ) { - if (i < unchanged) - vmap[unchangedblock[i]] = i; - else - vmap[sortblock[i].org_idx] = i; - } + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + float co[3]; + mul_v3_m4v3(co, mat, ve->co); - MEM_freeN(sortblock); - if (unchangedblock) - MEM_freeN(unchangedblock); + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } + } - BM_mesh_remap(em->bm, vmap, NULL, NULL); + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); - MEM_freeN(vmap); -} + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); + mul_m4_v3(mat, co); -static int edbm_vertices_sort_exec(bContext *C, wmOperator *UNUSED(op)) -{ - xsortvert_flag(C, BM_ELEM_SELECT); - return OPERATOR_FINISHED; -} + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } + } -void MESH_OT_vertices_sort(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Vertex Sort"; - ot->description = "Sort vertex order"; - ot->idname = "MESH_OT_vertices_sort"; + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); - /* api callbacks */ - ot->exec = edbm_vertices_sort_exec; + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); + mul_m4_v3(mat, co); - ot->poll = EM_view3d_poll; /* uses view relative X axis to sort verts */ + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } + } + } - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} + else if (action == SRT_CURSOR_DISTANCE) { + View3D *v3d = CTX_wm_view3d(C); + float cur[3]; + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; -/* ********************** SORT FACES ******************* */ + if (v3d && v3d->localvd) + copy_v3_v3(cur, v3d->cursor); + else + copy_v3_v3(cur, scene->cursor); + invert_m4_m4(mat, ob->obmat); + mul_m4_v3(mat, cur); + + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = len_squared_v3v3(cur, ve->co) * fact; + } + else { + pb[i] = TRUE; + } + } + } -static void permutate(void *list, int num, int size, int *index) -{ - void *buf; - int len; - int i; + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); - len = num * size; + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); - buf = MEM_mallocN(len, "permutate"); - memcpy(buf, list, len); - - for (i = 0; i < num; i++) { - memcpy((char *)list + (i * size), (char *)buf + (index[i] * size), size); - } - MEM_freeN(buf); -} + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } -/* sort faces on view axis */ -static float *face_sort_floats; -static int float_sort(const void *v1, const void *v2) -{ - float x1, x2; - - x1 = face_sort_floats[((int *) v1)[0]]; - x2 = face_sort_floats[((int *) v2)[0]]; - - if (x1 > x2) return 1; - else if (x1 < x2) return -1; - return 0; -} + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); -static int edbm_sort_faces_exec(bContext *C, wmOperator *op) -{ - RegionView3D *rv3d = ED_view3d_context_rv3d(C); - View3D *v3d = CTX_wm_view3d(C); - Object *ob = CTX_data_edit_object(C); - Scene *scene = CTX_data_scene(C); - Mesh *me; - CustomDataLayer *layer; - int i, j, *index; - int event; - float reverse = 1; - // XXX int ctrl = 0; - - if (!v3d) return OPERATOR_CANCELLED; - - /* This operator work in Object Mode, not in edit mode. - * After talk with Campbell we agree that there is no point to port this to EditMesh right now. - * so for now, we just exit_editmode and enter_editmode at the end of this function. - */ - ED_object_exit_editmode(C, EM_FREEDATA); + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); - me = ob->data; - if (me->totpoly == 0) { - ED_object_enter_editmode(C, 0); - return OPERATOR_FINISHED; + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } } - event = RNA_enum_get(op->ptr, "type"); - - // XXX - //if (ctrl) - // reverse = -1; - - /* create index list */ - index = (int *)MEM_mallocN(sizeof(int) * me->totpoly, "sort faces"); - for (i = 0; i < me->totpoly; i++) { - index[i] = i; + /* Faces only! */ + else if (action == SRT_MATERIAL && totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + /* Reverse materials' order, not order of faces inside each mat! */ + /* Note: cannot use totcol, as mat_nr may sometimes be greater... */ + float srt = reverse ? (float)(MAXMAT - fa->mat_nr) : (float)fa->mat_nr; + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + /* Multiplying with totface and adding i ensures us we keep current order for all faces of same mat. */ + sb[affected[2]++].srt = srt * ((float)totelem[2]) + ((float)i); +/* printf("e: %d; srt: %f; final: %f\n", i, srt, srt * ((float)totface) + ((float)i));*/ + } + else { + pb[i] = TRUE; + } + } } - - face_sort_floats = (float *) MEM_mallocN(sizeof(float) * me->totpoly, "sort faces float"); - /* sort index list instead of faces itself - * and apply this permutation to all face layers - */ - if (event == 5) { - /* Random */ - for (i = 0; i < me->totpoly; i++) { - face_sort_floats[i] = BLI_frand(); + else if (action == SRT_SELECTED) { + int *tbuf[3] = {NULL, NULL, NULL}, *tb; + + if (totelem[0]) { + tb = tbuf[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert tbuf"); + mp = map[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert map"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + mp[affected[0]++] = i; + } + else { + *tb = i; + tb++; + } + } } - qsort(index, me->totpoly, sizeof(int), float_sort); - } - else { - MPoly *mp; - MLoop *ml; - MVert *mv; - float vec[3]; - float mat[4][4]; - float cur[3]; - - if (event == 1) - mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */ - else if (event == 2) { /* sort from cursor */ - if (v3d && v3d->localvd) { - copy_v3_v3(cur, v3d->cursor); + + if (totelem[1]) { + tb = tbuf[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge tbuf"); + mp = map[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge map"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + mp[affected[1]++] = i; } else { - copy_v3_v3(cur, scene->cursor); + *tb = i; + tb++; + } + } + } + + if (totelem[2]) { + tb = tbuf[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face tbuf"); + mp = map[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face map"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + mp[affected[2]++] = i; + } + else { + *tb = i; + tb++; + } } - invert_m4_m4(mat, OBACT->obmat); - mul_m4_v3(mat, cur); } - - mp = me->mpoly; - for (i = 0; i < me->totpoly; i++, mp++) { - if (event == 3) { - face_sort_floats[i] = ((float)mp->mat_nr) * reverse; + for (j = 3; j--;) { + int tot = totelem[j]; + int aff = affected[j]; + tb = tbuf[j]; + mp = map[j]; + if (!(tb && mp)) + continue; + if (ELEM(aff, 0, tot)) { + MEM_freeN(tb); + MEM_freeN(mp); + map[j] = NULL; + continue; } - else if (event == 4) { - /* selected first */ - if (mp->flag & ME_FACE_SEL) - face_sort_floats[i] = 0.0; - else - face_sort_floats[i] = reverse; + if (reverse) { + memcpy(tb + (tot - aff), mp, aff * sizeof(int)); } else { - /* find the face's center */ - ml = me->mloop + mp->loopstart; - zero_v3(vec); - for (j = 0; j < mp->totloop; j++, ml++) { - mv = me->mvert + ml->v; - add_v3_v3(vec, mv->co); + memcpy(mp + aff, tb, (tot - aff) * sizeof(int)); + tb = mp; + mp = map[j] = tbuf[j]; + tbuf[j] = tb; + } + + /* Reverse mapping, we want an org2new one! */ + for (i = tot, tb = tbuf[j] + tot - 1; i--; tb--) { + mp[*tb] = i; + } + MEM_freeN(tbuf[j]); + } + } + + else if (action == SRT_RANDOMIZE) { + if (totelem[0]) { + /* Re-init random generator for each element type, to get consistant random when + * enabling/disabling an element type. */ + BLI_srandom(seed); + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = BLI_frand(); } - mul_v3_fl(vec, 1.0f / (float)mp->totloop); - - if (event == 1) { /* sort on view axis */ - mul_m4_v3(mat, vec); - face_sort_floats[i] = vec[2] * reverse; + else { + pb[i] = TRUE; } - else if (event == 2) { /* distance from cursor */ - face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */ + } + } + + if (totelem[1]) { + BLI_srandom(seed); + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + BLI_srandom(seed); + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; } } } - qsort(index, me->totpoly, sizeof(int), float_sort); - } - - MEM_freeN(face_sort_floats); - for (i = 0; i < me->pdata.totlayer; i++) { - layer = &me->pdata.layers[i]; - permutate(layer->data, me->totpoly, CustomData_sizeof(layer->type), index); } - MEM_freeN(index); - DAG_id_tag_update(ob->data, 0); + else if (action == SRT_REVERSE) { + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); - /* Return to editmode. */ - ED_object_enter_editmode(C, 0); + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } - return OPERATOR_FINISHED; -} + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); -void MESH_OT_sort_faces(wmOperatorType *ot) -{ - static EnumPropertyItem type_items[] = { - { 1, "VIEW_AXIS", 0, "View Axis", "" }, - { 2, "CURSOR_DISTANCE", 0, "Cursor Distance", "" }, - { 3, "MATERIAL", 0, "Material", "" }, - { 4, "SELECTED", 0, "Selected", "" }, - { 5, "RANDOMIZE", 0, "Randomize", "" }, - { 0, NULL, 0, NULL, NULL }}; + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } - /* identifiers */ - ot->name = "Sort Faces"; // XXX (Ctrl to reverse)%t| - ot->description = "The faces of the active Mesh Object are sorted, based on the current view"; - ot->idname = "MESH_OT_sort_faces"; + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); - /* api callbacks */ - ot->invoke = WM_menu_invoke; - ot->exec = edbm_sort_faces_exec; - ot->poll = ED_operator_editmesh; + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + } - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +/* printf("%d vertices: %d to be affected…\n", totelem[0], affected[0]);*/ +/* printf("%d edges: %d to be affected…\n", totelem[1], affected[1]);*/ +/* printf("%d faces: %d to be affected…\n", totelem[2], affected[2]);*/ + if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) { + for (j = 3; j--;) { + if (pblock[j]) + MEM_freeN(pblock[j]); + if (sblock[j]) + MEM_freeN(sblock[j]); + if (map[j]) + MEM_freeN(map[j]); + } + return; + } - /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + /* Sort affected elements, and populate mapping arrays, if needed. */ + for (j = 3; j--;) { + pb = pblock[j]; + sb = sblock[j]; + if (pb && sb && !map[j]) { + char *p_blk; + bmelemsort *s_blk; + tot = totelem[j]; + aff = affected[j]; + + qsort(sb, aff, sizeof(bmelemsort), bmelemsort_comp); + + mp = map[j] = MEM_mallocN(sizeof(int) * tot, "sort_bmelem map"); + p_blk = pb + tot - 1; + s_blk = sb + aff - 1; + for (i = tot; i--; p_blk--) { + if (*p_blk) { /* Protected! */ + mp[i] = i; + } + else { + mp[s_blk->org_idx] = i; + s_blk--; + } + } + } + if (pb) + MEM_freeN(pb); + if (sb) + MEM_freeN(sb); + } + + BM_mesh_remap(em->bm, map[0], map[1], map[2]); +/* DAG_id_tag_update(ob->data, 0);*/ + + for (j = 3; j--;) { + if (map[j]) + MEM_freeN(map[j]); + } } -/* ******************************* Randomize verts ************************* */ -static void hashvert_flag(BMEditMesh *em, int flag, unsigned int seed) +static int edbm_sort_elements_exec(bContext *C, wmOperator *op) { - BMVert *ve; - BMIter iter; - char *block /* Just to mark protected vertices */, *t_blk; - int *randblock, *vmap, *t_idx, *r_idx; - int totvert, randomized = 0, /*protected = 0, */ i; - - totvert = em->bm->totvert; - - block = MEM_callocN(sizeof(char) * totvert, "randvert block"); - randblock = MEM_callocN(sizeof(int) * totvert, "randvert randblock"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - block[i] = FALSE; - randblock[randomized++] = i; - } - else { - block[i] = TRUE; - } + int action = RNA_enum_get(op->ptr, "type"); + PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements"); + int elem_types = 0; + int reverse = RNA_boolean_get(op->ptr, "reverse"); + unsigned int seed = RNA_int_get(op->ptr, "seed"); + + /* If no elem_types set, use current selection mode to set it! */ + if (RNA_property_is_set(op->ptr, prop_elem_types)) { + elem_types = RNA_property_enum_get(op->ptr, prop_elem_types); } -/* protected = totvert - randomized;*/ -/* printf("%d verts: %d to be randomized, %d protected…\n", totvert, randomized, protected);*/ - if (randomized == 0) { - MEM_freeN(block); - MEM_freeN(randblock); - return; + else { + BMEditMesh *em = BMEdit_FromObject(CTX_data_edit_object(C)); + if (em->selectmode & SCE_SELECT_VERTEX) + elem_types |= BM_VERT; + if (em->selectmode & SCE_SELECT_EDGE) + elem_types |= BM_EDGE; + if (em->selectmode & SCE_SELECT_FACE) + elem_types |= BM_FACE; + RNA_enum_set(op->ptr, "elements", elem_types); } - - /* Randomize non-protected vertices indices, and create an array mapping old idx to new - * from both blocks, keeping protected vertices at the same indices. */ - vmap = randblock; - randblock = MEM_mallocN(sizeof(int) * randomized, "randvert randblock"); - memcpy(randblock, vmap, randomized * sizeof(int)); - BLI_array_randomize((void *)randblock, sizeof(int), randomized, seed); - t_blk = block + totvert - 1; - t_idx = vmap + totvert - 1; - r_idx = randblock + randomized - 1; - for (i = totvert; i--; t_blk--, t_idx--) { - if (*t_blk) /* Protected! */ - *t_idx = i; + sort_bmelem_flag(C, elem_types, BM_ELEM_SELECT, action, reverse, seed); + return OPERATOR_FINISHED; +} + +static int edbm_sort_elements_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + int action = RNA_enum_get(ptr, "type"); + + /* Only show seed for randomize action! */ + if (strcmp(prop_id, "seed") == 0) { + if (action == SRT_RANDOMIZE) + return TRUE; else - *t_idx = *r_idx--; + return FALSE; } - MEM_freeN(randblock); - MEM_freeN(block); - - BM_mesh_remap(em->bm, vmap, NULL, NULL); + /* Hide seed for reverse and randomize actions! */ + if (strcmp(prop_id, "reverse") == 0) { + if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) + return FALSE; + else + return TRUE; + } - MEM_freeN(vmap); + return TRUE; } -static int edbm_vertices_randomize_exec(bContext *C, wmOperator *op) +static void edbm_sort_elements_ui(bContext *C, wmOperator *op) { - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BMEdit_FromObject(obedit); - unsigned int seed = RNA_int_get(op->ptr, "seed"); + uiLayout *layout = op->layout; + wmWindowManager *wm = CTX_wm_manager(C); + PointerRNA ptr; - hashvert_flag(em, BM_ELEM_SELECT, seed); + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - return OPERATOR_FINISHED; + /* Main auto-draw call. */ + uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0'); } -void MESH_OT_vertices_randomize(wmOperatorType *ot) +void MESH_OT_sort_elements(wmOperatorType *ot) { + static EnumPropertyItem type_items[] = { + {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", + "Sort selected elements from farest to nearest one in current view"}, + {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", + "Sort selected elements from left to right one in current view"}, + {SRT_CURSOR_DISTANCE, "CURSOR_DISTANCE", 0, "Cursor Distance", + "Sort selected elements from nearest to farest from 3D cursor"}, + {SRT_MATERIAL, "MATERIAL", 0, "Material", + "Sort selected elements from smallest to greatest material index (faces only!)"}, + {SRT_SELECTED, "SELECTED", 0, "Selected", + "Move all selected elements in first places, preserving their relative order " + "(WARNING: this will affect unselected elements' indices as well!)"}, + {SRT_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Randomize order of selected elements"}, + {SRT_REVERSE, "REVERSE", 0, "Reverse", "Reverse current order of selected elements"}, + {0, NULL, 0, NULL, NULL}, + }; + + static EnumPropertyItem elem_items[] = { + {BM_VERT, "VERT", 0, "Vertices", ""}, + {BM_EDGE, "EDGE", 0, "Edges", ""}, + {BM_FACE, "FACE", 0, "Faces", ""}, + {0, NULL, 0, NULL, NULL}, + }; + /* identifiers */ - ot->name = "Vertex Randomize"; - ot->description = "Randomize vertex order"; - ot->idname = "MESH_OT_vertices_randomize"; + ot->name = "Sort Mesh Elements"; + ot->description = "The order of selected vertices/edges/faces is modified, based on a given method"; + ot->idname = "MESH_OT_sort_elements"; /* api callbacks */ - ot->exec = edbm_vertices_randomize_exec; - + ot->invoke = WM_menu_invoke; + ot->exec = edbm_sort_elements_exec; ot->poll = ED_operator_editmesh; + ot->ui = edbm_sort_elements_ui; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* Properties */ - ot->prop = RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for the random generator", 0, 255); + /* properties */ + ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Type of re-ordering operation to apply"); + RNA_def_enum_flag(ot->srna, "elements", elem_items, 0, "Elements", + "Which elements to affect (vertices, edges and/or faces)"); + RNA_def_boolean(ot->srna, "reverse", FALSE, "Reverse", "Reverse the sorting effect"); + RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for random-based operations", 0, 255); } -/******end of qsort stuff ****/ - +/****** end of qsort stuff ****/ static int edbm_noise_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a17f335091b..533ead1ff29 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -545,11 +545,11 @@ static void free_undo(void *me_v) { Mesh *me = me_v; if (me->key) { - free_key(me->key); + BKE_key_free(me->key); MEM_freeN(me->key); } - free_mesh(me, FALSE); + BKE_mesh_free(me, FALSE); MEM_freeN(me); } @@ -611,7 +611,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, int do_face_idx buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); if (do_face_idx_array) EDBM_index_arrays_free(em); return NULL; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f611a985797..bc11a627be6 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -556,11 +556,11 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } if (!ima) { @@ -808,16 +808,16 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) * contain the normal of the poly the face was tessellated from. */ face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface); - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, - mesh->totloop, mesh->totpoly, - NULL /* polyNors_r */, - mesh->mface, mesh->totface, - polyindex, face_nors, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, + mesh->totloop, mesh->totpoly, + NULL /* polyNors_r */, + mesh->mface, mesh->totface, + polyindex, face_nors, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); (void)polyindex; (void)face_nors; #endif @@ -1138,13 +1138,13 @@ void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_calc_normals(Mesh *mesh) { #ifdef USE_BMESH_MPOLY_NORMALS - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL, NULL, 0, NULL, NULL, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL, NULL, 0, NULL, NULL, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); #endif } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index a5eb39c7da4..ee74cea48af 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -148,8 +148,6 @@ extern struct EnumPropertyItem *corner_type_items; void MESH_OT_merge(struct wmOperatorType *ot); void MESH_OT_subdivide(struct wmOperatorType *ot); void MESH_OT_remove_doubles(struct wmOperatorType *ot); -void MESH_OT_vertices_randomize(struct wmOperatorType *ot); -void MESH_OT_vertices_sort(struct wmOperatorType *ot); void MESH_OT_spin(struct wmOperatorType *ot); void MESH_OT_screw(struct wmOperatorType *ot); @@ -184,7 +182,7 @@ void MESH_OT_rip(struct wmOperatorType *ot); void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot); void MESH_OT_blend_from_shape(struct wmOperatorType *ot); -void MESH_OT_sort_faces(struct wmOperatorType *ot); +void MESH_OT_sort_elements(struct wmOperatorType *ot); void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot); /* ******************* mesh_data.c */ diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index cc640e38fc2..14d20d68455 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -316,8 +316,8 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, } else { obedit = base->object; - scene_deselect_all(scene); - scene_select_base(scene, base); + BKE_scene_base_deselect_all(scene); + BKE_scene_base_select(scene, base); copy_v3_v3(obedit->loc, co); copy_v3_v3(obedit->rot, rot); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 37ae5b4a967..dc0d576d701 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -87,8 +87,6 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_primitive_ico_sphere_add); WM_operatortype_append(MESH_OT_duplicate); WM_operatortype_append(MESH_OT_remove_doubles); - WM_operatortype_append(MESH_OT_vertices_sort); - WM_operatortype_append(MESH_OT_vertices_randomize); WM_operatortype_append(MESH_OT_spin); WM_operatortype_append(MESH_OT_screw); @@ -118,7 +116,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_dissolve_limited); WM_operatortype_append(MESH_OT_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); - WM_operatortype_append(MESH_OT_sort_faces); + WM_operatortype_append(MESH_OT_sort_elements); WM_operatortype_append(MESH_OT_mark_freestyle_face); WM_operatortype_append(MESH_OT_delete); @@ -199,49 +197,49 @@ void ED_operatormacros_mesh(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Cut mesh loop and slide it"; + ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Duplicate mesh and move"; + ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Rip polygons and move the result"; + ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_rip"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude region and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", + "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude faces and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", + "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude edges and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", + "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude vertices and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", + "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -355,11 +353,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", TRUE); - RNA_boolean_set(kmi->ptr, "only_select", FALSE); + RNA_boolean_set(kmi->ptr, "only_selected", FALSE); kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", FALSE); - RNA_boolean_set(kmi->ptr, "only_select", TRUE); + RNA_boolean_set(kmi->ptr, "only_selected", TRUE); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index e41807787f1..aa89eaa0c6d 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -182,7 +182,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ - nkey = copy_key(key); + nkey = BKE_key_copy(key); /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { @@ -524,13 +524,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { - free_ipo(nkey->ipo); + BKE_ipo_free(nkey->ipo); BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); } #endif - free_key(nkey); + BKE_key_free(nkey); BLI_remlink(&bmain->key, nkey); MEM_freeN(nkey); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index fd842ce4f7c..ed51f53eb03 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -67,24 +67,24 @@ /* This function is used to free all MetaElems from MetaBall */ void free_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; + MetaBall *mb = (MetaBall *)obedit->data; - mb->editelems= NULL; - mb->lastelem= NULL; + mb->editelems = NULL; + mb->lastelem = NULL; } /* This function is called, when MetaBall Object is * switched from object mode to edit mode */ void make_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml;/*, *newml;*/ + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml; /*, *newml;*/ - ml= mb->elems.first; + ml = mb->elems.first; while (ml) { if (ml->flag & SELECT) mb->lastelem = ml; - ml= ml->next; + ml = ml->next; } mb->editelems = &mb->elems; @@ -100,22 +100,22 @@ void load_editMball(Object *UNUSED(obedit)) /* Add metaelem primitive to metaball object (which is in edit mode) */ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mball = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; /* Deselect all existing metaelems */ - ml= mball->editelems->first; + ml = mball->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - ml= BKE_metaball_element_add(mball, type); + ml = BKE_mball_element_add(mball, type); copy_v3_v3(&ml->x, mat[3]); ml->flag |= SELECT; - mball->lastelem= ml; + mball->lastelem = ml; return ml; } @@ -125,12 +125,12 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU static int mball_select_all_exec(bContext *C, wmOperator *op) { //Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; int action = RNA_enum_get(op->ptr, "action"); - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -139,26 +139,26 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) action = SEL_DESELECT; break; } - ml= ml->next; + ml = ml->next; } } - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { switch (action) { - case SEL_SELECT: - ml->flag |= SELECT; - break; - case SEL_DESELECT: - ml->flag &= ~SELECT; - break; - case SEL_INVERT: - ml->flag ^= SELECT; - break; + case SEL_SELECT: + ml->flag |= SELECT; + break; + case SEL_DESELECT: + ml->flag &= ~SELECT; + break; + case SEL_INVERT: + ml->flag ^= SELECT; + break; } - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); } return OPERATOR_FINISHED; @@ -176,7 +176,7 @@ void MBALL_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -186,16 +186,16 @@ void MBALL_OT_select_all(wmOperatorType *ot) /* Random metaball selection */ static int select_random_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - float percent= RNA_float_get(op->ptr, "percent"); + float percent = RNA_float_get(op->ptr, "percent"); if (percent == 0.0f) return OPERATOR_CANCELLED; - ml= mb->editelems->first; - BLI_srand(BLI_rand()); /* Random seed */ + ml = mb->editelems->first; + BLI_srand(BLI_rand()); /* Random seed */ /* Stupid version of random selection. Should be improved. */ while (ml) { @@ -203,10 +203,10 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) ml->flag |= SELECT; else ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return OPERATOR_FINISHED; } @@ -225,7 +225,7 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly", 0.0001f, 1.0f); @@ -236,22 +236,22 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) /* Duplicate selected MetaElements */ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *newml; - ml= mb->editelems->last; + ml = mb->editelems->last; if (ml) { while (ml) { if (ml->flag & SELECT) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(mb->editelems, newml); - mb->lastelem= newml; + mb->lastelem = newml; ml->flag &= ~SELECT; } - ml= ml->prev; + ml = ml->prev; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -260,7 +260,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - int retv= duplicate_metaelems_exec(C, op); + int retv = duplicate_metaelems_exec(C, op); if (retv == OPERATOR_FINISHED) { RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); @@ -284,7 +284,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -295,22 +295,22 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) /* Delete all selected MetaElems (not MetaBall) */ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *next; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { - next= ml->next; + next = ml->next; if (ml->flag & SELECT) { - if (mb->lastelem==ml) mb->lastelem= NULL; + if (mb->lastelem == ml) mb->lastelem = NULL; BLI_remlink(mb->editelems, ml); MEM_freeN(ml); } - ml= next; + ml = next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -329,7 +329,7 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************************** Hide operator *****************************/ @@ -337,20 +337,20 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) /* Hide selected MetaElems */ static int hide_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - const int invert= RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; + const int invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { if ((ml->flag & SELECT) != invert) ml->flag |= MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -369,7 +369,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -380,18 +380,18 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) /* Unhide all edited MetaElems */ static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { ml->flag &= ~MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -410,69 +410,69 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ int mouse_mball(bContext *C, const int mval[2], int extend) { - static MetaElem *startelem=NULL; - Object *obedit= CTX_data_edit_object(C); + static MetaElem *startelem = NULL; + Object *obedit = CTX_data_edit_object(C); ViewContext vc; - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml, *act=NULL; + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml, *act = NULL; int a, hits; - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; rcti rect; view3d_set_viewcontext(C, &vc); - rect.xmin = mval[0]-12; - rect.xmax = mval[0]+12; - rect.ymin = mval[1]-12; - rect.ymax = mval[1]+12; + rect.xmin = mval[0] - 12; + rect.xmax = mval[0] + 12; + rect.ymin = mval[1] - 12; + rect.ymax = mval[1] + 12; - hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); /* does startelem exist? */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { - if (ml==startelem) break; - ml= ml->next; + if (ml == startelem) break; + ml = ml->next; } - if (ml==NULL) startelem= mb->editelems->first; + if (ml == NULL) startelem = mb->editelems->first; - if (hits>0) { - ml= startelem; + if (hits > 0) { + ml = startelem; while (ml) { - for (a=0; a<hits; a++) { + for (a = 0; a < hits; a++) { /* index converted for gl stuff */ - if (ml->selcol1==buffer[ 4 * a + 3 ]) { + if (ml->selcol1 == buffer[4 * a + 3]) { ml->flag |= MB_SCALE_RAD; - act= ml; + act = ml; } - if (ml->selcol2==buffer[ 4 * a + 3 ]) { + if (ml->selcol2 == buffer[4 * a + 3]) { ml->flag &= ~MB_SCALE_RAD; - act= ml; + act = ml; } } if (act) break; - ml= ml->next; - if (ml==NULL) ml= mb->editelems->first; - if (ml==startelem) break; + ml = ml->next; + if (ml == NULL) ml = mb->editelems->first; + if (ml == startelem) break; } /* When some metaelem was found, then it is necessary to select or * deselect it. */ if (act) { - if (extend==0) { + if (extend == 0) { /* Deselect all existing metaelems */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } /* Select only metaelem clicked on */ act->flag |= SELECT; @@ -483,9 +483,9 @@ int mouse_mball(bContext *C, const int mval[2], int extend) else act->flag |= SELECT; } - mb->lastelem= act; + mb->lastelem = act; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return 1; } @@ -502,54 +502,54 @@ static void freeMetaElemlist(ListBase *lb) { MetaElem *ml, *next; - if (lb==NULL) return; + if (lb == NULL) return; - ml= lb->first; + ml = lb->first; while (ml) { - next= ml->next; + next = ml->next; BLI_remlink(lb, ml); MEM_freeN(ml); - ml= next; + ml = next; } - lb->first= lb->last= NULL; + lb->first = lb->last = NULL; } static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe)) { - ListBase *lb= lbu; - ListBase *editelems= lbe; + ListBase *lb = lbu; + ListBase *editelems = lbe; MetaElem *ml, *newml; freeMetaElemlist(editelems); /* copy 'undo' MetaElems to 'edit' MetaElems */ - ml= lb->first; + ml = lb->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(editelems, newml); - ml= ml->next; + ml = ml->next; } } static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) { - ListBase *editelems= lbe; + ListBase *editelems = lbe; ListBase *lb; MetaElem *ml, *newml; /* allocate memory for undo ListBase */ - lb= MEM_callocN(sizeof(ListBase), "listbase undo"); - lb->first= lb->last= NULL; + lb = MEM_callocN(sizeof(ListBase), "listbase undo"); + lb->first = lb->last = NULL; /* copy contents of current ListBase to the undo ListBase */ - ml= editelems->first; + ml = editelems->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(lb, newml); - ml= ml->next; + ml = ml->next; } return lb; @@ -558,7 +558,7 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) /* free undo ListBase of MetaElems */ static void free_undoMball(void *lbv) { - ListBase *lb= lbv; + ListBase *lb = lbv; freeMetaElemlist(lb); MEM_freeN(lb); @@ -566,8 +566,8 @@ static void free_undoMball(void *lbv) static ListBase *metaball_get_editelems(Object *ob) { - if (ob && ob->type==OB_MBALL) { - struct MetaBall *mb= (struct MetaBall*)ob->data; + if (ob && ob->type == OB_MBALL) { + struct MetaBall *mb = (struct MetaBall *)ob->data; return mb->editelems; } return NULL; @@ -576,7 +576,7 @@ static ListBase *metaball_get_editelems(Object *ob) static void *get_data(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); return metaball_get_editelems(obedit); } diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 5d019cc49d9..1c77eba2019 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -75,9 +75,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d030e61952e..466338a736f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -147,7 +147,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *r if (rot) copy_v3_v3(ob->rot, rot); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); } /* uses context to figure out transform for primitive */ @@ -325,7 +325,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ - ob = add_object(scene, type); + ob = BKE_object_add(scene, type); BASACT->lay = ob->lay = layer; /* editor level activate, notifiers */ ED_base_object_activate(C, BASACT); @@ -733,7 +733,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) rename_id(&ob->id, get_lamp_defname(type)); rename_id(&la->id, get_lamp_defname(type)); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &la->id); la->use_nodes = 1; } @@ -891,7 +891,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { DAG_id_type_tag(bmain, ID_OB); BLI_remlink(&scene->base, base); - free_libblock_us(&bmain->object, base->object); + BKE_libblock_free_us(&bmain->object, base->object); if (scene->basact == base) scene->basact = NULL; MEM_freeN(base); } @@ -923,7 +923,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) { if (scene_iter != scene && !(scene_iter->id.lib)) { - base_other = object_in_scene(base->object, scene_iter); + base_other = BKE_scene_base_find(scene_iter, base->object); if (base_other) { ED_base_object_free_and_unlink(bmain, scene_iter, base_other); } @@ -975,7 +975,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* XXX check object pointers */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - object_relink(ob); + BKE_object_relink(ob); } CTX_DATA_END; @@ -993,7 +993,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) id = (ID *)ma->mtex[a]->tex; if (id) { ID_NEW_US(ma->mtex[a]->tex) - else ma->mtex[a]->tex = copy_texture(ma->mtex[a]->tex); + else ma->mtex[a]->tex = BKE_texture_copy(ma->mtex[a]->tex); id->us--; } } @@ -1073,7 +1073,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, for (dob = lb->first; dob; dob = dob->next) { Base *basen; - Object *ob = copy_object(dob->ob); + Object *ob = BKE_object_copy(dob->ob); /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1097,7 +1097,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob->lay = base->lay; copy_m4_m4(ob->obmat, dob->mat); - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); if (dupli_gh) BLI_ghash_insert(dupli_gh, dob, ob); @@ -1143,7 +1143,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* note, this may be the parent of other objects, but it should * still work out ok */ - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); /* to set ob_dst->orig and in case theres any other discrepicies */ DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1162,7 +1162,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* similer to the code above, see comments */ invert_m4_m4(ob_dst->parentinv, dob->mat); - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1239,12 +1239,12 @@ static EnumPropertyItem convert_target_items[] = { static void curvetomesh(Scene *scene, Object *ob) { if (ob->disp.first == NULL) - makeDispListCurveTypes(scene, ob, 0); /* force creation */ + BKE_displist_make_curveTypes(scene, ob, 0); /* force creation */ - nurbs_to_mesh(ob); /* also does users */ + BKE_mesh_from_nurbs(ob); /* also does users */ if (ob->type == OB_MESH) - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); } static int convert_poll(bContext *C) @@ -1265,7 +1265,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) ob = base->object; } - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1325,7 +1325,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* When 2 objects with linked data are selected, converting both * would keep modifiers on all but the converted object [#26003] */ if (ob->type == OB_MESH) { - object_free_modifiers(ob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(ob); /* after derivedmesh calls! */ } } } @@ -1341,16 +1341,16 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; } - mesh_to_curve(scene, newob); + BKE_mesh_from_curve(scene, newob); if (newob->type == OB_CURVE) - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; @@ -1364,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; @@ -1383,7 +1383,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* re-tessellation is called by DM_to_mesh */ dm->release(dm); - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_FONT) { ob->flag |= OB_DONE; @@ -1405,7 +1405,7 @@ static int convert_exec(bContext *C, wmOperator *op) cu = newob->data; if (!newob->disp.first) - makeDispListCurveTypes(scene, newob, 0); + BKE_displist_make_curveTypes(scene, newob, 0); newob->type = OB_CURVE; cu->type = OB_CURVE; @@ -1446,7 +1446,7 @@ static int convert_exec(bContext *C, wmOperator *op) curvetomesh(scene, newob); /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { @@ -1467,7 +1467,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob = ob; /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } curvetomesh(scene, newob); @@ -1479,7 +1479,7 @@ static int convert_exec(bContext *C, wmOperator *op) base->flag &= ~SELECT; ob->flag &= ~SELECT; - baseob = BKE_metaball_basis_find(scene, ob); + baseob = BKE_mball_basis_find(scene, ob); if (ob != baseob) { /* if motherball is converting it would be marked as done later */ @@ -1487,7 +1487,7 @@ static int convert_exec(bContext *C, wmOperator *op) } if (!baseob->disp.first) { - makeDispListMBall(scene, baseob); + BKE_displist_make_mball(scene, baseob); } if (!(baseob->flag & OB_DONE)) { @@ -1499,7 +1499,7 @@ static int convert_exec(bContext *C, wmOperator *op) mb = newob->data; mb->id.us--; - newob->data = add_mesh("Mesh"); + newob->data = BKE_mesh_add("Mesh"); newob->type = OB_MESH; me = newob->data; @@ -1509,7 +1509,7 @@ static int convert_exec(bContext *C, wmOperator *op) for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]); } - mball_to_mesh(&baseob->disp, newob->data); + BKE_mesh_from_metaball(&baseob->disp, newob->data); if (obact->type == OB_MBALL) { basact = basen; @@ -1631,7 +1631,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base ; /* nothing? */ } else { - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1657,7 +1657,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)obn->mat[a]; if (id) { ID_NEW_US(obn->mat[a]) - else obn->mat[a] = copy_material(obn->mat[a]); + else obn->mat[a] = BKE_material_copy(obn->mat[a]); id->us--; if (dupflag & USER_DUP_ACT) { @@ -1672,7 +1672,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *) psys->part; if (id) { ID_NEW_US(psys->part) - else psys->part = psys_copy_settings(psys->part); + else psys->part = BKE_particlesettings_copy(psys->part); if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&psys->part->id); @@ -1691,7 +1691,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MESH) { ID_NEW_US2(obn->data) else { - obn->data = copy_mesh(obn->data); + obn->data = BKE_mesh_copy(obn->data); if (obn->fluidsimSettings) { obn->fluidsimSettings->orgMesh = (Mesh *)obn->data; @@ -1736,7 +1736,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MBALL) { ID_NEW_US2(obn->data) else { - obn->data = BKE_metaball_copy(obn->data); + obn->data = BKE_mball_copy(obn->data); didit = 1; } id->us--; @@ -1746,7 +1746,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_LAMP) { ID_NEW_US2(obn->data) else { - obn->data = copy_lamp(obn->data); + obn->data = BKE_lamp_copy(obn->data); didit = 1; } id->us--; @@ -1760,8 +1760,8 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_ARM) { ID_NEW_US2(obn->data) else { - obn->data = copy_armature(obn->data); - armature_rebuild_pose(obn, obn->data); + obn->data = BKE_armature_copy(obn->data); + BKE_pose_rebuild(obn, obn->data); didit = 1; } id->us--; @@ -1773,7 +1773,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_lattice(obn->data); + obn->data = BKE_lattice_copy(obn->data); didit = 1; } id->us--; @@ -1793,7 +1793,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_speaker(obn->data); + obn->data = BKE_speaker_copy(obn->data); didit = 1; } id->us--; @@ -1832,7 +1832,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)(*matarar)[a]; if (id) { ID_NEW_US((*matarar)[a]) - else (*matarar)[a] = copy_material((*matarar)[a]); + else (*matarar)[a] = BKE_material_copy((*matarar)[a]); id->us--; } @@ -1863,7 +1863,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag ob = basen->object; /* link own references to the newly duplicated data [#26816] */ - object_relink(ob); + BKE_object_relink(ob); set_sca_new_poins_ob(ob); DAG_scene_sort(bmain, scene); @@ -1954,7 +1954,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob = (Object *)find_id("OB", name); + ob = (Object *)BKE_libblock_find_name(ID_OB, name); if (ob == NULL) return OPERATOR_CANCELLED; @@ -2033,7 +2033,7 @@ static int join_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } @@ -2086,7 +2086,7 @@ static int join_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 593a5b6f1fe..cea9a0aae6b 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -49,6 +49,7 @@ #include "BLI_math_geom.h" #include "BKE_blender.h" +#include "BKE_ccg.h" #include "BKE_screen.h" #include "BKE_context.h" #include "BKE_global.h" @@ -475,32 +476,32 @@ static void interp_barycentric_tri_data(float data[3][3], float u, float v, floa /* mode = 0: interpolate normals, * mode = 1: interpolate coord */ -static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, float crn_y, int mode, float res[3]) +static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float crn_y, int mode, float res[3]) { int x0, x1, y0, y1; float u, v; float data[4][3]; x0 = (int) crn_x; - x1 = x0 >= (grid_size - 1) ? (grid_size - 1) : (x0 + 1); + x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1); y0 = (int) crn_y; - y1 = y0 >= (grid_size - 1) ? (grid_size - 1) : (y0 + 1); + y1 = y0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (y0 + 1); u = crn_x - x0; v = crn_y - y0; if (mode == 0) { - copy_v3_v3(data[0], grid[y0 * grid_size + x0].no); - copy_v3_v3(data[1], grid[y0 * grid_size + x1].no); - copy_v3_v3(data[2], grid[y1 * grid_size + x1].no); - copy_v3_v3(data[3], grid[y1 * grid_size + x0].no); + copy_v3_v3(data[0], CCG_grid_elem_no(key, grid, x0, y0)); + copy_v3_v3(data[1], CCG_grid_elem_no(key, grid, x1, y0)); + copy_v3_v3(data[2], CCG_grid_elem_no(key, grid, x1, y1)); + copy_v3_v3(data[3], CCG_grid_elem_no(key, grid, x0, y1)); } else { - copy_v3_v3(data[0], grid[y0 * grid_size + x0].co); - copy_v3_v3(data[1], grid[y0 * grid_size + x1].co); - copy_v3_v3(data[2], grid[y1 * grid_size + x1].co); - copy_v3_v3(data[3], grid[y1 * grid_size + x0].co); + copy_v3_v3(data[0], CCG_grid_elem_co(key, grid, x0, y0)); + copy_v3_v3(data[1], CCG_grid_elem_co(key, grid, x1, y0)); + copy_v3_v3(data[2], CCG_grid_elem_co(key, grid, x1, y1)); + copy_v3_v3(data[3], CCG_grid_elem_co(key, grid, x0, y1)); } interp_bilinear_quad_data(data, u, v, res); @@ -509,7 +510,8 @@ static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, f static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3]) { MFace mface; - DMGridData **grid_data; + CCGElem **grid_data; + CCGKey key; float crn_x, crn_y; int grid_size, S, face_side; int *grid_offset, g_index; @@ -519,6 +521,7 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig grid_size = hidm->getGridSize(hidm); grid_data = hidm->getGridData(hidm); grid_offset = hidm->getGridOffset(hidm); + hidm->getGridKey(hidm, &key); face_side = (grid_size << 1) - 1; @@ -546,10 +549,10 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig CLAMP(crn_y, 0.0f, grid_size); if (n != NULL) - interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 0, n); + interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 0, n); if (co != NULL) - interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 1, co); + interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 1, co); } /* mode = 0: interpolate normals, @@ -619,7 +622,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) if (bkr->simple) smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); } height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); @@ -1020,7 +1023,8 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, + MULTIRES_USE_LOCAL_MMD); cddm->release(cddm); } @@ -1040,7 +1044,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, + MULTIRES_USE_LOCAL_MMD); cddm->release(cddm); return dm; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index e63e0e34934..d73b53deecc 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -89,7 +89,7 @@ ListBase *get_active_constraints(Object *ob) if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (pchan) return &pchan->constraints; } @@ -309,23 +309,23 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) * the constraint is deemed invalid */ /* default IK check ... */ - if (exist_object(data->tar) == 0) { + if (BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } if (data->poletar) { - if (exist_object(data->poletar) == 0) { + if (BKE_object_exists_check(data->poletar) == 0) { data->poletar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->poletar == owner) { - if (!get_named_bone(get_armature(owner), data->polesubtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->polesubtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -339,12 +339,12 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) bPivotConstraint *data = curcon->data; /* target doesn't have to exist, but if it is non-null, it must exist! */ - if (data->tar && exist_object(data->tar) == 0) { + if (data->tar && BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -446,14 +446,14 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) /* disable and clear constraints targets that are incorrect */ for (ct = targets.first; ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ - if (exist_object(ct->tar) == 0) { + if (BKE_object_exists_check(ct->tar) == 0) { /* object doesn't exist, but constraint requires target */ ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (ct->tar == owner) { if (type == CONSTRAINT_OBTYPE_BONE) { - if (!get_named_bone(get_armature(owner), ct->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), ct->subtarget)) { /* bone must exist in armature... */ // TODO: clear subtarget? curcon->flag |= CONSTRAINT_DISABLE; @@ -585,7 +585,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int list = &ob->constraints; } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) list = &pchan->constraints; else { @@ -713,7 +713,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? if (ob && ob->pose) - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* calculate/set inverse matrix: * We just calculate all transform-stack eval up to but not including this constraint. @@ -729,7 +729,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, * to use as baseline ("pmat") to derive delta from. This extra calc saves users * from having pressing "Clear Inverse" first */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); copy_m4_m4(pmat, pchan->pose_mat); /* 2. knock out constraints starting from this one */ @@ -746,7 +746,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 3. solve pose without disabled constraints */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* 4. determine effect of constraint by removing the newly calculated * pchan->pose_mat from the original pchan->pose_mat, thus determining @@ -769,13 +769,13 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 6. recalculate pose with new inv-mat applied */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (ob) { Object workob; - /* use what_does_parent to find inverse - just like for normal parenting */ - what_does_parent(scene, ob, &workob); + /* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */ + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(invmat, workob.obmat); } } @@ -977,7 +977,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) void ED_object_constraint_update(Object *ob) { - if (ob->pose) update_pose_constraint_flags(ob->pose); + if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); object_test_constraints(ob); @@ -1147,7 +1147,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* free constraints for all selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -1253,7 +1253,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) void POSE_OT_constraints_copy(wmOperatorType *ot) { /* identifiers */ - ot->name = "Copy Constraints to Selected"; + ot->name = "Copy Constraints to Selected Bones"; ot->idname = "POSE_OT_constraints_copy"; ot->description = "Copy constraints to other selected bones"; @@ -1294,7 +1294,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) void OBJECT_OT_constraints_copy(wmOperatorType *ot) { /* identifiers */ - ot->name = "Copy Constraints to Selected"; + ot->name = "Copy Constraints to Selected Objects"; ot->idname = "OBJECT_OT_constraints_copy"; ot->description = "Copy constraints to other selected objects"; @@ -1312,7 +1312,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add) { Object *obact = ED_object_active_context(C); - bPoseChannel *pchanact = get_active_posechannel(obact); + bPoseChannel *pchanact = BKE_pose_channel_active(obact); short only_curve = 0, only_mesh = 0, only_ob = 0; short found = 0; @@ -1413,7 +1413,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o Object *obt; /* add new target object */ - obt = add_object(scene, OB_EMPTY); + obt = BKE_object_add(scene, OB_EMPTY); /* set layers OK */ newbase = BASACT; @@ -1434,7 +1434,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o copy_v3_v3(obt->loc, obact->obmat[3]); } - /* restore, add_object sets active */ + /* restore, BKE_object_add sets active */ BASACT = base; base->flag |= SELECT; @@ -1459,7 +1459,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase pchan = NULL; } else { - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* ensure not to confuse object/pose adding */ if (pchan == NULL) { @@ -1541,7 +1541,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase object_test_constraints(ob); if (pchan) - update_pose_constraint_flags(ob->pose); + BKE_pose_update_constraint_flags(ob->pose); /* force depsgraph to get recalculated since new relationships added */ @@ -1586,7 +1586,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(ED_object_active_context(C)); + Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C)); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; @@ -1689,8 +1689,8 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) /* present menu with options + validation for targets to use */ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); - bPoseChannel *pchan = get_active_posechannel(ob); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraint *con = NULL; uiPopupMenu *pup; @@ -1773,7 +1773,7 @@ void POSE_OT_ik_add(wmOperatorType *ot) /* remove IK constraints from selected bones */ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only remove IK Constraints */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c669bbfe3b2..c97ad9c62f9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -427,7 +427,7 @@ void ED_object_enter_editmode(bContext *C, int flag) ob = base->object; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); return; } @@ -465,11 +465,11 @@ void ED_object_enter_editmode(bContext *C, int flag) bArmature *arm = base->object->data; if (!arm) return; /* - * The function object_data_is_libdata make a problem here, the + * The function BKE_object_obdata_is_libdata make a problem here, the * check for ob->proxy return 0 and let blender enter to edit mode * this causes a crash when you try leave the edit mode. * The problem is that i can't remove the ob->proxy check from - * object_data_is_libdata that prevent the bugfix #6614, so + * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ if (arm->id.lib) { @@ -749,10 +749,10 @@ static void copy_texture_space(Object *to, Object *ob) /* pass */ } else if (to->type == OB_MBALL) { - BKE_metaball_tex_space_calc(to); + BKE_mball_texspace_calc(to); } else { - BKE_curve_tex_space_calc(to->data); + BKE_curve_texspace_calc(to->data); } } @@ -783,7 +783,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) return; } else if (event == 24) { - /* moved to object_link_modifiers */ + /* moved to BKE_object_link_modifiers */ /* copymenu_modifiers(bmain, scene, v3d, ob); */ return; } @@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->vfontbi = cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); - BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */ + BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */ BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); @@ -1125,6 +1125,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -1200,6 +1201,39 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + if (scene == NULL) + return OPERATOR_CANCELLED; + + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ + ED_objects_recalculate_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Object Paths"; + ot->idname = "OBJECT_OT_paths_update"; + ot->description = "Recalculate paths for selected objects"; + + /* api callbakcs */ + ot->exec = object_update_paths_exec; + ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* Clear motion paths for selected objects only */ void ED_objects_clear_paths(bContext *C) { @@ -1256,7 +1290,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) { if (ob->type == OB_MESH) { - mesh_set_smooth_flag(ob, !clear); + BKE_mesh_smooth_flag_set(ob, !clear); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -1350,7 +1384,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) space = 1.0; if (ob->type == OB_MESH) { float size[3]; - mesh_get_texspace(ob->data, NULL, NULL, size); + BKE_mesh_texspace_get(ob->data, NULL, NULL, size); space = size[0] / size[1]; } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { @@ -1402,7 +1436,7 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( { RNA_enum_item_add(&item, &totitem, input); } - ++input; + input++; } RNA_enum_item_end(&item, &totitem); @@ -1703,6 +1737,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Game Property"; ot->idname = "OBJECT_OT_game_property_copy"; + ot->description = "Copy/merge/replace a game property from active object to all selected objects"; /* api callbacks */ ot->exec = game_property_copy_exec; @@ -1733,6 +1768,7 @@ void OBJECT_OT_game_property_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Game Property"; ot->idname = "OBJECT_OT_game_property_clear"; + ot->description = "Remove all game properties from all selected objects"; /* api callbacks */ ot->exec = game_property_clear_exec; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index dd6c08a2247..b47591dddee 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -327,6 +327,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Group"; ot->idname = "OBJECT_OT_group_remove"; + ot->description = "Remove the active object from this group"; /* api callbacks */ ot->exec = group_remove_exec; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 2cfefa61a18..e9341d90e86 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -417,13 +417,13 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) Base *base, *basedit; Object *ob; - ob = add_object(scene, OB_EMPTY); + ob = BKE_object_add(scene, OB_EMPTY); - basedit = object_in_scene(obedit, scene); - base = object_in_scene(ob, scene); + basedit = BKE_scene_base_find(scene, obedit); + base = BKE_scene_base_find(scene, ob); base->lay = ob->lay = obedit->lay; - /* icky, add_object sets new base as active. + /* icky, BKE_object_add sets new base as active. * so set it back to the original edit object */ scene->basact = basedit; @@ -469,7 +469,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ @@ -648,7 +648,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) /* reset functionality */ if (hmd->object) { - bPoseChannel *pchan = get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); if (hmd->subtarget[0] && pchan) { float imat[4][4], mat[4][4]; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ee9d776ea3b..e834c93b0d8 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -84,6 +84,7 @@ void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); +void OBJECT_OT_paths_update(struct wmOperatorType *ot); void OBJECT_OT_paths_clear(struct wmOperatorType *ot); void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 648f530881a..7b37ca8ab95 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -271,12 +271,12 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) if (ob) { lt = ob->data; - resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { ob = CTX_data_active_object(C); lt = ob->data; - resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 281ca7e59b6..191677989b9 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -76,6 +76,7 @@ #include "ED_armature.h" #include "ED_object.h" #include "ED_screen.h" +#include "ED_sculpt.h" #include "ED_mesh.h" #include "WM_api.h" @@ -147,9 +148,13 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } else if (type == eModifierType_Surface) DAG_scene_sort(bmain, scene); - else if (type == eModifierType_Multires) + else if (type == eModifierType_Multires) { /* set totlvl from existing MDISPS layer if object already had it */ multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); + + /* ensure that grid paint mask layer is created */ + ED_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md); + } } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -368,7 +373,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (totvert == 0) return 0; /* add new mesh */ - obn = add_object(scene, OB_MESH); + obn = BKE_object_add(scene, OB_MESH); me = obn->data; me->totvert = totvert; @@ -545,7 +550,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_vertexCos_get(cu, &cu->nurb, &numVerts); - mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); + mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); BK_curve_vertexCos_apply(cu, &cu->nurb, vertexCos); MEM_freeN(vertexCos); @@ -610,6 +615,9 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi BLI_remlink(&ob->modifiers, md); modifier_free(md); + /* ensure mesh paint mask layer remains after applying */ + ED_sculpt_mask_layers_ensure(ob, NULL); + return 1; } @@ -661,7 +669,7 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) if (mti->flags & eModifierTypeFlag_NoUserAdd) continue; - if (!object_support_modifier_type(ob, md_item->value)) + if (!BKE_object_support_modifier_type_check(ob, md_item->value)) continue; } else { @@ -918,7 +926,8 @@ static int modifier_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev static EnumPropertyItem modifier_apply_as_items[] = { {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; void OBJECT_OT_modifier_apply(wmOperatorType *ot) { @@ -1369,13 +1378,13 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) dm->release(dm); } else if (ob->type == OB_LATTICE) { - lattice_calc_modifiers(scene, ob); + BKE_lattice_modifiers_calc(scene, ob); } else if (ob->type == OB_MBALL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(scene, ob, 0); + BKE_displist_make_curveTypes(scene, ob, 0); } mmd->bindfunc = NULL; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 4cd18d91249..b7dc3fd7bea 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -77,6 +77,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); WM_operatortype_append(OBJECT_OT_paths_calculate); + WM_operatortype_append(OBJECT_OT_paths_update); WM_operatortype_append(OBJECT_OT_paths_clear); WM_operatortype_append(OBJECT_OT_forcefield_toggle); @@ -222,18 +223,18 @@ void ED_operatormacros_object(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); } /* grr, should be able to pass options on... */ - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -241,9 +242,9 @@ void ED_operatormacros_object(void) } /* XXX */ - ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add Named At Cursor", + "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Add named object at cursor"; RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME - 2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 4678416e1c9..b3e16c8d4eb 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -235,7 +235,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par3 = v3 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { @@ -243,7 +243,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par1 = v1 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } @@ -335,24 +335,24 @@ static int make_proxy_exec(bContext *C, wmOperator *op) char name[MAX_ID_NAME + 4]; /* Add new object for the proxy */ - newob = add_object(scene, OB_EMPTY); + newob = BKE_object_add(scene, OB_EMPTY); BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); rename_id(&newob->id, name); /* set layers OK */ - newbase = BASACT; /* add_object sets active... */ + newbase = BASACT; /* BKE_object_add sets active... */ newbase->lay = oldbase->lay; newob->lay = newbase->lay; - /* remove base, leave user count of object, it gets linked in object_make_proxy */ + /* remove base, leave user count of object, it gets linked in BKE_object_make_proxy */ if (gob == NULL) { BLI_remlink(&scene->base, oldbase); MEM_freeN(oldbase); } - object_make_proxy(newob, ob, gob); + BKE_object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ DAG_scene_sort(bmain, scene); @@ -439,7 +439,7 @@ void ED_object_parent_clear(bContext *C, int type) } else if (type == 1) { ob->parent = NULL; - object_apply_mat4(ob, ob->obmat, TRUE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if (type == 2) unit_m4(ob->parentinv); @@ -533,7 +533,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; - makeDispListCurveTypes(scene, par, 0); /* force creation of path data */ + BKE_displist_make_curveTypes(scene, par, 0); /* force creation of path data */ } else cu->flag |= CU_FOLLOW; @@ -554,7 +554,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } } else if (partype == PAR_BONE) { - pchan = get_active_posechannel(par); + pchan = BKE_pose_channel_active(par); if (pchan == NULL) { BKE_report(reports, RPT_ERROR, "No active Bone"); @@ -571,7 +571,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object Object workob; /* apply transformation of previous parenting */ - /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ + /* BKE_object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ /* set the parent (except for follow-path constraint option) */ if (partype != PAR_PATH_CONST) { @@ -650,13 +650,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } /* get corrected inverse */ ob->partype = PAROBJECT; - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { /* calculate inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } @@ -814,7 +814,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->parent) { if (ob->partype & PARSLOW) { ob->partype -= PARSLOW; - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); ob->partype |= PARSLOW; ob->recalc |= OB_RECALC_OB; } @@ -920,7 +920,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if (type == 1) - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); } CTX_DATA_END; @@ -1217,7 +1217,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_bases) { - if (!object_in_scene(base->object, scene_to)) { + if (!BKE_scene_base_find(scene_to, base->object)) { Base *nbase = MEM_mallocN(sizeof(Base), "newbase"); *nbase = *base; BLI_addhead(&(scene_to->base), nbase); @@ -1313,7 +1313,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - object_link_modifiers(obt, ob); + BKE_object_link_modifiers(obt, ob); obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; break; } @@ -1401,7 +1401,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) if ( (base->flag & flag) == flag) { if (ob->id.lib == NULL && ob->id.us > 1) { /* base gets copy of object */ - obn = copy_object(ob); + obn = BKE_object_copy(ob); base->object = obn; ob->id.us--; } @@ -1413,7 +1413,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) /* object pointers */ for (base = FIRSTBASE; base; base = base->next) { - object_relink(base->object); + BKE_object_relink(base->object); } set_sca_new_poins(); @@ -1447,7 +1447,7 @@ static void new_id_matar(Material **matar, int totcol) id->us--; } else if (id->us > 1) { - matar[a] = copy_material(matar[a]); + matar[a] = BKE_material_copy(matar[a]); id->us--; id->newid = (ID *)matar[a]; } @@ -1478,7 +1478,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) switch (ob->type) { case OB_LAMP: - ob->data = la = copy_lamp(ob->data); + ob->data = la = BKE_lamp_copy(ob->data); for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) { ID_NEW(la->mtex[a]->object); @@ -1489,13 +1489,13 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ob->data = BKE_camera_copy(ob->data); break; case OB_MESH: - ob->data = copy_mesh(ob->data); + ob->data = BKE_mesh_copy(ob->data); //me= ob->data; //if (me && me->key) // ipo_idnew(me->key->ipo); /* drivers */ break; case OB_MBALL: - ob->data = BKE_metaball_copy(ob->data); + ob->data = BKE_mball_copy(ob->data); break; case OB_CURVE: case OB_SURF: @@ -1505,15 +1505,15 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ID_NEW(cu->taperobj); break; case OB_LATTICE: - ob->data = copy_lattice(ob->data); + ob->data = BKE_lattice_copy(ob->data); break; case OB_ARMATURE: ob->recalc |= OB_RECALC_DATA; - ob->data = copy_armature(ob->data); - armature_rebuild_pose(ob, ob->data); + ob->data = BKE_armature_copy(ob->data); + BKE_pose_rebuild(ob, ob->data); break; case OB_SPEAKER: - ob->data = copy_speaker(ob->data); + ob->data = BKE_speaker_copy(ob->data); break; default: if (G.debug & G_DEBUG) @@ -1568,7 +1568,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ if (ma->id.us > 1) { - man = copy_material(ma); + man = BKE_material_copy(ma); BKE_copy_animdata_id_action(&man->id); man->id.us = 0; @@ -1579,7 +1579,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) { if (tex->id.us > 1) { tex->id.us--; - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&tex->id); man->mtex[b]->tex = tex; } @@ -1606,7 +1606,7 @@ static void do_single_tex_user(Tex **from) tex->id.us--; } else if (tex->id.us > 1) { - texn = copy_texture(tex); + texn = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&texn->id); tex->id.newid = (ID *)texn; tex->id.us--; @@ -1911,7 +1911,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma = (Material *)find_id("MA", name); + ma = (Material *)BKE_libblock_find_name(ID_MA, name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ed53e4a9b91..86823be09a4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -416,7 +416,7 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ - baspar = object_in_scene(basact->object->parent, scene); + baspar = BKE_scene_base_find(scene, basact->object->parent); /* can be NULL if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { @@ -487,7 +487,7 @@ static short select_grouped_object_hooks(bContext *C, Object *ob) if (md->type == eModifierType_Hook) { hmd = (HookModifierData *) md; if (hmd->object && !(hmd->object->flag & SELECT)) { - base = object_in_scene(hmd->object, scene); + base = BKE_scene_base_find(scene, hmd->object); if (base && (BASE_SELECTABLE(v3d, base))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -884,9 +884,9 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ - Object *ob = (Object *)find_id("OB", tmpname); + Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname); if (ob) { - Base *secbase = object_in_scene(ob, scene); + Base *secbase = BKE_scene_base_find(scene, ob); if (secbase) { ED_base_object_select(secbase, BA_SELECT); diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 5d31bfff99a..19864ed58cf 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -77,7 +77,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix) { KeyBlock *kb; - if ((kb = object_insert_shape_key(scene, ob, NULL, from_mix))) { + if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) { Key *key = ob_get_key(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -141,7 +141,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) else if (GS(key->from->name) == ID_CU) ((Curve *)key->from)->key = NULL; else if (GS(key->from->name) == ID_LT) ((Lattice *)key->from)->key = NULL; - free_libblock_us(&(bmain->key), key); + BKE_libblock_free_us(&(bmain->key), key); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -403,6 +403,7 @@ void OBJECT_OT_shape_key_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror Shape Key"; ot->idname = "OBJECT_OT_shape_key_mirror"; + ot->description = "Mirror the current shape key along the local X axis"; /* api callbacks */ ot->poll = shape_key_mode_poll; @@ -474,6 +475,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Shape Key"; ot->idname = "OBJECT_OT_shape_key_move"; + ot->description = "Move the active shape key up/down in the list"; /* api callbacks */ ot->poll = shape_key_mode_poll; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index b8a7ce999f1..34395163ad3 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -370,8 +370,8 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) /* a change was made, adjust the children to compensate */ for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) { if (ob_child->parent == ob) { - object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); - what_does_parent(scene, ob_child, &workob); + BKE_object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); + BKE_object_workob_calc_parent(scene, ob_child, &workob); invert_m4_m4(ob_child->parentinv, workob.obmat); } } @@ -434,17 +434,17 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* calculate rotation/scale matrix */ if (apply_scale && apply_rot) - object_to_mat3(ob, rsmat); + BKE_object_to_mat3(ob, rsmat); else if (apply_scale) - object_scale_to_mat3(ob, rsmat); + BKE_object_scale_to_mat3(ob, rsmat); else if (apply_rot) { float tmat[3][3], timat[3][3]; /* simple rotation matrix */ - object_rot_to_mat3(ob, rsmat); + BKE_object_rot_to_mat3(ob, rsmat); /* correct for scale, note mul_m3_m3m3 has swapped args! */ - object_scale_to_mat3(ob, tmat); + BKE_object_scale_to_mat3(ob, tmat); invert_m3_m3(timat, tmat); mul_m3_m3m3(rsmat, timat, rsmat); mul_m3_m3m3(rsmat, rsmat, tmat); @@ -460,7 +460,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (!(apply_scale && apply_rot)) { /* correct for scale and rotation that is still applied */ - object_to_mat3(ob, obmat); + BKE_object_to_mat3(ob, obmat); invert_m3_m3(iobmat, obmat); mul_m3_m3m3(tmat, rsmat, iobmat); mul_m3_v3(tmat, mat[3]); @@ -491,7 +491,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } /* update normals */ - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } else if (ob->type == OB_ARMATURE) { ED_armature_apply_transform(ob, mat); @@ -546,9 +546,9 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo unit_axis_angle(ob->rotAxis, &ob->rotAngle); } - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -573,9 +573,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - where_is_object(scene, ob); - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_where_is_calc(scene, ob); /* update for any children that may get moved */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -750,7 +750,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else { /* only bounds support */ INIT_MINMAX(min, max); - minmax_object_duplis(scene, ob, min, max); + BKE_object_minmax_dupli(scene, ob, min, max); mid_v3_v3v3(cent, min, max); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); @@ -772,11 +772,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { mesh_center_median(me, cent); } - else { mesh_center_bounds(me, cent); } + else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); } + else { BKE_mesh_center_bounds(me, cent); } negate_v3_v3(cent_neg, cent); - mesh_translate(me, cent_neg, 1); + BKE_mesh_translate(me, cent_neg, 1); tot_change++; me->id.flag |= LIB_DOIT; @@ -854,8 +854,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) arm->id.flag |= LIB_DOIT; /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ - where_is_object(scene, ob); - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_object_where_is_calc(scene, ob); + BKE_pose_where_is(scene, ob); /* needed for bone parents */ ignore_parent_tx(bmain, scene, ob); @@ -867,11 +867,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) MetaBall *mb = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } - else { BKE_metaball_center_bounds(mb, cent); } + else if (around == V3D_CENTROID) { BKE_mball_center_median(mb, cent); } + else { BKE_mball_center_bounds(mb, cent); } negate_v3_v3(cent_neg, cent); - BKE_metaball_translate(mb, cent_neg); + BKE_mball_translate(mb, cent_neg); tot_change++; mb->id.flag |= LIB_DOIT; @@ -893,9 +893,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ add_v3_v3(ob->loc, centn); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -915,9 +915,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ add_v3_v3(ob_other->loc, centn); - where_is_object(scene, ob_other); + BKE_object_where_is_calc(scene, ob_other); if (ob_other->type == OB_ARMATURE) { - where_is_pose(scene, ob_other); /* needed for bone parents */ + BKE_pose_where_is(scene, ob_other); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob_other); } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index acafe62150f..0c0611d3d33 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2122,6 +2122,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_add"; + ot->description = "Add a new vertex group to the active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2152,6 +2153,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove"; + ot->description = "Delete the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2187,6 +2189,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) /* identifiers */ ot->name = "Assign Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_assign"; + ot->description = "Assign the selected vertices to the current (or a new) vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2229,6 +2232,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) /* identifiers */ ot->name = "Remove from Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove_from"; + ot->description = "Remove the selected vertices from the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2262,6 +2266,7 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_select"; + ot->description = "Select all the vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2286,6 +2291,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) /* identifiers */ ot->name = "Deselect Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_deselect"; + ot->description = "Deselect all selected vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2312,6 +2318,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_copy"; + ot->description = "Make a copy of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2342,6 +2349,7 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Group Levels"; ot->idname = "OBJECT_OT_vertex_group_levels"; + ot->description = "Add some offset and multiply with some gain the weights of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2372,6 +2380,7 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_normalize"; + ot->description = "Normalize weights of the active vertex group, so that the highest ones are now 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2400,6 +2409,8 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize All Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_normalize_all"; + ot->description = "Normalize all weights of all vertex groups, " + "so that for each vertex, the sum of all weights is 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2480,6 +2491,7 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot) /* identifiers */ ot->name = "Change the Lock On Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_lock"; + ot->description = "Change the lock state of all vertex groups of active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2510,6 +2522,7 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) /* identifiers */ ot->name = "Invert Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_invert"; + ot->description = "Invert active vertex group's weights"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2996,6 +3009,7 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_move"; + ot->description = "Move the active vertex group up/down in the list"; /* api callbacks */ ot->poll = vertex_group_poll; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7fb5352979d..64f4ffe4881 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1367,6 +1367,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select All"; ot->idname = "PARTICLE_OT_select_all"; + ot->description = "(De)select all particles' keys"; /* api callbacks */ ot->exec = pe_select_all_exec; @@ -1441,6 +1442,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot) /* identifiers */ ot->name = "Select Roots"; ot->idname = "PARTICLE_OT_select_roots"; + ot->description = "Select roots of all visible particles"; /* api callbacks */ ot->exec = select_roots_exec; @@ -1481,7 +1483,8 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) /* identifiers */ ot->name = "Select Tips"; ot->idname = "PARTICLE_OT_select_tips"; - + ot->description = "Select tips of all visible particles"; + /* api callbacks */ ot->exec = select_tips_exec; ot->poll = PE_poll; @@ -1525,6 +1528,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname = "PARTICLE_OT_select_linked"; + ot->description = "Select nearest particle from mouse pointer"; /* api callbacks */ ot->exec = select_linked_exec; @@ -1717,6 +1721,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot) /* identifiers */ ot->name = "Hide Selected"; ot->idname = "PARTICLE_OT_hide"; + ot->description = "Hide selected particles"; /* api callbacks */ ot->exec = hide_exec; @@ -1759,6 +1764,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name = "Reveal"; ot->idname = "PARTICLE_OT_reveal"; + ot->description = "Show hidden particles"; /* api callbacks */ ot->exec = reveal_exec; @@ -1817,6 +1823,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name = "Select Less"; ot->idname = "PARTICLE_OT_select_less"; + ot->description = "Deselect boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_less_exec; @@ -1878,6 +1885,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "PARTICLE_OT_select_more"; + ot->description = "Select keys linked to boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_more_exec; @@ -1974,6 +1982,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) /* identifiers */ ot->name = "Rekey"; ot->idname = "PARTICLE_OT_rekey"; + ot->description = "Change the number of keys of selected particles (root and tip keys included)"; /* api callbacks */ ot->exec = rekey_exec; @@ -2304,6 +2313,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) /* identifiers */ ot->name = "Subdivide"; ot->idname = "PARTICLE_OT_subdivide"; + ot->description = "Subdivide selected particles segments (adds keys)"; /* api callbacks */ ot->exec = subdivide_exec; @@ -2392,6 +2402,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Doubles"; ot->idname = "PARTICLE_OT_remove_doubles"; + ot->description = "Remove selected particles close enough of others"; /* api callbacks */ ot->exec = remove_doubles_exec; @@ -2442,6 +2453,7 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Set"; ot->idname = "PARTICLE_OT_weight_set"; + ot->description = "Set the weight of selected keys"; /* api callbacks */ ot->exec = weight_set_exec; @@ -2450,7 +2462,8 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1); + RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", + "Interpolation factor between current brush weight, and keys' weights", 0, 1); } /************************ cursor drawing *******************************/ @@ -2545,6 +2558,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "PARTICLE_OT_delete"; + ot->description = "Delete selected particles or keys"; /* api callbacks */ ot->exec = delete_exec; @@ -2710,6 +2724,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror"; ot->idname = "PARTICLE_OT_mirror"; + ot->description = "Duplicate and mirror the selected particles along the local X axis"; /* api callbacks */ ot->exec = mirror_exec; @@ -3739,6 +3754,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) /* identifiers */ ot->name = "Brush Edit"; ot->idname = "PARTICLE_OT_brush_edit"; + ot->description = "Apply a stroke of brush to the particles"; /* api callbacks */ ot->exec = brush_edit_exec; @@ -4068,7 +4084,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } if (!ok) { - minmax_object(ob, min, max); + BKE_object_minmax(ob, min, max); ok= 1; } @@ -4229,6 +4245,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Particle Edit Toggle"; ot->idname = "PARTICLE_OT_particle_edit_toggle"; + ot->description = "Toggle particle edit mode"; /* api callbacks */ ot->exec = particle_edit_toggle_exec; @@ -4278,6 +4295,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Edited"; ot->idname = "PARTICLE_OT_edited_clear"; + ot->description = "Undo all edition performed on the particle system"; /* api callbacks */ ot->exec = clear_edited_exec; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 13e407040c3..b57500df719 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -158,7 +158,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy particle setting */ if (psys->part) - part= psys_copy_settings(psys->part); + part= BKE_particlesettings_copy(psys->part); else part= psys_new_settings("ParticleSettings", bmain); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 068e93e7a5a..5a56672f766 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -126,7 +126,7 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * float dim[3]; float longest_axis; - object_get_dimensions(domainob, dim); + BKE_object_dimensions_get(domainob, dim); longest_axis = MAX3(dim[0], dim[1], dim[2]); return longest_axis * scene->unit.scale_length; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 6573647aaee..c935cb7da82 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -173,6 +173,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* identifiers */ ot->name = "Free All Physics Bakes"; ot->idname = "PTCACHE_OT_free_bake_all"; + ot->description = "Free all baked caches of all objects in the current scene"; /* api callbacks */ ot->exec = ptcache_free_bake_all_exec; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1a2e42d691a..595b51d22c4 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -170,7 +170,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s if (scn) { /* camera switch wont have updated */ scn->r.cfra = (*scene)->r.cfra; - scene_camera_switch_update(scn); + BKE_scene_camera_switch_update(scn); *scene = scn; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 9f611b52669..de3d2d4e871 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -271,7 +271,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok = BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ + ok = BKE_imbuf_write_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ if (ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -413,7 +413,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if (oglrender->timer) { /* exec will not have a timer */ scene->r.cfra = oglrender->cfrao; - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer); } @@ -451,7 +451,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) scene = oglrender->scene; oglrender->reports = op->reports; - oglrender->mh = BKE_get_movie_handle(scene->r.im_format.imtype); + oglrender->mh = BKE_movie_handle_get(scene->r.im_format.imtype); if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); @@ -478,7 +478,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) Object *camera = NULL; /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); /* go to next frame */ @@ -488,17 +488,17 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if (lay & 0xFF000000) lay &= 0xFF000000; - scene_update_for_newframe(bmain, scene, lay); + BKE_scene_update_for_newframe(bmain, scene, lay); CFRA++; } - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { - /* since scene_update_for_newframe() is used rather + /* since BKE_scene_update_for_newframe() is used rather * then ED_update_for_newframe() the camera needs to be set */ - if (scene_camera_switch_update(scene)) { + if (BKE_scene_camera_switch_update(scene)) { oglrender->v3d->camera = scene->camera; } @@ -506,7 +506,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); camera = scene->camera; } @@ -546,7 +546,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } else { BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok = BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); + ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok == 0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 32ed74097e1..f7024444e86 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -754,13 +754,13 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - /* free_material decrements texture, prevent this. hack alert! */ + /* 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; } - free_material(sp->matcopy); + BKE_material_free(sp->matcopy); properties = IDP_GetProperties((ID *)sp->matcopy, FALSE); if (properties) { @@ -776,7 +776,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied texture */ BLI_remlink(&pr_main->tex, sp->texcopy); - free_texture(sp->texcopy); + BKE_texture_free(sp->texcopy); properties = IDP_GetProperties((ID *)sp->texcopy, FALSE); if (properties) { @@ -792,7 +792,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied world */ BLI_remlink(&pr_main->world, sp->worldcopy); - free_world(sp->worldcopy); + BKE_world_free(sp->worldcopy); properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE); if (properties) { @@ -808,7 +808,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied lamp */ BLI_remlink(&pr_main->lamp, sp->lampcopy); - free_lamp(sp->lampcopy); + BKE_lamp_free(sp->lampcopy); properties = IDP_GetProperties((ID *)sp->lampcopy, FALSE); if (properties) { diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 6231970ae40..fed336e8e45 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -194,7 +194,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op)) EditFont *ef = ((Curve *)ob->data)->editfont; int i, selstart, selend; - if (ef && BKE_font_getselection(ob, &selstart, &selend)) { + if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) { for (i = selstart; i <= selend; i++) ef->textbufinfo[i].mat_nr = ob->actcol; } @@ -212,7 +212,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot) /* identifiers */ ot->name = "Assign Material Slot"; ot->idname = "OBJECT_OT_material_slot_assign"; - ot->description = "Assign the material in the selected material slot to the selected vertices"; + ot->description = "Assign active material slot to selection"; /* api callbacks */ ot->exec = material_slot_assign_exec; @@ -296,7 +296,7 @@ void OBJECT_OT_material_slot_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select Material Slot"; ot->idname = "OBJECT_OT_material_slot_select"; - ot->description = "Select vertices assigned to the selected material slot"; + ot->description = "Select by active material slot"; /* api callbacks */ ot->exec = material_slot_select_exec; @@ -315,7 +315,7 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot) /* identifiers */ ot->name = "Deselect Material Slot"; ot->idname = "OBJECT_OT_material_slot_deselect"; - ot->description = "Deselect vertices assigned to the selected material slot"; + ot->description = "Deselect by active material slot"; /* api callbacks */ ot->exec = material_slot_deselect_exec; @@ -376,12 +376,12 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy material */ if (ma) { - ma = copy_material(ma); + ma = BKE_material_copy(ma); } else { - ma = add_material("Material"); + ma = BKE_material_add("Material"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); ma->use_nodes = 1; } @@ -429,7 +429,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy texture */ if (tex) - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); else tex = add_texture("Texture"); @@ -476,12 +476,12 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy world */ if (wo) { - wo = copy_world(wo); + wo = BKE_world_copy(wo); } else { wo = add_world("World"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &wo->id); wo->use_nodes = 1; } @@ -525,7 +525,7 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - scene_add_render_layer(scene, NULL); + BKE_scene_add_render_layer(scene, NULL); scene->r.actlay = BLI_countlist(&scene->r.layers) - 1; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); @@ -552,7 +552,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay); - if (!scene_remove_render_layer(CTX_data_main(C), scene, rl)) + if (!BKE_scene_remove_render_layer(CTX_data_main(C), scene, rl)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 2fa1e759e21..0f286d91613 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -104,10 +104,10 @@ 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 = ar->winrct.xmax - ar->winrct.xmin + 1; + int height = ar->winrct.ymax - ar->winrct.ymin + 1; - wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); + wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); glLoadIdentity(); } @@ -117,7 +117,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) /* generic notes first */ switch (note->category) { case NC_WM: - if (note->data==ND_FILEREAD) + if (note->data == ND_FILEREAD) ED_region_tag_redraw(ar); break; case NC_WINDOW: @@ -145,7 +145,7 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa) if (sa->type && sa->type->refresh) { sa->type->refresh(C, sa); } - sa->do_refresh= 0; + sa->do_refresh = 0; } /* based on screen region draw tags, set draw tags in azones, and future region tabs etc */ @@ -154,15 +154,15 @@ void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) { AZone *az; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { int xs, ys; - xs= (az->x1+az->x2)/2; - ys= (az->y1+az->y2)/2; + xs = (az->x1 + az->x2) / 2; + ys = (az->y1 + az->y2) / 2; /* test if inside */ if (BLI_in_rcti(&ar->winrct, xs, ys)) { - az->do_draw= 1; + az->do_draw = 1; } } } @@ -181,16 +181,16 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) glColor4ub(255, 255, 255, 180); fdrawline(x1, y2, x2, y1); glColor4ub(255, 255, 255, 130); - fdrawline(x1, y2-dy, x2-dx, y1); + fdrawline(x1, y2 - dy, x2 - dx, y1); glColor4ub(255, 255, 255, 80); - fdrawline(x1, y2-2*dy, x2-2*dx, y1); + fdrawline(x1, y2 - 2 * dy, x2 - 2 * dx, y1); glColor4ub(0, 0, 0, 210); - fdrawline(x1, y2+1, x2+1, y1); + fdrawline(x1, y2 + 1, x2 + 1, y1); glColor4ub(0, 0, 0, 180); - fdrawline(x1, y2-dy+1, x2-dx+1, y1); + fdrawline(x1, y2 - dy + 1, x2 - dx + 1, y1); glColor4ub(0, 0, 0, 150); - fdrawline(x1, y2-2*dy+1, x2-2*dx+1, y1); + fdrawline(x1, y2 - 2 * dy + 1, x2 - 2 * dx + 1, y1); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -199,8 +199,8 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) static void region_draw_azone_icon(AZone *az) { GLUquadricObj *qobj = NULL; - short midx = az->x1 + (az->x2 - az->x1)/2; - short midy = az->y1 + (az->y2 - az->y1)/2; + short midx = az->x1 + (az->x2 - az->x1) / 2; + short midy = az->y1 + (az->y2 - az->y1) / 2; qobj = gluNewQuadric(); @@ -226,8 +226,8 @@ static void region_draw_azone_icon(AZone *az) gluDeleteQuadric(qobj); /* + */ - sdrawline(midx, midy-2, midx, midy+3); - sdrawline(midx-2, midy, midx+3, midy); + sdrawline(midx, midy - 2, midx, midy + 3); + sdrawline(midx - 2, midy, midx + 3, midy); } static void draw_azone_plus(float x1, float y1, float x2, float y2) @@ -235,9 +235,9 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) float width = 2.0f; float pad = 4.0f; - glRectf((x1 + x2 - width)*0.5f, y1 + pad, (x1 + x2 + width)*0.5f, y2 - pad); - glRectf(x1 + pad, (y1 + y2 - width)*0.5f, (x1 + x2 - width)*0.5f, (y1 + y2 + width)*0.5f); - glRectf((x1 + x2 + width)*0.5f, (y1 + y2 - width)*0.5f, x2 - pad, (y1 + y2 + width)*0.5f); + glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad); + glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f); + glRectf((x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f); } static void region_draw_azone_tab_plus(AZone *az) @@ -288,14 +288,14 @@ static void region_draw_azone_tab(AZone *az) uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_BOTTOM_TO_TOPLEFT: uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_LEFT_TO_TOPRIGHT: uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); @@ -327,19 +327,19 @@ static void region_draw_azone_tria(AZone *az) /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1+az->x2)/2, (float)az->y2); + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2); break; case AE_BOTTOM_TO_TOPLEFT: - ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1+az->x2)/2, (float)az->y1); + ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1); break; case AE_LEFT_TO_TOPRIGHT: - ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1+az->y2)/2); + ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2); break; case AE_RIGHT_TO_TOPLEFT: - ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1+az->y2)/2); + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2); break; } @@ -350,8 +350,8 @@ static void region_draw_azone_tria(AZone *az) /* only exported for WM */ void ED_area_overdraw(bContext *C) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *sa; /* Draw AZones, in screenspace */ @@ -360,23 +360,23 @@ void ED_area_overdraw(bContext *C) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { AZone *az; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { if (az->do_draw) { - if (az->type==AZONE_AREA) { + if (az->type == AZONE_AREA) { area_draw_azone(az->x1, az->y1, az->x2, az->y2); } - else if (az->type==AZONE_REGION) { + else if (az->type == AZONE_REGION) { if (az->ar) { /* only display tab or icons when the region is hidden */ - if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if (G.rt==3) + if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + if (G.rt == 3) region_draw_azone_icon(az); - else if (G.rt==2) + else if (G.rt == 2) region_draw_azone_tria(az); - else if (G.rt==1) + else if (G.rt == 1) region_draw_azone_tab(az); else region_draw_azone_tab_plus(az); @@ -384,7 +384,7 @@ void ED_area_overdraw(bContext *C) } } - az->do_draw= 0; + az->do_draw = 0; } } } @@ -395,21 +395,21 @@ void ED_area_overdraw(bContext *C) /* get scissor rect, checking overlapping regions */ void region_scissor_winrct(ARegion *ar, rcti *winrct) { - *winrct= ar->winrct; + *winrct = ar->winrct; if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) return; while (ar->prev) { - ar= ar->prev; + ar = ar->prev; if (BLI_isect_rcti(winrct, &ar->winrct, NULL)) { - if (ar->flag & RGN_FLAG_HIDDEN); - else if (ar->alignment & RGN_SPLIT_PREV); - else if (ar->alignment==RGN_OVERLAP_LEFT) { + if (ar->flag & RGN_FLAG_HIDDEN) ; + else if (ar->alignment & RGN_SPLIT_PREV) ; + else if (ar->alignment == RGN_OVERLAP_LEFT) { winrct->xmin = ar->winrct.xmax + 1; } - else if (ar->alignment==RGN_OVERLAP_RIGHT) { + else if (ar->alignment == RGN_OVERLAP_RIGHT) { winrct->xmax = ar->winrct.xmin - 1; } else break; @@ -421,19 +421,19 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct) /* makes region ready for drawing, sets pixelspace */ void ED_region_set(const bContext *C, ARegion *ar) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); rcti winrct; /* checks other overlapping regions */ region_scissor_winrct(ar, &winrct); - ar->drawrct= winrct; + ar->drawrct = winrct; /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); - UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); ED_region_pixelspace(ar); } @@ -442,9 +442,9 @@ void ED_region_set(const bContext *C, ARegion *ar) /* only exported for WM */ void ED_region_do_draw(bContext *C, ARegion *ar) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); - ARegionType *at= ar->type; + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); + ARegionType *at = ar->type; rcti winrct; /* see BKE_spacedata_draw_locks() */ @@ -456,7 +456,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* if no partial draw rect set, full rect */ if (ar->drawrct.xmin == ar->drawrct.xmax) - ar->drawrct= winrct; + ar->drawrct = winrct; else { /* extra clip for safety */ ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin); @@ -468,7 +468,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); - UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); /* optional header info instead? */ if (ar->headerstr) { @@ -487,7 +487,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL); - ar->do_draw= 0; + ar->do_draw = 0; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); uiFreeInactiveBlocks(C, &ar->uiblocks); @@ -505,7 +505,7 @@ void ED_region_tag_redraw(ARegion *ar) { if (ar) { /* zero region means full region redraw */ - ar->do_draw= RGN_DRAW; + ar->do_draw = RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); } } @@ -513,7 +513,7 @@ void ED_region_tag_redraw(ARegion *ar) void ED_region_tag_redraw_overlay(ARegion *ar) { if (ar) - ar->do_draw_overlay= RGN_DRAW; + ar->do_draw_overlay = RGN_DRAW; } void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) @@ -521,8 +521,8 @@ void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) if (ar) { if (!ar->do_draw) { /* no redraw set yet, set partial region */ - ar->do_draw= RGN_DRAW_PARTIAL; - ar->drawrct= *rct; + ar->do_draw = RGN_DRAW_PARTIAL; + ar->drawrct = *rct; } else if (ar->drawrct.xmin != ar->drawrct.xmax) { /* partial redraw already set, expand region */ @@ -539,7 +539,7 @@ void ED_area_tag_redraw(ScrArea *sa) ARegion *ar; if (sa) - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_tag_redraw(ar); } @@ -548,7 +548,7 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) ARegion *ar; if (sa) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == regiontype) { ED_region_tag_redraw(ar); } @@ -559,7 +559,7 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) void ED_area_tag_refresh(ScrArea *sa) { if (sa) - sa->do_refresh= 1; + sa->do_refresh = 1; } /* *************************************************************** */ @@ -573,16 +573,16 @@ void ED_area_headerprint(ScrArea *sa, const char *str) if (sa == NULL) return; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_HEADER) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_HEADER) { if (str) { - if (ar->headerstr==NULL) - ar->headerstr= MEM_mallocN(256, "headerprint"); + if (ar->headerstr == NULL) + ar->headerstr = MEM_mallocN(256, "headerprint"); BLI_strncpy(ar->headerstr, str, 256); } else if (ar->headerstr) { MEM_freeN(ar->headerstr); - ar->headerstr= NULL; + ar->headerstr = NULL; } ED_region_tag_redraw(ar); } @@ -600,53 +600,53 @@ static void area_azone_initialize(ScrArea *sa) BLI_freelistN(&sa->actionzones); /* set area action zones */ - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_AREA; - az->x1= sa->totrct.xmin - 1; - az->y1= sa->totrct.ymin - 1; - az->x2= sa->totrct.xmin + (AZONESPOT-1); - az->y2= sa->totrct.ymin + (AZONESPOT-1); + az->type = AZONE_AREA; + az->x1 = sa->totrct.xmin - 1; + az->y1 = sa->totrct.ymin - 1; + az->x2 = sa->totrct.xmin + (AZONESPOT - 1); + az->y2 = sa->totrct.ymin + (AZONESPOT - 1); BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_AREA; - az->x1= sa->totrct.xmax + 1; - az->y1= sa->totrct.ymax + 1; - az->x2= sa->totrct.xmax - (AZONESPOT-1); - az->y2= sa->totrct.ymax - (AZONESPOT-1); + az->type = AZONE_AREA; + az->x1 = sa->totrct.xmax + 1; + az->y1 = sa->totrct.ymax + 1; + az->x2 = sa->totrct.xmax - (AZONESPOT - 1); + az->y2 = sa->totrct.ymax - (AZONESPOT - 1); BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } -#define AZONEPAD_EDGE 4 -#define AZONEPAD_ICON 9 +#define AZONEPAD_EDGE 4 +#define AZONEPAD_ICON 9 static void region_azone_edge(AZone *az, ARegion *ar) { switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymax - AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymax - AZONEPAD_EDGE; + az->x2 = ar->winrct.xmax; + az->y2 = ar->winrct.ymax; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin + AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymin + AZONEPAD_EDGE; + az->x2 = ar->winrct.xmax; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmin + AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymin; + az->x2 = ar->winrct.xmin + AZONEPAD_EDGE; + az->y2 = ar->winrct.ymax; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmax - AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmax; + az->y1 = ar->winrct.ymin; + az->x2 = ar->winrct.xmax - AZONEPAD_EDGE; + az->y2 = ar->winrct.ymax; break; } @@ -656,55 +656,55 @@ static void region_azone_edge(AZone *az, ARegion *ar) static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot=0; + int tot = 0; /* count how many actionzones with along same edge are available. * This allows for adding more action zones in the future without * having to worry about correct offset */ - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax + AZONEPAD_ICON; - az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON; - az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON; + az->x1 = ar->winrct.xmax - tot * 2 * AZONEPAD_ICON; + az->y1 = ar->winrct.ymax + AZONEPAD_ICON; + az->x2 = ar->winrct.xmax - tot * AZONEPAD_ICON; + az->y2 = ar->winrct.ymax + 2 * AZONEPAD_ICON; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_ICON; - az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymin - AZONEPAD_ICON; + az->x1 = ar->winrct.xmin + AZONEPAD_ICON; + az->y1 = ar->winrct.ymin - 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_ICON; + az->y2 = ar->winrct.ymin - AZONEPAD_ICON; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin - AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + az->x1 = ar->winrct.xmin - 2 * AZONEPAD_ICON; + az->y1 = ar->winrct.ymax - tot * 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmin - AZONEPAD_ICON; + az->y2 = ar->winrct.ymax - tot * AZONEPAD_ICON; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax + AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + az->x1 = ar->winrct.xmax + AZONEPAD_ICON; + az->y1 = ar->winrct.ymax - tot * 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmax + 2 * AZONEPAD_ICON; + az->y2 = ar->winrct.ymax - tot * AZONEPAD_ICON; break; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ - for (azt= sa->actionzones.first; azt; azt= azt->next) { - if (az!=azt) { - if ( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { - if (az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) { - az->x1+= AZONESPOT; - az->x2+= AZONESPOT; + for (azt = sa->actionzones.first; azt; azt = azt->next) { + if (az != azt) { + if (ABS(az->x1 - azt->x1) < 2 && ABS(az->y1 - azt->y1) < 2) { + if (az->edge == AE_TOP_TO_BOTTOMRIGHT || az->edge == AE_BOTTOM_TO_TOPLEFT) { + az->x1 += AZONESPOT; + az->x2 += AZONESPOT; } else { - az->y1-= AZONESPOT; - az->y2-= AZONESPOT; + az->y1 -= AZONESPOT; + az->y2 -= AZONESPOT; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -712,44 +712,44 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } } -#define AZONEPAD_TAB_PLUSW 14 -#define AZONEPAD_TAB_PLUSH 14 +#define AZONEPAD_TAB_PLUSW 14 +#define AZONEPAD_TAB_PLUSH 14 /* region already made zero sized, in shape of edge */ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2.5 * AZONEPAD_TAB_PLUSW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - 1.5 * AZONEPAD_TAB_PLUSW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; - az->y1= ar->winrct.ymin - AZONEPAD_TAB_PLUSH; - az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmax - 2.5 * AZONEPAD_TAB_PLUSW; + az->y1 = ar->winrct.ymin - AZONEPAD_TAB_PLUSH; + az->x2 = ar->winrct.xmax - 1.5 * AZONEPAD_TAB_PLUSW; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin - AZONEPAD_TAB_PLUSH; - az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; - az->x2= ar->winrct.xmin; - az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + az->x1 = ar->winrct.xmin - AZONEPAD_TAB_PLUSH; + az->y1 = ar->winrct.ymax - 2.5 * AZONEPAD_TAB_PLUSW; + az->x2 = ar->winrct.xmin; + az->y2 = ar->winrct.ymax - 1.5 * AZONEPAD_TAB_PLUSW; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH; - az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2.5 * AZONEPAD_TAB_PLUSW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH; + az->y2 = ar->winrct.ymax - 1.5 * AZONEPAD_TAB_PLUSW; break; } /* rect needed for mouse pointer test */ @@ -757,89 +757,89 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) } -#define AZONEPAD_TABW 18 -#define AZONEPAD_TABH 7 +#define AZONEPAD_TABW 18 +#define AZONEPAD_TABH 7 /* region already made zero sized, in shape of edge */ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - AZONEPAD_TABW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TABH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2 * AZONEPAD_TABW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - AZONEPAD_TABW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TABH; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_TABW; - az->y1= ar->winrct.ymin - AZONEPAD_TABH; - az->x2= ar->winrct.xmin + 2*AZONEPAD_TABW; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmin + AZONEPAD_TABW; + az->y1 = ar->winrct.ymin - AZONEPAD_TABH; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_TABW; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin + 1 - AZONEPAD_TABH; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; - az->x2= ar->winrct.xmin + 1; - az->y2= ar->winrct.ymax - AZONEPAD_TABW; + az->x1 = ar->winrct.xmin + 1 - AZONEPAD_TABH; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TABW; + az->x2 = ar->winrct.xmin + 1; + az->y2 = ar->winrct.ymax - AZONEPAD_TABW; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TABH; - az->y2= ar->winrct.ymax - AZONEPAD_TABW; + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TABW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TABH; + az->y2 = ar->winrct.ymax - AZONEPAD_TABW; break; } /* rect needed for mouse pointer test */ BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } -#define AZONEPAD_TRIAW 16 -#define AZONEPAD_TRIAH 9 +#define AZONEPAD_TRIAW 16 +#define AZONEPAD_TRIAH 9 /* region already made zero sized, in shape of edge */ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - AZONEPAD_TRIAW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TRIAH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2 * AZONEPAD_TRIAW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - AZONEPAD_TRIAW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TRIAH; break; - case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_TRIAW; - az->y1= ar->winrct.ymin - AZONEPAD_TRIAH; - az->x2= ar->winrct.xmin + 2*AZONEPAD_TRIAW; - az->y2= ar->winrct.ymin; + case AE_BOTTOM_TO_TOPLEFT: + az->x1 = ar->winrct.xmin + AZONEPAD_TRIAW; + az->y1 = ar->winrct.ymin - AZONEPAD_TRIAH; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_TRIAW; + az->y2 = ar->winrct.ymin; break; - case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin + 1 - AZONEPAD_TRIAH; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; - az->x2= ar->winrct.xmin + 1; - az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + case AE_LEFT_TO_TOPRIGHT: + az->x1 = ar->winrct.xmin + 1 - AZONEPAD_TRIAH; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TRIAW; + az->x2 = ar->winrct.xmin + 1; + az->y2 = ar->winrct.ymax - AZONEPAD_TRIAW; break; - case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TRIAH; - az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + case AE_RIGHT_TO_TOPLEFT: + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TRIAW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TRIAH; + az->y2 = ar->winrct.ymax - AZONEPAD_TRIAW; break; } /* rect needed for mouse pointer test */ @@ -851,18 +851,18 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) { AZone *az; - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_REGION; - az->ar= ar; - az->edge= edge; + az->type = AZONE_REGION; + az->ar = ar; + az->edge = edge; - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if (G.rt==3) + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + if (G.rt == 3) region_azone_icon(sa, az, ar); - else if (G.rt==2) + else if (G.rt == 2) region_azone_tria(sa, az, ar); - else if (G.rt==1) + else if (G.rt == 1) region_azone_tab(sa, az, ar); else region_azone_tab_plus(sa, az, ar); @@ -878,11 +878,11 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) { - /* edge code (t b l r) is along which area edge azone will be drawn */ + /* edge code (t b l r) is along which area edge azone will be drawn */ - if (alignment==RGN_ALIGN_TOP) + if (alignment == RGN_ALIGN_TOP) region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT); - else if (alignment==RGN_ALIGN_BOTTOM) + else if (alignment == RGN_ALIGN_BOTTOM) region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT); else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT); @@ -893,21 +893,21 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) /* dir is direction to check, not the splitting edge direction! */ static int rct_fits(rcti *rect, char dir, int size) { - if (dir=='h') { - return rect->xmax-rect->xmin - size; + if (dir == 'h') { + return rect->xmax - rect->xmin - size; } else { // 'v' - return rect->ymax-rect->ymin - size; + return rect->ymax - rect->ymin - size; } } static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int quad) { - rcti *remainder_prev= remainder; + rcti *remainder_prev = remainder; int prefsizex, prefsizey; int alignment; - if (ar==NULL) + if (ar == NULL) return; /* no returns in function, winrct gets set in the end again */ @@ -916,53 +916,53 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* for test; allow split of previously defined region */ if (ar->alignment & RGN_SPLIT_PREV) if (ar->prev) - remainder= &ar->prev->winrct; + remainder = &ar->prev->winrct; alignment = ar->alignment & ~RGN_SPLIT_PREV; /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; /* user errors */ - if (ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) - alignment= RGN_ALIGN_NONE; + if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT) + alignment = RGN_ALIGN_NONE; /* prefsize, for header we stick to exception */ - prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex; - if (ar->regiontype==RGN_TYPE_HEADER) - prefsizey= ar->type->prefsizey; - else if (ar->regiontype==RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { - prefsizey= UI_UNIT_Y * 2 + (UI_UNIT_Y/2); + prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex; + if (ar->regiontype == RGN_TYPE_HEADER) + prefsizey = ar->type->prefsizey; + else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { + prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2); } else - prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; + prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey; /* hidden is user flag */ - if (ar->flag & RGN_FLAG_HIDDEN); + if (ar->flag & RGN_FLAG_HIDDEN) ; /* XXX floating area region, not handled yet here */ - else if (alignment == RGN_ALIGN_FLOAT); + else if (alignment == RGN_ALIGN_FLOAT) ; /* remainder is too small for any usage */ - else if ( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) { + else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } - else if (alignment==RGN_ALIGN_NONE) { + else if (alignment == RGN_ALIGN_NONE) { /* typically last region */ - ar->winrct= *remainder; + ar->winrct = *remainder; BLI_init_rcti(remainder, 0, 0, 0, 0); } - else if (alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) { + else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { - if ( rct_fits(remainder, 'v', prefsizey) < 0 ) { + if (rct_fits(remainder, 'v', prefsizey) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { - int fac= rct_fits(remainder, 'v', prefsizey); + int fac = rct_fits(remainder, 'v', prefsizey); - if (fac < 0 ) + if (fac < 0) prefsizey += fac; - ar->winrct= *remainder; + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_TOP) { + if (alignment == RGN_ALIGN_TOP) { ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1; remainder->ymax = ar->winrct.ymin - 1; } @@ -972,92 +972,92 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } } } - else if ( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { + else if (ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { - if ( rct_fits(remainder, 'h', prefsizex) < 0 ) { + if (rct_fits(remainder, 'h', prefsizex) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { - int fac= rct_fits(remainder, 'h', prefsizex); + int fac = rct_fits(remainder, 'h', prefsizex); - if (fac < 0 ) + if (fac < 0) prefsizex += fac; - ar->winrct= *remainder; + ar->winrct = *remainder; if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) { ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1; - if (alignment==RGN_ALIGN_RIGHT) + if (alignment == RGN_ALIGN_RIGHT) remainder->xmax = ar->winrct.xmin - 1; } else { ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1; - if (alignment==RGN_ALIGN_LEFT) + if (alignment == RGN_ALIGN_LEFT) remainder->xmin = ar->winrct.xmax + 1; } } } - else if (alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) { + else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) { /* percentage subdiv*/ - ar->winrct= *remainder; + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_HSPLIT) { - if ( rct_fits(remainder, 'h', prefsizex) > 4) { - ar->winrct.xmax = (remainder->xmin+remainder->xmax)/2; - remainder->xmin = ar->winrct.xmax+1; + if (alignment == RGN_ALIGN_HSPLIT) { + if (rct_fits(remainder, 'h', prefsizex) > 4) { + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + remainder->xmin = ar->winrct.xmax + 1; } else { BLI_init_rcti(remainder, 0, 0, 0, 0); } } else { - if ( rct_fits(remainder, 'v', prefsizey) > 4) { - ar->winrct.ymax = (remainder->ymin+remainder->ymax)/2; - remainder->ymin = ar->winrct.ymax+1; + if (rct_fits(remainder, 'v', prefsizey) > 4) { + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + remainder->ymin = ar->winrct.ymax + 1; } else { BLI_init_rcti(remainder, 0, 0, 0, 0); } } } - else if (alignment==RGN_ALIGN_QSPLIT) { - ar->winrct= *remainder; + else if (alignment == RGN_ALIGN_QSPLIT) { + ar->winrct = *remainder; /* test if there's still 4 regions left */ - if (quad==0) { - ARegion *artest= ar->next; - int count= 1; + if (quad == 0) { + ARegion *artest = ar->next; + int count = 1; while (artest) { - artest->alignment= RGN_ALIGN_QSPLIT; - artest= artest->next; + artest->alignment = RGN_ALIGN_QSPLIT; + artest = artest->next; count++; } - if (count!=4) { + if (count != 4) { /* let's stop adding regions */ BLI_init_rcti(remainder, 0, 0, 0, 0); if (G.debug & G_DEBUG) printf("region quadsplit failed\n"); } - else quad= 1; + else quad = 1; } if (quad) { - if (quad==1) { /* left bottom */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + if (quad == 1) { /* left bottom */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; } - else if (quad==2) { /* left top */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + else if (quad == 2) { /* left top */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; } - else if (quad==3) { /* right bottom */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + else if (quad == 3) { /* right bottom */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; } - else { /* right top */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + else { /* right top */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; BLI_init_rcti(remainder, 0, 0, 0, 0); } @@ -1066,16 +1066,16 @@ 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 = ar->winrct.xmax - ar->winrct.xmin + 1; + ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; /* set winrect for azones */ - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - ar->winrct= *remainder; + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_TOP) + if (alignment == RGN_ALIGN_TOP) ar->winrct.ymin = ar->winrct.ymax; - else if (alignment==RGN_ALIGN_BOTTOM) + else if (alignment == RGN_ALIGN_BOTTOM) ar->winrct.ymax = ar->winrct.ymin; else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) ar->winrct.xmin = ar->winrct.xmax; @@ -1088,9 +1088,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* restore prev-split exception */ 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; + 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; } } @@ -1113,34 +1113,34 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) { - short rt= 0; // CLAMPIS(G.rt, 0, 16); + short rt = 0; // CLAMPIS(G.rt, 0, 16); - if (sa->v1->vec.x>0) sa->totrct.xmin = sa->v1->vec.x+1+rt; + if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + 1 + rt; else sa->totrct.xmin = sa->v1->vec.x; - if (sa->v4->vec.x<sizex-1) sa->totrct.xmax = sa->v4->vec.x-1-rt; + if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - 1 - rt; else sa->totrct.xmax = sa->v4->vec.x; - if (sa->v1->vec.y>0) sa->totrct.ymin = sa->v1->vec.y+1+rt; + if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + 1 + rt; else sa->totrct.ymin = sa->v1->vec.y; - if (sa->v2->vec.y<sizey-1) sa->totrct.ymax = sa->v2->vec.y-1-rt; + if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - 1 - rt; 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 = sa->totrct.xmax - sa->totrct.xmin + 1; + sa->winy = sa->totrct.ymax - sa->totrct.ymin + 1; } /* used for area initialize below */ static void region_subwindow(wmWindow *win, ARegion *ar) { - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { if (ar->swinid) wm_subwindow_close(win, ar->swinid); - ar->swinid= 0; + ar->swinid = 0; } - else if (ar->swinid==0) - ar->swinid= wm_subwindow_open(win, &ar->winrct); + else if (ar->swinid == 0) + ar->swinid = wm_subwindow_open(win, &ar->winrct); else wm_subwindow_position(win, ar->swinid, &ar->winrct); } @@ -1164,10 +1164,10 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0); /* time space only has this keymap, the others get a boundbox restricted map */ - if (sa->spacetype!=SPACE_TIME) { + if (sa->spacetype != SPACE_TIME) { ARegion *ar; - static rcti rect= {0, 10000, 0, 30}; /* same local check for all areas */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + static rcti rect = {0, 10000, 0, 30}; /* same local check for all areas */ + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); } @@ -1205,15 +1205,15 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) rcti rect; /* set typedefinitions */ - sa->type= BKE_spacetype_from_id(sa->spacetype); + sa->type = BKE_spacetype_from_id(sa->spacetype); - if (sa->type==NULL) { - sa->butspacetype= sa->spacetype= SPACE_VIEW3D; - sa->type= BKE_spacetype_from_id(sa->spacetype); + if (sa->type == NULL) { + sa->butspacetype = sa->spacetype = SPACE_VIEW3D; + sa->type = BKE_spacetype_from_id(sa->spacetype); } - for (ar= sa->regionbase.first; ar; ar= ar->next) - ar->type= BKE_regiontype_from_id(sa->type, ar->regiontype); + for (ar = sa->regionbase.first; ar; ar = ar->next) + ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype); /* area sizes */ area_calc_totrct(sa, win->sizex, win->sizey); @@ -1222,7 +1222,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) area_azone_initialize(sa); /* region rect sizes */ - rect= sa->totrct; + rect = sa->totrct; region_rect_recursive(sa, sa->regionbase.first, &rect, 0); /* default area handlers */ @@ -1232,7 +1232,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) sa->type->init(wm, sa); /* region windows, default and own handlers */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { region_subwindow(win, ar); if (ar->swinid) { @@ -1248,7 +1248,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */ - if (ar->regiontype==RGN_TYPE_HEADER) + if (ar->regiontype == RGN_TYPE_HEADER) ar->v2d.flag &= ~V2D_IS_INITIALISED; } } @@ -1261,17 +1261,17 @@ 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 = ar->winrct.xmax - ar->winrct.xmin + 1; + ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; /* UI convention */ - wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); + wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); glLoadIdentity(); } void ED_region_toggle_hidden(bContext *C, ARegion *ar) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); ar->flag ^= RGN_FLAG_HIDDEN; @@ -1288,11 +1288,11 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) { SpaceType *st; ARegion *ar; - int spacetype= sa1->spacetype; + int spacetype = sa1->spacetype; - sa1->headertype= sa2->headertype; - sa1->spacetype= sa2->spacetype; - sa1->butspacetype= sa2->butspacetype; + sa1->headertype = sa2->headertype; + sa1->spacetype = sa2->spacetype; + sa1->butspacetype = sa2->butspacetype; if (swap_space == 1) { SWAP(ListBase, sa1->spacedata, sa2->spacedata); @@ -1315,16 +1315,16 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) SWAP(ListBase, sa1->regionbase, sa2->regionbase); } else { - if (swap_space<2) { - st= BKE_spacetype_from_id(spacetype); - for (ar= sa1->regionbase.first; ar; ar= ar->next) + if (swap_space < 2) { + st = BKE_spacetype_from_id(spacetype); + for (ar = sa1->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sa1->regionbase); } - st= BKE_spacetype_from_id(sa2->spacetype); - for (ar= sa2->regionbase.first; ar; ar= ar->next) { - ARegion *newar= BKE_area_region_copy(st, ar); + st = BKE_spacetype_from_id(sa2->spacetype); + for (ar = sa2->regionbase.first; ar; ar = ar->next) { + ARegion *newar = BKE_area_region_copy(st, ar); BLI_addtail(&sa1->regionbase, newar); } } @@ -1334,7 +1334,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) { - ScrArea *tmp= MEM_callocN(sizeof(ScrArea), "addscrarea"); + ScrArea *tmp = MEM_callocN(sizeof(ScrArea), "addscrarea"); ED_area_exit(C, sa1); ED_area_exit(C, sa2); @@ -1366,34 +1366,34 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) ED_area_exit(C, sa); - st= BKE_spacetype_from_id(type); - slold= sa->spacedata.first; + st = BKE_spacetype_from_id(type); + slold = sa->spacedata.first; - sa->spacetype= type; - sa->butspacetype= type; - sa->type= st; + sa->spacetype = type; + sa->butspacetype = type; + sa->type = st; /* check previously stored space */ - for (sl= sa->spacedata.first; sl; sl= sl->next) - if (sl->spacetype==type) + for (sl = sa->spacedata.first; sl; sl = sl->next) + if (sl->spacetype == type) break; /* old spacedata... happened during work on 2.50, remove */ - if (sl && sl->regionbase.first==NULL) { + if (sl && sl->regionbase.first == NULL) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); if (slold == sl) { - slold= NULL; + slold = NULL; } - sl= NULL; + sl = NULL; } if (sl) { /* swap regions */ - slold->regionbase= sa->regionbase; - sa->regionbase= sl->regionbase; - sl->regionbase.first= sl->regionbase.last= NULL; + slold->regionbase = sa->regionbase; + sa->regionbase = sl->regionbase; + sl->regionbase.first = sl->regionbase.last = NULL; /* put in front of list */ BLI_remlink(&sa->spacedata, sl); @@ -1402,14 +1402,14 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) else { /* new space */ if (st) { - sl= st->new(C); + sl = st->new(C); BLI_addhead(&sa->spacedata, sl); /* swap regions */ if (slold) - slold->regionbase= sa->regionbase; - sa->regionbase= sl->regionbase; - sl->regionbase.first= sl->regionbase.last= NULL; + slold->regionbase = sa->regionbase; + sa->regionbase = sl->regionbase; + sl->regionbase.first = sl->regionbase.last = NULL; } } @@ -1419,7 +1419,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) WM_event_add_mousemove(C); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); ED_area_tag_refresh(sa); } @@ -1446,47 +1446,47 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) ED_area_tag_redraw(sa); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); } static const char *editortype_pup(void) { - const char *types= N_( - "Editor type:%t" - "|3D View %x1" + const char *types = N_( + "Editor type:%t" + "|3D View %x1" - "|%l" + "|%l" - "|Timeline %x15" - "|Graph Editor %x2" - "|DopeSheet %x12" - "|NLA Editor %x13" + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|%l" + "|%l" - "|UV/Image Editor %x6" + "|UV/Image Editor %x6" - "|Video Sequence Editor %x8" - "|Movie Clip Editor %x20" - "|Text Editor %x9" - "|Node Editor %x16" - "|Logic Editor %x17" + "|Video Sequence Editor %x8" + "|Movie Clip Editor %x20" + "|Text Editor %x9" + "|Node Editor %x16" + "|Logic Editor %x17" - "|%l" + "|%l" - "|Properties %x4" - "|Outliner %x3" - "|User Preferences %x19" - "|Info%x7" + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" - "|%l" + "|%l" - "|File Browser %x5" + "|File Browser %x5" - "|%l" + "|%l" - "|Python Console %x18" - ); + "|Python Console %x18" + ); return IFACE_(types); } @@ -1497,20 +1497,20 @@ static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2) ED_area_tag_redraw(CTX_wm_area(C)); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, CTX_wm_area(C)); } /* returns offset for next button in header */ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); uiBut *but; - int xco= 8; + int xco = 8; but = uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, - editortype_pup(), xco, yco, UI_UNIT_X+10, UI_UNIT_Y, - &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, - TIP_("Displays current editor type. Click for menu of available types")); + editortype_pup(), xco, yco, UI_UNIT_X + 10, UI_UNIT_Y, + &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, + TIP_("Displays current editor type. Click for menu of available types")); uiButSetFunc(but, spacefunc, NULL, NULL); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ @@ -1519,12 +1519,12 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) { - ScrArea *sa= CTX_wm_area(C); - int xco= 8; + ScrArea *sa = CTX_wm_area(C); + int xco = 8; uiBut *but; if (!sa->full) - xco= ED_area_header_switchbutton(C, block, yco); + xco = ED_area_header_switchbutton(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1554,25 +1554,25 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr) { - ScrArea *sa= CTX_wm_area(C); - uiStyle *style= UI_GetStyle(); + ScrArea *sa = CTX_wm_area(C); + uiStyle *style = UI_GetStyle(); uiBlock *block; PanelType *pt; Panel *panel; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - int x, y, xco, yco, w, em, triangle, open, newcontext= 0; + int x, y, xco, yco, w, em, triangle, open, newcontext = 0; if (contextnr >= 0) - newcontext= UI_view2d_tab_set(v2d, contextnr); + newcontext = UI_view2d_tab_set(v2d, contextnr); if (vertical) { - w= v2d->cur.xmax - v2d->cur.xmin; - em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; + w = v2d->cur.xmax - v2d->cur.xmin; + em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } else { - w= UI_PANEL_WIDTH; - em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; + w = UI_PANEL_WIDTH; + em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } /* create panels */ @@ -1581,7 +1581,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(v2d); - for (pt= ar->type->paneltypes.first; pt; pt= pt->next) { + for (pt = ar->type->paneltypes.first; pt; pt = pt->next) { /* verify context */ if (context) if (pt->context[0] && strcmp(context, pt->context) != 0) @@ -1589,25 +1589,25 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* draw panel */ if (pt->draw && (!pt->poll || pt->poll(C, pt))) { - block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); - panel= uiBeginPanel(sa, ar, block, pt, &open); + block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); + panel = uiBeginPanel(sa, ar, block, pt, &open); /* bad fixed values */ - triangle= (int)(UI_UNIT_Y * 1.1f); + triangle = (int)(UI_UNIT_Y * 1.1f); if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { /* for enabled buttons */ - panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, - triangle, UI_UNIT_Y+style->panelspace+2, UI_UNIT_Y, 1, style); + panel->layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, + triangle, UI_UNIT_Y + style->panelspace + 2, UI_UNIT_Y, 1, style); pt->draw_header(C, panel); uiBlockLayoutResolve(block, &xco, &yco); - panel->labelofs= xco - triangle; - panel->layout= NULL; + panel->labelofs = xco - triangle; + panel->layout = NULL; } else { - panel->labelofs= 0; + panel->labelofs = 0; } if (open) { @@ -1615,23 +1615,23 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* panel context can either be toolbar region or normal panels region */ if (ar->regiontype == RGN_TYPE_TOOLS) - panelContext= UI_LAYOUT_TOOLBAR; + panelContext = UI_LAYOUT_TOOLBAR; else - panelContext= UI_LAYOUT_PANEL; + panelContext = UI_LAYOUT_PANEL; - panel->layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, - style->panelspace, 0, w-2*style->panelspace, em, style); + panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, + style->panelspace, 0, w - 2 * style->panelspace, em, style); pt->draw(C, panel); uiBlockLayoutResolve(block, &xco, &yco); - panel->layout= NULL; + panel->layout = NULL; - yco -= 2*style->panelspace; + yco -= 2 * style->panelspace; uiEndPanel(block, w, -yco); } else { - yco= 0; + yco = 0; uiEndPanel(block, w, 0); } @@ -1643,28 +1643,28 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * uiEndPanels(C, ar, &x, &y); /* clear */ - UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW)?TH_PREVIEW_BACK:TH_BACK); + UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); glClear(GL_COLOR_BUFFER_BIT); /* before setting the view */ if (vertical) { /* only allow scrolling in vertical direction */ - v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; - v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); + v2d->keepofs |= V2D_LOCKOFS_X | V2D_KEEPOFS_Y; + v2d->keepofs &= ~(V2D_LOCKOFS_Y | V2D_KEEPOFS_X); v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; // don't jump back when panels close or hide if (!newcontext) - y= MAX2(-y, -v2d->cur.ymin); + y = MAX2(-y, -v2d->cur.ymin); else - y= -y; + y = -y; } else { /* for now, allow scrolling in both directions (since layouts are optimized for vertical, * they often don't fit in horizontal layout) */ - v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_LOCKOFS_Y|V2D_KEEPOFS_X|V2D_KEEPOFS_Y); + v2d->keepofs &= ~(V2D_LOCKOFS_X | V2D_LOCKOFS_Y | V2D_KEEPOFS_X | V2D_KEEPOFS_Y); //v2d->keepofs |= V2D_LOCKOFS_Y|V2D_KEEPOFS_X; //v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; @@ -1672,12 +1672,12 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * // don't jump back when panels close or hide if (!newcontext) - x= MAX2(x, v2d->cur.xmax); - y= -y; + x = MAX2(x, v2d->cur.xmax); + y = -y; } // +V2D_SCROLL_HEIGHT is workaround to set the actual height - UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, x + V2D_SCROLL_WIDTH, y + V2D_SCROLL_HEIGHT); /* set the view */ UI_view2d_view_ortho(v2d); @@ -1689,7 +1689,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -1699,13 +1699,13 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) - // scrollbars for button regions - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + // scrollbars for button regions + ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE; ar->v2d.keepzoom |= V2D_KEEPZOOM; - // correctly initialized User-Prefs? + // correctly initialized User-Prefs? if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; @@ -1717,52 +1717,52 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) void ED_region_header(const bContext *C, ARegion *ar) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiBlock *block; uiLayout *layout; HeaderType *ht; Header header = {NULL}; int maxco, xco, yco; - int headery= ED_area_headersize(); + int headery = ED_area_headersize(); /* clear */ - UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL); + UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(&ar->v2d); - xco= maxco= 8; - yco= headery-4; + xco = maxco = 8; + yco = headery - 4; /* draw all headers types */ - for (ht= ar->type->headertypes.first; ht; ht= ht->next) { - block= uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); - layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); + for (ht = ar->type->headertypes.first; ht; ht = ht->next) { + block = uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); + layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); if (ht->draw) { - header.type= ht; - header.layout= layout; + header.type = ht; + header.layout = layout; ht->draw(C, &header); /* for view2d */ - xco= uiLayoutGetWidth(layout); + xco = uiLayoutGetWidth(layout); if (xco > maxco) - maxco= xco; + maxco = xco; } uiBlockLayoutResolve(block, &xco, &yco); /* for view2d */ if (xco > maxco) - maxco= xco; + maxco = xco; uiEndBlock(C, block); uiDrawBlock(C, block); } /* 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, ar->v2d.tot.ymax - ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); @@ -1776,20 +1776,20 @@ void ED_region_header_init(ARegion *ar) /* UI_UNIT_Y is defined as U variable now, depending dpi */ int ED_area_headersize(void) { - return UI_UNIT_Y+6; + return UI_UNIT_Y + 6; } void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) { const int header_height = 18; - uiStyle *style= UI_GetStyle(); - int fontid= style->widget.uifont_id; + uiStyle *style = UI_GetStyle(); + int fontid = style->widget.uifont_id; rcti rect; BLF_size(fontid, 11.0f, 72); /* background box */ - rect= ar->winrct; + rect = ar->winrct; rect.xmin = 0; rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height; @@ -1805,7 +1805,7 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.0f, 0.0f, 0.0f, alpha); - glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1); + glRecti(rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); glDisable(GL_BLEND); /* text */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 69db65fda1c..0f1ffb856e7 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -92,7 +92,7 @@ GLubyte stipple_quarttone[128] = { GLubyte stipple_diag_stripes_pos[128] = { - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, + 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, @@ -111,7 +111,7 @@ GLubyte stipple_diag_stripes_pos[128] = { GLubyte stipple_diag_stripes_neg[128] = { - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, + 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, @@ -134,16 +134,16 @@ void fdrawbezier(float vec[4][3]) float dist; float curve_res = 24, spline_step = 0.0f; - dist= 0.5f*ABS(vec[0][0] - vec[3][0]); + dist = 0.5f * ABS(vec[0][0] - vec[3][0]); /* check direction later, for top sockets */ - vec[1][0]= vec[0][0]+dist; - vec[1][1]= vec[0][1]; + vec[1][0] = vec[0][0] + dist; + vec[1][1] = vec[0][1]; - vec[2][0]= vec[3][0]-dist; - vec[2][1]= vec[3][1]; + vec[2][0] = vec[3][0] - dist; + vec[2][1] = vec[3][1]; /* we can reuse the dist variable here to increment the GL curve eval amount*/ - dist = 1.0f/curve_res; + dist = 1.0f / curve_res; cpack(0x0); glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]); @@ -193,7 +193,7 @@ void fdrawbox(float x1, float y1, float x2, float y2) void fdrawcheckerboard(float x1, float y1, float x2, float y2) { - unsigned char col1[4]= {40, 40, 40}, col2[4]= {50, 50, 50}; + unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50}; GLubyte checker_stipple[32 * 32 / 8] = { 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, @@ -238,11 +238,11 @@ void sdrawline(short x1, short y1, short x2, short y2) static void sdrawtripoints(short x1, short y1, short x2, short y2) { short v[2]; - v[0]= x1; v[1]= y1; + v[0] = x1; v[1] = y1; glVertex2sv(v); - v[0]= x1; v[1]= y2; + v[0] = x1; v[1] = y2; glVertex2sv(v); - v[0]= x2; v[1]= y1; + v[0] = x2; v[1] = y1; glVertex2sv(v); } @@ -285,7 +285,7 @@ void sdrawbox(short x1, short y1, short x2, short y2) void setlinestyle(int nr) { - if (nr==0) { + if (nr == 0) { glDisable(GL_LINE_STIPPLE); } else { @@ -295,20 +295,20 @@ void setlinestyle(int nr) } } - /* Invert line handling */ +/* Invert line handling */ -#define gl_toggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode)) +#define gl_toggle(mode, onoff) (((onoff) ? glEnable : glDisable)(mode)) void set_inverted_drawing(int enable) { - glLogicOp(enable?GL_INVERT:GL_COPY); + glLogicOp(enable ? GL_INVERT : GL_COPY); gl_toggle(GL_COLOR_LOGIC_OP, enable); gl_toggle(GL_DITHER, !enable); } void sdrawXORline(int x0, int y0, int x1, int y1) { - if (x0==x1 && y0==y1) return; + if (x0 == x1 && y0 == y1) return; set_inverted_drawing(1); @@ -323,35 +323,35 @@ void sdrawXORline(int x0, int y0, int x1, int y1) void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) { static short old[4][2][2]; - static char flags[4]= {0, 0, 0, 0}; + static char flags[4] = {0, 0, 0, 0}; - /* with builtin memory, max 4 lines */ + /* with builtin memory, max 4 lines */ set_inverted_drawing(1); glBegin(GL_LINES); - if (nr== -1) { /* flush */ - for (nr=0; nr<4; nr++) { + if (nr == -1) { /* flush */ + for (nr = 0; nr < 4; nr++) { if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); - flags[nr]= 0; + flags[nr] = 0; } } } else { - if (nr>=0 && nr<4) { + if (nr >= 0 && nr < 4) { if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); } - old[nr][0][0]= x0; - old[nr][0][1]= y0; - old[nr][1][0]= x1; - old[nr][1][1]= y1; + old[nr][0][0] = x0; + old[nr][0][1] = y0; + old[nr][1][0] = x1; + old[nr][1][1] = y1; - flags[nr]= 1; + flags[nr] = 1; } glVertex2i(x0, y0); @@ -364,14 +364,14 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) void fdrawXORellipse(float xofs, float yofs, float hw, float hh) { - if (hw==0) return; + if (hw == 0) return; set_inverted_drawing(1); glPushMatrix(); glTranslatef(xofs, yofs, 0.0f); glScalef(1.0f, hh / hw, 1.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, hw, 20); + glutil_draw_lined_arc(0.0, M_PI * 2.0, hw, 20); glPopMatrix(); set_inverted_drawing(0); @@ -382,7 +382,7 @@ void fdrawXORcirc(float xofs, float yofs, float rad) glPushMatrix(); glTranslatef(xofs, yofs, 0.0); - glutil_draw_lined_arc(0.0, M_PI*2.0, rad, 20); + glutil_draw_lined_arc(0.0, M_PI * 2.0, rad, 20); glPopMatrix(); set_inverted_drawing(0); @@ -394,11 +394,11 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment glBegin(GL_TRIANGLE_FAN); glVertex2f(0.0, 0.0); - for (i=0; i<nsegments; i++) { - float t= (float) i/(nsegments-1); - float cur= start + t*angle; + for (i = 0; i < nsegments; i++) { + float t = (float) i / (nsegments - 1); + float cur = start + t * angle; - glVertex2f(cosf(cur)*radius, sinf(cur)*radius); + glVertex2f(cosf(cur) * radius, sinf(cur) * radius); } glEnd(); } @@ -408,11 +408,11 @@ void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments int i; glBegin(GL_LINE_STRIP); - for (i=0; i<nsegments; i++) { - float t= (float) i/(nsegments-1); - float cur= start + t*angle; + for (i = 0; i < nsegments; i++) { + float t = (float) i / (nsegments - 1); + float cur = start + t * angle; - glVertex2f(cosf(cur)*radius, sinf(cur)*radius); + glVertex2f(cosf(cur) * radius, sinf(cur) * radius); } glEnd(); } @@ -433,29 +433,29 @@ float glaGetOneFloat(int param) void glaRasterPosSafe2f(float x, float y, float known_good_x, float known_good_y) { - GLubyte dummy= 0; + GLubyte dummy = 0; - /* As long as known good coordinates are correct - * this is guaranteed to generate an ok raster - * position (ignoring potential (real) overflow - * issues). - */ + /* As long as known good coordinates are correct + * this is guaranteed to generate an ok raster + * position (ignoring potential (real) overflow + * issues). + */ glRasterPos2f(known_good_x, known_good_y); - /* Now shift the raster position to where we wanted - * it in the first place using the glBitmap trick. - */ + /* Now shift the raster position to where we wanted + * it in the first place using the glBitmap trick. + */ glBitmap(0, 0, 0, 0, x - known_good_x, y - known_good_y, &dummy); } static int get_cached_work_texture(int *w_r, int *h_r) { - static GLint texid= -1; - static int tex_w= 256; - static int tex_h= 256; + static GLint texid = -1; + static int tex_w = 256; + static int tex_h = 256; - if (texid==-1) { - GLint ltexid= glaGetOneInteger(GL_TEXTURE_2D); + if (texid == -1) { + GLint ltexid = glaGetOneInteger(GL_TEXTURE_2D); unsigned char *tbuf; glGenTextures(1, (GLuint *)&texid); @@ -465,28 +465,28 @@ static int get_cached_work_texture(int *w_r, int *h_r) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - tbuf= MEM_callocN(tex_w*tex_h*4, "tbuf"); + tbuf = MEM_callocN(tex_w * tex_h * 4, "tbuf"); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex_w, tex_h, 0, GL_RGBA, GL_UNSIGNED_BYTE, tbuf); MEM_freeN(tbuf); glBindTexture(GL_TEXTURE_2D, ltexid); } - *w_r= tex_w; - *h_r= tex_h; + *w_r = tex_w; + *h_r = tex_h; return texid; } void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, void *rect, float scaleX, float scaleY) { - unsigned char *uc_rect= (unsigned char*) rect; - float *f_rect= (float *)rect; - float xzoom= glaGetOneFloat(GL_ZOOM_X), yzoom= glaGetOneFloat(GL_ZOOM_Y); - int ltexid= glaGetOneInteger(GL_TEXTURE_2D); - int lrowlength= glaGetOneInteger(GL_UNPACK_ROW_LENGTH); + unsigned char *uc_rect = (unsigned char *) rect; + float *f_rect = (float *)rect; + float xzoom = glaGetOneFloat(GL_ZOOM_X), yzoom = glaGetOneFloat(GL_ZOOM_Y); + int ltexid = glaGetOneInteger(GL_TEXTURE_2D); + int lrowlength = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); int subpart_x, subpart_y, tex_w, tex_h; int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y; - int texid= get_cached_work_texture(&tex_w, &tex_h); + int texid = get_cached_work_texture(&tex_w, &tex_h); /* Specify the color outside this function, and tex will modulate it. * This is useful for changing alpha without using glPixelTransferf() @@ -505,66 +505,66 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, #endif /* setup seamless 2=on, 0=off */ - seamless= ((tex_w<img_w || tex_h<img_h) && tex_w>2 && tex_h>2)? 2: 0; - - offset_x= tex_w - seamless; - offset_y= tex_h - seamless; - - nsubparts_x= (img_w + (offset_x - 1))/(offset_x); - nsubparts_y= (img_h + (offset_y - 1))/(offset_y); - - for (subpart_y=0; subpart_y<nsubparts_y; subpart_y++) { - for (subpart_x=0; subpart_x<nsubparts_x; subpart_x++) { - int remainder_x= img_w-subpart_x*offset_x; - int remainder_y= img_h-subpart_y*offset_y; - int subpart_w= (remainder_x<tex_w)? remainder_x: tex_w; - int subpart_h= (remainder_y<tex_h)? remainder_y: tex_h; - int offset_left= (seamless && subpart_x!=0)? 1: 0; - int offset_bot= (seamless && subpart_y!=0)? 1: 0; - int offset_right= (seamless && remainder_x>tex_w)? 1: 0; - int offset_top= (seamless && remainder_y>tex_h)? 1: 0; - float rast_x= x+subpart_x*offset_x*xzoom; - float rast_y= y+subpart_y*offset_y*yzoom; + seamless = ((tex_w < img_w || tex_h < img_h) && tex_w > 2 && tex_h > 2) ? 2 : 0; + + offset_x = tex_w - seamless; + offset_y = tex_h - seamless; + + nsubparts_x = (img_w + (offset_x - 1)) / (offset_x); + nsubparts_y = (img_h + (offset_y - 1)) / (offset_y); + + for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) { + for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) { + int remainder_x = img_w - subpart_x * offset_x; + int remainder_y = img_h - subpart_y * offset_y; + int subpart_w = (remainder_x < tex_w) ? remainder_x : tex_w; + int subpart_h = (remainder_y < tex_h) ? remainder_y : tex_h; + int offset_left = (seamless && subpart_x != 0) ? 1 : 0; + int offset_bot = (seamless && subpart_y != 0) ? 1 : 0; + int offset_right = (seamless && remainder_x > tex_w) ? 1 : 0; + int offset_top = (seamless && remainder_y > tex_h) ? 1 : 0; + float rast_x = x + subpart_x * offset_x * xzoom; + float rast_y = y + subpart_y * offset_y * yzoom; /* check if we already got these because we always get 2 more when doing seamless*/ - if (subpart_w<=seamless || subpart_h<=seamless) + if (subpart_w <= seamless || subpart_h <= seamless) continue; - if (format==GL_FLOAT) { - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); + if (format == GL_FLOAT) { + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * 4 + subpart_x * offset_x * 4]); /* add an extra border of pixels so linear looks ok at edges of full image. */ - if (subpart_w<tex_w) - glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if (subpart_h<tex_h) - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if (subpart_w<tex_w && subpart_h<tex_h) - glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); + if (subpart_w < tex_w) + glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]); + if (subpart_h < tex_h) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + subpart_x * offset_x * 4]); + if (subpart_w < tex_w && subpart_h < tex_h) + glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_FLOAT, &f_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]); } else { - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * 4 + subpart_x * offset_x * 4]); - if (subpart_w<tex_w) - glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y*offset_y*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); - if (subpart_h<tex_h) - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + subpart_x*offset_x*4]); - if (subpart_w<tex_w && subpart_h<tex_h) - glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y*offset_y+subpart_h-1)*img_w*4 + (subpart_x*offset_x+subpart_w-1)*4]); + if (subpart_w < tex_w) + glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[subpart_y * offset_y * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]); + if (subpart_h < tex_h) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, subpart_h, subpart_w, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + subpart_x * offset_x * 4]); + if (subpart_w < tex_w && subpart_h < tex_h) + glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, subpart_h, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &uc_rect[(subpart_y * offset_y + subpart_h - 1) * img_w * 4 + (subpart_x * offset_x + subpart_w - 1) * 4]); } glEnable(GL_TEXTURE_2D); glBegin(GL_QUADS); - glTexCoord2f((float)(0 + offset_left)/tex_w, (float)(0 + offset_bot)/tex_h); - glVertex2f(rast_x + (float)offset_left*xzoom, rast_y + (float)offset_bot*xzoom); + glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(0 + offset_bot) / tex_h); + glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)offset_bot * xzoom); - glTexCoord2f((float)(subpart_w - offset_right)/tex_w, (float)(0 + offset_bot)/tex_h); - glVertex2f(rast_x + (float)(subpart_w - offset_right)*xzoom*scaleX, rast_y + (float)offset_bot*xzoom); + glTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(0 + offset_bot) / tex_h); + glVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)offset_bot * xzoom); - glTexCoord2f((float)(subpart_w - offset_right)/tex_w, (float)(subpart_h - offset_top)/tex_h); - glVertex2f(rast_x + (float)(subpart_w - offset_right)*xzoom*scaleX, rast_y + (float)(subpart_h - offset_top)*yzoom*scaleY); + glTexCoord2f((float)(subpart_w - offset_right) / tex_w, (float)(subpart_h - offset_top) / tex_h); + glVertex2f(rast_x + (float)(subpart_w - offset_right) * xzoom * scaleX, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY); - glTexCoord2f((float)(0 + offset_left)/tex_w, (float)(subpart_h - offset_top)/tex_h); - glVertex2f(rast_x + (float)offset_left*xzoom, rast_y + (float)(subpart_h - offset_top)*yzoom*scaleY); + glTexCoord2f((float)(0 + offset_left) / tex_w, (float)(subpart_h - offset_top) / tex_h); + glVertex2f(rast_x + (float)offset_left * xzoom, rast_y + (float)(subpart_h - offset_top) * yzoom * scaleY); glEnd(); glDisable(GL_TEXTURE_2D); } @@ -587,51 +587,51 @@ void glaDrawPixelsTex(float x, float y, int img_w, int img_h, int format, void * void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int format, int type, void *rect) { - float xzoom= glaGetOneFloat(GL_ZOOM_X); - float yzoom= glaGetOneFloat(GL_ZOOM_Y); - - /* The pixel space coordinate of the intersection of - * the [zoomed] image with the origin. - */ - float ix= -x/xzoom; - float iy= -y/yzoom; - - /* The maximum pixel amounts the image can be cropped - * at the lower left without exceeding the origin. - */ - int off_x= floor(MAX2(ix, 0)); - int off_y= floor(MAX2(iy, 0)); + float xzoom = glaGetOneFloat(GL_ZOOM_X); + float yzoom = glaGetOneFloat(GL_ZOOM_Y); + + /* The pixel space coordinate of the intersection of + * the [zoomed] image with the origin. + */ + float ix = -x / xzoom; + float iy = -y / yzoom; - /* The zoomed space coordinate of the raster position - * (starting at the lower left most unclipped pixel). - */ - float rast_x= x + off_x*xzoom; - float rast_y= y + off_y*yzoom; + /* The maximum pixel amounts the image can be cropped + * at the lower left without exceeding the origin. + */ + int off_x = floor(MAX2(ix, 0)); + int off_y = floor(MAX2(iy, 0)); + + /* The zoomed space coordinate of the raster position + * (starting at the lower left most unclipped pixel). + */ + float rast_x = x + off_x * xzoom; + float rast_y = y + off_y * yzoom; GLfloat scissor[4]; int draw_w, draw_h; - /* Determine the smallest number of pixels we need to draw - * before the image would go off the upper right corner. - * - * It may seem this is just an optimization but some graphics - * cards (ATI) freak out if there is a large zoom factor and - * a large number of pixels off the screen (probably at some - * level the number of image pixels to draw is getting multiplied - * by the zoom and then clamped). Making sure we draw the - * fewest pixels possible keeps everyone mostly happy (still - * fails if we zoom in on one really huge pixel so that it - * covers the entire screen). - */ + /* Determine the smallest number of pixels we need to draw + * before the image would go off the upper right corner. + * + * It may seem this is just an optimization but some graphics + * cards (ATI) freak out if there is a large zoom factor and + * a large number of pixels off the screen (probably at some + * level the number of image pixels to draw is getting multiplied + * by the zoom and then clamped). Making sure we draw the + * fewest pixels possible keeps everyone mostly happy (still + * fails if we zoom in on one really huge pixel so that it + * covers the entire screen). + */ glGetFloatv(GL_SCISSOR_BOX, scissor); - draw_w = MIN2(img_w-off_x, ceil((scissor[2]-rast_x)/xzoom)); - draw_h = MIN2(img_h-off_y, ceil((scissor[3]-rast_y)/yzoom)); + draw_w = MIN2(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom)); + draw_h = MIN2(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom)); - if (draw_w>0 && draw_h>0) { + if (draw_w > 0 && draw_h > 0) { int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); - /* Don't use safe RasterPos (slower) if we can avoid it. */ - if (rast_x>=0 && rast_y>=0) { + /* Don't use safe RasterPos (slower) if we can avoid it. */ + if (rast_x >= 0 && rast_y >= 0) { glRasterPos2f(rast_x, rast_y); } else { @@ -639,24 +639,24 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo } glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w); - if (format==GL_LUMINANCE || format==GL_RED) { - if (type==GL_FLOAT) { - float *f_rect= (float *)rect; - glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)); + if (format == GL_LUMINANCE || format == GL_RED) { + if (type == GL_FLOAT) { + float *f_rect = (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x)); } - else if (type==GL_INT || type==GL_UNSIGNED_INT) { - int *i_rect= (int *)rect; - glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x)); + else if (type == GL_INT || type == GL_UNSIGNED_INT) { + int *i_rect = (int *)rect; + glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y * row_w + off_x)); } } else { /* RGBA */ - if (type==GL_FLOAT) { - float *f_rect= (float *)rect; - glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4); + if (type == GL_FLOAT) { + float *f_rect = (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x) * 4); } - else if (type==GL_UNSIGNED_BYTE) { - unsigned char *uc_rect= (unsigned char *) rect; - glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4); + else if (type == GL_UNSIGNED_BYTE) { + unsigned char *uc_rect = (unsigned char *) rect; + glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y * row_w + off_x) * 4); } } @@ -668,17 +668,17 @@ 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; + int sc_w = screen_rect->xmax - screen_rect->xmin + 1; + int sc_h = screen_rect->ymax - screen_rect->ymin + 1; glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); - /* The 0.375 magic number is to shift the matrix so that - * both raster and vertex integer coordinates fall at pixel - * centers properly. For a longer discussion see the OpenGL - * Programming Guide, Appendix H, Correctness Tips. - */ + /* The 0.375 magic number is to shift the matrix so that + * both raster and vertex integer coordinates fall at pixel + * centers properly. For a longer discussion see the OpenGL + * Programming Guide, Appendix H, Correctness Tips. + */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -703,7 +703,7 @@ struct gla2DDrawInfo { void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) { - *rect= di->world_rect; + *rect = di->world_rect; } void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) @@ -711,20 +711,20 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) int sc_w, sc_h; float wo_w, wo_h; - di->world_rect= *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 = (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); - di->wo_to_sc[0]= sc_w/wo_w; - di->wo_to_sc[1]= sc_h/wo_h; + di->wo_to_sc[0] = sc_w / wo_w; + di->wo_to_sc[1] = sc_h / wo_h; } gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) { - gla2DDrawInfo *di= MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); + gla2DDrawInfo *di = MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); int sc_w, sc_h; float wo_w, wo_h; @@ -733,9 +733,9 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat); glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat); - di->screen_rect= *screen_rect; + di->screen_rect = *screen_rect; if (world_rect) { - di->world_rect= *world_rect; + di->world_rect = *world_rect; } else { di->world_rect.xmin = di->screen_rect.xmin; @@ -744,13 +744,13 @@ 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 = (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); - di->wo_to_sc[0]= sc_w/wo_w; - di->wo_to_sc[1]= sc_h/wo_h; + di->wo_to_sc[0] = sc_w / wo_w; + di->wo_to_sc[1] = sc_h / wo_h; glaDefine2DArea(&di->screen_rect); @@ -759,13 +759,13 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r) { - *sc_x_r= (wo_x - di->world_rect.xmin)*di->wo_to_sc[0]; - *sc_y_r= (wo_y - di->world_rect.ymin)*di->wo_to_sc[1]; + *sc_x_r = (wo_x - di->world_rect.xmin) * di->wo_to_sc[0]; + *sc_y_r = (wo_y - di->world_rect.ymin) * di->wo_to_sc[1]; } void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2]) { - screen_r[0]= (world[0] - di->world_rect.xmin)*di->wo_to_sc[0]; - screen_r[1]= (world[1] - di->world_rect.ymin)*di->wo_to_sc[1]; + screen_r[0] = (world[0] - di->world_rect.xmin) * di->wo_to_sc[0]; + screen_r[1] = (world[1] - di->world_rect.ymin) * di->wo_to_sc[1]; } void glaEnd2DDraw(gla2DDrawInfo *di) @@ -783,8 +783,8 @@ void glaEnd2DDraw(gla2DDrawInfo *di) /* **************** GL_POINT hack ************************ */ -static int curmode=0; -static int pointhack=0; +static int curmode = 0; +static int pointhack = 0; static GLubyte Squaredot[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -792,15 +792,15 @@ static GLubyte Squaredot[16] = {0xff, 0xff, 0xff, 0xff, void bglBegin(int mode) { - curmode= mode; + curmode = mode; - if (mode==GL_POINTS) { + if (mode == GL_POINTS) { float value[4]; glGetFloatv(GL_POINT_SIZE_RANGE, value); if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack= floor(value[0] + 0.5f); - if (pointhack>4) pointhack= 4; + pointhack = floor(value[0] + 0.5f); + if (pointhack > 4) pointhack = 4; } else glBegin(mode); } @@ -814,8 +814,8 @@ int bglPointHack(void) glGetFloatv(GL_POINT_SIZE_RANGE, value); if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack_px= floorf(value[0]+0.5f); - if (pointhack_px>4) pointhack_px= 4; + pointhack_px = floorf(value[0] + 0.5f); + if (pointhack_px > 4) pointhack_px = 4; return pointhack_px; } return 0; @@ -825,46 +825,46 @@ int bglPointHack(void) void bglVertex3fv(const float vec[3]) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos3fv(vec); - glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); - } - else glVertex3fv(vec); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos3fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot); + } + else glVertex3fv(vec); + break; } } void bglVertex3f(float x, float y, float z) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos3f(x, y, z); - glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); - } - else glVertex3f(x, y, z); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos3f(x, y, z); + glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot); + } + else glVertex3f(x, y, z); + break; } } void bglVertex2fv(const float vec[2]) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos2fv(vec); - glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot); - } - else glVertex2fv(vec); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos2fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack / 2, pointhack / 2, 0.0, 0.0, Squaredot); + } + else glVertex2fv(vec); + break; } } void bglEnd(void) { - if (pointhack) pointhack= 0; + if (pointhack) pointhack = 0; else glEnd(); } @@ -872,7 +872,7 @@ void bglEnd(void) /* Uses current OpenGL state to get view matrices for gluProject/gluUnProject */ void bgl_get_mats(bglMats *mats) { - const double badvalue= 1.0e-6; + const double badvalue = 1.0e-6; glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview); glGetDoublev(GL_PROJECTION_MATRIX, mats->projection); @@ -901,7 +901,7 @@ void bgl_get_mats(bglMats *mats) /* dist is only for ortho now... */ void bglPolygonOffset(float viewdist, float dist) { - static float winmat[16], offset=0.0; + static float winmat[16], offset = 0.0; if (dist != 0.0f) { float offs; @@ -915,11 +915,11 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if (winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking - else offs= 0.0005f*dist; // should be clipping value or so... + if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist; // ortho tweaking + else offs = 0.0005f * dist; // should be clipping value or so... - winmat[14]-= offs; - offset+= offs; + winmat[14] -= offs; + offset += offs; glLoadMatrixf(winmat); glMatrixMode(GL_MODELVIEW); @@ -927,8 +927,8 @@ void bglPolygonOffset(float viewdist, float dist) else { glMatrixMode(GL_PROJECTION); - winmat[14]+= offset; - offset= 0.0; + winmat[14] += offset; + offset = 0.0; glLoadMatrixf(winmat); glMatrixMode(GL_MODELVIEW); } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 9e044068468..352039c5a61 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -72,19 +72,19 @@ const char *screen_context_dir[] = { int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { - bScreen *sc= CTX_wm_screen(C); - Scene *scene= sc->scene; + bScreen *sc = CTX_wm_screen(C); + Scene *scene = sc->scene; Base *base; unsigned int lay = scene->lay; -#if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */ - Object *obact= CTX_data_active_object(C); - Object *obedit= CTX_data_edit_object(C); - base= CTX_data_active_base(C); +#if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */ + Object *obact = CTX_data_active_object(C); + Object *obedit = CTX_data_edit_object(C); + base = CTX_data_active_base(C); #else - Object *obedit= scene->obedit; - Object *obact= OBACT; - base= BASACT; + Object *obedit = scene->obedit; + Object *obact = OBACT; + base = BASACT; #endif if (CTX_data_dir(member)) { @@ -96,9 +96,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { - int visible_objects= CTX_data_equals(member, "visible_objects"); + int visible_objects = CTX_data_equals(member, "visible_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & scene->lay)) { if (visible_objects) CTX_data_id_list_add(result, &base->object->id); @@ -110,11 +110,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { - int selectable_objects= CTX_data_equals(member, "selectable_objects"); + int selectable_objects = CTX_data_equals(member, "selectable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & lay) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0 && (base->object->restrictflag & OB_RESTRICT_SELECT) == 0) { if (selectable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -126,9 +126,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { - int selected_objects= CTX_data_equals(member, "selected_objects"); + int selected_objects = CTX_data_equals(member, "selected_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & scene->lay)) { if (selected_objects) CTX_data_id_list_add(result, &base->object->id); @@ -140,12 +140,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { - int selected_editable_objects= CTX_data_equals(member, "selected_editable_objects"); + int selected_editable_objects = CTX_data_equals(member, "selected_editable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & scene->lay)) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if (0==object_is_libdata(base->object)) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -158,13 +158,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { - bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; - EditBone *ebone, *flipbone=NULL; - int editable_bones= CTX_data_equals(member, "editable_bones"); + bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; + EditBone *ebone, *flipbone = NULL; + int editable_bones = CTX_data_equals(member, "editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled @@ -190,7 +190,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult /* only include bones if visible */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0) + if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } @@ -200,13 +200,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { - bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; - EditBone *ebone, *flipbone=NULL; - int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones"); + bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; + EditBone *ebone, *flipbone = NULL; + int selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled @@ -242,12 +242,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "visible_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); - bArmature *arm= (obpose) ? obpose->data : NULL; + Object *obpose = BKE_object_pose_armature_get(obact); + bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); @@ -258,12 +258,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); - bArmature *arm= (obpose) ? obpose->data : NULL; + Object *obpose = BKE_object_pose_armature_get(obact); + bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) @@ -276,7 +276,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "active_bone")) { if (obact && obact->type == OB_ARMATURE) { - bArmature *arm= obact->data; + bArmature *arm = obact->data; if (arm->edbo) { if (arm->act_edbone) { CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone); @@ -293,9 +293,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; - Object *obpose= object_pose_armature_get(obact); + Object *obpose = BKE_object_pose_armature_get(obact); - pchan= get_active_posechannel(obpose); + pchan = BKE_pose_channel_active(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); return 1; @@ -357,10 +357,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); @@ -368,10 +368,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } @@ -381,10 +381,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_editable_sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } @@ -394,19 +394,19 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_operator")) { - wmOperator *op= NULL; + wmOperator *op = NULL; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - op= sfile->op; + op = sfile->op; } - else if ((op= uiContextActiveOperator(C))) { + else if ((op = uiContextActiveOperator(C))) { /* do nothign */ } else { /* note, this checks poll, could be a problem, but this also * happens for the toolbar */ - op= WM_operator_last_redo(C); + op = WM_operator_last_redo(C); } /* TODO, get the operator from popup's */ diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 512cd404273..d714f82b58b 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -66,16 +66,16 @@ /* XXX actually should be not here... solve later */ #include "wm_subwindow.h" -#include "screen_intern.h" /* own module include */ +#include "screen_intern.h" /* own module include */ /* ******************* screen vert, edge, area managing *********************** */ static ScrVert *screen_addvert(bScreen *sc, short x, short y) { - ScrVert *sv= MEM_callocN(sizeof(ScrVert), "addscrvert"); - sv->vec.x= x; - sv->vec.y= y; + ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); + sv->vec.x = x; + sv->vec.y = y; BLI_addtail(&sc->vertbase, sv); return sv; @@ -86,19 +86,19 @@ static void sortscrvert(ScrVert **v1, ScrVert **v2) ScrVert *tmp; if (*v1 > *v2) { - tmp= *v1; - *v1= *v2; - *v2= tmp; + tmp = *v1; + *v1 = *v2; + *v2 = tmp; } } static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) { - ScrEdge *se= MEM_callocN(sizeof(ScrEdge), "addscredge"); + ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); sortscrvert(&v1, &v2); - se->v1= v1; - se->v2= v2; + se->v1 = v1; + se->v2 = v2; BLI_addtail(&sc->edgebase, se); return se; @@ -110,8 +110,8 @@ ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) ScrEdge *se; sortscrvert(&v1, &v2); - for (se= sc->edgebase.first; se; se= se->next) - if (se->v1==v1 && se->v2==v2) + for (se = sc->edgebase.first; se; se = se->next) + if (se->v1 == v1 && se->v2 == v2) return se; return NULL; @@ -123,50 +123,50 @@ void removedouble_scrverts(bScreen *sc) ScrEdge *se; ScrArea *sa; - verg= sc->vertbase.first; + verg = sc->vertbase.first; while (verg) { - if (verg->newv==NULL) { /* !!! */ - v1= verg->next; + if (verg->newv == NULL) { /* !!! */ + v1 = verg->next; while (v1) { - if (v1->newv==NULL) { /* !?! */ - if (v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) { + if (v1->newv == NULL) { /* !?! */ + if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) { /* printf("doublevert\n"); */ - v1->newv= verg; + v1->newv = verg; } } - v1= v1->next; + v1 = v1->next; } } - verg= verg->next; + verg = verg->next; } /* replace pointers in edges and faces */ - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - if (se->v1->newv) se->v1= se->v1->newv; - if (se->v2->newv) se->v2= se->v2->newv; + if (se->v1->newv) se->v1 = se->v1->newv; + if (se->v2->newv) se->v2 = se->v2->newv; /* edges changed: so.... */ sortscrvert(&(se->v1), &(se->v2)); - se= se->next; + se = se->next; } - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { - if (sa->v1->newv) sa->v1= sa->v1->newv; - if (sa->v2->newv) sa->v2= sa->v2->newv; - if (sa->v3->newv) sa->v3= sa->v3->newv; - if (sa->v4->newv) sa->v4= sa->v4->newv; - sa= sa->next; + if (sa->v1->newv) sa->v1 = sa->v1->newv; + if (sa->v2->newv) sa->v2 = sa->v2->newv; + if (sa->v3->newv) sa->v3 = sa->v3->newv; + if (sa->v4->newv) sa->v4 = sa->v4->newv; + sa = sa->next; } /* remove */ - verg= sc->vertbase.first; + verg = sc->vertbase.first; while (verg) { - v1= verg->next; + v1 = verg->next; if (verg->newv) { BLI_remlink(&sc->vertbase, verg); MEM_freeN(verg); } - verg= v1; + verg = v1; } } @@ -178,22 +178,22 @@ void removenotused_scrverts(bScreen *sc) /* we assume edges are ok */ - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - se->v1->flag= 1; - se->v2->flag= 1; - se= se->next; + se->v1->flag = 1; + se->v2->flag = 1; + se = se->next; } - sv= sc->vertbase.first; + sv = sc->vertbase.first; while (sv) { - svn= sv->next; - if (sv->flag==0) { + svn = sv->next; + if (sv->flag == 0) { BLI_remlink(&sc->vertbase, sv); MEM_freeN(sv); } - else sv->flag= 0; - sv= svn; + else sv->flag = 0; + sv = svn; } } @@ -202,18 +202,18 @@ void removedouble_scredges(bScreen *sc) ScrEdge *verg, *se, *sn; /* compare */ - verg= sc->edgebase.first; + verg = sc->edgebase.first; while (verg) { - se= verg->next; + se = verg->next; while (se) { - sn= se->next; - if (verg->v1==se->v1 && verg->v2==se->v2) { + sn = se->next; + if (verg->v1 == se->v1 && verg->v2 == se->v2) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } - se= sn; + se = sn; } - verg= verg->next; + verg = verg->next; } } @@ -221,35 +221,35 @@ void removenotused_scredges(bScreen *sc) { ScrEdge *se, *sen; ScrArea *sa; - int a=0; + int a = 0; /* sets flags when edge is used in area */ - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { - se= screen_findedge(sc, sa->v1, sa->v2); - if (se==NULL) printf("error: area %d edge 1 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v2, sa->v3); - if (se==NULL) printf("error: area %d edge 2 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v3, sa->v4); - if (se==NULL) printf("error: area %d edge 3 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v4, sa->v1); - if (se==NULL) printf("error: area %d edge 4 doesn't exist\n", a); - else se->flag= 1; - sa= sa->next; + se = screen_findedge(sc, sa->v1, sa->v2); + if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v2, sa->v3); + if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v3, sa->v4); + if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v4, sa->v1); + if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a); + else se->flag = 1; + sa = sa->next; a++; } - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - sen= se->next; - if (se->flag==0) { + sen = se->next; + if (se->flag == 0) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } - else se->flag= 0; - se= sen; + else se->flag = 0; + se = sen; } } @@ -262,21 +262,21 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my) { ScrEdge *se; - for (se= sc->edgebase.first; se; se= se->next) { + for (se = sc->edgebase.first; se; se = se->next) { if (scredge_is_horizontal(se)) { short min, max; - min= MIN2(se->v1->vec.x, se->v2->vec.x); - max= MAX2(se->v1->vec.x, se->v2->vec.x); + min = MIN2(se->v1->vec.x, se->v2->vec.x); + max = MAX2(se->v1->vec.x, se->v2->vec.x); - if (abs(my-se->v1->vec.y)<=2 && mx>=min && mx<=max) + if (abs(my - se->v1->vec.y) <= 2 && mx >= min && mx <= max) return se; } else { short min, max; - min= MIN2(se->v1->vec.y, se->v2->vec.y); - max= MAX2(se->v1->vec.y, se->v2->vec.y); + min = MIN2(se->v1->vec.y, se->v2->vec.y); + max = MAX2(se->v1->vec.y, se->v2->vec.y); - if (abs(mx-se->v1->vec.x)<=2 && my>=min && my<=max) + if (abs(mx - se->v1->vec.x) <= 2 && my >= min && my <= max) return se; } } @@ -289,13 +289,13 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my) /* adds no space data */ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) { - ScrArea *sa= MEM_callocN(sizeof(ScrArea), "addscrarea"); - sa->v1= v1; - sa->v2= v2; - sa->v3= v3; - sa->v4= v4; - sa->headertype= headertype; - sa->spacetype= sa->butspacetype= spacetype; + ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea"); + sa->v1 = v1; + sa->v2 = v2; + sa->v3 = v3; + sa->v4 = v4; + sa->headertype = headertype; + sa->spacetype = sa->butspacetype = spacetype; BLI_addtail(&sc->areabase, sa); @@ -320,31 +320,31 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) short x, y; // area big enough? - if (dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0; - if (dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; + if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * AREAMINX)) return 0; + if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * AREAMINY)) return 0; // to be sure CLAMP(fac, 0.0f, 1.0f); - if (dir=='h') { - y= sa->v1->vec.y+ fac*(sa->v2->vec.y- sa->v1->vec.y); + if (dir == 'h') { + y = sa->v1->vec.y + fac * (sa->v2->vec.y - sa->v1->vec.y); - if (y- sa->v1->vec.y < AREAMINY) - y= sa->v1->vec.y+ AREAMINY; - else if (sa->v2->vec.y- y < AREAMINY) - y= sa->v2->vec.y- AREAMINY; - else y-= (y % AREAGRID); + if (y - sa->v1->vec.y < AREAMINY) + y = sa->v1->vec.y + AREAMINY; + else if (sa->v2->vec.y - y < AREAMINY) + y = sa->v2->vec.y - AREAMINY; + else y -= (y % AREAGRID); return y; } else { - x= sa->v1->vec.x+ fac*(sa->v4->vec.x- sa->v1->vec.x); + x = sa->v1->vec.x + fac * (sa->v4->vec.x - sa->v1->vec.x); - if (x- sa->v1->vec.x < AREAMINX) - x= sa->v1->vec.x+ AREAMINX; - else if (sa->v4->vec.x- x < AREAMINX) - x= sa->v4->vec.x- AREAMINX; - else x-= (x % AREAGRID); + if (x - sa->v1->vec.x < AREAMINX) + x = sa->v1->vec.x + AREAMINX; + else if (sa->v4->vec.x - x < AREAMINX) + x = sa->v4->vec.x - AREAMINX; + else x -= (x % AREAGRID); return x; } @@ -352,19 +352,19 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) { - ScrArea *newa=NULL; + ScrArea *newa = NULL; ScrVert *sv1, *sv2; short split; - if (sa==NULL) return NULL; + if (sa == NULL) return NULL; - split= testsplitpoint(sa, dir, fac); - if (split==0) return NULL; + split = testsplitpoint(sa, dir, fac); + if (split == 0) return NULL; - if (dir=='h') { + if (dir == 'h') { /* new vertices */ - sv1= screen_addvert(sc, sa->v1->vec.x, split); - sv2= screen_addvert(sc, sa->v4->vec.x, split); + sv1 = screen_addvert(sc, sa->v1->vec.x, split); + sv2 = screen_addvert(sc, sa->v4->vec.x, split); /* new edges */ screen_addedge(sc, sa->v1, sv1); @@ -374,18 +374,18 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) screen_addedge(sc, sv1, sv2); /* new areas: top */ - newa= screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); + newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); area_copy_data(newa, sa, 0); /* area below */ - sa->v2= sv1; - sa->v3= sv2; + sa->v2 = sv1; + sa->v3 = sv2; } else { /* new vertices */ - sv1= screen_addvert(sc, split, sa->v1->vec.y); - sv2= screen_addvert(sc, split, sa->v2->vec.y); + sv1 = screen_addvert(sc, split, sa->v1->vec.y); + sv2 = screen_addvert(sc, split, sa->v2->vec.y); /* new edges */ screen_addedge(sc, sa->v1, sv1); @@ -395,12 +395,12 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) screen_addedge(sc, sv1, sv2); /* new areas: left */ - newa= screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype); + newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype); area_copy_data(newa, sa, 0); /* area right */ - sa->v1= sv1; - sa->v2= sv2; + sa->v1 = sv1; + sa->v2 = sv2; } /* remove double vertices en edges */ @@ -419,16 +419,16 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) bScreen *sc; ScrVert *sv1, *sv2, *sv3, *sv4; - sc= alloc_libblock(&G.main->screen, ID_SCR, name); - sc->scene= scene; - sc->do_refresh= 1; - sc->redraws_flag= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; - sc->winid= win->winid; - - sv1= screen_addvert(sc, 0, 0); - sv2= screen_addvert(sc, 0, win->sizey-1); - sv3= screen_addvert(sc, win->sizex-1, win->sizey-1); - sv4= screen_addvert(sc, win->sizex-1, 0); + sc = BKE_libblock_alloc(&G.main->screen, ID_SCR, name); + sc->scene = scene; + sc->do_refresh = 1; + sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; + sc->winid = win->winid; + + sv1 = screen_addvert(sc, 0, 0); + sv2 = screen_addvert(sc, 0, win->sizey - 1); + sv3 = screen_addvert(sc, win->sizex - 1, win->sizey - 1); + sv4 = screen_addvert(sc, win->sizex - 1, 0); screen_addedge(sc, sv1, sv2); screen_addedge(sc, sv2, sv3); @@ -448,42 +448,42 @@ static void screen_copy(bScreen *to, bScreen *from) ScrArea *sa, *saf; /* free contents of 'to', is from blenkernel screen.c */ - free_screen(to); + BKE_screen_free(to); BLI_duplicatelist(&to->vertbase, &from->vertbase); BLI_duplicatelist(&to->edgebase, &from->edgebase); BLI_duplicatelist(&to->areabase, &from->areabase); - to->regionbase.first= to->regionbase.last= NULL; + to->regionbase.first = to->regionbase.last = NULL; - s2= to->vertbase.first; - for (s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) { - s1->newv= s2; + s2 = to->vertbase.first; + for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { + s1->newv = s2; } - for (se= to->edgebase.first; se; se= se->next) { - se->v1= se->v1->newv; - se->v2= se->v2->newv; + for (se = to->edgebase.first; se; se = se->next) { + se->v1 = se->v1->newv; + se->v2 = se->v2->newv; sortscrvert(&(se->v1), &(se->v2)); } - saf= from->areabase.first; - for (sa= to->areabase.first; sa; sa= sa->next, saf= saf->next) { - sa->v1= sa->v1->newv; - sa->v2= sa->v2->newv; - sa->v3= sa->v3->newv; - sa->v4= sa->v4->newv; - - sa->spacedata.first= sa->spacedata.last= NULL; - sa->regionbase.first= sa->regionbase.last= NULL; - sa->actionzones.first= sa->actionzones.last= NULL; - sa->handlers.first= sa->handlers.last= NULL; + saf = from->areabase.first; + for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { + sa->v1 = sa->v1->newv; + sa->v2 = sa->v2->newv; + sa->v3 = sa->v3->newv; + sa->v4 = sa->v4->newv; + + sa->spacedata.first = sa->spacedata.last = NULL; + sa->regionbase.first = sa->regionbase.last = NULL; + sa->actionzones.first = sa->actionzones.last = NULL; + sa->handlers.first = sa->handlers.last = NULL; area_copy_data(sa, saf, 0); } /* put at zero (needed?) */ - for (s1= from->vertbase.first; s1; s1= s1->next) - s1->newv= NULL; + for (s1 = from->vertbase.first; s1; s1 = s1->next) + s1->newv = NULL; } @@ -496,27 +496,27 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) ScrVert *sav1, *sav2, *sav3, *sav4; ScrVert *sbv1, *sbv2, *sbv3, *sbv4; - if (sa==NULL || sb==NULL) return -1; + if (sa == NULL || sb == NULL) return -1; - sav1= sa->v1; - sav2= sa->v2; - sav3= sa->v3; - sav4= sa->v4; - sbv1= sb->v1; - sbv2= sb->v2; - sbv3= sb->v3; - sbv4= sb->v4; + sav1 = sa->v1; + sav2 = sa->v2; + sav3 = sa->v3; + sav4 = sa->v4; + sbv1 = sb->v1; + sbv2 = sb->v2; + sbv3 = sb->v3; + sbv4 = sb->v4; - if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return 0; } - else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ return 1; } - else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ return 2; } - else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return 3; } @@ -524,9 +524,9 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) } /* Helper function to join 2 areas, it has a return value, 0=failed 1=success - * used by the split, join operators + * used by the split, join operators */ -int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) +int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) { int dir; @@ -534,32 +534,32 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) /*printf("dir is : %i\n", dir);*/ if (dir < 0) { - if (sa1 ) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; - if (sa2 ) sa2->flag &= ~AREA_FLAG_DRAWJOINTO; + if (sa1) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; + if (sa2) sa2->flag &= ~AREA_FLAG_DRAWJOINTO; return 0; } if (dir == 0) { - sa1->v1= sa2->v1; - sa1->v2= sa2->v2; + sa1->v1 = sa2->v1; + sa1->v2 = sa2->v2; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } else if (dir == 1) { - sa1->v2= sa2->v2; - sa1->v3= sa2->v3; + sa1->v2 = sa2->v2; + sa1->v3 = sa2->v3; screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } else if (dir == 2) { - sa1->v3= sa2->v3; - sa1->v4= sa2->v4; + sa1->v3 = sa2->v3; + sa1->v4 = sa2->v4; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } else if (dir == 3) { - sa1->v1= sa2->v1; - sa1->v4= sa2->v4; + sa1->v1 = sa2->v1; + sa1->v4 = sa2->v4; screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } @@ -581,34 +581,38 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) /* select connected, only in the right direction */ /* 'dir' is the direction of EDGE */ - if (edge->v1->vec.x==edge->v2->vec.x) dir= 'v'; - else dir= 'h'; + if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v'; + else dir = 'h'; - sv= sc->vertbase.first; + sv = sc->vertbase.first; while (sv) { sv->flag = 0; - sv= sv->next; + sv = sv->next; } - edge->v1->flag= 1; - edge->v2->flag= 1; + edge->v1->flag = 1; + edge->v2->flag = 1; - oneselected= 1; + oneselected = 1; while (oneselected) { - se= sc->edgebase.first; - oneselected= 0; + se = sc->edgebase.first; + oneselected = 0; while (se) { - if (se->v1->flag + se->v2->flag==1) { - if (dir=='h') if (se->v1->vec.y==se->v2->vec.y) { - se->v1->flag= se->v2->flag= 1; - oneselected= 1; + if (se->v1->flag + se->v2->flag == 1) { + if (dir == 'h') { + if (se->v1->vec.y == se->v2->vec.y) { + se->v1->flag = se->v2->flag = 1; + oneselected = 1; + } } - if (dir=='v') if (se->v1->vec.x==se->v2->vec.x) { - se->v1->flag= se->v2->flag= 1; - oneselected= 1; + if (dir == 'v') { + if (se->v1->vec.x == se->v2->vec.x) { + se->v1->flag = se->v2->flag = 1; + oneselected = 1; } + } } - se= se->next; + se = se->next; } } } @@ -616,52 +620,52 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) /* test if screen vertices should be scaled */ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) { - ScrVert *sv=NULL; + ScrVert *sv = NULL; ScrArea *sa; int sizex, sizey; float facx, facy, tempf, min[2], max[2]; /* calculate size */ - min[0]= min[1]= 10000.0f; - max[0]= max[1]= 0.0f; + min[0] = min[1] = 10000.0f; + max[0] = max[1] = 0.0f; - for (sv= sc->vertbase.first; sv; sv= sv->next) { - min[0]= MIN2(min[0], sv->vec.x); - min[1]= MIN2(min[1], sv->vec.y); - max[0]= MAX2(max[0], sv->vec.x); - max[1]= MAX2(max[1], sv->vec.y); + for (sv = sc->vertbase.first; sv; sv = sv->next) { + min[0] = MIN2(min[0], sv->vec.x); + min[1] = MIN2(min[1], sv->vec.y); + max[0] = MAX2(max[0], sv->vec.x); + max[1] = MAX2(max[1], sv->vec.y); } /* always make 0.0 left under */ - for (sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv = sc->vertbase.first; sv; sv = sv->next) { sv->vec.x -= min[0]; sv->vec.y -= min[1]; } - sizex= max[0]-min[0]; - sizey= max[1]-min[1]; + sizex = max[0] - min[0]; + sizey = max[1] - min[1]; - if (sizex!= winsizex || sizey!= winsizey) { - facx= winsizex; - facx/= (float)sizex; - facy= winsizey; - facy/= (float)sizey; + if (sizex != winsizex || sizey != winsizey) { + facx = winsizex; + facx /= (float)sizex; + facy = winsizey; + facy /= (float)sizey; /* make sure it fits! */ - for (sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv = sc->vertbase.first; sv; sv = sv->next) { /* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428] * need some way to store these as floats internally and re-apply from there. */ - tempf= ((float)sv->vec.x)*facx; - sv->vec.x= (short)(tempf+0.5f); - sv->vec.x+= AREAGRID-1; - sv->vec.x-= (sv->vec.x % AREAGRID); + tempf = ((float)sv->vec.x) * facx; + sv->vec.x = (short)(tempf + 0.5f); + sv->vec.x += AREAGRID - 1; + sv->vec.x -= (sv->vec.x % AREAGRID); CLAMP(sv->vec.x, 0, winsizex); - tempf= ((float)sv->vec.y)*facy; - sv->vec.y= (short)(tempf+0.5f); - sv->vec.y+= AREAGRID-1; - sv->vec.y-= (sv->vec.y % AREAGRID); + tempf = ((float)sv->vec.y) * facy; + sv->vec.y = (short)(tempf + 0.5f); + sv->vec.y += AREAGRID - 1; + sv->vec.y -= (sv->vec.y % AREAGRID); CLAMP(sv->vec.y, 0, winsizey); } @@ -671,26 +675,26 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* ton: removed option now, it needs Context... */ /* make each window at least ED_area_headersize() high */ - for (sa= sc->areabase.first; sa; sa= sa->next) { - int headery= ED_area_headersize()+1; + for (sa = sc->areabase.first; sa; sa = sa->next) { + int headery = ED_area_headersize() + 1; - if (sa->v1->vec.y+headery > sa->v2->vec.y) { + if (sa->v1->vec.y + headery > sa->v2->vec.y) { /* lower edge */ - ScrEdge *se= screen_findedge(sc, sa->v4, sa->v1); - if (se && sa->v1!=sa->v2 ) { + ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1); + if (se && sa->v1 != sa->v2) { int yval; select_connected_scredge(sc, se); /* all selected vertices get the right offset */ - yval= sa->v2->vec.y-headery; - sv= sc->vertbase.first; + yval = sa->v2->vec.y - headery; + sv = sc->vertbase.first; while (sv) { /* if is a collapsed area */ - if (sv!=sa->v2 && sv!=sa->v3) { - if (sv->flag) sv->vec.y= yval; + if (sv != sa->v2 && sv != sa->v3) { + if (sv->flag) sv->vec.y = yval; } - sv= sv->next; + sv = sv->next; } } } @@ -714,17 +718,17 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if (height<width) { - h = height/8; - w = height/4; + if (height < width) { + h = height / 8; + w = height / 4; } else { - h = width/8; - w = width/4; + h = width / 8; + w = width / 4; } points[0].x = sa->v1->vec.x; - points[0].y = sa->v1->vec.y + height/2; + points[0].y = sa->v1->vec.y + height / 2; points[1].x = sa->v1->vec.x; points[1].y = sa->v1->vec.y; @@ -733,13 +737,13 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) points[2].y = sa->v4->vec.y; points[3].x = sa->v4->vec.x - w; - points[3].y = sa->v4->vec.y + height/2 - 2*h; + points[3].y = sa->v4->vec.y + height / 2 - 2 * h; - points[4].x = sa->v4->vec.x - 2*w; - points[4].y = sa->v4->vec.y + height/2; + points[4].x = sa->v4->vec.x - 2 * w; + points[4].y = sa->v4->vec.y + height / 2; points[5].x = sa->v4->vec.x - w; - points[5].y = sa->v4->vec.y + height/2 + 2*h; + points[5].y = sa->v4->vec.y + height / 2 + 2 * h; points[6].x = sa->v3->vec.x - w; points[6].y = sa->v3->vec.y; @@ -748,15 +752,15 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) points[7].y = sa->v2->vec.y; points[8].x = sa->v4->vec.x; - points[8].y = sa->v4->vec.y + height/2 - h; + points[8].y = sa->v4->vec.y + height / 2 - h; points[9].x = sa->v4->vec.x; - points[9].y = sa->v4->vec.y + height/2 + h; + points[9].y = sa->v4->vec.y + height / 2 + h; - if (dir=='l') { + if (dir == 'l') { /* when direction is left, then we flip direction of arrow */ float cx = sa->v1->vec.x + width; - for (i=0;i<10;i++) { + for (i = 0; i < 10; i++) { points[i].x -= cx; points[i].x = -points[i].x; points[i].x += sa->v1->vec.x; @@ -764,11 +768,11 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for (i=0;i<5;i++) + for (i = 0; i < 5; i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for (i=4;i<8;i++) + for (i = 4; i < 8; i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -786,16 +790,16 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if (height<width) { - h = height/4; - w = height/8; + if (height < width) { + h = height / 4; + w = height / 8; } else { - h = width/4; - w = width/8; + h = width / 4; + w = width / 8; } - points[0].x = sa->v1->vec.x + width/2; + points[0].x = sa->v1->vec.x + width / 2; points[0].y = sa->v3->vec.y; points[1].x = sa->v2->vec.x; @@ -804,13 +808,13 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[2].x = sa->v1->vec.x; points[2].y = sa->v1->vec.y + h; - points[3].x = sa->v1->vec.x + width/2 - 2*w; + points[3].x = sa->v1->vec.x + width / 2 - 2 * w; points[3].y = sa->v1->vec.y + h; - points[4].x = sa->v1->vec.x + width/2; - points[4].y = sa->v1->vec.y + 2*h; + points[4].x = sa->v1->vec.x + width / 2; + points[4].y = sa->v1->vec.y + 2 * h; - points[5].x = sa->v1->vec.x + width/2 + 2*w; + points[5].x = sa->v1->vec.x + width / 2 + 2 * w; points[5].y = sa->v1->vec.y + h; points[6].x = sa->v4->vec.x; @@ -819,16 +823,16 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[7].x = sa->v3->vec.x; points[7].y = sa->v3->vec.y; - points[8].x = sa->v1->vec.x + width/2 - w; + points[8].x = sa->v1->vec.x + width / 2 - w; points[8].y = sa->v1->vec.y; - points[9].x = sa->v1->vec.x + width/2 + w; + points[9].x = sa->v1->vec.x + width / 2 + w; points[9].y = sa->v1->vec.y; - if (dir=='u') { + if (dir == 'u') { /* when direction is up, then we flip direction of arrow */ float cy = sa->v1->vec.y + height; - for (i=0;i<10;i++) { + for (i = 0; i < 10; i++) { points[i].y -= cy; points[i].y = -points[i].y; points[i].y += sa->v1->vec.y; @@ -836,11 +840,11 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for (i=0;i<5;i++) + for (i = 0; i < 5; i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for (i=4;i<8;i++) + for (i = 4; i < 8; i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -852,7 +856,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) /* draw join shape due to direction of joining */ static void draw_join_shape(ScrArea *sa, char dir) { - if (dir=='u' || dir=='d') + if (dir == 'u' || dir == 'd') draw_vertical_join_shape(sa, dir); else draw_horizontal_join_shape(sa, dir); @@ -883,38 +887,38 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a) { /* right border area */ - if (x2<sizex-1) - sdrawline(x2+a, y1, x2+a, y2); + if (x2 < sizex - 1) + sdrawline(x2 + a, y1, x2 + a, y2); /* left border area */ - if (x1>0) /* otherwise it draws the emboss of window over */ - sdrawline(x1+a, y1, x1+a, y2); + if (x1 > 0) /* otherwise it draws the emboss of window over */ + sdrawline(x1 + a, y1, x1 + a, y2); /* top border area */ - if (y2<sizey-1) - sdrawline(x1, y2+a, x2, y2+a); + if (y2 < sizey - 1) + sdrawline(x1, y2 + a, x2, y2 + a); /* bottom border area */ - if (y1>0) - sdrawline(x1, y1+a, x2, y1+a); + if (y1 > 0) + sdrawline(x1, y1 + a, x2, y1 + a); } /** screen edges drawing **/ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center) { - short x1= sa->v1->vec.x; - short y1= sa->v1->vec.y; - short x2= sa->v3->vec.x; - short y2= sa->v3->vec.y; + short x1 = sa->v1->vec.x; + short y1 = sa->v1->vec.y; + short x2 = sa->v3->vec.x; + short y2 = sa->v3->vec.y; short a, rt; - rt= 0; // CLAMPIS(G.rt, 0, 16); + rt = 0; // CLAMPIS(G.rt, 0, 16); - if (center==0) { + if (center == 0) { cpack(0x505050); - for (a=-rt; a<=rt; a++) - if (a!=0) + for (a = -rt; a <= rt; a++) + if (a != 0) drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a); } else { @@ -929,10 +933,10 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) { bScreen *newsc; - if (sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ + if (sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ /* make new empty screen: */ - newsc= ED_screen_add(win, sc->scene, sc->id.name+2); + newsc = ED_screen_add(win, sc->scene, sc->id.name + 2); /* copy all data */ screen_copy(newsc, sc); @@ -942,11 +946,11 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) /* screen sets cursor based on swinid */ static void region_cursor_set(wmWindow *win, int swinid) { - ScrArea *sa= win->screen->areabase.first; + ScrArea *sa = win->screen->areabase.first; - for (;sa; sa= sa->next) { - ARegion *ar= sa->regionbase.first; - for (;ar; ar= ar->next) { + for (; sa; sa = sa->next) { + ARegion *ar = sa->regionbase.first; + for (; ar; ar = ar->next) { if (ar->swinid == swinid) { if (ar->type && ar->type->cursor) ar->type->cursor(win, sa, ar); @@ -960,25 +964,25 @@ static void region_cursor_set(wmWindow *win, int swinid) void ED_screen_do_listen(bContext *C, wmNotifier *note) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); /* generic notes */ switch (note->category) { case NC_WM: - if (note->data==ND_FILEREAD) - win->screen->do_draw= 1; + if (note->data == ND_FILEREAD) + win->screen->do_draw = 1; break; case NC_WINDOW: - win->screen->do_draw= 1; + win->screen->do_draw = 1; break; case NC_SCREEN: - if (note->data==ND_SUBWINACTIVE) + if (note->data == ND_SUBWINACTIVE) uiFreeActiveButtons(C, win->screen); - if (note->action==NA_EDITED) - win->screen->do_draw= win->screen->do_refresh= 1; + if (note->action == NA_EDITED) + win->screen->do_draw = win->screen->do_refresh = 1; break; case NC_SCENE: - if (note->data==ND_MODE) + if (note->data == ND_MODE) region_cursor_set(win, note->swinid); break; } @@ -988,21 +992,21 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) void ED_screen_draw(wmWindow *win) { ScrArea *sa; - ScrArea *sa1= NULL; - ScrArea *sa2= NULL; - ScrArea *sa3= NULL; + ScrArea *sa1 = NULL; + ScrArea *sa2 = NULL; + ScrArea *sa3 = NULL; int dir = -1; int dira = -1; wmSubWindowSet(win, win->screen->mainwin); - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa = win->screen->areabase.first; sa; sa = sa->next) { if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa; if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa; - if (sa->flag & (AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V)) sa3 = sa; + if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa; drawscredge_area(sa, win->sizex, win->sizey, 0); } - for (sa= win->screen->areabase.first; sa; sa= sa->next) + for (sa = win->screen->areabase.first; sa; sa = sa->next) drawscredge_area(sa, win->sizex, win->sizey, 1); /* blended join arrow */ @@ -1040,29 +1044,29 @@ void ED_screen_draw(wmWindow *win) if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) { sdrawline(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y); glColor4ub(0, 0, 0, 100); - sdrawline(sa3->totrct.xmin, win->eventstate->y+1, sa3->totrct.xmax, win->eventstate->y+1); + sdrawline(sa3->totrct.xmin, win->eventstate->y + 1, sa3->totrct.xmax, win->eventstate->y + 1); } else { sdrawline(win->eventstate->x, sa3->totrct.ymin, win->eventstate->x, sa3->totrct.ymax); glColor4ub(0, 0, 0, 100); - sdrawline(win->eventstate->x+1, sa3->totrct.ymin, win->eventstate->x+1, sa3->totrct.ymax); + sdrawline(win->eventstate->x + 1, sa3->totrct.ymin, win->eventstate->x + 1, sa3->totrct.ymax); } glDisable(GL_BLEND); } - win->screen->do_draw= 0; + win->screen->do_draw = 0; } /* helper call for below, dpi changes headers */ static void screen_refresh_headersizes(void) { - const ListBase *lb= BKE_spacetypes_list(); + const ListBase *lb = BKE_spacetypes_list(); SpaceType *st; - for (st= lb->first; st; st= st->next) { - ARegionType *art= BKE_regiontype_from_id(st, RGN_TYPE_HEADER); - if (art) art->prefsizey= ED_area_headersize(); + for (st = lb->first; st; st = st->next) { + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); + if (art) art->prefsizey = ED_area_headersize(); } } @@ -1076,21 +1080,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) rcti winrct; winrct.xmin = 0; - winrct.xmax = win->sizex-1; + winrct.xmax = win->sizex - 1; winrct.ymin = 0; - winrct.ymax = win->sizey-1; + winrct.ymax = win->sizey - 1; screen_test_scale(win->screen, win->sizex, win->sizey); - if (win->screen->mainwin==0) - win->screen->mainwin= wm_subwindow_open(win, &winrct); + if (win->screen->mainwin == 0) + win->screen->mainwin = wm_subwindow_open(win, &winrct); else wm_subwindow_position(win, win->screen->mainwin, &winrct); /* header size depends on DPI, let's verify */ screen_refresh_headersizes(); - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ ED_area_initialize(wm, win, sa); @@ -1104,9 +1108,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) if (G.debug & G_DEBUG_EVENTS) { printf("%s: set screen\n", __func__); } - win->screen->do_refresh= 0; + win->screen->do_refresh = 0; - win->screen->context= ed_screen_context; + win->screen->context = ed_screen_context; } /* file read, set all screens, ... */ @@ -1114,10 +1118,10 @@ void ED_screens_initialize(wmWindowManager *wm) { wmWindow *win; - for (win= wm->windows.first; win; win= win->next) { + for (win = wm->windows.first; win; win = win->next) { - if (win->screen==NULL) - win->screen= G.main->screen.first; + if (win->screen == NULL) + win->screen = G.main->screen.first; ED_screen_refresh(wm, win); } @@ -1128,28 +1132,28 @@ void ED_screens_initialize(wmWindowManager *wm) void ED_region_exit(bContext *C, ARegion *ar) { - ARegion *prevar= CTX_wm_region(C); + ARegion *prevar = CTX_wm_region(C); CTX_wm_region_set(C, ar); WM_event_remove_handlers(C, &ar->handlers); if (ar->swinid) wm_subwindow_close(CTX_wm_window(C), ar->swinid); - ar->swinid= 0; + ar->swinid = 0; if (ar->headerstr) MEM_freeN(ar->headerstr); - ar->headerstr= NULL; + ar->headerstr = NULL; CTX_wm_region_set(C, prevar); } void ED_area_exit(bContext *C, ScrArea *sa) { - ScrArea *prevsa= CTX_wm_area(C); + ScrArea *prevsa = CTX_wm_area(C); ARegion *ar; if (sa->spacetype == SPACE_FILE) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; if (sl && sl->spacetype == SPACE_FILE) { ED_fileselect_exit(C, (SpaceFile *)sl); } @@ -1159,7 +1163,7 @@ void ED_area_exit(bContext *C, ScrArea *sa) } CTX_wm_area_set(C, sa); - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_exit(C, ar); WM_event_remove_handlers(C, &sa->handlers); @@ -1168,8 +1172,8 @@ void ED_area_exit(bContext *C, ScrArea *sa) void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *prevwin= CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *prevwin = CTX_wm_window(C); ScrArea *sa; ARegion *ar; @@ -1177,21 +1181,21 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) if (screen->animtimer) WM_event_remove_timer(wm, window, screen->animtimer); - screen->animtimer= NULL; + screen->animtimer = NULL; if (screen->mainwin) wm_subwindow_close(window, screen->mainwin); - screen->mainwin= 0; - screen->subwinactive= 0; + screen->mainwin = 0; + screen->subwinactive = 0; - for (ar= screen->regionbase.first; ar; ar= ar->next) + for (ar = screen->regionbase.first; ar; ar = ar->next) ED_region_exit(C, ar); - for (sa= screen->areabase.first; sa; sa= sa->next) + for (sa = screen->areabase.first; sa; sa = sa->next) ED_area_exit(C, sa); /* mark it available for use for other windows */ - screen->winid= 0; + screen->winid = 0; if (prevwin->screen->temp == 0) { /* use previous window if possible */ @@ -1209,17 +1213,17 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) /* case when on area-edge or in azones, or outside window */ static void screen_cursor_set(wmWindow *win, wmEvent *event) { - AZone *az= NULL; + AZone *az = NULL; ScrArea *sa; - for (sa= win->screen->areabase.first; sa; sa= sa->next) - if ((az=is_in_area_actionzone(sa, event->x, event->y))) + for (sa = win->screen->areabase.first; sa; sa = sa->next) + if ((az = is_in_area_actionzone(sa, event->x, event->y))) break; if (sa) { - if (az->type==AZONE_AREA) + if (az->type == AZONE_AREA) WM_cursor_set(win, CURSOR_EDIT); - else if (az->type==AZONE_REGION) { + else if (az->type == AZONE_REGION) { if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) WM_cursor_set(win, CURSOR_X_MOVE); else @@ -1227,7 +1231,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) } } else { - ScrEdge *actedge= screen_find_active_scredge(win->screen, event->x, event->y); + ScrEdge *actedge = screen_find_active_scredge(win->screen, event->x, event->y); if (actedge) { if (scredge_is_horizontal(actedge)) @@ -1245,72 +1249,72 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) /* event type is mouse move */ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); if (win->screen) { - bScreen *scr= win->screen; + bScreen *scr = win->screen; ScrArea *sa; ARegion *ar; - int oldswin= scr->subwinactive; + int oldswin = scr->subwinactive; - for (sa= scr->areabase.first; sa; sa= sa->next) { + for (sa = scr->areabase.first; sa; sa = sa->next) { if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - if (NULL==is_in_area_actionzone(sa, event->x, event->y)) + if (NULL == is_in_area_actionzone(sa, event->x, event->y)) break; } if (sa) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (BLI_in_rcti(&ar->winrct, event->x, event->y)) - scr->subwinactive= ar->swinid; + scr->subwinactive = ar->swinid; } } else - scr->subwinactive= scr->mainwin; + scr->subwinactive = scr->mainwin; /* check for redraw headers */ - if (oldswin!=scr->subwinactive) { + if (oldswin != scr->subwinactive) { - for (sa= scr->areabase.first; sa; sa= sa->next) { - int do_draw= 0; + for (sa = scr->areabase.first; sa; sa = sa->next) { + int do_draw = 0; - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->swinid==oldswin || ar->swinid==scr->subwinactive) - do_draw= 1; + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->swinid == oldswin || ar->swinid == scr->subwinactive) + do_draw = 1; if (do_draw) { - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_HEADER) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_HEADER) ED_region_tag_redraw(ar); } } } /* cursors, for time being set always on edges, otherwise aregion doesnt switch */ - if (scr->subwinactive==scr->mainwin) { + if (scr->subwinactive == scr->mainwin) { screen_cursor_set(win, event); } - else if (oldswin!=scr->subwinactive) { + else if (oldswin != scr->subwinactive) { region_cursor_set(win, scr->subwinactive); - WM_event_add_notifier(C, NC_SCREEN|ND_SUBWINACTIVE, scr); + WM_event_add_notifier(C, NC_SCREEN | ND_SUBWINACTIVE, scr); } } } int ED_screen_area_active(const bContext *C) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); if (win && sc && sa) { - AZone *az= is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); + AZone *az = is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); ARegion *ar; if (az && az->type == AZONE_REGION) return 1; - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid == sc->subwinactive) return 1; } @@ -1321,35 +1325,35 @@ int ED_screen_area_active(const bContext *C) /* Do NOT call in area/region queues! */ void ED_screen_set(bContext *C, bScreen *sc) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); - bScreen *oldscreen= CTX_wm_screen(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + bScreen *oldscreen = CTX_wm_screen(C); ID *id; /* validate screen, it's called with notifier reference */ - for (id= CTX_data_main(C)->screen.first; id; id= id->next) + for (id = CTX_data_main(C)->screen.first; id; id = id->next) if (sc == (bScreen *)id) break; - if (id==NULL) + if (id == NULL) return; /* check for valid winid */ - if (sc->winid!=0 && sc->winid!=win->winid) + if (sc->winid != 0 && sc->winid != win->winid) return; - if (sc->full) { /* find associated full */ + if (sc->full) { /* find associated full */ bScreen *sc1; - for (sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) { - ScrArea *sa= sc1->areabase.first; - if (sa->full==sc) { - sc= sc1; + for (sc1 = CTX_data_main(C)->screen.first; sc1; sc1 = sc1->id.next) { + ScrArea *sa = sc1->areabase.first; + if (sa->full == sc) { + sc = sc1; break; } } } if (oldscreen != sc) { - wmTimer *wt= oldscreen->animtimer; + wmTimer *wt = oldscreen->animtimer; ScrArea *sa; /* remove handlers referencing areas in old screen */ @@ -1358,22 +1362,22 @@ void ED_screen_set(bContext *C, bScreen *sc) } /* we put timer to sleep, so screen_exit has to think there's no timer */ - oldscreen->animtimer= NULL; + oldscreen->animtimer = NULL; if (wt) WM_event_timer_sleep(wm, win, wt, 1); ED_screen_exit(C, win, oldscreen); - oldscreen->animtimer= wt; + oldscreen->animtimer = wt; - win->screen= sc; - CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf + win->screen = sc; + CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf /* prevent multiwin errors */ - sc->winid= win->winid; + sc->winid = win->winid; ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, NC_WINDOW, NULL); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENSET, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENSET, sc); /* makes button hilites work */ WM_event_add_mousemove(C); @@ -1384,7 +1388,7 @@ static int ed_screen_used(wmWindowManager *wm, bScreen *sc) { wmWindow *win; - for (win=wm->windows.first; win; win=win->next) + for (win = wm->windows.first; win; win = win->next) if (win->screen == sc) return 1; @@ -1394,11 +1398,11 @@ static int ed_screen_used(wmWindowManager *wm, bScreen *sc) /* only call outside of area/region loops */ void ED_screen_delete(bContext *C, bScreen *sc) { - Main *bmain= CTX_data_main(C); - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); + Main *bmain = CTX_data_main(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); bScreen *newsc; - int delete= 1; + int delete = 1; /* don't allow deleting temp fullscreens for now */ if (sc->full == SCREENFULL) { @@ -1410,12 +1414,12 @@ void ED_screen_delete(bContext *C, bScreen *sc) * long as we are able to find a screen that is unused, we * can safely assume ours is not in use anywhere an delete it */ - for (newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + for (newsc = sc->id.prev; newsc; newsc = newsc->id.prev) if (!ed_screen_used(wm, newsc)) break; if (!newsc) { - for (newsc= sc->id.next; newsc; newsc=newsc->id.next) + for (newsc = sc->id.next; newsc; newsc = newsc->id.next) if (!ed_screen_used(wm, newsc)) break; } @@ -1426,32 +1430,32 @@ void ED_screen_delete(bContext *C, bScreen *sc) ED_screen_set(C, newsc); if (delete && win->screen != sc) - free_libblock(&bmain->screen, sc); + BKE_libblock_free(&bmain->screen, sc); } /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); bScreen *sc; if (screen == NULL) return; if (ed_screen_used(CTX_wm_manager(C), screen)) - ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO); - for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if ((U.flag & USER_SCENEGLOBAL) || sc==screen) { + for (sc = CTX_data_main(C)->screen.first; sc; sc = sc->id.next) { + if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { if (scene != sc->scene) { /* all areas endlocalview */ - // XXX ScrArea *sa= sc->areabase.first; - // while (sa) { - // endlocalview(sa); - // sa= sa->next; - // } - sc->scene= scene; + // XXX ScrArea *sa= sc->areabase.first; + // while (sa) { + // endlocalview(sa); + // sa= sa->next; + // } + sc->scene = scene; } } @@ -1460,42 +1464,42 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) // copy_view3d_lock(0); /* space.c */ /* are there cameras in the views that are not in the scene? */ - for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if ( (U.flag & USER_SCENEGLOBAL) || sc==screen) { - ScrArea *sa= sc->areabase.first; + for (sc = CTX_data_main(C)->screen.first; sc; sc = sc->id.next) { + if ( (U.flag & USER_SCENEGLOBAL) || sc == screen) { + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; BKE_screen_view3d_sync(v3d, scene); - if (!v3d->camera || !object_in_scene(v3d->camera, scene)) { - v3d->camera= scene_find_camera(sc->scene); + if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { + v3d->camera = BKE_scene_camera_find(sc->scene); // XXX if (sc==curscreen) handle_view3d_lock(); if (!v3d->camera) { ARegion *ar; - for (ar=v3d->regionbase.first; ar; ar= ar->next) { + for (ar = v3d->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp==RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp = RV3D_PERSP; } } } } } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } } } CTX_data_scene_set(C, scene); - set_scene_bg(bmain, scene); + BKE_scene_set_background(bmain, scene); ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, scene, screen, 1); @@ -1508,29 +1512,29 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) /* only call outside of area/region loops */ void ED_screen_delete_scene(bContext *C, Scene *scene) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); Scene *newscene; if (scene->id.prev) - newscene= scene->id.prev; + newscene = scene->id.prev; else if (scene->id.next) - newscene= scene->id.next; + newscene = scene->id.next; else return; ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - unlink_scene(bmain, scene, newscene); + BKE_scene_unlink(bmain, scene, newscene); } ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= CTX_wm_screen(C); - ScrArea *newsa= NULL; + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *newsa = NULL; - if (!sa || sa->full==NULL) { - newsa= ED_screen_full_toggle(C, win, sa); + if (!sa || sa->full == NULL) { + newsa = ED_screen_full_toggle(C, win, sa); } if (!newsa) { @@ -1538,7 +1542,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) /* if this has been called from the temporary info header generated in * temp fullscreen layouts, find the correct fullscreen area to change * to create a new space inside */ - for (newsa = screen->areabase.first; newsa; newsa=newsa->next) { + for (newsa = screen->areabase.first; newsa; newsa = newsa->next) { if (!(sa->flag & AREA_TEMP_INFO)) break; } @@ -1555,7 +1559,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) void ED_screen_full_prevspace(bContext *C, ScrArea *sa) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); ED_area_prevspace(C, sa); @@ -1566,7 +1570,7 @@ void ED_screen_full_prevspace(bContext *C, ScrArea *sa) /* restore a screen / area back to default operation, after temp fullscreen modes */ void ED_screen_full_restore(bContext *C, ScrArea *sa) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); SpaceLink *sl = sa->spacedata.first; /* if fullscreen area has a secondary space (such as a file browser or fullscreen render @@ -1579,13 +1583,13 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa) /* Special check added for non-render image window (back from fullscreen through "Back to Previous" button) */ if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima= sa->spacedata.first; + SpaceImage *sima = sa->spacedata.first; if (!(sima->flag & SI_PREVSPACE) && !(sima->flag & SI_FULLWINDOW)) sima_restore = 1; } if (sl->spacetype == SPACE_IMAGE && !sima_restore) { - SpaceImage *sima= sa->spacedata.first; + SpaceImage *sima = sa->spacedata.first; if (sima->flag & SI_PREVSPACE) sima->flag &= ~SI_PREVSPACE; if (sima->flag & SI_FULLWINDOW) { @@ -1616,7 +1620,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* ensure we don't have a button active anymore, can crash when * switching screens with tooltip open because region and tooltip * are no longer in the same screen */ - for (ar=sa->regionbase.first; ar; ar=ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) uiFreeBlocks(C, &ar->uiblocks); /* prevent hanging header prints */ @@ -1627,76 +1631,76 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) ScrArea *old; /*short fulltype;*/ /*UNUSED*/ - sc= sa->full; /* the old screen to restore */ - oldscreen= win->screen; /* the one disappearing */ + sc = sa->full; /* the old screen to restore */ + oldscreen = win->screen; /* the one disappearing */ /*fulltype = sc->full;*/ - sc->full= 0; + sc->full = 0; /* removed: SCREENAUTOPLAY exception here */ /* find old area */ - for (old= sc->areabase.first; old; old= old->next) + for (old = sc->areabase.first; old; old = old->next) if (old->full) break; - if (old==NULL) { + if (old == NULL) { if (G.debug & G_DEBUG) printf("%s: something wrong in areafullscreen\n", __func__); return NULL; } - area_copy_data(old, sa, 1); /* 1 = swap spacelist */ + area_copy_data(old, sa, 1); /* 1 = swap spacelist */ if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; - old->full= NULL; + old->full = NULL; /* animtimer back */ - sc->animtimer= oldscreen->animtimer; - oldscreen->animtimer= NULL; + sc->animtimer = oldscreen->animtimer; + oldscreen->animtimer = NULL; ED_screen_set(C, sc); - free_screen(oldscreen); - free_libblock(&CTX_data_main(C)->screen, oldscreen); + BKE_screen_free(oldscreen); + BKE_libblock_free(&CTX_data_main(C)->screen, oldscreen); } else { ScrArea *newa; - char newname[MAX_ID_NAME-2]; + char newname[MAX_ID_NAME - 2]; - oldscreen= win->screen; + oldscreen = win->screen; /* nothing wrong with having only 1 area, as far as I can see... * is there only 1 area? */ #if 0 - if (oldscreen->areabase.first==oldscreen->areabase.last) + if (oldscreen->areabase.first == oldscreen->areabase.last) return NULL; #endif oldscreen->full = SCREENFULL; - BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name+2, "full"); - sc= ED_screen_add(win, oldscreen->scene, newname); + BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "full"); + sc = ED_screen_add(win, oldscreen->scene, newname); sc->full = SCREENFULL; // XXX /* timer */ - sc->animtimer= oldscreen->animtimer; - oldscreen->animtimer= NULL; + sc->animtimer = oldscreen->animtimer; + oldscreen->animtimer = NULL; /* returns the top small area */ - newa= area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1); + newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1); ED_area_newspace(C, newa, SPACE_INFO); /* use random area when we have no active one, e.g. when the * mouse is outside of the window and we open a file browser */ if (!sa) - sa= oldscreen->areabase.first; + sa = oldscreen->areabase.first; /* copy area */ - newa= newa->prev; - area_copy_data(newa, sa, 1); /* 1 = swap spacelist */ + newa = newa->prev; + area_copy_data(newa, sa, 1); /* 1 = swap spacelist */ sa->flag |= AREA_TEMP_INFO; - sa->full= oldscreen; - newa->full= oldscreen; - newa->next->full= oldscreen; // XXX + sa->full = oldscreen; + newa->full = oldscreen; + newa->next->full = oldscreen; // XXX ED_screen_set(C, sc); } @@ -1710,26 +1714,26 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* update frame rate info for viewport drawing */ void ED_refresh_viewport_fps(bContext *C) { - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; - Scene *scene= CTX_data_scene(C); + wmTimer *animtimer = CTX_wm_screen(C)->animtimer; + Scene *scene = CTX_data_scene(C); /* is anim playback running? */ if (animtimer && (U.uiflag & USER_SHOW_FPS)) { - ScreenFrameRateInfo *fpsi= scene->fps_info; + ScreenFrameRateInfo *fpsi = scene->fps_info; /* if there isn't any info, init it first */ if (fpsi == NULL) - fpsi= scene->fps_info= MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); + fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); /* update the values */ - fpsi->redrawtime= fpsi->lredrawtime; - fpsi->lredrawtime= animtimer->ltime; + fpsi->redrawtime = fpsi->lredrawtime; + fpsi->lredrawtime = animtimer->ltime; } else { /* playback stopped or shouldn't be running */ if (scene->fps_info) MEM_freeN(scene->fps_info); - scene->fps_info= NULL; + scene->fps_info = NULL; } } @@ -1738,56 +1742,56 @@ void ED_refresh_viewport_fps(bContext *C) */ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable) { - bScreen *screen= CTX_wm_screen(C); - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); - Scene *scene= CTX_data_scene(C); + bScreen *screen = CTX_wm_screen(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + Scene *scene = CTX_data_scene(C); if (screen->animtimer) WM_event_remove_timer(wm, win, screen->animtimer); - screen->animtimer= NULL; + screen->animtimer = NULL; if (enable) { - ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); + ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); - screen->animtimer= WM_event_add_timer(wm, win, TIMER0, (1.0/FPS)); + screen->animtimer = WM_event_add_timer(wm, win, TIMER0, (1.0 / FPS)); - sad->ar= CTX_wm_region(C); + sad->ar = CTX_wm_region(C); /* if startframe is larger than current frame, we put currentframe on startframe. * note: first frame then is not drawn! (ton) */ if (scene->r.sfra > scene->r.cfra) { - sad->sfra= scene->r.cfra; - scene->r.cfra= scene->r.sfra; + sad->sfra = scene->r.cfra; + scene->r.cfra = scene->r.sfra; } else sad->sfra = scene->r.cfra; - sad->redraws= redraws; - sad->refresh= refresh; - sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; - sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; + sad->redraws = redraws; + sad->refresh = refresh; + sad->flag |= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; + sad->flag |= (sync == 0) ? ANIMPLAY_FLAG_NO_SYNC : (sync == 1) ? ANIMPLAY_FLAG_SYNC : 0; - screen->animtimer->customdata= sad; + screen->animtimer->customdata = sad; } /* notifier catched by top header, for button */ - WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen); + WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, screen); } /* helper for screen_animation_play() - only to be used for TimeLine */ static ARegion *time_top_left_3dwindow(bScreen *screen) { - ARegion *aret= NULL; + ARegion *aret = NULL; ScrArea *sa; - int min= 10000; + int min = 10000; - for (sa= screen->areabase.first; sa; sa= sa->next) { - if (sa->spacetype==SPACE_VIEW3D) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { if (ar->winrct.xmin - ar->winrct.ymin < min) { - aret= ar; - min= ar->winrct.xmin - ar->winrct.ymin; + aret = ar; + min = ar->winrct.xmin - ar->winrct.ymin; } } } @@ -1800,14 +1804,14 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) { if (screen && screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; - sad->redraws= redraws; - sad->refresh= refresh; - sad->ar= NULL; + sad->redraws = redraws; + sad->refresh = refresh; + sad->ar = NULL; if (redraws & TIME_REGION) - sad->ar= time_top_left_3dwindow(screen); + sad->ar = time_top_left_3dwindow(screen); } } @@ -1816,12 +1820,12 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute)) { #ifdef DURIAN_CAMERA_SWITCH - void *camera= scene_camera_switch_find(scene); + void *camera = BKE_scene_camera_switch_find(scene); if (camera && scene->camera != camera) { bScreen *sc; - scene->camera= camera; + scene->camera = camera; /* are there cameras in the views that are not in the scene? */ - for (sc= bmain->screen.first; sc; sc= sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { BKE_screen_view3d_scene_sync(sc); } } @@ -1830,14 +1834,14 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS //extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */ /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); ED_clip_update_frame(bmain, scene->r.cfra); /* this function applies the changes too */ /* XXX future: do all windows */ - scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ + BKE_scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); @@ -1855,7 +1859,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS /* update animated texture nodes */ { Tex *tex; - for (tex= bmain->tex.first; tex; tex= tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->use_nodes && tex->nodetree) { ntreeTexTagAnimated(tex->nodetree); } diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 90533fd3a12..aa11c3eecdd 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -35,24 +35,24 @@ struct wmWindow; struct Scene; -#define AZONESPOT 12 +#define AZONESPOT 12 /* area.c */ -void area_copy_data (ScrArea *sa1, ScrArea *sa2, int swap_space); +void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space); /* screen_edit.c */ -ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2); -ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge); -int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2); -int area_getorientation(ScrArea *sa, ScrArea *sb); -void select_connected_scredge(bScreen *sc, ScrEdge *edge); - -void removenotused_scrverts(bScreen *sc); -void removedouble_scrverts(bScreen *sc); -void removedouble_scredges(bScreen *sc); -void removenotused_scredges(bScreen *sc); -int scredge_is_horizontal(ScrEdge *se); -ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); +ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2); +ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge); +int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2); +int area_getorientation(ScrArea *sa, ScrArea *sb); +void select_connected_scredge(bScreen *sc, ScrEdge *edge); + +void removenotused_scrverts(bScreen *sc); +void removedouble_scrverts(bScreen *sc); +void removedouble_scredges(bScreen *sc); +void removenotused_scredges(bScreen *sc); +int scredge_is_horizontal(ScrEdge *se); +ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); struct AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); @@ -66,7 +66,3 @@ void SCREEN_OT_screenshot(struct wmOperatorType *ot); void SCREEN_OT_screencast(struct wmOperatorType *ot); #endif /* __SCREEN_INTERN_H__ */ - - - - diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 49672b77d43..52e1f90606f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -78,35 +78,35 @@ #include "wm_window.h" -#include "screen_intern.h" /* own module include */ +#include "screen_intern.h" /* own module include */ -#define KM_MODAL_CANCEL 1 -#define KM_MODAL_APPLY 2 -#define KM_MODAL_STEP10 3 -#define KM_MODAL_STEP10_OFF 4 +#define KM_MODAL_CANCEL 1 +#define KM_MODAL_APPLY 2 +#define KM_MODAL_STEP10 3 +#define KM_MODAL_STEP10_OFF 4 /* ************** Exported Poll tests ********************** */ int ED_operator_regionactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_region(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_region(C) == NULL) return 0; return 1; } int ED_operator_areaactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_area(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_area(C) == NULL) return 0; return 1; } int ED_operator_screenactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; return 1; } @@ -114,8 +114,8 @@ int ED_operator_screenactive(bContext *C) static int ED_operator_screenactive_norender(bContext *C) { if (G.rendering) return 0; - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; return 1; } @@ -134,28 +134,28 @@ static int screen_active_editable(bContext *C) /* when mouse is over area-edge */ int ED_operator_screen_mainwinactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_screen(C)->subwinactive != CTX_wm_screen(C)->mainwin) return 0; return 1; } int ED_operator_scene_editable(bContext *C) { - Scene *scene= CTX_data_scene(C); - if (scene && scene->id.lib==NULL) + Scene *scene = CTX_data_scene(C); + if (scene && scene->id.lib == NULL) return 1; return 0; } int ED_operator_objectmode(bContext *C) { - Scene *scene= CTX_data_scene(C); - Object *obact= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); - if (scene==NULL || scene->id.lib) + if (scene == NULL || scene->id.lib) return 0; - if ( CTX_data_edit_object(C) ) + if (CTX_data_edit_object(C) ) return 0; /* add a check for ob->mode too? */ @@ -169,7 +169,7 @@ int ED_operator_objectmode(bContext *C) static int ed_spacetype_test(bContext *C, int type) { if (ED_operator_areaactive(C)) { - SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); + SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C); return sl && (sl->spacetype == type); } return 0; @@ -193,7 +193,7 @@ int ED_operator_region_view3d_active(bContext *C) int ED_operator_animview_active(bContext *C) { if (ED_operator_areaactive(C)) { - SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); + SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C); if (sl && (ELEM5(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME))) return TRUE; } @@ -216,7 +216,7 @@ int ED_operator_outliner_active_no_editobject(bContext *C) { if (ed_spacetype_test(C, SPACE_OUTLINER)) { Object *ob = ED_object_active_context(C); - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (ob && ob == obedit) return 0; else @@ -242,7 +242,7 @@ int ED_operator_buttons_active(bContext *C) int ED_operator_node_active(bContext *C) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); if (snode && snode->edittree) return 1; @@ -313,8 +313,8 @@ int ED_operator_object_active_editable_font(bContext *C) int ED_operator_editmesh(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_MESH) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_MESH) return NULL != BMEdit_FromObject(obedit); return 0; } @@ -335,19 +335,19 @@ int ED_operator_editmesh_region_view3d(bContext *C) int ED_operator_editarmature(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_ARMATURE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_ARMATURE) return NULL != ((bArmature *)obedit->data)->edbo; return 0; } int ED_operator_posemode(bContext *C) { - Object *obact= CTX_data_active_object(C); + Object *obact = CTX_data_active_object(C); if (obact && !(obact->mode & OB_MODE_EDIT)) { Object *obpose; - if ((obpose= object_pose_armature_get(obact))) { + if ((obpose = BKE_object_pose_armature_get(obact))) { if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) { return 1; } @@ -360,8 +360,8 @@ int ED_operator_posemode(bContext *C) /* wrapper for ED_space_image_show_uvedit */ int ED_operator_uvedit(bContext *C) { - SpaceImage *sima= CTX_wm_space_image(C); - Object *obedit= CTX_data_edit_object(C); + SpaceImage *sima = CTX_wm_space_image(C); + Object *obedit = CTX_data_edit_object(C); return ED_space_image_show_uvedit(sima, obedit); } @@ -383,7 +383,7 @@ int ED_operator_uvmap(bContext *C) int ED_operator_editsurfcurve(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) return NULL != ((Curve *)obedit->data)->editnurb; return 0; @@ -400,51 +400,51 @@ int ED_operator_editsurfcurve_region_view3d(bContext *C) int ED_operator_editcurve(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_CURVE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_CURVE) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } int ED_operator_editcurve_3d(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_CURVE) { - Curve *cu= (Curve *)obedit->data; + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_CURVE) { + Curve *cu = (Curve *)obedit->data; - return (cu->flag&CU_3D) && (NULL != cu->editnurb); + return (cu->flag & CU_3D) && (NULL != cu->editnurb); } return 0; } int ED_operator_editsurf(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_SURF) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_SURF) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } int ED_operator_editfont(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_FONT) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_FONT) return NULL != ((Curve *)obedit->data)->editfont; return 0; } int ED_operator_editlattice(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_LATTICE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_LATTICE) return NULL != ((Lattice *)obedit->data)->editlatt; return 0; } int ED_operator_editmball(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_MBALL) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_MBALL) return NULL != ((MetaBall *)obedit->data)->editelems; return 0; } @@ -482,11 +482,11 @@ typedef struct sActionzoneData { /* used by other operators too */ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) { - ScrArea *sa= NULL; - sa= scr->areabase.first; + ScrArea *sa = NULL; + sa = scr->areabase.first; while (sa) { if (BLI_in_rcti(&sa->totrct, x, y)) break; - sa= sa->next; + sa = sa->next; } return sa; @@ -495,15 +495,15 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) /* quick poll to save operators to be created and handled */ static int actionzone_area_poll(bContext *C) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); if (sa && win) { AZone *az; - int x= win->eventstate->x; - int y= win->eventstate->y; + int x = win->eventstate->x; + int y = win->eventstate->y; - for (az= sa->actionzones.first; az; az= az->next) + for (az = sa->actionzones.first; az; az = az->next) if (BLI_in_rcti(&az->rect, x, y)) return 1; } @@ -512,15 +512,15 @@ static int actionzone_area_poll(bContext *C) AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) { - AZone *az= NULL; + AZone *az = NULL; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { if (BLI_in_rcti(&az->rect, x, y)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ - int radius= (x-az->x1)*(x-az->x1) + (y-az->y1)*(y-az->y1); + int radius = (x - az->x1) * (x - az->x1) + (y - az->y1) * (y - az->y1); - if (radius <= AZONESPOT*AZONESPOT) + if (radius <= AZONESPOT * AZONESPOT) break; } else if (az->type == AZONE_REGION) { @@ -537,47 +537,47 @@ static void actionzone_exit(wmOperator *op) { if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } /* send EVT_ACTIONZONE event */ static void actionzone_apply(bContext *C, wmOperator *op, int type) { wmEvent event; - wmWindow *win= CTX_wm_window(C); - sActionzoneData *sad= op->customdata; + wmWindow *win = CTX_wm_window(C); + sActionzoneData *sad = op->customdata; - sad->modifier= RNA_int_get(op->ptr, "modifier"); + sad->modifier = RNA_int_get(op->ptr, "modifier"); - event= *(win->eventstate); /* XXX huh huh? make api call */ - if (type==AZONE_AREA) - event.type= EVT_ACTIONZONE_AREA; + event = *(win->eventstate); /* XXX huh huh? make api call */ + if (type == AZONE_AREA) + event.type = EVT_ACTIONZONE_AREA; else - event.type= EVT_ACTIONZONE_REGION; - event.customdata= op->customdata; - event.customdatafree= TRUE; - op->customdata= NULL; + event.type = EVT_ACTIONZONE_REGION; + event.customdata = op->customdata; + event.customdatafree = TRUE; + op->customdata = NULL; wm_event_add(win, &event); } static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { - AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); + AZone *az = is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); sActionzoneData *sad; /* quick escape */ - if (az==NULL) + if (az == NULL) return OPERATOR_PASS_THROUGH; /* ok we do the actionzone */ - sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); - sad->sa1= CTX_wm_area(C); - sad->az= az; - sad->x= event->x; sad->y= event->y; + sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); + sad->sa1 = CTX_wm_area(C); + sad->az = az; + sad->x = event->x; sad->y = event->y; /* region azone directly reacts on mouse clicks */ - if (sad->az->type==AZONE_REGION) { + if (sad->az->type == AZONE_REGION) { actionzone_apply(C, op, AZONE_REGION); actionzone_exit(op); return OPERATOR_FINISHED; @@ -593,30 +593,30 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= op->customdata; + sActionzoneData *sad = op->customdata; int deltax, deltay; - int mindelta= sad->az->type==AZONE_REGION?1:12; + int mindelta = sad->az->type == AZONE_REGION ? 1 : 12; switch (event->type) { case MOUSEMOVE: /* calculate gesture direction */ - deltax= (event->x - sad->x); - deltay= (event->y - sad->y); + deltax = (event->x - sad->x); + deltay = (event->y - sad->y); if (deltay > ABS(deltax)) - sad->gesture_dir= 'n'; + sad->gesture_dir = 'n'; else if (deltax > ABS(deltay)) - sad->gesture_dir= 'e'; + sad->gesture_dir = 'e'; else if (deltay < -ABS(deltax)) - sad->gesture_dir= 's'; + sad->gesture_dir = 's'; else - sad->gesture_dir= 'w'; + sad->gesture_dir = 'w'; /* gesture is large enough? */ if (ABS(deltax) > mindelta || ABS(deltay) > mindelta) { /* second area, for join */ - sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); + sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* apply sends event */ actionzone_apply(C, op, sad->az->type); actionzone_exit(op); @@ -688,16 +688,16 @@ typedef struct sAreaSwapData { static int area_swap_init(wmOperator *op, wmEvent *event) { - sAreaSwapData *sd= NULL; - sActionzoneData *sad= event->customdata; + sAreaSwapData *sd = NULL; + sActionzoneData *sad = event->customdata; - if (sad==NULL || sad->sa1==NULL) + if (sad == NULL || sad->sa1 == NULL) return 0; - sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); - sd->sa1= sad->sa1; - sd->sa2= sad->sa2; - op->customdata= sd; + sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); + sd->sa1 = sad->sa1; + sd->sa2 = sad->sa2; + op->customdata = sd; return 1; } @@ -708,7 +708,7 @@ static void area_swap_exit(bContext *C, wmOperator *op) WM_cursor_restore(CTX_wm_window(C)); if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static int area_swap_cancel(bContext *C, wmOperator *op) @@ -733,15 +733,15 @@ static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event) static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= op->customdata; + sActionzoneData *sad = op->customdata; switch (event->type) { case MOUSEMOVE: /* second area, for join */ - sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); + sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); break; case LEFTMOUSE: /* release LMB */ - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { if (!sad->sa2 || sad->sa1 == sad->sa2) { return area_swap_cancel(C, op); @@ -754,7 +754,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) area_swap_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -790,35 +790,35 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa; rcti rect; - win= CTX_wm_window(C); - sc= CTX_wm_screen(C); - sa= CTX_wm_area(C); + win = CTX_wm_window(C); + sc = CTX_wm_screen(C); + sa = CTX_wm_area(C); /* XXX hrmf! */ - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad==NULL) + if (sad == NULL) return OPERATOR_PASS_THROUGH; - sa= sad->sa1; + sa = sad->sa1; } /* poll() checks area context, but we don't accept full-area windows */ if (sc->full != SCREENNORMAL) { - if (event->type==EVT_ACTIONZONE_AREA) + if (event->type == EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_CANCELLED; } /* adds window to WM */ - rect= sa->totrct; + rect = sa->totrct; BLI_translate_rcti(&rect, win->posx, win->posy); - newwin= WM_window_open(C, &rect); + newwin = WM_window_open(C, &rect); /* allocs new screen and adds to newly created window, using window size */ - newsc= ED_screen_add(newwin, CTX_data_scene(C), sc->id.name+2); - newwin->screen= newsc; + newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2); + newwin->screen = newsc; /* copy area to new screen */ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); @@ -826,9 +826,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) ED_area_tag_redraw((ScrArea *)newsc->areabase.first); /* screen, areas init */ - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - if (event->type==EVT_ACTIONZONE_AREA) + if (event->type == EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_FINISHED; @@ -848,7 +848,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) /* ************** move area edge operator *********************************** */ /* operator state vars used: - * x, y mouse coord near edge + * x, y mouse coord near edge * delta movement of edge * * functions: @@ -884,56 +884,56 @@ typedef struct sAreaMoveData { static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller) { ScrArea *sa; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; /* we check all areas and test for free space with MINSIZE */ - *bigger= *smaller= 100000; + *bigger = *smaller = 100000; - for (sa= sc->areabase.first; sa; sa= sa->next) { - if (dir=='h') { - int y1= sa->v2->vec.y - sa->v1->vec.y-areaminy; + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (dir == 'h') { + int y1 = sa->v2->vec.y - sa->v1->vec.y - areaminy; /* if top or down edge selected, test height */ if (sa->v1->flag && sa->v4->flag) - *bigger= MIN2(*bigger, y1); + *bigger = MIN2(*bigger, y1); else if (sa->v2->flag && sa->v3->flag) - *smaller= MIN2(*smaller, y1); + *smaller = MIN2(*smaller, y1); } else { - int x1= sa->v4->vec.x - sa->v1->vec.x-AREAMINX; + int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX; /* if left or right edge selected, test width */ if (sa->v1->flag && sa->v2->flag) - *bigger= MIN2(*bigger, x1); + *bigger = MIN2(*bigger, x1); else if (sa->v3->flag && sa->v4->flag) - *smaller= MIN2(*smaller, x1); + *smaller = MIN2(*smaller, x1); } } } /* validate selection inside screen, set variables OK */ /* return 0: init failed */ -static int area_move_init (bContext *C, wmOperator *op) +static int area_move_init(bContext *C, wmOperator *op) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); ScrEdge *actedge; sAreaMoveData *md; int x, y; /* required properties */ - x= RNA_int_get(op->ptr, "x"); - y= RNA_int_get(op->ptr, "y"); + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); /* setup */ - actedge= screen_find_active_scredge(sc, x, y); - if (actedge==NULL) return 0; + actedge = screen_find_active_scredge(sc, x, y); + if (actedge == NULL) return 0; - md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); - op->customdata= md; + md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); + op->customdata = md; - md->dir= scredge_is_horizontal(actedge)?'h':'v'; - if (md->dir=='h') md->origval= actedge->v1->vec.y; - else md->origval= actedge->v1->vec.x; + md->dir = scredge_is_horizontal(actedge) ? 'h' : 'v'; + if (md->dir == 'h') md->origval = actedge->v1->vec.y; + else md->origval = actedge->v1->vec.x; select_connected_scredge(sc, actedge); /* now all vertices with 'flag==1' are the ones that can be moved. */ @@ -946,48 +946,48 @@ static int area_move_init (bContext *C, wmOperator *op) /* moves selected screen edge amount of delta, used by split & move */ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); ScrVert *v1; ScrArea *sa; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; - delta= CLAMPIS(delta, -smaller, bigger); + delta = CLAMPIS(delta, -smaller, bigger); - for (v1= sc->vertbase.first; v1; v1= v1->next) { + for (v1 = sc->vertbase.first; v1; v1 = v1->next) { if (v1->flag) { /* that way a nice AREAGRID */ - if ((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-1) { - v1->vec.x= origval + delta; - if (delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID); + if ((dir == 'v') && v1->vec.x > 0 && v1->vec.x < win->sizex - 1) { + v1->vec.x = origval + delta; + if (delta != bigger && delta != -smaller) v1->vec.x -= (v1->vec.x % AREAGRID); } - if ((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) { - v1->vec.y= origval + delta; + if ((dir == 'h') && v1->vec.y > 0 && v1->vec.y < win->sizey - 1) { + v1->vec.y = origval + delta; - v1->vec.y+= AREAGRID-1; - v1->vec.y-= (v1->vec.y % AREAGRID); + v1->vec.y += AREAGRID - 1; + v1->vec.y -= (v1->vec.y % AREAGRID); /* prevent too small top header */ - if (v1->vec.y > win->sizey-areaminy) - v1->vec.y= win->sizey-areaminy; + if (v1->vec.y > win->sizey - areaminy) + v1->vec.y = win->sizey - areaminy; } } } - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) ED_area_tag_redraw(sa); } - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); /* redraw everything */ + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */ } static void area_move_apply(bContext *C, wmOperator *op) { - sAreaMoveData *md= op->customdata; + sAreaMoveData *md = op->customdata; int delta; - delta= RNA_int_get(op->ptr, "delta"); + delta = RNA_int_get(op->ptr, "delta"); area_move_apply_do(C, md->origval, delta, md->dir, md->bigger, md->smaller); } @@ -995,7 +995,7 @@ static void area_move_exit(bContext *C, wmOperator *op) { if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); @@ -1041,18 +1041,18 @@ static int area_move_cancel(bContext *C, wmOperator *op) /* modal callback for while moving edges */ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) { - sAreaMoveData *md= op->customdata; + sAreaMoveData *md = op->customdata; int delta, x, y; /* execute the events */ switch (event->type) { case MOUSEMOVE: - x= RNA_int_get(op->ptr, "x"); - y= RNA_int_get(op->ptr, "y"); + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); - delta= (md->dir == 'v')? event->x - x: event->y - y; - if (md->step) delta= delta - (delta % md->step); + delta = (md->dir == 'v') ? event->x - x : event->y - y; + if (md->step) delta = delta - (delta % md->step); RNA_int_set(op->ptr, "delta", delta); area_move_apply(C, op); @@ -1069,10 +1069,10 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) return area_move_cancel(C, op); case KM_MODAL_STEP10: - md->step= 10; + md->step = 10; break; case KM_MODAL_STEP10_OFF: - md->step= 0; + md->step = 0; break; } } @@ -1109,7 +1109,7 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) * dir direction 'v' or 'h' * * operator customdata: - * area pointer to (active) area + * area pointer to (active) area * x, y last used mouse pos * (more, see below) * @@ -1137,21 +1137,21 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) * call exit() or cancel() and remove handler */ -#define SPLIT_STARTED 1 -#define SPLIT_PROGRESS 2 +#define SPLIT_STARTED 1 +#define SPLIT_PROGRESS 2 typedef struct sAreaSplitData { - int x, y; /* last used mouse position */ - - int origval; /* for move areas */ - int bigger, smaller; /* constraints for moving new edge */ - int delta; /* delta move edge */ - int origmin, origsize; /* to calculate fac, for property storage */ - int previewmode; /* draw previewline, then split */ + int x, y; /* last used mouse position */ - ScrEdge *nedge; /* new edge */ - ScrArea *sarea; /* start area */ - ScrArea *narea; /* new area */ + int origval; /* for move areas */ + int bigger, smaller; /* constraints for moving new edge */ + int delta; /* delta move edge */ + int origmin, origsize; /* to calculate fac, for property storage */ + int previewmode; /* draw previewline, then split */ + + ScrEdge *nedge; /* new edge */ + ScrArea *sarea; /* start area */ + ScrArea *narea; /* new area */ } sAreaSplitData; @@ -1161,15 +1161,15 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sAreaSplitData *sd; /* custom data */ - sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); - op->customdata= sd; + sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + op->customdata = sd; - sd->sarea= CTX_wm_area(C); + sd->sarea = CTX_wm_area(C); if (sd->sarea) { - int dir= RNA_enum_get(op->ptr, "direction"); + int dir = RNA_enum_get(op->ptr, "direction"); - if (dir=='h') + if (dir == 'h') sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; else sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; @@ -1180,28 +1180,28 @@ static int area_split_menu_init(bContext *C, wmOperator *op) /* generic init, no UI stuff here, assumes active area */ static int area_split_init(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); sAreaSplitData *sd; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; int dir; /* required context */ - if (sa==NULL) return 0; + if (sa == NULL) return 0; /* required properties */ - dir= RNA_enum_get(op->ptr, "direction"); + dir = RNA_enum_get(op->ptr, "direction"); /* minimal size */ - if (dir=='v' && sa->winx < 2*AREAMINX) return 0; - if (dir=='h' && sa->winy < 2*areaminy) return 0; + if (dir == 'v' && sa->winx < 2 * AREAMINX) return 0; + if (dir == 'h' && sa->winy < 2 * areaminy) return 0; /* custom data */ - sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); - op->customdata= sd; + sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + op->customdata = sd; - sd->sarea= sa; - sd->origsize= dir=='v' ? sa->winx:sa->winy; - sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin; + sd->sarea = sa; + sd->origsize = dir == 'v' ? sa->winx : sa->winy; + sd->origmin = dir == 'v' ? sa->totrct.xmin : sa->totrct.ymin; return 1; } @@ -1210,25 +1210,25 @@ static int area_split_init(bContext *C, wmOperator *op) /* used with split operator */ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) { - ScrVert *sav1= sa->v1; - ScrVert *sav2= sa->v2; - ScrVert *sav3= sa->v3; - ScrVert *sav4= sa->v4; - ScrVert *sbv1= sb->v1; - ScrVert *sbv2= sb->v2; - ScrVert *sbv3= sb->v3; - ScrVert *sbv4= sb->v4; + ScrVert *sav1 = sa->v1; + ScrVert *sav2 = sa->v2; + ScrVert *sav3 = sa->v3; + ScrVert *sav4 = sa->v4; + ScrVert *sbv1 = sb->v1; + ScrVert *sbv2 = sb->v2; + ScrVert *sbv3 = sb->v3; + ScrVert *sbv4 = sb->v4; - if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return screen_findedge(screen, sav1, sav2); } - else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ return screen_findedge(screen, sav2, sav3); } - else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ return screen_findedge(screen, sav3, sav4); } - else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return screen_findedge(screen, sav1, sav4); } @@ -1239,35 +1239,35 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) /* do the split, return success */ static int area_split_apply(bContext *C, wmOperator *op) { - bScreen *sc= CTX_wm_screen(C); - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + bScreen *sc = CTX_wm_screen(C); + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; - fac= RNA_float_get(op->ptr, "factor"); - dir= RNA_enum_get(op->ptr, "direction"); + fac = RNA_float_get(op->ptr, "factor"); + dir = RNA_enum_get(op->ptr, "direction"); - sd->narea= area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ + sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ if (sd->narea) { ScrVert *sv; - sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea); + sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - for (sv= sc->vertbase.first; sv; sv= sv->next) + for (sv = sc->vertbase.first; sv; sv = sv->next) sv->flag = 0; - sd->nedge->v1->flag= 1; - sd->nedge->v2->flag= 1; + sd->nedge->v1->flag = 1; + sd->nedge->v2->flag = 1; - if (dir=='h') sd->origval= sd->nedge->v1->vec.y; - else sd->origval= sd->nedge->v1->vec.x; + if (dir == 'h') sd->origval = sd->nedge->v1->vec.y; + else sd->origval = sd->nedge->v1->vec.x; ED_area_tag_redraw(sd->sarea); ED_area_tag_redraw(sd->narea); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return 1; } @@ -1278,19 +1278,19 @@ static int area_split_apply(bContext *C, wmOperator *op) static void area_split_exit(bContext *C, wmOperator *op) { if (op->customdata) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; if (sd->sarea) ED_area_tag_redraw(sd->sarea); if (sd->narea) ED_area_tag_redraw(sd->narea); if (sd->sarea) - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); MEM_freeN(op->customdata); op->customdata = NULL; } WM_cursor_restore(CTX_wm_window(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); @@ -1308,28 +1308,28 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) if (CTX_wm_screen(C)->full != SCREENNORMAL) return OPERATOR_CANCELLED; - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad->modifier>0) { + if (sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if (sad==NULL || sad->sa1==NULL || sad->az==NULL) + if (sad == NULL || sad->sa1 == NULL || sad->az == NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas not equal it should be passed on */ - if (CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) + if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ - if (sad->gesture_dir=='n' || sad->gesture_dir=='s') { - dir= 'h'; + if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') { + dir = 'h'; RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx); } else { - dir= 'v'; + dir = 'v'; RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy); } RNA_enum_set(op->ptr, "direction", dir); @@ -1345,20 +1345,20 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) /* retrieve initial mouse coord, so we can find the active edge */ if (RNA_struct_property_is_set(op->ptr, "mouse_x")) - x= RNA_int_get(op->ptr, "mouse_x"); + x = RNA_int_get(op->ptr, "mouse_x"); else - x= event->x; + x = event->x; if (RNA_struct_property_is_set(op->ptr, "mouse_y")) - y= RNA_int_get(op->ptr, "mouse_y"); + y = RNA_int_get(op->ptr, "mouse_y"); else - y= event->x; + y = event->x; - actedge= screen_find_active_scredge(CTX_wm_screen(C), x, y); - if (actedge==NULL) + actedge = screen_find_active_scredge(CTX_wm_screen(C), x, y); + if (actedge == NULL) return OPERATOR_CANCELLED; - dir= scredge_is_horizontal(actedge)?'v':'h'; + dir = scredge_is_horizontal(actedge) ? 'v' : 'h'; RNA_enum_set(op->ptr, "direction", dir); @@ -1368,12 +1368,12 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) } - sd= (sAreaSplitData *)op->customdata; + sd = (sAreaSplitData *)op->customdata; - sd->x= event->x; - sd->y= event->y; + sd->x = event->x; + sd->y = event->y; - if (event->type==EVT_ACTIONZONE_AREA) { + if (event->type == EVT_ACTIONZONE_AREA) { /* do the split */ if (area_split_apply(C, op)) { @@ -1386,7 +1386,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) } } else { - sd->previewmode= 1; + sd->previewmode = 1; /* add temp handler for edge move or cancel */ WM_event_add_modal_handler(C, op); @@ -1413,7 +1413,7 @@ static int area_split_exec(bContext *C, wmOperator *op) static int area_split_cancel(bContext *C, wmOperator *op) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; if (sd->previewmode) { } @@ -1433,44 +1433,44 @@ static int area_split_cancel(bContext *C, wmOperator *op) static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; /* execute the events */ switch (event->type) { case MOUSEMOVE: - dir= RNA_enum_get(op->ptr, "direction"); + dir = RNA_enum_get(op->ptr, "direction"); - sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; - if (sd->previewmode==0) + sd->delta = (dir == 'v') ? event->x - sd->origval : event->y - sd->origval; + if (sd->previewmode == 0) area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); else { if (sd->sarea) { - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); } - sd->sarea= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */ + sd->sarea = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */ if (sd->sarea) { ED_area_tag_redraw(sd->sarea); - if (dir=='v') { - sd->origsize= sd->sarea->winx; - sd->origmin= sd->sarea->totrct.xmin; + if (dir == 'v') { + sd->origsize = sd->sarea->winx; + sd->origmin = sd->sarea->totrct.xmin; sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; } else { - sd->origsize= sd->sarea->winy; - sd->origmin= sd->sarea->totrct.ymin; + sd->origsize = sd->sarea->winy; + sd->origmin = sd->sarea->totrct.ymin; sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; } } - CTX_wm_window(C)->screen->do_draw= 1; + CTX_wm_window(C)->screen->do_draw = 1; } - fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin; + fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin; RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); break; @@ -1482,7 +1482,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } else { - if (event->val==KM_RELEASE) { /* mouse up */ + if (event->val == KM_RELEASE) { /* mouse up */ area_split_exit(C, op); return OPERATOR_FINISHED; } @@ -1491,17 +1491,17 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) case MIDDLEMOUSE: case TABKEY: - if (sd->previewmode==0) { + if (sd->previewmode == 0) { } else { dir = RNA_enum_get(op->ptr, "direction"); - if (event->val==KM_PRESS) { + if (event->val == KM_PRESS) { if (sd->sarea) { - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); - if (dir=='v') { + if (dir == 'v') { RNA_enum_set(op->ptr, "direction", 'h'); sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; @@ -1528,9 +1528,10 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) } static EnumPropertyItem prop_direction_items[] = { -{'h', "HORIZONTAL", 0, "Horizontal", ""}, -{'v', "VERTICAL", 0, "Vertical", ""}, -{0, NULL, 0, NULL, NULL}}; + {'h', "HORIZONTAL", 0, "Horizontal", ""}, + {'v', "VERTICAL", 0, "Vertical", ""}, + {0, NULL, 0, NULL, NULL} +}; static void SCREEN_OT_area_split(wmOperatorType *ot) { @@ -1574,16 +1575,16 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) ARegion *ar; int dist; - if (edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) { + if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { dist = sa->totrct.xmax - sa->totrct.xmin; } - else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ + else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = sa->totrct.ymax - sa->totrct.ymin; } /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ - for (ar=sa->regionbase.first; ar; ar=ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar == scalear) continue; @@ -1609,10 +1610,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= event->customdata; + sActionzoneData *sad = event->customdata; AZone *az; - if (event->type!=EVT_ACTIONZONE_REGION) { + if (event->type != EVT_ACTIONZONE_REGION) { BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } @@ -1620,31 +1621,31 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) az = sad->az; if (az->ar) { - RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); + RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); int maxsize; - op->customdata= rmd; + op->customdata = rmd; rmd->az = az; - rmd->ar= az->ar; + rmd->ar = az->ar; rmd->sa = sad->sa1; - rmd->edge= az->edge; - rmd->origx= event->x; - rmd->origy= event->y; + rmd->edge = az->edge; + rmd->origx = event->x; + rmd->origy = event->y; rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge); /* if not set we do now, otherwise it uses type */ - if (rmd->ar->sizex==0) - rmd->ar->sizex= rmd->ar->type->prefsizex; - if (rmd->ar->sizey==0) - rmd->ar->sizey= rmd->ar->type->prefsizey; + if (rmd->ar->sizex == 0) + rmd->ar->sizex = rmd->ar->type->prefsizex; + if (rmd->ar->sizey == 0) + rmd->ar->sizey = rmd->ar->type->prefsizey; /* now copy to regionmovedata */ - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { - rmd->origval= rmd->ar->sizex; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + rmd->origval = rmd->ar->sizex; } else { - rmd->origval= rmd->ar->sizey; + rmd->origval = rmd->ar->sizey; } /* limit headers to standard height for now */ @@ -1666,16 +1667,16 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) static int region_scale_get_maxsize(RegionMoveData *rmd) { - int maxsize= 0; + int maxsize = 0; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { return rmd->sa->winx - UI_UNIT_X; } if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { /* this calculation seems overly verbose * can someone explain why this method is necessary? - campbell */ - maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); + maxsize = rmd->maxsize - ((rmd->sa->headertype == HEADERTOP) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4); } return maxsize; @@ -1683,19 +1684,19 @@ static int region_scale_get_maxsize(RegionMoveData *rmd) static void region_scale_validate_size(RegionMoveData *rmd) { - if ((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { - short *size, maxsize= -1; + if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) { + short *size, maxsize = -1; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) - size= &rmd->ar->sizex; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) + size = &rmd->ar->sizex; else - size= &rmd->ar->sizey; + size = &rmd->ar->sizey; - maxsize= region_scale_get_maxsize(rmd); + maxsize = region_scale_get_maxsize(rmd); if (*size > maxsize && maxsize > 0) - *size= maxsize; + *size = maxsize; } } @@ -1707,22 +1708,22 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { - RegionMoveData *rmd= op->customdata; + RegionMoveData *rmd = op->customdata; int delta; /* execute the events */ switch (event->type) { case MOUSEMOVE: - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { - delta= event->x - rmd->origx; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + delta = event->x - rmd->origx; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta; - rmd->ar->sizex= rmd->origval + delta; + rmd->ar->sizex = rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); if (rmd->ar->sizex < UI_UNIT_X) { - rmd->ar->sizex= rmd->origval; + rmd->ar->sizex = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } @@ -1730,33 +1731,33 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) region_scale_toggle_hidden(C, rmd); } else { - int maxsize= region_scale_get_maxsize(rmd); - delta= event->y - rmd->origy; - if (rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; + int maxsize = region_scale_get_maxsize(rmd); + delta = event->y - rmd->origy; + if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta; - rmd->ar->sizey= rmd->origval + delta; + rmd->ar->sizey = rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if (rmd->ar->sizey < UI_UNIT_Y/4) { - rmd->ar->sizey= rmd->origval; + if (rmd->ar->sizey < UI_UNIT_Y / 4) { + rmd->ar->sizey = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) - rmd->ar->sizey= maxsize; + rmd->ar->sizey = maxsize; else if (rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); break; case LEFTMOUSE: - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if (rmd->ar->flag & RGN_FLAG_HIDDEN) { @@ -1767,7 +1768,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) } ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } MEM_freeN(op->customdata); op->customdata = NULL; @@ -1813,8 +1814,8 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_offset_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int delta; delta = RNA_int_get(op->ptr, "delta"); @@ -1825,7 +1826,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op) sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -1834,6 +1835,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) { ot->name = "Frame Offset"; ot->idname = "SCREEN_OT_frame_offset"; + ot->description = "Move current frame forward/backward by a given number"; ot->exec = frame_offset_exec; @@ -1848,9 +1850,9 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_jump_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + wmTimer *animtimer = CTX_wm_screen(C)->animtimer; /* Don't change CFRA directly if animtimer is running as this can cause * first/last frame not to be actually shown (bad since for example physics @@ -1862,19 +1864,19 @@ static int frame_jump_exec(bContext *C, wmOperator *op) sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME; if (RNA_boolean_get(op->ptr, "end")) - sad->nextfra= PEFRA; + sad->nextfra = PEFRA; else - sad->nextfra= PSFRA; + sad->nextfra = PSFRA; } else { if (RNA_boolean_get(op->ptr, "end")) - CFRA= PEFRA; + CFRA = PEFRA; else - CFRA= PSFRA; + CFRA = PSFRA; sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } return OPERATOR_FINISHED; @@ -1901,21 +1903,21 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int keyframe_jump_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - bDopeSheet ads= {NULL}; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; float cfra; - short next= RNA_boolean_get(op->ptr, "next"); + short next = RNA_boolean_get(op->ptr, "next"); short done = 0; /* sanity checks */ if (scene == NULL) return OPERATOR_CANCELLED; - cfra= (float)(CFRA); + cfra = (float)(CFRA); /* init binarytree-list for getting keyframes */ BLI_dlrbTree_init(&keys); @@ -1932,14 +1934,14 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) /* find matching keyframe in the right direction */ do { if (next) - ak= (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); + ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); else - ak= (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra); + ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra); if (ak) { if (CFRA != (int)ak->cfra) { /* this changes the frame, so set the frame and we're done */ - CFRA= (int)ak->cfra; + CFRA = (int)ak->cfra; done = 1; } else { @@ -1958,7 +1960,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -1984,35 +1986,35 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int screen_set_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); - bScreen *screen_prev= screen; + bScreen *screen = CTX_wm_screen(C); + bScreen *screen_prev = screen; - ScrArea *sa= CTX_wm_area(C); - int tot= BLI_countlist(&CTX_data_main(C)->screen); - int delta= RNA_int_get(op->ptr, "delta"); + ScrArea *sa = CTX_wm_area(C); + int tot = BLI_countlist(&CTX_data_main(C)->screen); + int delta = RNA_int_get(op->ptr, "delta"); /* temp screens are for userpref or render display */ if (screen->temp) return OPERATOR_CANCELLED; - if (delta==1) { + if (delta == 1) { while (tot--) { - screen= screen->id.next; - if (screen==NULL) screen= CTX_data_main(C)->screen.first; - if (screen->winid==0 && screen->full==0 && screen != screen_prev) + screen = screen->id.next; + if (screen == NULL) screen = CTX_data_main(C)->screen.first; + if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) break; } } - else if (delta== -1) { + else if (delta == -1) { while (tot--) { - screen= screen->id.prev; - if (screen==NULL) screen= CTX_data_main(C)->screen.last; - if (screen->winid==0 && screen->full==0 && screen != screen_prev) + screen = screen->id.prev; + if (screen == NULL) screen = CTX_data_main(C)->screen.last; + if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) break; } } else { - screen= NULL; + screen = NULL; } if (screen && screen_prev != screen) { @@ -2047,15 +2049,15 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op)) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa=NULL; + ScrArea *sa = NULL; /* search current screen for 'fullscreen' areas */ /* prevents restoring info header, when mouse is over it */ - for (sa=screen->areabase.first; sa; sa=sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; } - if (sa==NULL) sa= CTX_wm_area(C); + if (sa == NULL) sa = CTX_wm_area(C); ED_screen_full_toggle(C, CTX_wm_window(C), sa); return OPERATOR_FINISHED; @@ -2104,11 +2106,10 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) * call exit() and remove handler when LMB confirm */ -typedef struct sAreaJoinData -{ - ScrArea *sa1; /* first area to be considered */ - ScrArea *sa2; /* second area to be considered */ - ScrArea *scr; /* designed for removal */ +typedef struct sAreaJoinData { + ScrArea *sa1; /* first area to be considered */ + ScrArea *sa2; /* second area to be considered */ + ScrArea *scr; /* designed for removal */ } sAreaJoinData; @@ -2119,40 +2120,40 @@ typedef struct sAreaJoinData static int area_join_init(bContext *C, wmOperator *op) { ScrArea *sa1, *sa2; - sAreaJoinData* jd= NULL; + sAreaJoinData *jd = NULL; int x1, y1; int x2, y2; - int shared= 0; + int shared = 0; /* required properties, make negative to get return 0 if not set by caller */ - x1= RNA_int_get(op->ptr, "min_x"); - y1= RNA_int_get(op->ptr, "min_y"); - x2= RNA_int_get(op->ptr, "max_x"); - y2= RNA_int_get(op->ptr, "max_y"); + x1 = RNA_int_get(op->ptr, "min_x"); + y1 = RNA_int_get(op->ptr, "min_y"); + x2 = RNA_int_get(op->ptr, "max_x"); + y2 = RNA_int_get(op->ptr, "max_y"); sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); - if (sa1==NULL || sa2==NULL || sa1==sa2) + if (sa1 == NULL || sa2 == NULL || sa1 == sa2) return 0; /* do areas share an edge? */ - if (sa1->v1==sa2->v1 || sa1->v1==sa2->v2 || sa1->v1==sa2->v3 || sa1->v1==sa2->v4) shared++; - if (sa1->v2==sa2->v1 || sa1->v2==sa2->v2 || sa1->v2==sa2->v3 || sa1->v2==sa2->v4) shared++; - if (sa1->v3==sa2->v1 || sa1->v3==sa2->v2 || sa1->v3==sa2->v3 || sa1->v3==sa2->v4) shared++; - if (sa1->v4==sa2->v1 || sa1->v4==sa2->v2 || sa1->v4==sa2->v3 || sa1->v4==sa2->v4) shared++; - if (shared!=2) { + if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++; + if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++; + if (sa1->v3 == sa2->v1 || sa1->v3 == sa2->v2 || sa1->v3 == sa2->v3 || sa1->v3 == sa2->v4) shared++; + if (sa1->v4 == sa2->v1 || sa1->v4 == sa2->v2 || sa1->v4 == sa2->v3 || sa1->v4 == sa2->v4) shared++; + if (shared != 2) { printf("areas don't share edge\n"); return 0; } - jd = (sAreaJoinData*)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); + jd = (sAreaJoinData *)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; jd->sa2 = sa2; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - op->customdata= jd; + op->customdata = jd; return 1; } @@ -2203,19 +2204,19 @@ static int area_join_exec(bContext *C, wmOperator *op) static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad->modifier>0) { + if (sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if (sad==NULL || sad->sa1==NULL || sad->sa2==NULL) + if (sad == NULL || sad->sa1 == NULL || sad->sa2 == NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas equal it should be passed on */ - if (sad->sa1==sad->sa2) + if (sad->sa1 == sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ @@ -2258,7 +2259,7 @@ static int area_join_cancel(bContext *C, wmOperator *op) /* modal callback while selecting area (space) that will be removed */ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); sAreaJoinData *jd = (sAreaJoinData *)op->customdata; /* execute the events */ @@ -2300,7 +2301,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) } else { /* we are back in the area previously selected for keeping - * we swap the areas if possible to allow user to choose */ + * we swap the areas if possible to allow user to choose */ if (jd->sa2 != NULL) { if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; @@ -2325,14 +2326,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) } } } - break; + break; case LEFTMOUSE: - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { ED_area_tag_redraw(jd->sa1); ED_area_tag_redraw(jd->sa2); area_join_apply(C, op); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); area_join_exit(C, op); return OPERATOR_FINISHED; } @@ -2361,7 +2362,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) ot->poll = screen_active_editable; ot->cancel = area_join_cancel; - ot->flag = OPTYPE_BLOCKING|OPTYPE_INTERNAL; + ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* rna */ RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX); @@ -2377,20 +2378,20 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, wmEvent *even uiPopupMenu *pup; uiLayout *layout; PointerRNA ptr1, ptr2; - ScrEdge *actedge= screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y); + ScrEdge *actedge = screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y); - if (actedge==NULL) return OPERATOR_CANCELLED; + if (actedge == NULL) return OPERATOR_CANCELLED; - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); WM_operator_properties_create(&ptr1, "SCREEN_OT_area_join"); /* mouse cursor on edge, '4' can fail on wide edges... */ - RNA_int_set(&ptr1, "min_x", event->x+4); - RNA_int_set(&ptr1, "min_y", event->y+4); - RNA_int_set(&ptr1, "max_x", event->x-4); - RNA_int_set(&ptr1, "max_y", event->y-4); + RNA_int_set(&ptr1, "min_x", event->x + 4); + RNA_int_set(&ptr1, "min_y", event->y + 4); + RNA_int_set(&ptr1, "max_x", event->x - 4); + RNA_int_set(&ptr1, "max_y", event->y - 4); WM_operator_properties_create(&ptr2, "SCREEN_OT_area_split"); @@ -2425,18 +2426,18 @@ static void SCREEN_OT_area_options(wmOperatorType *ot) static int spacedata_cleanup(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); bScreen *screen; ScrArea *sa; - int tot= 0; + int tot = 0; - for (screen= bmain->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacedata.first != sa->spacedata.last) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; BLI_remlink(&sa->spacedata, sl); - tot+= BLI_countlist(&sa->spacedata); + tot += BLI_countlist(&sa->spacedata); BKE_spacedata_freelist(&sa->spacedata); BLI_addtail(&sa->spacedata, sl); } @@ -2464,7 +2465,7 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) { - wmOperator *lastop= CTX_wm_manager(C)->operators.last; + wmOperator *lastop = CTX_wm_manager(C)->operators.last; if (lastop) WM_operator_repeat(C, lastop); @@ -2488,20 +2489,20 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot) static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmOperator *lastop; uiPopupMenu *pup; uiLayout *layout; int items, i; - items= BLI_countlist(&wm->operators); - if (items==0) + items = BLI_countlist(&wm->operators); + if (items == 0) return OPERATOR_CANCELLED; - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); - for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--) + for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) uiItemIntO(layout, lastop->type->name, ICON_NONE, op->type->idname, "index", i); uiPupMenuEnd(C, pup); @@ -2511,9 +2512,9 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev static int repeat_history_exec(bContext *C, wmOperator *op) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); - op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); + op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); if (op) { /* let's put it as last operator in list */ BLI_remlink(&wm->operators, op); @@ -2545,7 +2546,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - wmOperator *lastop= WM_operator_last_redo(C); + wmOperator *lastop = WM_operator_last_redo(C); if (lastop) WM_operator_redo_popup(C, lastop); @@ -2571,27 +2572,27 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot) /* insert a region in the area region list */ static int region_quadview_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); /* some rules... */ - if (ar->regiontype!=RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted"); - else if (ar->alignment==RGN_ALIGN_QSPLIT) { - ScrArea *sa= CTX_wm_area(C); + else if (ar->alignment == RGN_ALIGN_QSPLIT) { + ScrArea *sa = CTX_wm_area(C); ARegion *arn; /* keep current region */ - ar->alignment= 0; + ar->alignment = 0; - if (sa->spacetype==SPACE_VIEW3D) { - RegionView3D *rv3d= ar->regiondata; - rv3d->viewlock= 0; + if (sa->spacetype == SPACE_VIEW3D) { + RegionView3D *rv3d = ar->regiondata; + rv3d->viewlock = 0; rv3d->rflag &= ~RV3D_CLIPPING; } - for (ar= sa->regionbase.first; ar; ar= arn) { - arn= ar->next; - if (ar->alignment==RGN_ALIGN_QSPLIT) { + for (ar = sa->regionbase.first; ar; ar = arn) { + arn = ar->next; + if (ar->alignment == RGN_ALIGN_QSPLIT) { ED_region_exit(C, ar); BKE_area_region_free(sa->type, ar); BLI_remlink(&sa->regionbase, ar); @@ -2599,24 +2600,24 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } } ED_area_tag_redraw(sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } else if (ar->next) BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted"); else { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); ARegion *newar; int count; - ar->alignment= RGN_ALIGN_QSPLIT; + ar->alignment = RGN_ALIGN_QSPLIT; - for (count=0; count<3; count++) { - newar= BKE_area_region_copy(sa->type, ar); + for (count = 0; count < 3; count++) { + newar = BKE_area_region_copy(sa->type, ar); BLI_addtail(&sa->regionbase, newar); } /* lock views and set them */ - if (sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype == SPACE_VIEW3D) { /* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set, * otherwise when restoring rv3d->localvd the 'viewquat' won't * match the 'view', set on entering localview See: [#26315], @@ -2625,31 +2626,31 @@ static int region_quadview_exec(bContext *C, wmOperator *op) * localview with a 4-split would assign these view locks */ RegionView3D *rv3d; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_FRONT; rv3d->persp= RV3D_ORTHO; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_FRONT; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_TOP; rv3d->persp= RV3D_ORTHO; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_TOP; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_RIGHT; rv3d->persp= RV3D_ORTHO; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_RIGHT; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->view = RV3D_VIEW_CAMERA; rv3d->persp = RV3D_CAMOB; ED_view3d_lock(rv3d); - if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } } ED_area_tag_redraw(sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -2677,22 +2678,22 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) /* flip a region alignment */ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); if (!ar) return OPERATOR_CANCELLED; - if (ar->alignment==RGN_ALIGN_TOP) - ar->alignment= RGN_ALIGN_BOTTOM; - else if (ar->alignment==RGN_ALIGN_BOTTOM) - ar->alignment= RGN_ALIGN_TOP; - else if (ar->alignment==RGN_ALIGN_LEFT) - ar->alignment= RGN_ALIGN_RIGHT; - else if (ar->alignment==RGN_ALIGN_RIGHT) - ar->alignment= RGN_ALIGN_LEFT; + if (ar->alignment == RGN_ALIGN_TOP) + ar->alignment = RGN_ALIGN_BOTTOM; + else if (ar->alignment == RGN_ALIGN_BOTTOM) + ar->alignment = RGN_ALIGN_TOP; + else if (ar->alignment == RGN_ALIGN_LEFT) + ar->alignment = RGN_ALIGN_RIGHT; + else if (ar->alignment == RGN_ALIGN_RIGHT) + ar->alignment = RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2703,6 +2704,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Region"; ot->idname = "SCREEN_OT_region_flip"; + ot->description = "Toggle the region's alignment (left/right or top/bottom)"; /* api callbacks */ ot->exec = region_flip_exec; @@ -2715,14 +2717,14 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* flip a header region alignment */ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); /* find the header region * - try context first, but upon failing, search all regions in area... */ if ((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) { - ScrArea *sa= CTX_wm_area(C); - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ScrArea *sa = CTX_wm_area(C); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* don't do anything if no region */ if (ar == NULL) @@ -2730,18 +2732,18 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) } /* copied from SCREEN_OT_region_flip */ - if (ar->alignment==RGN_ALIGN_TOP) - ar->alignment= RGN_ALIGN_BOTTOM; - else if (ar->alignment==RGN_ALIGN_BOTTOM) - ar->alignment= RGN_ALIGN_TOP; - else if (ar->alignment==RGN_ALIGN_LEFT) - ar->alignment= RGN_ALIGN_RIGHT; - else if (ar->alignment==RGN_ALIGN_RIGHT) - ar->alignment= RGN_ALIGN_LEFT; + if (ar->alignment == RGN_ALIGN_TOP) + ar->alignment = RGN_ALIGN_BOTTOM; + else if (ar->alignment == RGN_ALIGN_BOTTOM) + ar->alignment = RGN_ALIGN_TOP; + else if (ar->alignment == RGN_ALIGN_LEFT) + ar->alignment = RGN_ALIGN_RIGHT; + else if (ar->alignment == RGN_ALIGN_RIGHT) + ar->alignment = RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2752,6 +2754,7 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Header Region"; ot->idname = "SCREEN_OT_header_flip"; + ot->description = "Toggle the header over/below the main window area"; /* api callbacks */ ot->exec = header_flip_exec; @@ -2764,13 +2767,13 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); uiPopupMenu *pup; uiLayout *layout; - pup= uiPupMenuBegin(C, "Header", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Header", ICON_NONE); + layout = uiPupMenuLayout(pup); // XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator if (ar->alignment == RGN_ALIGN_TOP) @@ -2820,7 +2823,7 @@ static int match_area_with_refresh(int spacetype, int refresh) static int match_region_with_redraws(int spacetype, int regiontype, int redraws) { - if (regiontype==RGN_TYPE_WINDOW) { + if (regiontype == RGN_TYPE_WINDOW) { switch (spacetype) { case SPACE_VIEW3D: @@ -2835,7 +2838,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) break; case SPACE_TIME: /* if only 1 window or 3d windows, we do timeline too */ - if (redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN)) + if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) return 1; break; case SPACE_BUTS: @@ -2843,7 +2846,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) return 1; break; case SPACE_SEQ: - if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_NODE: @@ -2861,8 +2864,8 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) } } - else if (regiontype==RGN_TYPE_UI) { - if (spacetype==SPACE_CLIP) { + else if (regiontype == RGN_TYPE_UI) { + if (spacetype == SPACE_CLIP) { /* Track Preview button is on Properties Editor in SpaceClip, * and it's very common case when users want it be refreshing * during playback, so asking people to enable special option @@ -2874,14 +2877,14 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) if (redraws & TIME_ALL_BUTS_WIN) return 1; } - else if (regiontype==RGN_TYPE_HEADER) { - if (spacetype==SPACE_TIME) + else if (regiontype == RGN_TYPE_HEADER) { + if (spacetype == SPACE_TIME) return 1; } - else if (regiontype==RGN_TYPE_PREVIEW) { + else if (regiontype == RGN_TYPE_PREVIEW) { switch (spacetype) { case SPACE_SEQ: - if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_CLIP: @@ -2893,21 +2896,21 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); - if (screen->animtimer && screen->animtimer==event->customdata) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + if (screen->animtimer && screen->animtimer == event->customdata) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; ScrArea *sa; int sync; float time; /* sync, don't sync, or follow scene setting */ - if (sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; - else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; - else sync= (scene->flag & SCE_FRAME_DROP); + if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1; + else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync = 0; + else sync = (scene->flag & SCE_FRAME_DROP); if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == FALSE && @@ -2942,13 +2945,13 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* jump back to end? */ if (PRVRANGEON) { if (scene->r.cfra < scene->r.psfra) { - scene->r.cfra= scene->r.pefra; + scene->r.cfra = scene->r.pefra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } else { if (scene->r.cfra < scene->r.sfra) { - scene->r.cfra= scene->r.efra; + scene->r.cfra = scene->r.efra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } @@ -2957,13 +2960,13 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* jump back to start? */ if (PRVRANGEON) { if (scene->r.cfra > scene->r.pefra) { - scene->r.cfra= scene->r.psfra; + scene->r.cfra = scene->r.psfra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } else { if (scene->r.cfra > scene->r.efra) { - scene->r.cfra= scene->r.sfra; + scene->r.cfra = scene->r.sfra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } @@ -2982,14 +2985,14 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(CTX_data_main(C), scene, screen, 1); - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { ARegion *ar; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar==sad->ar) + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar == sad->ar) ED_region_tag_redraw(ar); else - if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) - ED_region_tag_redraw(ar); + if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) + ED_region_tag_redraw(ar); } if (match_area_with_refresh(sa->spacetype, sad->refresh)) @@ -3006,7 +3009,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e * since the frames-per-second value may have been changed */ // TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? - wt->timestep= (1.0/FPS); + wt->timestep = (1.0 / FPS); return OPERATOR_FINISHED; } @@ -3032,7 +3035,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* toggle operator */ int ED_screen_animation_play(bContext *C, int sync, int mode) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); if (screen->animtimer) { @@ -3041,7 +3044,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) sound_stop_scene(scene); } else { - int refresh= SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ + int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ if (mode == 1) // XXX only play audio forwards!? sound_play_scene(scene); @@ -3049,10 +3052,10 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); if (screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; - sad->ar= CTX_wm_region(C); + sad->ar = CTX_wm_region(C); } } @@ -3061,11 +3064,11 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) static int screen_animation_play_exec(bContext *C, wmOperator *op) { - int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; - int sync= -1; + int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; + int sync = -1; if (RNA_struct_property_is_set(op->ptr, "sync")) - sync= (RNA_boolean_get(op->ptr, "sync")); + sync = (RNA_boolean_get(op->ptr, "sync")); return ED_screen_animation_play(C, sync, mode); } @@ -3092,19 +3095,19 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) static int screen_animation_cancel_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); if (screen->animtimer) { if (RNA_boolean_get(op->ptr, "restore_frame")) { - ScreenAnimData *sad= screen->animtimer->customdata; - Scene *scene= CTX_data_scene(C); + ScreenAnimData *sad = screen->animtimer->customdata; + Scene *scene = CTX_data_scene(C); /* reset current frame before stopping, and just send a notifier to deal with the rest * (since playback still needs to be stopped) */ - scene->r.cfra= sad->sfra; + scene->r.cfra = sad->sfra; - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* call the other "toggling" operator to clean up now */ @@ -3152,11 +3155,11 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) #if 0 static int border_select_do(bContext *C, wmOperator *op) { - int event_type= RNA_int_get(op->ptr, "event_type"); + int event_type = RNA_int_get(op->ptr, "event_type"); - if (event_type==LEFTMOUSE) + if (event_type == LEFTMOUSE) printf("border select do select\n"); - else if (event_type==RIGHTMOUSE) + else if (event_type == RIGHTMOUSE) printf("border select deselect\n"); else printf("border select do something\n"); @@ -3194,10 +3197,10 @@ static void SCREEN_OT_border_select(wmOperatorType *ot) static int fullscreen_back_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa=NULL; + ScrArea *sa = NULL; /* search current screen for 'fullscreen' areas */ - for (sa=screen->areabase.first; sa; sa=sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; } if (!sa) { @@ -3229,12 +3232,12 @@ static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *ev rcti rect; int sizex, sizey; - sizex= 800; - sizey= 480; + sizex = 800; + sizey = 480; /* some magic to calculate postition */ - rect.xmin = event->x + CTX_wm_window(C)->posx - sizex/2; - rect.ymin = event->y + CTX_wm_window(C)->posy - sizey/2; + rect.xmin = event->x + CTX_wm_window(C)->posx - sizex / 2; + rect.ymin = event->y + CTX_wm_window(C)->posy - sizey / 2; rect.xmax = rect.xmin + sizex; rect.ymax = rect.ymin + sizey; @@ -3261,11 +3264,11 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); - sc= ED_screen_duplicate(win, sc); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc); + sc = ED_screen_duplicate(win, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc); return OPERATOR_FINISHED; } @@ -3282,16 +3285,16 @@ static void SCREEN_OT_new(wmOperatorType *ot) ot->poll = WM_operator_winactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************* delete screen operator *********************/ static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENDELETE, sc); return OPERATOR_FINISHED; } @@ -3307,22 +3310,22 @@ static void SCREEN_OT_delete(wmOperatorType *ot) ot->exec = screen_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************* new scene operator *********************/ static int scene_new_exec(bContext *C, wmOperator *op) { - Scene *newscene, *scene= CTX_data_scene(C); - Main *bmain= CTX_data_main(C); - int type= RNA_enum_get(op->ptr, "type"); + Scene *newscene, *scene = CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + int type = RNA_enum_get(op->ptr, "type"); if (type == SCE_COPY_NEW) { - newscene= add_scene("Scene"); + newscene = BKE_scene_add("Scene"); } else { /* different kinds of copying */ - newscene= copy_scene(scene, type); + newscene = BKE_scene_copy(scene, type); /* these can't be handled in blenkernel curently, so do them here */ if (type == SCE_COPY_LINK_DATA) { @@ -3335,14 +3338,14 @@ static int scene_new_exec(bContext *C, wmOperator *op) ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene); return OPERATOR_FINISHED; } static void SCENE_OT_new(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"}, {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"}, {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"}, @@ -3360,7 +3363,7 @@ static void SCENE_OT_new(wmOperatorType *ot) ot->invoke = WM_menu_invoke; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); @@ -3370,14 +3373,14 @@ static void SCENE_OT_new(wmOperatorType *ot) static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ED_screen_delete_scene(C, scene); if (G.debug & G_DEBUG) printf("scene delete %p\n", scene); - WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene); + WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene); return OPERATOR_FINISHED; } @@ -3393,7 +3396,7 @@ static void SCENE_OT_delete(wmOperatorType *ot) ot->exec = scene_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** Assigning operatortypes to global list, adding handlers **************** */ @@ -3462,7 +3465,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf) wmKeyMap *keymap; /* Standard Modal keymap ------------------------------------------------ */ - keymap= WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); + keymap = WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY); @@ -3478,8 +3481,8 @@ static void keymap_modal_set(wmKeyConfig *keyconf) static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_PATH) { - if (drag->icon==ICON_FILE_BLEND) + if (drag->type == WM_DRAG_PATH) { + if (drag->icon == ICON_FILE_BLEND) return 1; } return 0; @@ -3489,7 +3492,7 @@ static void open_file_drop_copy(wmDrag *drag, wmDropBox *drop) { /* copy drag path to properties */ RNA_string_set(drop->ptr, "filepath", drag->path); - drop->opcontext= WM_OP_EXEC_DEFAULT; + drop->opcontext = WM_OP_EXEC_DEFAULT; } @@ -3540,7 +3543,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_screencast", F3KEY, KM_PRESS, KM_ALT, 0); /* tests */ - WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); @@ -3555,12 +3558,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* undo */ #ifdef __APPLE__ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); - WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0); + WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); /* render */ @@ -3575,7 +3578,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); #endif - WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); /* Anim Playback ------------------------------------------------ */ @@ -3590,8 +3593,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf) RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", FALSE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", FALSE); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", TRUE); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", FALSE); @@ -3609,7 +3612,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", TRUE); WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0); @@ -3619,17 +3622,17 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #if 0 // XXX: disabled for restoring later... bad implementation keymap = WM_keymap_find(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); + RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "reverse", TRUE); - RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); + RNA_boolean_set(kmi->ptr, "reverse", TRUE); + RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0); #endif /* dropbox for entire window */ - lb= WM_dropboxmap_find("Window", 0, 0); + lb = WM_dropboxmap_find("Window", 0, 0); WM_dropbox_add(lb, "WM_OT_open_mainfile", open_file_drop_poll, open_file_drop_copy); keymap_modal_set(keyconf); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 22a1770412f..256df21b79a 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -78,18 +78,18 @@ typedef struct ScreenshotData { /* get shot from frontbuffer */ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) { - wmWindow *win= CTX_wm_window(C); - int x=0, y=0; - unsigned int *dumprect= NULL; - - x= 0; - y= 0; - *dumpsx= win->sizex; - *dumpsy= win->sizey; + wmWindow *win = CTX_wm_window(C); + int x = 0, y = 0; + unsigned int *dumprect = NULL; + + x = 0; + y = 0; + *dumpsx = win->sizex; + *dumpsy = win->sizey; if (*dumpsx && *dumpsy) { - dumprect= MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); + dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); @@ -108,17 +108,17 @@ static int screenshot_data_create(bContext *C, wmOperator *op) /* do redraw so we don't show popups/menus */ WM_redraw_windows(C); - dumprect= screenshot(C, &dumpsx, &dumpsy); + dumprect = screenshot(C, &dumpsx, &dumpsy); if (dumprect) { - ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot"); - ScrArea *sa= CTX_wm_area(C); + ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot"); + ScrArea *sa = CTX_wm_area(C); - scd->dumpsx= dumpsx; - scd->dumpsy= dumpsy; - scd->dumprect= dumprect; + scd->dumpsx = dumpsx; + scd->dumpsy = dumpsy; + scd->dumprect = dumprect; if (sa) { - scd->crop= sa->totrct; + scd->crop = sa->totrct; } BKE_imformat_defaults(&scd->im_format); @@ -128,46 +128,46 @@ static int screenshot_data_create(bContext *C, wmOperator *op) return TRUE; } else { - op->customdata= NULL; + op->customdata = NULL; return FALSE; } } static void screenshot_data_free(wmOperator *op) { - ScreenshotData *scd= op->customdata; + ScreenshotData *scd = op->customdata; if (scd) { if (scd->dumprect) MEM_freeN(scd->dumprect); MEM_freeN(scd); - op->customdata= NULL; + op->customdata = NULL; } } 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; + 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; if (cropw > 0 && croph > 0) { - for (y=0; y<croph; y++, to+=cropw, from+=ibuf->x) - memmove(to, from, sizeof(unsigned int)*cropw); + for (y = 0; y < croph; y++, to += cropw, from += ibuf->x) + memmove(to, from, sizeof(unsigned int) * cropw); - ibuf->x= cropw; - ibuf->y= croph; + ibuf->x = cropw; + ibuf->y = croph; } } static int screenshot_exec(bContext *C, wmOperator *op) { - ScreenshotData *scd= op->customdata; + ScreenshotData *scd = op->customdata; if (scd == NULL) { /* when running exec directly */ screenshot_data_create(C, op); - scd= op->customdata; + scd = op->customdata; } if (scd) { @@ -179,8 +179,8 @@ static int screenshot_exec(bContext *C, wmOperator *op) BLI_path_abs(path, G.main->name); /* operator ensures the extension */ - ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); - ibuf->rect= scd->dumprect; + ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); + ibuf->rect = scd->dumprect; /* crop to show only single editor */ if (!RNA_boolean_get(op->ptr, "full")) @@ -190,7 +190,7 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } - BKE_write_ibuf(ibuf, path, &scd->im_format); + BKE_imbuf_write(ibuf, path, &scd->im_format); IMB_freeImBuf(ibuf); } @@ -255,6 +255,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) { ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname = "SCREEN_OT_screenshot"; + ot->description = "Capture a picture of the active area or whole Blender window"; ot->invoke = screenshot_invoke; ot->check = screenshot_check; @@ -265,8 +266,8 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag = 0; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screenshot the whole Blender window"); } /* *************** screenshot movie job ************************* */ @@ -284,7 +285,7 @@ typedef struct ScreenshotJob { static void screenshot_freejob(void *sjv) { - ScreenshotJob *sj= sjv; + ScreenshotJob *sj = sjv; if (sj->dumprect) MEM_freeN(sj->dumprect); @@ -296,15 +297,15 @@ static void screenshot_freejob(void *sjv) /* called before redraw notifiers, copies a new dumprect */ static void screenshot_updatejob(void *sjv) { - ScreenshotJob *sj= sjv; + ScreenshotJob *sj = sjv; unsigned int *dumprect; - if (sj->dumprect==NULL) { - dumprect= MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); + if (sj->dumprect == NULL) { + dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); - sj->dumprect= dumprect; + sj->dumprect = dumprect; } } @@ -312,13 +313,13 @@ static void screenshot_updatejob(void *sjv) /* only this runs inside thread */ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress)) { - ScreenshotJob *sj= sjv; - RenderData rd= sj->scene->r; - bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype); + ScreenshotJob *sj = sjv; + RenderData rd = sj->scene->r; + bMovieHandle *mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype); /* we need this as local variables for renderdata */ - rd.frs_sec= U.scrcastfps; - rd.frs_sec_base= 1.0f; + rd.frs_sec = U.scrcastfps; + rd.frs_sec_base = 1.0f; if (BKE_imtype_is_movie(rd.im_format.imtype)) { if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { @@ -327,20 +328,20 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } } else - mh= NULL; + mh = NULL; - sj->stop= stop; - sj->do_update= do_update; + sj->stop = stop; + sj->do_update = do_update; - *do_update= 1; // wait for opengl rect + *do_update = 1; // wait for opengl rect - while (*stop==0) { + while (*stop == 0) { if (sj->dumprect) { if (mh) { if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect, - sj->dumpsx, sj->dumpsy, &sj->reports)) + sj->dumpsx, sj->dumpsy, &sj->reports)) { BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra); printf("Appended frame %d\n", rd.cfra); @@ -350,16 +351,16 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } } else { - ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); + ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); char name[FILE_MAX]; int ok; BKE_makepicstring(name, rd.pic, sj->bmain->name, rd.cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE); - ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(ibuf, name, &rd.im_format); + ibuf->rect = sj->dumprect; + ok = BKE_imbuf_write(ibuf, name, &rd.im_format); - if (ok==0) { + if (ok == 0) { printf("Write error: cannot save %s\n", name); BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name); break; @@ -374,9 +375,9 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } MEM_freeN(sj->dumprect); - sj->dumprect= NULL; + sj->dumprect = NULL; - *do_update= 1; + *do_update = 1; rd.cfra++; @@ -393,38 +394,38 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float static int screencast_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); - wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0); - ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); + bScreen *screen = CTX_wm_screen(C); + wmJob *steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0); + ScreenshotJob *sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); /* setup sj */ if (RNA_boolean_get(op->ptr, "full")) { - wmWindow *win= CTX_wm_window(C); - sj->x= 0; - sj->y= 0; - sj->dumpsx= win->sizex; - sj->dumpsy= win->sizey; + wmWindow *win = CTX_wm_window(C); + sj->x = 0; + sj->y = 0; + sj->dumpsx = win->sizex; + sj->dumpsy = win->sizey; } else { - ScrArea *curarea= CTX_wm_area(C); - sj->x= curarea->totrct.xmin; - sj->y= curarea->totrct.ymin; - sj->dumpsx= curarea->totrct.xmax - sj->x; - sj->dumpsy= curarea->totrct.ymax - sj->y; + ScrArea *curarea = CTX_wm_area(C); + sj->x = curarea->totrct.xmin; + sj->y = curarea->totrct.ymin; + sj->dumpsx = curarea->totrct.xmax - sj->x; + sj->dumpsy = curarea->totrct.ymax - sj->y; } - sj->bmain= CTX_data_main(C); - sj->scene= CTX_data_scene(C); + sj->bmain = CTX_data_main(C); + sj->scene = CTX_data_scene(C); BKE_reports_init(&sj->reports, RPT_PRINT); /* setup job */ WM_jobs_customdata(steve, sj, screenshot_freejob); - WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST); + WM_jobs_timer(steve, 0.1, 0, NC_SCREEN | ND_SCREENCAST); WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL); WM_jobs_start(CTX_wm_manager(C), steve); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENCAST, screen); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); return OPERATOR_FINISHED; } @@ -433,6 +434,7 @@ void SCREEN_OT_screencast(wmOperatorType *ot) { ot->name = "Make Screencast"; ot->idname = "SCREEN_OT_screencast"; + ot->description = "Capture a video of the active area or whole Blender window"; ot->invoke = WM_operator_confirm; ot->exec = screencast_exec; @@ -441,8 +443,5 @@ void SCREEN_OT_screencast(wmOperatorType *ot) ot->flag = 0; RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screencast the whole Blender window"); } - - - diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index cf8179b4d0e..043b7ecb5cb 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -42,6 +42,7 @@ set(SRC paint_cursor.c paint_hide.c paint_image.c + paint_mask.c paint_ops.c paint_stroke.c paint_undo.c diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index 47536d99fcb..87bc89f810c 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_ccg.h" #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_mesh.h" @@ -83,10 +84,14 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3]) /* return true if the element should be hidden/shown */ static int is_effected(PartialVisArea area, float planes[4][4], - const float co[3]) + const float co[3], + const float mask) { if (area == PARTIALVIS_ALL) return 1; + else if (area == PARTIALVIS_MASKED) { + return mask > 0.5; + } else { int inside = planes_contain_v3(planes, 4, co); return ((inside && area == PARTIALVIS_INSIDE) || @@ -101,20 +106,24 @@ static void partialvis_update_mesh(Object *ob, PartialVisArea area, float planes[4][4]) { + Mesh *me = ob->data; MVert *mvert; + float *paint_mask; int *vert_indices; int any_changed = 0, any_visible = 0, totvert, i; BLI_pbvh_node_num_verts(pbvh, node, NULL, &totvert); BLI_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); + paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); for (i = 0; i < totvert; i++) { MVert *v = &mvert[vert_indices[i]]; + float vmask = paint_mask ? paint_mask[vert_indices[i]] : 0; /* hide vertex if in the hide volume */ - if (is_effected(area, planes, v->co)) { + if (is_effected(area, planes, v->co, vmask)) { if (action == PARTIALVIS_HIDE) v->flag |= ME_HIDE; else @@ -141,16 +150,18 @@ static void partialvis_update_grids(Object *ob, PartialVisArea area, float planes[4][4]) { - DMGridData **grids; + CCGElem **grids; + CCGKey key; BLI_bitmap *grid_hidden; int any_visible = 0; - int *grid_indices, gridsize, totgrid, any_changed, i; + int *grid_indices, totgrid, any_changed, i; /* get PBVH data */ BLI_pbvh_node_get_grids(pbvh, node, - &grid_indices, &totgrid, NULL, &gridsize, + &grid_indices, &totgrid, NULL, NULL, &grids, NULL); grid_hidden = BLI_pbvh_grid_hidden(pbvh); + BLI_pbvh_get_grid_key(pbvh, &key); sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); @@ -164,7 +175,7 @@ static void partialvis_update_grids(Object *ob, switch (action) { case PARTIALVIS_HIDE: /* create grid flags data */ - gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize, + gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, "partialvis_update_grids"); break; case PARTIALVIS_SHOW: @@ -182,21 +193,23 @@ static void partialvis_update_grids(Object *ob, continue; } - for (y = 0; y < gridsize; y++) { - for (x = 0; x < gridsize; x++) { - const float *co = grids[g][y * gridsize + x].co; + for (y = 0; y < key.grid_size; y++) { + for (x = 0; x < key.grid_size; x++) { + CCGElem *elem = CCG_grid_elem(&key, grids[g], x, y); + const float *co = CCG_elem_co(&key, elem); + float mask = *CCG_elem_mask(&key, elem); /* skip grid element if not in the effected area */ - if (is_effected(area, planes, co)) { + if (is_effected(area, planes, co, mask)) { /* set or clear the hide flag */ - BLI_BITMAP_MODIFY(gh, y * gridsize + x, + BLI_BITMAP_MODIFY(gh, y * key.grid_size + x, action == PARTIALVIS_HIDE); any_changed = 1; } /* keep track of whether any elements are still hidden */ - if (BLI_BITMAP_GET(gh, y * gridsize + x)) + if (BLI_BITMAP_GET(gh, y * key.grid_size + x)) any_hidden = 1; else any_visible = 1; @@ -263,7 +276,9 @@ static void get_pbvh_nodes(PBVH *pbvh, cb = BLI_pbvh_node_planes_exclude_AABB; break; case PARTIALVIS_ALL: + case PARTIALVIS_MASKED: cb = NULL; + break; } BLI_pbvh_search_gather(pbvh, cb, clip_planes, nodes, totnode); @@ -328,9 +343,9 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ if (pbvh_type == PBVH_FACES) { - mesh_flush_hidden_from_verts(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } ED_region_tag_redraw(ar); @@ -342,7 +357,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, wmEvent *event) { PartialVisArea area = RNA_enum_get(op->ptr, "area"); - if (area != PARTIALVIS_ALL) + if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) return WM_border_select_invoke(C, op, event); else return op->type->exec(C, op); @@ -353,17 +368,21 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) static EnumPropertyItem action_items[] = { {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem area_items[] = { {PARTIALVIS_OUTSIDE, "OUTSIDE", 0, "Outside", "Hide or show vertices outside the selection"}, {PARTIALVIS_INSIDE, "INSIDE", 0, "Inside", "Hide or show vertices inside the selection"}, {PARTIALVIS_ALL, "ALL", 0, "All", "Hide or show all vertices"}, - {0, NULL, 0, NULL, NULL}}; + {PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"}, + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Hide/Show"; ot->idname = "PAINT_OT_hide_show"; + ot->description = "Hide/show some vertices"; /* api callbacks */ ot->invoke = hide_show_invoke; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a025a84bea9..c46c153aa70 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -310,7 +310,7 @@ typedef struct ProjPaintState { short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/ short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ short do_mask_normal; /* mask out pixels based on their normals */ - short do_new_shading_nodes; /* cache scene_use_new_shading_nodes value */ + short do_new_shading_nodes; /* cache BKE_scene_use_new_shading_nodes value */ float normal_angle; /* what angle to mask at*/ float normal_angle_inner; float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */ @@ -526,7 +526,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) { Image *ima; - if (scene_use_new_shading_nodes(s->scene)) { + if (BKE_scene_use_new_shading_nodes(s->scene)) { MFace *mf = &s->dm_mface[face_index]; ED_object_get_active_image(s->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -542,7 +542,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa { Image *ima; - if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ + if (ps->do_new_shading_nodes) { /* cached BKE_scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface + face_index; ED_object_get_active_image(ps->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -4775,7 +4775,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1; ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1; ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1; - ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */ + ps->do_new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* only cache the value */ if (ps->tool == PAINT_TOOL_CLONE) ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE); @@ -4858,7 +4858,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (pop->mode != PAINT_MODE_2D) { Object *ob = OBACT; - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (!me) { return 0; @@ -5160,6 +5160,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Image Paint"; ot->idname = "PAINT_OT_image_paint"; + ot->description = "Paint a stroke into the image"; /* api callbacks */ ot->exec = paint_exec; @@ -5387,6 +5388,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) /* identifiers */ ot->name = "Grab Clone"; ot->idname = "PAINT_OT_grab_clone"; + ot->description = "Move the clone source image"; /* api callbacks */ ot->exec = grab_clone_exec; @@ -5451,7 +5453,7 @@ static int image_paint_sample_color_poll(bContext *C) if (CTX_wm_view3d(C)) { Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - Mesh *me = get_mesh(obact); + Mesh *me = BKE_mesh_from_object(obact); if (me) { return !(me->editflag & ME_EDIT_PAINT_MASK); } @@ -5469,6 +5471,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /* identifiers */ ot->name = "Sample Color"; ot->idname = "PAINT_OT_sample_color"; + ot->description = "Use the mouse to sample a color in the image"; /* api callbacks */ ot->exec = sample_color_exec; @@ -5520,6 +5523,7 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Clone Cursor"; ot->idname = "PAINT_OT_clone_cursor_set"; + ot->description = "Set the location of the clone cursor"; /* api callbacks */ ot->exec = set_clone_cursor_exec; @@ -5554,12 +5558,12 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) if (ob == NULL) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects"); @@ -5602,6 +5606,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Texture Paint Toggle"; ot->idname = "PAINT_OT_texture_paint_toggle"; + ot->description = "Toggle texture paint mode in 3D view"; /* api callbacks */ ot->exec = texture_paint_toggle_exec; @@ -5794,7 +5799,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - image = BKE_add_image_imbuf(ibuf); + image = BKE_image_add_from_imbuf(ibuf); if (image) { /* now for the trickyness. store the view projection here! diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 65fb65c1553..a97563b258f 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -43,6 +43,7 @@ struct PaintStroke; struct PointerRNA; struct rcti; struct Scene; +struct RegionView3D; struct VPaint; struct ViewContext; struct wmEvent; @@ -56,8 +57,8 @@ typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, - StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeDone done, int event_type); + StrokeGetLocation get_location, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); int paint_space_stroke_enabled(struct Brush *br); @@ -115,24 +116,24 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot); * its minimum and maximum corners) into a screen-space rectangle, * returns zero if the result is empty */ int paint_convert_bb_to_rect(struct rcti *rect, - const float bb_min[3], - const float bb_max[3], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob); + const float bb_min[3], + const float bb_max[3], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob); /* Get four planes in object-space that describe the projection of * screen_rect from screen into object-space (essentially converting a * 2D screens-space bounding box into four 3D planes) */ void paint_calc_redraw_planes(float planes[4][4], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob, - const struct rcti *screen_rect); + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob, + const struct rcti *screen_rect); void projectf(struct bglMats *mats, const float v[3], float p[2]); float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); -float paint_get_tex_pixel(struct Brush* br, float u, float v); +float paint_get_tex_pixel(struct Brush *br, float u, float v); int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); @@ -179,9 +180,19 @@ typedef enum { typedef enum { PARTIALVIS_INSIDE, PARTIALVIS_OUTSIDE, - PARTIALVIS_ALL + PARTIALVIS_ALL, + PARTIALVIS_MASKED } PartialVisArea; void PAINT_OT_hide_show(struct wmOperatorType *ot); +/* paint_mask.c */ + +typedef enum { + PAINT_MASK_FLOOD_VALUE, + PAINT_MASK_INVERT +} PaintMaskFloodMode; + +void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot); + #endif /* __PAINT_INTERN_H__ */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c new file mode 100644 index 00000000000..000f43b0dec --- /dev/null +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -0,0 +1,143 @@ +/* + * $Id$ + * + * ***** 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 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/editors/sculpt_paint/paint_mask.c + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" + +#include "BLI_pbvh.h" + +#include "BKE_ccg.h" +#include "BKE_context.h" +#include "BKE_DerivedMesh.h" +#include "BKE_multires.h" +#include "BKE_paint.h" +#include "BKE_subsurf.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +#include "paint_intern.h" +#include "sculpt_intern.h" /* for undo push */ + +#include <stdlib.h> + +static void mask_flood_fill_set_elem(float *elem, + PaintMaskFloodMode mode, + float value) +{ + switch(mode) { + case PAINT_MASK_FLOOD_VALUE: + (*elem) = value; + break; + case PAINT_MASK_INVERT: + (*elem) = 1.0f - (*elem); + break; + } +} + +static int mask_flood_fill_exec(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + Object *ob = CTX_data_active_object(C); + PaintMaskFloodMode mode; + float value; + DerivedMesh *dm; + PBVH *pbvh; + PBVHNode **nodes; + int totnode, i; + + mode = RNA_enum_get(op->ptr, "mode"); + value = RNA_float_get(op->ptr, "value"); + + dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); + pbvh = dm->getPBVH(ob, dm); + ob->sculpt->pbvh = pbvh; + + BLI_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + sculpt_undo_push_begin("Mask flood fill"); + + for(i = 0; i < totnode; i++) { + PBVHVertexIter vi; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BLI_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { + mask_flood_fill_set_elem(vi.mask, mode, value); + } BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_mark_update(nodes[i]); + if(BLI_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + + sculpt_undo_push_end(); + + if(nodes) + MEM_freeN(nodes); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot) +{ + static EnumPropertyItem mode_items[] = { + {PAINT_MASK_FLOOD_VALUE, "VALUE", 0, "Value", "Set mask to the level specified by the \"value\" property"}, + {PAINT_MASK_INVERT, "INVERT", 0, "Invert", "Invert the mask"}, + {0}}; + + /* identifiers */ + ot->name = "Mask Flood Fill"; + ot->idname = "PAINT_OT_mask_flood_fill"; + + /* api callbacks */ + ot->exec = mask_flood_fill_exec; + ot->poll = sculpt_mode_poll; + + ot->flag = OPTYPE_REGISTER; + + /* rna */ + RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL); + RNA_def_float(ot->srna, "value", 0, 0, 1, "Value", "Mask level to use when mode is \"Value\"; zero means no masking and one is fully masked", 0, 1); +} diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 2699e9f56f8..f8ed20430e7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" #include <stdlib.h> +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -160,6 +161,7 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Vertex Colors"; ot->idname = "PAINT_OT_vertex_color_set"; + ot->description = "Fill the active vertex color layer with the current paint color"; /* api callbacks */ ot->exec = vertex_color_set_exec; @@ -203,6 +205,11 @@ static int brush_tool(const Brush *brush, size_t tool_offset) return *(((char *)brush) + tool_offset); } +static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool) +{ + *(((char *)brush) + tool_offset) = tool; +} + /* generic functions for setting the active brush based on the tool */ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) { @@ -226,11 +233,49 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c return NULL; } -static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode) +static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) +{ + if (!brush_orig || brush_tool(brush_orig, tool_offset) != tool) { + Brush *br; + /* if the current brush is not using the desired tool, look + for one that is */ + br = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + /* store the previously-selected brush */ + if (br) + br->toggle_brush = brush_orig; + + return br; + } + else if (brush_orig->toggle_brush && + BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1) + { + /* if current brush is using the desired tool, try to toggle + back to the previously selected brush (if it was set, and + if it still exists) */ + return brush_orig->toggle_brush; + } + else + return NULL; +} + +static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, + const size_t tool_offset, const int ob_mode, + const char *tool_name, int create_missing, + int toggle) { struct Brush *brush, *brush_orig = paint_brush(paint); - brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + if (toggle) + brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode); + else + brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + + if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) { + brush = BKE_brush_add(tool_name); + brush_tool_set(brush, tool_offset, tool); + brush->ob_mode = ob_mode; + brush->toggle_brush = brush_orig; + } if (brush) { paint_brush_set(paint, brush); @@ -251,6 +296,9 @@ static int brush_select_exec(bContext *C, wmOperator *op) ToolSettings *toolsettings = CTX_data_tool_settings(C); Paint *paint = NULL; int tool, paint_mode = RNA_enum_get(op->ptr, "paint_mode"); + int create_missing = RNA_boolean_get(op->ptr, "create_missing"); + int toggle = RNA_boolean_get(op->ptr, "toggle"); + const char *tool_name = "Brush"; size_t tool_offset; if (paint_mode == OB_MODE_ACTIVE) { @@ -273,29 +321,35 @@ static int brush_select_exec(bContext *C, wmOperator *op) paint = &toolsettings->sculpt->paint; tool_offset = offsetof(Brush, sculpt_tool); tool = RNA_enum_get(op->ptr, "sculpt_tool"); + RNA_enum_name_from_value(brush_sculpt_tool_items, tool, &tool_name); break; case OB_MODE_VERTEX_PAINT: paint = &toolsettings->vpaint->paint; tool_offset = offsetof(Brush, vertexpaint_tool); tool = RNA_enum_get(op->ptr, "vertex_paint_tool"); + RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_WEIGHT_PAINT: paint = &toolsettings->wpaint->paint; /* vertexpaint_tool is used for weight paint mode */ tool_offset = offsetof(Brush, vertexpaint_tool); tool = RNA_enum_get(op->ptr, "weight_paint_tool"); + RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_TEXTURE_PAINT: paint = &toolsettings->imapaint.paint; tool_offset = offsetof(Brush, imagepaint_tool); tool = RNA_enum_get(op->ptr, "texture_paint_tool"); + RNA_enum_name_from_value(brush_image_tool_items, tool, &tool_name); break; default: /* invalid paint mode */ return OPERATOR_CANCELLED; } - return brush_generic_tool_set(bmain, paint, tool, tool_offset, paint_mode); + return brush_generic_tool_set(bmain, paint, tool, tool_offset, + paint_mode, tool_name, create_missing, + toggle); } static void PAINT_OT_brush_select(wmOperatorType *ot) @@ -326,6 +380,9 @@ static void PAINT_OT_brush_select(wmOperatorType *ot) RNA_def_enum(ot->srna, "vertex_paint_tool", brush_vertex_tool_items, 0, "Vertex Paint Tool", ""); RNA_def_enum(ot->srna, "weight_paint_tool", brush_vertex_tool_items, 0, "Weight Paint Tool", ""); RNA_def_enum(ot->srna, "texture_paint_tool", brush_image_tool_items, 0, "Texture Paint Tool", ""); + + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling"); + RNA_def_boolean(ot->srna, "create_missing", 0, "Create Missing", "If the requested brush type does not exist, create a new brush"); } static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode, @@ -442,6 +499,9 @@ void ED_operatortypes_paint(void) /* partial visibility */ WM_operatortype_append(PAINT_OT_hide_show); + + /* paint masking */ + WM_operatortype_append(PAINT_OT_mask_flood_fill); } @@ -575,6 +635,15 @@ void ED_keymap_paint(wmKeyConfig *keyconf) for (i = 0; i <= 5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); + /* Clear mask */ + kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", MKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_FLOOD_VALUE); + RNA_float_set(kmi->ptr, "value", 0); + + /* Invert mask */ + kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT); + /* multires switch */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "level", 1); @@ -597,6 +666,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_FLATTEN, TKEY, KM_SHIFT); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CLAY, CKEY, 0); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CREASE, CKEY, KM_SHIFT); + kmi = keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_MASK, MKEY, 0); + RNA_boolean_set(kmi->ptr, "toggle", 1); + RNA_boolean_set(kmi->ptr, "create_missing", 1); /* */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index fe228839c47..9832bcf1528 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -188,7 +188,11 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev output[1] = event->y; if ((stroke->brush->flag & BRUSH_SMOOTH_STROKE) && - !ELEM4(stroke->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK) && + !ELEM4(stroke->brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK) && !(stroke->brush->flag & BRUSH_ANCHORED) && !(stroke->brush->flag & BRUSH_RESTORE_MESH)) { @@ -279,7 +283,7 @@ PaintStroke *paint_stroke_new(bContext *C, void paint_stroke_data_free(struct wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static void stroke_done(struct bContext *C, struct wmOperator *op) @@ -323,13 +327,13 @@ struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) { 0 } }; - static const char *name= "Paint Stroke Modal"; + static const char *name = "Paint Stroke Modal"; - struct wmKeyMap *keymap= WM_modalkeymap_get(keyconf, name); + struct wmKeyMap *keymap = WM_modalkeymap_get(keyconf, name); /* this function is called for each spacetype, only needs to add map once */ if (!keymap) { - keymap= WM_modalkeymap_add(keyconf, name, modal_items); + keymap = WM_modalkeymap_add(keyconf, name, modal_items); /* items for modal map */ WM_modalkeymap_add_item( diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index fb5ddda7a3e..4c374674c9a 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -186,7 +186,7 @@ float paint_get_tex_pixel(Brush *br, float u, float v) hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres); if (hasrgb & TEX_RGB) - texres.tin = (0.35f * texres.tr + 0.45f * texres.tg + 0.2f * texres.tb) * texres.ta; + texres.tin = rgb_to_grayscale(&texres.tr) * texres.ta; return texres.tin; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 37d5af553ab..c01da3a816f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -93,7 +93,7 @@ static int vertex_paint_use_fast_update_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (me && me->mcol) { return (me->mcol == CustomData_get_layer(&dm->faceData, CD_MCOL)); } @@ -110,7 +110,7 @@ static int vertex_paint_use_tessface_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); return (me->mpoly == CustomData_get_layer(&dm->faceData, CD_MPOLY)); } @@ -239,7 +239,7 @@ static void do_shared_vertex_tesscol(Mesh *me) mface = me->mface; mcol = (char *)me->mcol; for (a = me->totface; a > 0; a--, mface++, mcol += 16) { - if ((use_face_sel == FALSE)|| (mface->flag & ME_FACE_SEL)) { + if ((use_face_sel == FALSE) || (mface->flag & ME_FACE_SEL)) { scol = scolmain + 4 * mface->v1; mcol[1] = scol[1]; mcol[2] = scol[2]; mcol[3] = scol[3]; scol = scolmain + 4 * mface->v2; @@ -317,7 +317,7 @@ static void make_vertexcol(Object *ob) /* single ob */ { Mesh *me; if (!ob || ob->id.lib) return; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (me->edit_btmesh) return; @@ -433,7 +433,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) MLoopCol *lcol; int i, j, selected; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (!me->mloopcol) make_vertexcol(ob); @@ -551,7 +551,7 @@ void vpaint_dogamma(Scene *scene) unsigned char *cp, gamtab[256]; ob = OBACT; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if (me == 0 || me->mcol == 0 || me->totface == 0) return; @@ -1007,7 +1007,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) short change = FALSE; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1075,6 +1075,7 @@ void PAINT_OT_weight_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Weight"; ot->idname = "PAINT_OT_weight_sample"; + ot->description = "Use the mouse to sample a weight in the 3D view"; /* api callbacks */ ot->invoke = weight_sample_invoke; @@ -1094,7 +1095,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA Mesh *me; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1176,6 +1177,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Group"; ot->idname = "PAINT_OT_weight_sample_group"; + ot->description = "Select one of the vertex groups available under current mouse position"; /* api callbacks */ ot->exec = weight_sample_group_exec; @@ -1975,7 +1977,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ VPaint *wp = scene->toolsettings->wpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (ob->id.lib || me == NULL) return OPERATOR_PASS_THROUGH; if (ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; @@ -2038,6 +2040,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Mode"; ot->idname = "PAINT_OT_weight_paint_toggle"; + ot->description = "Toggle weight paint mode in 3D view"; /* api callbacks */ ot->exec = set_wpaint; @@ -2139,7 +2142,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED return FALSE; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; /* if nothing was added yet, we make dverts and a vertex deform group */ @@ -2154,7 +2157,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED if ((modob = modifiers_isDeformedByArmature(ob))) { Bone *actbone = ((bArmature *)modob->data)->act_bone; if (actbone) { - bPoseChannel *pchan = get_pose_channel(modob->pose, actbone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(modob->pose, actbone->name); if (pchan) { bDeformGroup *dg = defgroup_find_name(ob, pchan->name); @@ -2490,6 +2493,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint"; ot->idname = "PAINT_OT_weight_paint"; + ot->description = "Paint a stroke in the current vertex group's weights"; /* api callbacks */ ot->invoke = wpaint_invoke; @@ -2522,6 +2526,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Weight"; ot->idname = "PAINT_OT_weight_set"; + ot->description = "Fill the active vertex group with the current paint weight"; /* api callbacks */ ot->exec = weight_paint_set_exec; @@ -2541,9 +2546,9 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ VPaint *vp = scene->toolsettings->vpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); - if (me == NULL || object_data_is_libdata(ob)) { + if (me == NULL || BKE_object_obdata_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } @@ -2586,6 +2591,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint Mode"; ot->idname = "PAINT_OT_vertex_paint_toggle"; + ot->description = "Toggle the vertex paint mode in 3D view"; /* api callbacks */ ot->exec = set_vpaint; @@ -2678,7 +2684,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent float mat[4][4], imat[4][4]; /* context checks could be a poll() */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; @@ -2726,7 +2732,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MFace *mface = &me->mface[index]; unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index; unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index; @@ -2771,7 +2777,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MPoly *mpoly = &me->mpoly[index]; MFace *mf; MCol *mc; @@ -2991,6 +2997,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint"; ot->idname = "PAINT_OT_vertex_paint"; + ot->description = "Paint a stroke in the active vertex color layer"; /* api callbacks */ ot->invoke = vpaint_invoke; @@ -3040,6 +3047,8 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) /* identifiers */ ot->name = "Weight from Bones"; ot->idname = "PAINT_OT_weight_from_bones"; + ot->description = "Set the weights of the groups matching the attached armature's selected bones, " + "using the distance between the vertices and the bones"; /* api callbacks */ ot->exec = weight_from_bones_exec; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fa560dc138c..2d3a7680963 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -52,6 +52,7 @@ #include "DNA_brush_types.h" #include "BKE_brush.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -108,7 +109,7 @@ float *ED_sculpt_get_last_stroke(struct Object *ob) int ED_sculpt_minmax(bContext *C, float *min, float *max) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (ob && ob->sculpt && ob->sculpt->last_stroke_valid) { copy_v3_v3(min, ob->sculpt->last_stroke); @@ -123,7 +124,7 @@ int ED_sculpt_minmax(bContext *C, float *min, float *max) /* Sculpt mode handles multires differently from regular meshes, but only if * it's the last modifier on the stack and it is not on the first level */ -struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) +MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) { Mesh *me = (Mesh *)ob->data; ModifierData *md; @@ -257,6 +258,7 @@ typedef struct StrokeCache { float vertex_rotation; char saved_active_brush_name[MAX_ID_NAME]; + char saved_mask_brush_tool; int alt_smooth; float plane_trim_squared; @@ -289,11 +291,16 @@ static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) if (unode) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - copy_v3_v3(vd.co, unode->co[vd.i]); - if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); - else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); - + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (unode->type == SCULPT_UNDO_COORDS) { + copy_v3_v3(vd.co, unode->co[vd.i]); + if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); + else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); + } + else if (unode->type == SCULPT_UNDO_MASK) { + *vd.mask = unode->mask[vd.i]; + } if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } BLI_pbvh_vertex_iter_end; @@ -639,6 +646,15 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) case SCULPT_TOOL_DRAW: case SCULPT_TOOL_LAYER: return alpha * flip * pressure * overlap * feather; + + case SCULPT_TOOL_MASK: + overlap = (1 + overlap) / 2; + switch ((BrushMaskTool)brush->mask_tool) { + case BRUSH_MASK_DRAW: + return alpha * flip * pressure * overlap * feather; + case BRUSH_MASK_SMOOTH: + return alpha * pressure * feather; + } case SCULPT_TOOL_CREASE: case SCULPT_TOOL_BLOB: @@ -701,7 +717,8 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], const float len, const float sculpt_normal[3], const short vno[3], - const float fno[3]) + const float fno[3], + const float mask) { MTex *mtex = &br->mtex; float avg = 1; @@ -796,6 +813,9 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], avg *= frontface(br, sculpt_normal, vno, fno); + /* Paint mask */ + avg *= 1.0f - mask; + return avg; } @@ -882,7 +902,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { float fno[3]; @@ -893,7 +914,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { if (vd.no) { float fno[3]; @@ -1014,7 +1036,36 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co); } -static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) +/* Similar to neighbor_average(), but returns an averaged mask value + instead of coordinate. Also does not restrict based on border or + corner vertices. */ +static float neighbor_average_mask(SculptSession *ss, unsigned vert) +{ + const float *vmask = ss->vmask; + float avg = 0; + int i, total = 0; + + for (i = 0; i < ss->pmap[vert].count; i++) { + const MPoly *p = &ss->mpoly[ss->pmap[vert].indices[i]]; + unsigned f_adj_v[3]; + + if (poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { + int j; + + for (j = 0; j < 3; j++) { + avg += vmask[f_adj_v[j]]; + total++; + } + } + } + + if (total > 0) + return avg / (float)total; + else + return vmask[vert]; +} + +static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength, int smooth_mask) { Brush *brush = paint_brush(&sd->paint); PBVHVertexIter vd; @@ -1024,19 +1075,29 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); - float avg[3], val[3]; + ss->cache->view_normal, vd.no, vd.fno, + smooth_mask ? 0 : *vd.mask); + if (smooth_mask) { + float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; + val *= fade * bstrength; + *vd.mask += val; + CLAMP(*vd.mask, 0, 1); + } + else { + float avg[3], val[3]; - neighbor_average(ss, avg, vd.vert_indices[vd.i]); - sub_v3_v3v3(val, avg, vd.co); - mul_v3_fl(val, fade); + neighbor_average(ss, avg, vd.vert_indices[vd.i]); + sub_v3_v3v3(val, avg, vd.co); + mul_v3_fl(val, fade); - add_v3_v3(val, vd.co); + add_v3_v3(val, vd.co); - sculpt_clip(sd, ss, vd.co, val); + sculpt_clip(sd, ss, vd.co, val); + } if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -1045,13 +1106,16 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, BLI_pbvh_vertex_iter_end; } -static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) +static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, + float bstrength, int smooth_mask) { Brush *brush = paint_brush(&sd->paint); SculptBrushTest test; - DMGridData **griddata, *data; + CCGElem **griddata, *data; + CCGKey key; DMGridAdjacency *gridadj, *adj; - float (*tmpgrid)[3], (*tmprow)[3]; + float (*tmpgrid_co)[3], (*tmprow_co)[3]; + float *tmpgrid_mask, *tmprow_mask; int v1, v2, v3, v4; int *grid_indices, totgrid, gridsize, i, x, y; @@ -1061,24 +1125,40 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, NULL, &gridsize, &griddata, &gridadj); + BLI_pbvh_get_grid_key(ss->pbvh, &key); #pragma omp critical { - tmpgrid = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid"); - tmprow = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow"); + if (smooth_mask) { + tmpgrid_mask = MEM_mallocN(sizeof(float) * gridsize * gridsize, "tmpgrid_mask"); + tmprow_mask = MEM_mallocN(sizeof(float) * gridsize, "tmprow_mask"); + } + else { + tmpgrid_co = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid_co"); + tmprow_co = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow_co"); + } } for (i = 0; i < totgrid; ++i) { data = griddata[grid_indices[i]]; adj = &gridadj[grid_indices[i]]; - memset(tmpgrid, 0, sizeof(float) * 3 * gridsize * gridsize); + if (smooth_mask) + memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize); + else + memset(tmpgrid_co, 0, sizeof(float) * 3 * gridsize * gridsize); for (y = 0; y < gridsize - 1; y++) { - float tmp[3]; - v1 = y * gridsize; - add_v3_v3v3(tmprow[0], data[v1].co, data[v1 + gridsize].co); + if (smooth_mask) { + tmprow_mask[0] = (*CCG_elem_offset_mask(&key, data, v1) + + *CCG_elem_offset_mask(&key, data, v1 + gridsize)); + } + else { + add_v3_v3v3(tmprow_co[0], + CCG_elem_offset_co(&key, data, v1), + CCG_elem_offset_co(&key, data, v1 + gridsize)); + } for (x = 0; x < gridsize - 1; x++) { v1 = x + y * gridsize; @@ -1086,13 +1166,31 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no v3 = v1 + gridsize; v4 = v3 + 1; - add_v3_v3v3(tmprow[x + 1], data[v2].co, data[v4].co); - add_v3_v3v3(tmp, tmprow[x + 1], tmprow[x]); + if (smooth_mask) { + float tmp; + + tmprow_mask[x + 1] = (*CCG_elem_offset_mask(&key, data, v2) + + *CCG_elem_offset_mask(&key, data, v4)); + tmp = tmprow_mask[x + 1] + tmprow_mask[x]; + + tmpgrid_mask[v1] += tmp; + tmpgrid_mask[v2] += tmp; + tmpgrid_mask[v3] += tmp; + tmpgrid_mask[v4] += tmp; + } + else { + float tmp[3]; - add_v3_v3(tmpgrid[v1], tmp); - add_v3_v3(tmpgrid[v2], tmp); - add_v3_v3(tmpgrid[v3], tmp); - add_v3_v3(tmpgrid[v4], tmp); + add_v3_v3v3(tmprow_co[x + 1], + CCG_elem_offset_co(&key, data, v2), + CCG_elem_offset_co(&key, data, v4)); + add_v3_v3v3(tmp, tmprow_co[x + 1], tmprow_co[x]); + + add_v3_v3(tmpgrid_co[v1], tmp); + add_v3_v3(tmpgrid_co[v2], tmp); + add_v3_v3(tmpgrid_co[v3], tmp); + add_v3_v3(tmpgrid_co[v4], tmp); + } } } @@ -1101,6 +1199,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no for (x = 0; x < gridsize; ++x) { float *co; float *fno; + float *mask; int index; if (x == 0 && adj->index[0] == -1) @@ -1116,33 +1215,40 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no continue; index = x + y * gridsize; - co = data[index].co; - fno = data[index].no; + co = CCG_elem_offset_co(&key, data, index); + fno = CCG_elem_offset_no(&key, data, index); + mask = CCG_elem_offset_mask(&key, data, index); if (sculpt_brush_test(&test, co)) { + const float strength_mask = (smooth_mask ? 0 : *mask); const float fade = bstrength * tex_strength(ss, brush, co, test.dist, - ss->cache->view_normal, NULL, fno); - float *avg, val[3]; - float n; - - avg = tmpgrid[x + y * gridsize]; - - n = 1 / 16.0f; - + ss->cache->view_normal, + NULL, fno, strength_mask); + float n = 1.0f / 16.0f; + if (x == 0 || x == gridsize - 1) n *= 2; - + if (y == 0 || y == gridsize - 1) n *= 2; + + if (smooth_mask) { + *mask += ((tmpgrid_mask[x + y * gridsize] * n) - *mask) * fade; + } + else { + float *avg, val[3]; + + avg = tmpgrid_co[x + y * gridsize]; - mul_v3_fl(avg, n); + mul_v3_fl(avg, n); - sub_v3_v3v3(val, avg, co); - mul_v3_fl(val, fade); + sub_v3_v3v3(val, avg, co); + mul_v3_fl(val, fade); - add_v3_v3(val, co); + add_v3_v3(val, co); - sculpt_clip(sd, ss, co, val); + sculpt_clip(sd, ss, co, val); + } } } } @@ -1150,12 +1256,19 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no #pragma omp critical { - MEM_freeN(tmpgrid); - MEM_freeN(tmprow); + if (smooth_mask) { + MEM_freeN(tmpgrid_mask); + MEM_freeN(tmprow_mask); + } + else { + MEM_freeN(tmpgrid_co); + MEM_freeN(tmprow_co); + } } } -static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float bstrength) +static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, + float bstrength, int smooth_mask) { SculptSession *ss = ob->sculpt; const int max_iterations = 4; @@ -1172,10 +1285,13 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (n = 0; n < totnode; n++) { if (ss->multires) { - do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); + do_multires_smooth_brush(sd, ss, nodes[n], + iteration != count ? 1.0f : last, smooth_mask); + } + else if (ss->pmap) { + do_mesh_smooth_brush(sd, ss, nodes[n], + iteration != count ? 1.0f : last, smooth_mask); } - else if (ss->pmap) - do_mesh_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } if (ss->multires) @@ -1186,7 +1302,54 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { SculptSession *ss = ob->sculpt; - smooth(sd, ob, nodes, totnode, ss->cache->bstrength); + smooth(sd, ob, nodes, totnode, ss->cache->bstrength, FALSE); +} + +static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = paint_brush(&sd->paint); + float bstrength = ss->cache->bstrength; + int n; + + /* threaded loop over nodes */ + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test(&test, vd.co)) { + float fade = tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno, 0); + + (*vd.mask) += fade * bstrength; + CLAMP(*vd.mask, 0, 1); + + if (vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + BLI_pbvh_vertex_iter_end; + } + } +} + +static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = paint_brush(&sd->paint); + + switch ((BrushMaskTool)brush->mask_tool) { + case BRUSH_MASK_DRAW: + do_mask_brush_draw(sd, ob, nodes, totnode); + break; + case BRUSH_MASK_SMOOTH: + smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE); + break; + } } static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) @@ -1215,11 +1378,12 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ float fade = tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], offset, fade); @@ -1239,6 +1403,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float offset[3], area_normal[3]; float bstrength = ss->cache->bstrength; float flippedbstrength, crease_correction; + float brush_alpha; int n; calc_sculpt_normal(sd, ob, area_normal, nodes, totnode); @@ -1249,11 +1414,10 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_fl(offset, bstrength); /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - - if (BKE_brush_alpha_get(scene, brush) > 0.0f) - crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor / (BKE_brush_alpha_get(scene, brush) * BKE_brush_alpha_get(scene, brush)); - else - crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; + crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; + brush_alpha = BKE_brush_alpha_get(scene, brush); + if (brush_alpha > 0.0f) + crease_correction /= brush_alpha * brush_alpha; /* we always want crease to pinch or blob to relax even when draw is negative */ flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength : crease_correction * bstrength; @@ -1271,11 +1435,12 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ const float fade = tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); float val1[3]; float val2[3]; @@ -1313,10 +1478,12 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); + ss->cache->view_normal, vd.no, + vd.fno, *vd.mask); float val[3]; sub_v3_v3v3(val, test.location, vd.co); @@ -1378,7 +1545,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1417,10 +1584,11 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1467,10 +1635,11 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1516,10 +1685,11 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1570,10 +1740,11 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]); sub_v3_v3(proxy[vd.i], origco[vd.i]); @@ -1610,7 +1781,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode SculptUndoNode *unode; float (*origco)[3], *layer_disp; /* XXX: layer brush needs conversion to proxy but its more complicated */ - /* proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */ + /* proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); origco = unode->co; @@ -1623,10 +1794,11 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); float *disp = &layer_disp[vd.i]; float val[3]; @@ -1675,10 +1847,11 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); + ss->cache->view_normal, vd.no, vd.fno, *vd.mask); float val[3]; if (vd.fno) copy_v3_v3(val, vd.fno); @@ -1718,7 +1891,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { add_v3_v3(private_fc, unode->co[vd.i]); private_count++; @@ -1727,7 +1901,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { add_v3_v3(private_fc, vd.co); private_count++; @@ -1783,7 +1958,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { /* for area normal */ float fno[3]; @@ -1799,7 +1975,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { /* for area normal */ if (vd.no) { @@ -1928,7 +2105,8 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3 static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) { - return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared); + return (!(brush->flag & BRUSH_PLANE_TRIM) || + ((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared))); } static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) @@ -2002,7 +2180,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { float intr[3]; float val[3]; @@ -2013,7 +2192,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2073,7 +2252,8 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (plane_point_side_flip(vd.co, an, fc, flip)) { float intr[3]; @@ -2086,7 +2266,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2174,7 +2354,8 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_cube(&test, vd.co, mat)) { if (plane_point_side_flip(vd.co, sn, fc, flip)) { float intr[3]; @@ -2187,7 +2368,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, ss->cache->radius * test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2237,7 +2418,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (plane_point_side(vd.co, an, fc)) { float intr[3]; @@ -2250,7 +2432,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2300,7 +2482,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (!plane_point_side(vd.co, an, fc)) { float intr[3]; @@ -2313,7 +2496,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2371,7 +2554,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) for (a = 0; a < me->totvert; a++, mvert++) copy_v3_v3(mvert->co, vertCos[a]); - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, + me->mpoly, me->totloop, me->totpoly, + NULL, NULL, 0, NULL, NULL); } /* apply new coords on active key block */ @@ -2389,14 +2574,20 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) data.ss = ss; data.sd = sd; data.radius_squared = ss->cache->radius_squared; - data.original = ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_LAYER); + data.original = ELEM4(brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_LAYER); BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); /* Only act if some verts are inside the brush area */ if (totnode) { #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (n = 0; n < totnode; n++) { - sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); + sculpt_undo_push_node(ob, nodes[n], + brush->sculpt_tool == SCULPT_TOOL_MASK ? + SCULPT_UNDO_MASK : SCULPT_UNDO_COORDS); BLI_pbvh_node_mark_update(nodes[n]); } @@ -2453,14 +2644,18 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) case SCULPT_TOOL_SCRAPE: do_scrape_brush(sd, ob, nodes, totnode); break; + case SCULPT_TOOL_MASK: + do_mask_brush(sd, ob, nodes, totnode); + break; } - if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) { + if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) && + brush->autosmooth_factor > 0) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { - smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure)); + smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure), FALSE); } else { - smooth(sd, ob, nodes, totnode, brush->autosmooth_factor); + smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, FALSE); } } @@ -2513,7 +2708,8 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { float val[3]; int p; @@ -2583,7 +2779,8 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) for (n = 0; n < totnode; n++) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { sculpt_flush_pbvhvert_deform(ob, &vd); if (vertCos) { @@ -2604,7 +2801,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Modifiers could depend on mesh normals, so we should update them/ * Note, then if sculpting happens on locked key, normals should be re-calculated * after applying coords from keyblock on base mesh */ - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); } else if (ss->kb) { sculpt_update_keyblock(ob); @@ -2627,8 +2824,8 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, * XXX However, a different approach appears to be needed */ #if 0 if (sd->flags & SCULPT_SYMMETRY_FEATHER) { - float frac = 1.0f/max_overlap_count(sd); - float reduce = (feather-frac)/(1-frac); + float frac = 1.0f / max_overlap_count(sd); + float reduce = (feather - frac) / (1 - frac); printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce); @@ -2756,7 +2953,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->face_normals = NULL; } else { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); ss->totvert = me->totvert; ss->totpoly = me->totpoly; ss->mvert = me->mvert; @@ -2764,6 +2961,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->mloop = me->mloop; ss->face_normals = NULL; ss->multires = NULL; + ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); } /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */ @@ -2887,7 +3085,7 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) ss->cache->clip_tolerance[i]) { ss->cache->clip_tolerance[i] = - mmd->tolerance; + mmd->tolerance; } } } @@ -2940,15 +3138,22 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio /* Alt-Smooth */ if (ss->cache->alt_smooth) { - Paint *p = &sd->paint; - Brush *br; + if (brush->sculpt_tool == SCULPT_TOOL_MASK) { + cache->saved_mask_brush_tool = brush->mask_tool; + brush->mask_tool = BRUSH_MASK_SMOOTH; + } + else { + Paint *p = &sd->paint; + Brush *br; - BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); + BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, + sizeof(cache->saved_active_brush_name)); - br = (Brush *)find_id("BR", "Smooth"); - if (br) { - paint_brush_set(p, br); - brush = br; + br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth"); + if (br) { + paint_brush_set(p, br); + brush = br; + } } } @@ -3134,7 +3339,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, if (cache->first_time) { if (!BKE_brush_use_locked_size(scene, brush)) { - cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->true_location, BKE_brush_size_get(scene, brush)); + cache->initial_radius = paint_calc_object_space_radius(cache->vc, + cache->true_location, + BKE_brush_size_get(scene, brush)); BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); } else { @@ -3361,6 +3568,8 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) is_smooth |= mode == BRUSH_STROKE_SMOOTH; is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; + is_smooth |= ((brush->sculpt_tool == SCULPT_TOOL_MASK) && + (brush->mask_tool == BRUSH_MASK_SMOOTH)); sculpt_update_mesh_elements(scene, sd, ob, is_smooth); @@ -3507,15 +3716,20 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str /* Alt-Smooth */ if (ss->cache->alt_smooth) { - Paint *p = &sd->paint; - brush = (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if (brush) { - paint_brush_set(p, brush); + if (brush->sculpt_tool == SCULPT_TOOL_MASK) { + brush->mask_tool = ss->cache->saved_mask_brush_tool; + } + else { + Paint *p = &sd->paint; + brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name); + if (brush) { + paint_brush_set(p, brush); + } } } /* update last stroke position */ - ob->sculpt->last_stroke_valid= 1; + ob->sculpt->last_stroke_valid = 1; copy_v3_v3(ob->sculpt->last_stroke, ss->cache->true_location); mul_m4_v3(ob->obmat, ob->sculpt->last_stroke); @@ -3621,8 +3835,9 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) }; /* identifiers */ - ot->name = "Sculpt Mode"; + ot->name = "Sculpt"; ot->idname = "SCULPT_OT_brush_stroke"; + ot->description = "Sculpt a stroke into the geometry"; /* api callbacks */ ot->invoke = sculpt_brush_stroke_invoke; @@ -3668,6 +3883,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) /* identifiers */ ot->name = "Set Persistent Base"; ot->idname = "SCULPT_OT_set_persistent_base"; + ot->description = "Reset the copy of the mesh that is being sculpted on"; /* api callbacks */ ot->exec = sculpt_set_persistent_base; @@ -3685,6 +3901,71 @@ static void sculpt_init_session(Scene *scene, Object *ob) sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0); } +void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) +{ + float *paint_mask; + Mesh *me = ob->data; + + paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); + + /* if multires is active, create a grid paint mask layer if there + isn't one already */ + if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) { + GridPaintMask *gmask; + int level = MAX2(1, mmd->sculptlvl); + int gridsize = ccg_gridsize(level); + int gridarea = gridsize * gridsize; + int i, j; + + gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK, + CD_CALLOC, NULL, me->totloop); + + for (i = 0; i < me->totloop; i++) { + GridPaintMask *gpm = &gmask[i]; + + gpm->level = level; + gpm->data = MEM_callocN(sizeof(float) * gridarea, + "GridPaintMask.data"); + } + + /* if vertices already have mask, copy into multires data */ + if (paint_mask) { + for (i = 0; i < me->totpoly; i++) { + const MPoly *p = &me->mpoly[i]; + float avg = 0; + + /* mask center */ + for (j = 0; j < p->totloop; j++) { + const MLoop *l = &me->mloop[p->loopstart + j]; + avg += paint_mask[l->v]; + } + avg /= (float)p->totloop; + + /* fill in multires mask corner */ + for (j = 0; j < p->totloop; j++) { + GridPaintMask *gpm = &gmask[p->loopstart + j]; + const MLoop *l = &me->mloop[p->loopstart + j]; + const MLoop *prev = ME_POLY_LOOP_PREV(me->mloop, p, j); + const MLoop *next = ME_POLY_LOOP_NEXT(me->mloop, p, j); + + gpm->data[0] = avg; + gpm->data[1] = (paint_mask[l->v] + + paint_mask[next->v]) * 0.5f; + gpm->data[2] = (paint_mask[l->v] + + paint_mask[prev->v]) * 0.5f; + gpm->data[3] = paint_mask[l->v]; + } + } + } + } + + /* create vertex paint mask layer if there isn't one already */ + if (!paint_mask) { + CustomData_add_layer(&me->vdata, CD_PAINT_MASK, + CD_CALLOC, NULL, me->totvert); + } +} + static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -3731,6 +4012,9 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) sculpt_init_session(scene, ob); + /* Mask layer is required */ + ED_sculpt_mask_layers_ensure(ob, mmd); + paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT); paint_cursor_start(C, sculpt_poll); @@ -3746,6 +4030,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Sculpt Mode"; ot->idname = "SCULPT_OT_sculptmode_toggle"; + ot->description = "Toggle sculpt mode in 3D view"; /* api callbacks */ ot->exec = sculpt_toggle_mode; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 8ccf55ec4fb..f4467dc22fc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -53,7 +53,7 @@ struct SculptStroke; /* Interface */ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob); -void sculpt(Sculpt *sd); +void sculpt(struct Sculpt *sd); int sculpt_mode_poll(struct bContext *C); int sculpt_poll(struct bContext *C); @@ -69,7 +69,8 @@ int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]); typedef enum { SCULPT_UNDO_COORDS, - SCULPT_UNDO_HIDDEN + SCULPT_UNDO_HIDDEN, + SCULPT_UNDO_MASK } SculptUndoType; typedef struct SculptUndoNode { @@ -77,24 +78,25 @@ typedef struct SculptUndoNode { SculptUndoType type; - char idname[MAX_ID_NAME]; /* name instead of pointer*/ - void *node; /* only during push, not valid afterwards! */ + char idname[MAX_ID_NAME]; /* name instead of pointer*/ + void *node; /* only during push, not valid afterwards! */ float (*co)[3]; float (*orig_co)[3]; short (*no)[3]; + float *mask; int totvert; /* non-multires */ - int maxvert; /* to verify if totvert it still the same */ - int *index; /* to restore into right location */ + int maxvert; /* to verify if totvert it still the same */ + int *index; /* to restore into right location */ BLI_bitmap vert_hidden; /* multires */ - int maxgrid; /* same for grid */ - int gridsize; /* same for grid */ - int totgrid; /* to restore into right location */ - int *grids; /* to restore into right location */ + int maxgrid; /* same for grid */ + int gridsize; /* same for grid */ + int totgrid; /* to restore into right location */ + int *grids; /* to restore into right location */ BLI_bitmap *grid_hidden; /* layer brush */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c08ed2e85b9..d233c45a230 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -47,6 +47,7 @@ #include "DNA_scene_types.h" #include "DNA_mesh_types.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -76,7 +77,10 @@ static void update_cb(PBVHNode *node, void *rebuild) BLI_pbvh_node_fully_hidden_set(node, 0); } -static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) +static void sculpt_undo_restore_deformed(const SculptSession *ss, + SculptUndoNode *unode, + int uindex, int oindex, + float coord[3]) { if (unode->orig_co) { swap_v3_v3(coord, unode->orig_co[uindex]); @@ -154,19 +158,21 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo } else if (unode->maxgrid && dm->getGridData) { /* multires restore */ - DMGridData **grids, *grid; + CCGElem **grids, *grid; + CCGKey key; float (*co)[3]; int gridsize; grids = dm->getGridData(dm); gridsize = dm->getGridSize(dm); + dm->getGridKey(dm, &key); co = unode->co; for (j = 0; j < unode->totgrid; j++) { grid = grids[unode->grids[j]]; for (i = 0; i < gridsize * gridsize; i++, co++) - swap_v3_v3(grid[i].co, co[0]); + swap_v3_v3(CCG_elem_offset_co(&key, grid, i), co[0]); } } @@ -211,6 +217,49 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, return 1; } +static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode *unode) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + MVert *mvert; + float *vmask; + int *index, i, j; + + if (unode->maxvert) { + /* regular mesh restore */ + + index = unode->index; + mvert = ss->mvert; + vmask = ss->vmask; + + for (i = 0; i < unode->totvert; i++) { + SWAP(float, vmask[index[i]], unode->mask[i]); + mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; + } + } + else if (unode->maxgrid && dm->getGridData) { + /* multires restore */ + CCGElem **grids, *grid; + CCGKey key; + float *mask; + int gridsize; + + grids = dm->getGridData(dm); + gridsize = dm->getGridSize(dm); + dm->getGridKey(dm, &key); + + mask = unode->mask; + for (j = 0; j < unode->totgrid; j++) { + grid = grids[unode->grids[j]]; + + for (i = 0; i < gridsize * gridsize; i++, mask++) + SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask); + } + } + + return 1; +} + static void sculpt_undo_restore(bContext *C, ListBase *lb) { Scene *scene = CTX_data_scene(C); @@ -254,6 +303,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (sculpt_undo_restore_hidden(C, dm, unode)) rebuild = 1; break; + case SCULPT_UNDO_MASK: + if (sculpt_undo_restore_mask(C, dm, unode)) + update = 1; + break; } } @@ -276,8 +329,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (ss->modifiers_active) { Mesh *mesh = ob->data; - mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, - mesh->mface, mesh->totface, NULL); + BKE_mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, + mesh->mface, mesh->totface, NULL); free_sculptsession_deformMats(ss); tag_update |= 1; @@ -318,6 +371,8 @@ static void sculpt_undo_free(ListBase *lb) } MEM_freeN(unode->grid_hidden); } + if (unode->mask) + MEM_freeN(unode->mask); } } @@ -385,7 +440,10 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, case SCULPT_UNDO_COORDS: unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co"); unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no"); - undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * 3 + sizeof(short) * 3 + sizeof(int)) * allvert); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, + (sizeof(float) * 3 + + sizeof(short) * 3 + + sizeof(int)) * allvert); break; case SCULPT_UNDO_HIDDEN: if (maxgrid) @@ -394,6 +452,10 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); break; + case SCULPT_UNDO_MASK: + unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask"); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int)) * allvert); + break; } BLI_addtail(lb, unode); @@ -422,7 +484,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode) SculptSession *ss = ob->sculpt; PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) + { copy_v3_v3(unode->co[vd.i], vd.co); if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); else normal_float_to_short_v3(unode->no[vd.i], vd.fno); @@ -455,6 +518,18 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) } } +static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode) +{ + SculptSession *ss = ob->sculpt; + PBVHVertexIter vd; + + BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) + { + unode->mask[vd.i] = *vd.mask; + } + BLI_pbvh_vertex_iter_end; +} + SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type) { @@ -495,6 +570,9 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, case SCULPT_UNDO_HIDDEN: sculpt_undo_store_hidden(ob, unode); break; + case SCULPT_UNDO_MASK: + sculpt_undo_store_mask(ob, unode); + break; } /* store active shape key */ diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 24bc01989fc..e91b29ff0c1 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -286,11 +286,11 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) { scene->r.cfra = cfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); } scene->r.cfra = oldfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 024a9ffb57d..3961e566f80 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -73,22 +73,22 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); if (height > (v2d->mask.ymax - v2d->mask.ymin)) { /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) @@ -99,16 +99,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* loop through channels, and set up drawing depending on their type */ - { /* first pass: just the standard GL-drawing for backdrop + text */ - y= (float)ACHANNEL_FIRST; + { /* first pass: just the standard GL-drawing for backdrop + text */ + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first; ale; ale= ale->next) { - float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc); @@ -118,19 +118,19 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) y -= ACHANNEL_STEP; } } - { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)ACHANNEL_FIRST; + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first; ale; ale= ale->next) { - float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); @@ -153,7 +153,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* Keyframes */ /* extra padding for lengths (to go under scrollers) */ -#define EXTRA_SCROLL_PAD 100.0f +#define EXTRA_SCROLL_PAD 100.0f /* draw keyframes in each channel */ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) @@ -162,9 +162,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - bDopeSheet *ads= &saction->ads; - AnimData *adt= NULL; + View2D *v2d = &ar->v2d; + bDopeSheet *ads = &saction->ads; + AnimData *adt = NULL; float act_start, act_end, y; size_t items; @@ -196,41 +196,41 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); /* first backdrop strips */ - y= (float)(-ACHANNEL_HEIGHT); + y = (float)(-ACHANNEL_HEIGHT); glEnable(GL_BLEND); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - int sel=0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + int sel = 0; /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) - sel= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); if (ELEM3(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { switch (ale->type) { @@ -239,7 +239,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) // FIXME: hardcoded colors - reddish color from NLA glColor4f(0.8f, 0.2f, 0.0f, 0.4f); } - break; + break; case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: @@ -247,7 +247,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); } - break; + break; case ANIMTYPE_FILLACTD: case ANIMTYPE_DSSKEY: @@ -256,39 +256,39 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); } - break; + break; case ANIMTYPE_GROUP: { if (sel) glColor4ub(col1a[0], col1a[1], col1a[2], 0x22); else glColor4ub(col2a[0], col2a[1], col2a[2], 0x22); } - break; + break; default: { if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); } - break; + break; } /* draw region twice: firstly backdrop, then the current range */ - glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); if (ac->datatype == ANIMCONT_ACTION) - glRectf(act_start, (float)y-ACHANNEL_HEIGHT_HALF, act_end, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF, act_end, (float)y + ACHANNEL_HEIGHT_HALF); } else if (ac->datatype == ANIMCONT_GPENCIL) { /* frames less than one get less saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); - glRectf(0.0f, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF); /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); - glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); } } } @@ -303,19 +303,19 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) * This is to try to optimize this for heavier data sets * 2) Keyframes which are out of view horizontally are disregarded */ - y= (float)(-ACHANNEL_HEIGHT); + y = (float)(-ACHANNEL_HEIGHT); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { - adt= ANIM_nla_mapping_get(ac, ale); + adt = ANIM_nla_mapping_get(ac, ale); /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { @@ -344,7 +344,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } - y-= ACHANNEL_STEP; + y -= ACHANNEL_STEP; } /* free tempolary channels used for drawing */ @@ -355,8 +355,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); - glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD); - glVertex2f(saction->timeslide, v2d->cur.ymax); + glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); + glVertex2f(saction->timeslide, v2d->cur.ymax); glEnd(); } } diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a44eca17dfd..73c36fd8086 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -86,7 +86,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) uiIDContextProperty(C, &ptr, &prop); if (prop) { - bAction *action=NULL, *oldact=NULL; + bAction *action = NULL, *oldact = NULL; PointerRNA oldptr; /* create action - the way to do this depends on whether we've got an @@ -96,13 +96,13 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) oldptr = RNA_property_pointer_get(&ptr, prop); oldact = (bAction *)oldptr.id.data; - if (oldact && GS(oldact->id.name)==ID_AC) { + if (oldact && GS(oldact->id.name) == ID_AC) { /* make a copy of the existing action */ - action= copy_action(oldact); + action = BKE_action_copy(oldact); } else { /* just make a new (empty) action */ - action= add_empty_action("Action"); + action = add_empty_action("Action"); } /* when creating new ID blocks, use is already 1 (fake user), @@ -116,7 +116,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) } /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -130,11 +130,11 @@ void ACTION_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec = act_new_exec; - // NOTE: this is used in the NLA too... + // NOTE: this is used in the NLA too... //ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -143,9 +143,9 @@ void ACTION_OT_new(wmOperatorType *ot) /* *************************** Localise Markers ***************************** */ /* ensure that there is: - * 1) an active action editor - * 2) that the mode will have an active action available - * 3) that the set of markers being shown are the scene markers, not the list we're merging + * 1) an active action editor + * 2) that the mode will have an active action available + * 3) that the set of markers being shown are the scene markers, not the list we're merging * 4) that there are some selected markers */ static int act_markers_make_local_poll(bContext *C) @@ -170,14 +170,14 @@ static int act_markers_make_local_poll(bContext *C) return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL; } -static int act_markers_make_local_exec (bContext *C, wmOperator *UNUSED(op)) +static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op)) { ListBase *markers = ED_context_get_markers(C); SpaceAction *sact = CTX_wm_space_action(C); - bAction *act = (sact)? sact->action : NULL; + bAction *act = (sact) ? sact->action : NULL; - TimeMarker *marker, *markern=NULL; + TimeMarker *marker, *markern = NULL; /* sanity checks */ if (ELEM(NULL, markers, act)) @@ -198,8 +198,8 @@ static int act_markers_make_local_exec (bContext *C, wmOperator *UNUSED(op)) sact->flag |= SACTION_POSEMARKERS_SHOW; /* notifiers - both sets, as this change affects both */ - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -216,7 +216,7 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) ot->poll = act_markers_make_local_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -225,7 +225,7 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) /* *************************** Calculate Range ************************** */ /* Get the min/max keyframes*/ -static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, const short onlySel) +static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -234,43 +234,43 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons /* get data to filter, from Action or Dopesheet */ // XXX: what is sel doing here?! // Commented it, was breaking things (eg. the "auto preview range" tool). - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - *min= 999999999.0f; - *max= -999999999.0f; + *min = 999999999.0f; + *max = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (ale->datatype == ALE_GPFRAME) { - bGPDlayer *gpl= ale->data; + bGPDlayer *gpl = ale->data; bGPDframe *gpf; /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { - *min= MIN2(*min, gpf->framenum); - *max= MAX2(*max, gpf->framenum); + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { + *min = MIN2(*min, gpf->framenum); + *max = MAX2(*max, gpf->framenum); } } else { - FCurve *fcu= (FCurve *)ale->key_data; + FCurve *fcu = (FCurve *)ale->key_data; float tmin, tmax; /* get range and apply necessary scaling before processing */ calc_fcurve_range(fcu, &tmin, &tmax, onlySel, TRUE); if (adt) { - tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); - tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); + tmin = BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); + tmax = BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); } /* try to set cur using these values, if they're more extreme than previously set values */ - *min= MIN2(*min, tmin); - *max= MAX2(*max, tmax); + *min = MIN2(*min, tmin); + *max = MAX2(*max, tmax); } } @@ -280,12 +280,12 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons else { /* set default range */ if (ac->scene) { - *min= (float)ac->scene->r.sfra; - *max= (float)ac->scene->r.efra; + *min = (float)ac->scene->r.sfra; + *max = (float)ac->scene->r.efra; } else { - *min= -5; - *max= 100; + *min = -5; + *max = 100; } } } @@ -304,17 +304,17 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (ac.scene == NULL) return OPERATOR_CANCELLED; else - scene= ac.scene; + scene = ac.scene; /* set the range directly */ get_keyframe_extents(&ac, &min, &max, FALSE); scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(min + 0.5f); - scene->r.pefra= (int)floor(max + 0.5f); + scene->r.psfra = (int)floor(min + 0.5f); + scene->r.pefra = (int)floor(max + 0.5f); /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -331,7 +331,7 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** View-All Operator ****************** */ @@ -345,12 +345,12 @@ static int actkeys_viewall(bContext *C, const short onlySel) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* 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 * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -393,7 +393,7 @@ void ACTION_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void ACTION_OT_view_selected(wmOperatorType *ot) @@ -408,7 +408,7 @@ void ACTION_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -417,20 +417,20 @@ void ACTION_OT_view_selected(wmOperatorType *ot) /* ******************** Copy/Paste Keyframes Operator ************************* */ /* NOTE: the backend code for this is shared with the graph editor */ -static short copy_action_keys (bAnimContext *ac) +static short copy_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* clear buffer first */ free_anim_copybuf(); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* copy keyframes */ - ok= copy_animedit_keys(ac, &anim_data); + ok = copy_animedit_keys(ac, &anim_data); /* clean up */ BLI_freelistN(&anim_data); @@ -439,18 +439,18 @@ static short copy_action_keys (bAnimContext *ac) } -static short paste_action_keys (bAnimContext *ac, - const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) +static short paste_action_keys(bAnimContext *ac, + const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ - ok= paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); + ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); /* clean up */ BLI_freelistN(&anim_data); @@ -496,22 +496,22 @@ void ACTION_OT_copy(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int actkeys_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const eKeyPasteOffset offset_mode= RNA_enum_get(op->ptr, "offset"); - const eKeyMergeMode merge_mode= RNA_enum_get(op->ptr, "merge"); + const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); + const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* ac.reports by default will be the global reports list, which won't show warnings */ - ac.reports= op->reports; + ac.reports = op->reports; /* paste keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { @@ -530,7 +530,7 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -548,7 +548,7 @@ void ACTION_OT_paste(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); @@ -573,13 +573,13 @@ static void insert_action_keys(bAnimContext *ac, short mode) int filter; ReportList *reports = ac->reports; - Scene *scene= ac->scene; + Scene *scene = ac->scene; short flag = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - if (mode == 2) filter |= ANIMFILTER_SEL; - else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + if (mode == 2) filter |= ANIMFILTER_SEL; + else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -587,20 +587,20 @@ static void insert_action_keys(bAnimContext *ac, short mode) flag = ANIM_get_keyframing_flags(scene, 1); /* insert keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float cfra; /* adjust current frame for NLA-scaling */ if (adt) - cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else - cfra= (float)CFRA; + cfra = (float)CFRA; /* if there's an id */ if (ale->id) - insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } @@ -622,7 +622,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* what channels to affect? */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* insert keyframes */ insert_action_keys(&ac, mode); @@ -631,7 +631,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -649,7 +649,7 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); @@ -657,7 +657,7 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) /* ******************** Duplicate Keyframes Operator ************************* */ -static void duplicate_action_keys (bAnimContext *ac) +static void duplicate_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -665,13 +665,13 @@ static void duplicate_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_FCURVE) duplicate_fcurve_keys((FCurve *)ale->key_data); else @@ -700,7 +700,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -725,12 +725,12 @@ void ACTION_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Delete Keyframes Operator ************************* */ -static void delete_action_keys (bAnimContext *ac) +static void delete_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -738,16 +738,16 @@ static void delete_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type != ANIMTYPE_GPLAYER) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ale->adt; + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ale->adt; /* delete selected keyframes only */ delete_fcurve_keys(fcu); @@ -782,7 +782,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -800,23 +800,23 @@ void ACTION_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clean Keyframes Operator ************************* */ -static void clean_action_keys (bAnimContext *ac, float thresh) +static void clean_action_keys(bAnimContext *ac, float thresh) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) clean_fcurve((FCurve *)ale->key_data, thresh); /* free temp data */ @@ -837,7 +837,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get cleaning threshold */ - thresh= RNA_float_get(op->ptr, "threshold"); + thresh = RNA_float_get(op->ptr, "threshold"); /* clean keyframes */ clean_action_keys(&ac, thresh); @@ -846,7 +846,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -864,7 +864,7 @@ void ACTION_OT_clean(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); @@ -873,18 +873,18 @@ void ACTION_OT_clean(wmOperatorType *ot) /* ******************** Sample Keyframes Operator *********************** */ /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ -static void sample_action_keys (bAnimContext *ac) +static void sample_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) sample_fcurve((FCurve *)ale->key_data); /* admin and redraws */ @@ -910,7 +910,7 @@ static int actkeys_sample_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -927,7 +927,7 @@ void ACTION_OT_sample(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -936,8 +936,8 @@ void ACTION_OT_sample(wmOperatorType *ot) /* ******************** Set Extrapolation-Type Operator *********************** */ /* defines for make/clear cyclic extrapolation tools */ -#define MAKE_CYCLIC_EXPO -1 -#define CLEAR_CYCLIC_EXPO -2 +#define MAKE_CYCLIC_EXPO -1 +#define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ static EnumPropertyItem prop_actkeys_expo_types[] = { @@ -957,16 +957,16 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; if (mode >= 0) { /* just set mode setting */ - fcu->extend= mode; + fcu->extend = mode; } else { /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation @@ -981,7 +981,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) } else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ - FModifier *fcm, *fcn=NULL; + FModifier *fcm, *fcn = NULL; for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; @@ -1011,7 +1011,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setexpo_action_keys(&ac, mode); @@ -1020,7 +1020,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1038,7 +1038,7 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); @@ -1052,16 +1052,16 @@ static void setipo_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); /* cleanup */ @@ -1082,7 +1082,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setipo_action_keys(&ac, mode); @@ -1091,7 +1091,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1109,7 +1109,7 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); @@ -1124,18 +1124,18 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode); - KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); + KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { @@ -1162,7 +1162,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ sethandles_action_keys(&ac, mode); @@ -1171,7 +1171,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1189,7 +1189,7 @@ void ACTION_OT_handle_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); @@ -1203,16 +1203,16 @@ static void setkeytype_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_keytype(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL); /* cleanup */ @@ -1233,7 +1233,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setkeytype_action_keys(&ac, mode); @@ -1242,7 +1242,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1260,7 +1260,7 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_keyframe_type_items, 0, "Type", ""); @@ -1275,10 +1275,10 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot) static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1286,11 +1286,11 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) /* init edit data */ /* loop over action data, averaging values */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(&ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(&ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1304,13 +1304,13 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) /* set the new current frame value, based on the average time */ if (ked.i1) { - Scene *scene= ac.scene; - CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f); - SUBFRA= 0.f; + Scene *scene = ac.scene; + CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f); + SUBFRA = 0.f; } /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -1327,7 +1327,7 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Keyframes Operator *********************** */ @@ -1348,28 +1348,28 @@ static void snap_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_snap(mode); + edit_cb = ANIM_editkeyframes_snap(mode); - ked.scene= ac->scene; + ked.scene = ac->scene; if (mode == ACTKEYS_SNAP_NEAREST_MARKER) { - ked.list.first= (ac->markers) ? ac->markers->first : NULL; - ked.list.last= (ac->markers) ? ac->markers->last : NULL; + ked.list.first = (ac->markers) ? ac->markers->first : NULL; + ked.list.last = (ac->markers) ? ac->markers->last : NULL; } /* snap keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -1401,7 +1401,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get snapping mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* snap keyframes */ snap_action_keys(&ac, mode); @@ -1410,7 +1410,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1428,7 +1428,7 @@ void ACTION_OT_snap(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); @@ -1451,39 +1451,39 @@ static void mirror_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_mirror(mode); + edit_cb = ANIM_editkeyframes_mirror(mode); - ked.scene= ac->scene; + ked.scene = ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? if (mode == ACTKEYS_MIRROR_MARKER) { - TimeMarker *marker= NULL; + TimeMarker *marker = NULL; /* find first selected marker */ - marker= ED_markers_get_first_selected(ac->markers); + marker = ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) - ked.f1= (float)marker->frame; + ked.f1 = (float)marker->frame; else return; } /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -1515,7 +1515,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get mirroring mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* mirror keyframes */ mirror_action_keys(&ac, mode); @@ -1524,7 +1524,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1542,7 +1542,7 @@ void ACTION_OT_mirror(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 7074a109228..c684ae1de51 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -61,14 +61,14 @@ void ACTION_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ enum { - ACTKEYS_LRSEL_TEST = 0, + ACTKEYS_LRSEL_TEST = 0, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT } eActKeys_LeftRightSelect_Mode; /* defines for column-select mode */ enum { - ACTKEYS_COLUMNSEL_KEYS = 0, + ACTKEYS_COLUMNSEL_KEYS = 0, ACTKEYS_COLUMNSEL_CFRA, ACTKEYS_COLUMNSEL_MARKERS_COLUMN, ACTKEYS_COLUMNSEL_MARKERS_BETWEEN, diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index f502a97967f..e4a161e3e22 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -45,6 +45,7 @@ #include "action_intern.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_api.h" #include "WM_types.h" @@ -54,7 +55,7 @@ void action_operatortypes(void) { /* keyframes */ - /* selection */ + /* selection */ WM_operatortype_append(ACTION_OT_clickselect); WM_operatortype_append(ACTION_OT_select_all_toggle); WM_operatortype_append(ACTION_OT_select_border); @@ -64,7 +65,7 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_select_less); WM_operatortype_append(ACTION_OT_select_leftright); - /* editing */ + /* editing */ WM_operatortype_append(ACTION_OT_snap); WM_operatortype_append(ACTION_OT_mirror); WM_operatortype_append(ACTION_OT_frame_jump); @@ -93,9 +94,10 @@ void ED_operatormacros_action(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); @@ -105,82 +107,82 @@ void ED_operatormacros_action(void) /* ************************** registration - keymaps **********************************/ -static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; /* action_select.c - selection tools */ - /* click-select */ + /* click-select */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "column", TRUE); - /* select left/right */ + /* select left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); - /* deselect all */ + /* deselect all */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - /* column select */ + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); - /* select more/less */ + /* select more/less */ WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - /* select linekd */ + /* select linekd */ WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0); /* action_edit.c */ - /* snap - current frame to selected keys */ - // TODO: maybe since this is called jump, we're better to have it on <something>-J? - WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* snap - current frame to selected keys */ + // TODO: maybe since this is called jump, we're better to have it on <something>-J? + WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - /* menu + single-step transform */ + /* menu + single-step transform */ WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); - /* menu + set setting */ + /* menu + set setting */ WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); - /* destructive */ + /* destructive */ WM_keymap_add_item(keymap, "ACTION_OT_clean", OKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); @@ -190,19 +192,19 @@ static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - /* copy/paste */ + /* copy/paste */ WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); - /* auto-set range */ - WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + /* auto-set range */ + WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* animation module */ - /* channels list - * NOTE: these operators were originally for the channels list, but are added here too for convenience... - */ + /* channels list + * NOTE: these operators were originally for the channels list, but are added here too for convenience... + */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); /* transform system */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index a28f8ee1b99..0c6b0f5eb3d 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -79,42 +79,42 @@ /* Deselects keyframes in the action editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all + * - test: check if select or deselect all * - sel: how to select keyframes (SELECT_*) */ -static void deselect_action_keys (bAnimContext *ac, short test, short sel) +static void deselect_action_keys(bAnimContext *ac, short test, short sel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; /* determine type-based settings */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* init BezTriple looping data */ - test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { if (is_gplayer_frame_selected(ale->data)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } else { if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } @@ -122,10 +122,10 @@ static void deselect_action_keys (bAnimContext *ac, short test, short sel) } /* convert sel to selectmode, and use that to get editor */ - sel_cb= ANIM_editkeyframes_select(sel); + sel_cb = ANIM_editkeyframes_select(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) set_gplayer_frame_selection(ale->data, sel); else @@ -153,7 +153,7 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) deselect_action_keys(&ac, 1, SELECT_ADD); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -170,7 +170,7 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -178,7 +178,7 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all keyframes within region are selected (ACTKEYS_BORDERSEL_ALLKEYS) + * -> BKEY - 1) all keyframes within region are selected (ACTKEYS_BORDERSEL_ALLKEYS) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (ACTKEYS_BORDERSEL_FRAMERANGE) * -> 3) y-axis, so select all frames within channels that region included (ACTKEYS_BORDERSEL_CHANNELS) @@ -186,13 +186,13 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* defines for borderselect mode */ enum { - ACTKEYS_BORDERSEL_ALLKEYS = 0, + ACTKEYS_BORDERSEL_ALLKEYS = 0, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_CHANNELS, } /*eActKeys_BorderSelect_Mode*/; -static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short selectmode) +static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -200,52 +200,52 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin=0, ymax=(float)(-ACHANNEL_HEIGHT_HALF); + float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF); /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ - UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing/validation funcs */ - select_cb= ANIM_editkeyframes_select(selectmode); + select_cb = ANIM_editkeyframes_select(selectmode); if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); else - ok_cb= NULL; + ok_cb = NULL; /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - ymin= ymax - ACHANNEL_STEP; + ymin = ymax - ACHANNEL_STEP; /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { /* if channel is mapped in NLA, apply correction */ if (adt) { - ked.f1= BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP); - ked.f2= BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP); + ked.f2 = BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP); } else { - ked.f1= rectf.xmin; - ked.f2= rectf.xmax; + ked.f1 = rectf.xmin; + ked.f2 = rectf.xmax; } } /* perform vertical suitability check (if applicable) */ if ( (mode == ACTKEYS_BORDERSEL_FRAMERANGE) || - !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) + !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting */ if (ale->type == ANIMTYPE_GPLAYER) @@ -255,7 +255,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short } /* set minimum extent to be the maximum of the next channel */ - ymax=ymin; + ymax = ymin; } /* cleanup */ @@ -268,7 +268,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; int gesture_mode, extend; /* get editor data */ @@ -276,7 +276,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_action_keys(&ac, 1, SELECT_SUBTRACT); @@ -286,7 +286,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); if (gesture_mode == GESTURE_MODAL_SELECT) selectmode = SELECT_ADD; else @@ -300,18 +300,18 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= ACTKEYS_BORDERSEL_FRAMERANGE; + mode = ACTKEYS_BORDERSEL_FRAMERANGE; else - mode= ACTKEYS_BORDERSEL_CHANNELS; + mode = ACTKEYS_BORDERSEL_CHANNELS; } else - mode= ACTKEYS_BORDERSEL_ALLKEYS; + mode = ACTKEYS_BORDERSEL_ALLKEYS; /* apply borderselect action */ borderselect_action(&ac, rect, mode, selectmode); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -332,7 +332,7 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -362,14 +362,14 @@ static EnumPropertyItem prop_column_select_types[] = { /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c * should de-duplicate - campbell */ -static void markers_selectkeys_between (bAnimContext *ac) +static void markers_selectkeys_between(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; float min, max; /* get extreme markers */ @@ -378,19 +378,19 @@ static void markers_selectkeys_between (bAnimContext *ac) max += 0.5f; /* get editing funcs + data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); - ked.f1= min; - ked.f2= max; + ked.f1 = min; + ked.f2 = max; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys in-between */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -411,16 +411,16 @@ static void markers_selectkeys_between (bAnimContext *ac) /* Selects all visible keyframes in the same frames as the specified elements */ -static void columnselect_action_keys (bAnimContext *ac, short mode) +static void columnselect_action_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* initialize keyframe editing data */ @@ -428,17 +428,17 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) switch (mode) { case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */ if (ac->datatype == ANIMCONT_GPENCIL) { - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) gplayer_make_cfra_list(ale->data, &ked.list, 1); } else { - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); } BLI_freelistN(&anim_data); @@ -446,10 +446,10 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ - ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - ce->cfra= (float)CFRA; + ce->cfra = (float)CFRA; break; case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ @@ -461,30 +461,30 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) } /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(SELECT_ADD); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ - for (ce= ked.list.first; ce; ce= ce->next) { + for (ce = ked.list.first; ce; ce = ce->next) { /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); else - ked.f1= ce->cfra; + ked.f1 = ce->cfra; /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) @@ -511,7 +511,7 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* action to take depends on the mode */ - mode= RNA_enum_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); @@ -519,7 +519,7 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) columnselect_action_keys(&ac, mode); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -536,7 +536,7 @@ void ACTION_OT_select_column(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); @@ -544,11 +544,11 @@ void ACTION_OT_select_column(wmOperatorType *ot) /* ******************** Select Linked Operator *********************** */ -static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -560,11 +560,11 @@ static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { @@ -577,7 +577,7 @@ static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -594,38 +594,38 @@ void ACTION_OT_select_linked(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ -static void select_moreless_action_keys (bAnimContext *ac, short mode) +static void select_moreless_action_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc build_cb; /* init selmap building data */ - build_cb= ANIM_editkeyframes_buildselmap(mode); + build_cb = ANIM_editkeyframes_buildselmap(mode); /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; /* build up map of whether F-Curve's keyframes should be selected or not */ - ked.data= MEM_callocN(fcu->totvert, "selmap actEdit more"); + ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); /* based on this map, adjust the selection status of the keyframes */ @@ -633,7 +633,7 @@ static void select_moreless_action_keys (bAnimContext *ac, short mode) /* free the selmap used here */ MEM_freeN(ked.data); - ked.data= NULL; + ked.data = NULL; } /* Cleanup */ @@ -642,7 +642,7 @@ static void select_moreless_action_keys (bAnimContext *ac, short mode) /* ----------------- */ -static int actkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -654,7 +654,7 @@ static int actkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_action_keys(&ac, SELMAP_MORE); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -671,12 +671,12 @@ void ACTION_OT_select_more(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ----------------- */ -static int actkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -688,7 +688,7 @@ static int actkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_action_keys(&ac, SELMAP_LESS); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -705,7 +705,7 @@ void ACTION_OT_select_less(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select Left/Right Operator ************************* */ @@ -721,19 +721,19 @@ static EnumPropertyItem prop_actkeys_leftright_select_types[] = { /* --------------------------------- */ -static void actkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode) +static void actkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; - Scene *scene= ac->scene; + KeyframeEditData ked = {{NULL}}; + Scene *scene = ac->scene; /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -742,8 +742,8 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s } /* set callbacks and editing data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(select_mode); if (leftright == ACTKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; @@ -756,14 +756,14 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -777,16 +777,16 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s } /* Sync marker support */ - if (select_mode==SELECT_ADD) { - SpaceAction *saction= (SpaceAction *)ac->sl; + if (select_mode == SELECT_ADD) { + SpaceAction *saction = (SpaceAction *)ac->sl; if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) { ListBase *markers = ED_animcontext_get_markers(ac); TimeMarker *marker; - for (marker= markers->first; marker; marker= marker->next) { - if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || - ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) + for (marker = markers->first; marker; marker = marker->next) { + if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || + ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) { marker->flag |= SELECT; } @@ -803,7 +803,7 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s /* ----------------- */ -static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) +static int actkeys_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -815,9 +815,9 @@ static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == ACTKEYS_LRSEL_TEST) @@ -827,12 +827,12 @@ static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) actkeys_select_leftright(&ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -843,9 +843,9 @@ static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* handle mode-based testing */ if (leftright == ACTKEYS_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -873,7 +873,7 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", ""); @@ -891,20 +891,20 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) */ /* sensitivity factor for frame-selections */ -#define FRAME_CLICK_THRESH 0.1f +#define FRAME_CLICK_THRESH 0.1f /* ------------------- */ /* option 1) select keyframe directly under mouse */ -static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) +static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) { - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc select_cb, ok_cb; /* get functions for selecting keyframes */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); - ked.f1= selx; + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); + ked.f1 = selx; /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) @@ -919,34 +919,34 @@ static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short /* Option 3) Selects all visible keyframes in the same frame as the mouse click */ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float selx) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc select_cb, ok_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else - ked.f1= selx; + ked.f1 = selx; /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) @@ -962,14 +962,14 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se /* ------------------- */ -static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select_mode, short column) +static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, short column) { ListBase anim_data = {NULL, NULL}; DLRBT_Tree anim_keys; bAnimListElem *ale; int filter; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; bDopeSheet *ads = NULL; int channel_index; short found = 0; @@ -979,22 +979,22 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select /* get dopesheet info */ if (ac->datatype == ANIMCONT_DOPESHEET) - ads= ac->data; + ads = ac->data; /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click (size of keyframe icon) */ - UI_view2d_region_to_view(v2d, mval[0]-7, mval[1], &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, mval[0] - 7, mval[1], &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, mval[0] + 7, mval[1], &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* try to get channel */ - ale= BLI_findlink(&anim_data, channel_index); + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n", channel_index); @@ -1003,8 +1003,8 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } else { /* found match - must return here... */ - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - ActKeyColumn *ak, *akn=NULL; + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + ActKeyColumn *ak, *akn = NULL; /* make list of keyframes */ BLI_dlrbTree_init(&anim_keys); @@ -1013,28 +1013,28 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select switch (ale->datatype) { case ALE_SCE: { - Scene *scene= (Scene *)ale->key_data; + Scene *scene = (Scene *)ale->key_data; scene_to_keylist(ads, scene, &anim_keys, NULL); } - break; + break; case ALE_OB: { - Object *ob= (Object *)ale->key_data; + Object *ob = (Object *)ale->key_data; ob_to_keylist(ads, ob, &anim_keys, NULL); } - break; + break; case ALE_ACT: { - bAction *act= (bAction *)ale->key_data; + bAction *act = (bAction *)ale->key_data; action_to_keylist(adt, act, &anim_keys, NULL); } - break; + break; case ALE_FCURVE: { - FCurve *fcu= (FCurve *)ale->key_data; + FCurve *fcu = (FCurve *)ale->key_data; fcurve_to_keylist(adt, fcu, &anim_keys, NULL); } - break; + break; } } else if (ale->type == ANIMTYPE_SUMMARY) { @@ -1043,7 +1043,7 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } else if (ale->type == ANIMTYPE_GROUP) { // TODO: why don't we just give groups key_data too? - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; agroup_to_keylist(adt, agrp, &anim_keys, NULL); } else if (ale->type == ANIMTYPE_GPLAYER) { @@ -1053,20 +1053,20 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } /* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */ - for (ak= anim_keys.root; ak; ak= akn) { + for (ak = anim_keys.root; ak; ak = akn) { if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) { /* set the frame to use, and apply inverse-correction for NLA-mapping * so that the frame will get selected by the selection functions without * requiring to map each frame once again... */ - selx= BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP); - found= 1; + selx = BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP); + found = 1; break; } else if (ak->cfra < rectf.xmin) - akn= ak->right; + akn = ak->right; else - akn= ak->left; + akn = ak->left; } /* remove active channel from list of channels for separate treatment (since it's needed later on) */ @@ -1095,13 +1095,13 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select /* Highlight Action-Group or F-Curve? */ if (ale && ale->data) { if (ale->type == ANIMTYPE_GROUP) { - bActionGroup *agrp= ale->data; + bActionGroup *agrp = ale->data; agrp->flag |= AGRP_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); } else if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= ale->data; + FCurve *fcu = ale->data; fcu->flag |= FCURVE_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); @@ -1157,21 +1157,21 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* column selection */ - column= RNA_boolean_get(op->ptr, "column"); + column = RNA_boolean_get(op->ptr, "column"); /* select keyframe(s) based upon mouse position*/ mouse_action_keys(&ac, event->mval, selectmode, column); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void ACTION_OT_clickselect(wmOperatorType *ot) @@ -1186,7 +1186,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index c1875eb3a9a..ae4020aaaba 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -60,67 +60,67 @@ #include "ED_anim_api.h" #include "ED_markers.h" -#include "action_intern.h" // own include +#include "action_intern.h" /* own include */ /* ******************** default callbacks for action space ***************** */ static SpaceLink *action_new(const bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); SpaceAction *saction; ARegion *ar; - saction= MEM_callocN(sizeof(SpaceAction), "initaction"); - saction->spacetype= SPACE_ACTION; + saction = MEM_callocN(sizeof(SpaceAction), "initaction"); + saction->spacetype = SPACE_ACTION; saction->autosnap = SACTSNAP_FRAME; - saction->mode= SACTCONT_DOPESHEET; + saction->mode = SACTCONT_DOPESHEET; saction->ads.filterflag |= ADS_FILTER_SUMMARY; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for action"); + ar = MEM_callocN(sizeof(ARegion), "header for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel area for action"); + ar = MEM_callocN(sizeof(ARegion), "channel area for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - /* only need to set scroll settings, as this will use 'listview' v2d configuration */ + /* only need to set scroll settings, as this will use 'listview' v2d configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for action"); + ar = MEM_callocN(sizeof(ARegion), "main area for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = -10.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(sa->winx); ar->v2d.tot.ymax = 0.0f; ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.keepofs= V2D_KEEPOFS_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; return (SpaceLink *)saction; @@ -143,7 +143,7 @@ static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *action_duplicate(SpaceLink *sl) { - SpaceAction *sactionn= MEM_dupallocN(sl); + SpaceAction *sactionn = MEM_dupallocN(sl); /* clear or remove stuff from old */ @@ -167,12 +167,12 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) static void action_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceAction *saction= CTX_wm_space_action(C); + SpaceAction *saction = CTX_wm_space_action(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - short unit=0, flag=0; + short unit = 0, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -181,8 +181,8 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit= (saction->flag & SACTION_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -192,14 +192,14 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) } /* current frame */ - if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((saction->flag & SACTION_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - flag = (ac.markers && (ac.markers != &ac.scene->markers))? DRAW_MARKERS_LOCAL : 0; + flag = (ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0; draw_markers_time(C, flag); /* preview range */ @@ -210,7 +210,7 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -231,7 +231,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear and setup matrix */ @@ -249,7 +249,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -299,7 +299,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -346,7 +346,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -354,7 +354,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) /* editor level listener */ static void action_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceAction *saction= (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -379,7 +379,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_SCENE: switch (wmn->data) { - case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -392,7 +392,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_OBJECT: switch (wmn->data) { - case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_BONE_ACTIVE: saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -446,7 +446,7 @@ static void action_header_area_listener(ARegion *ar, wmNotifier *wmn) static void action_refresh(const bContext *C, ScrArea *sa) { - SpaceAction *saction= (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled @@ -464,52 +464,52 @@ static void action_refresh(const bContext *C, ScrArea *sa) /* only called once, from space/spacetypes.c */ void ED_spacetype_action(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype action"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action"); ARegionType *art; - st->spaceid= SPACE_ACTION; + st->spaceid = SPACE_ACTION; strncpy(st->name, "Action", BKE_ST_MAXNAME); - st->new= action_new; - st->free= action_free; - st->init= action_init; - st->duplicate= action_duplicate; - st->operatortypes= action_operatortypes; - st->keymap= action_keymap; - st->listener= action_listener; - st->refresh= action_refresh; + st->new = action_new; + st->free = action_free; + st->init = action_init; + st->duplicate = action_duplicate; + st->operatortypes = action_operatortypes; + st->keymap = action_keymap; + st->listener = action_listener; + st->refresh = action_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_WINDOW; - art->init= action_main_area_init; - art->draw= action_main_area_draw; - art->listener= action_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->init = action_main_area_init; + art->draw = action_main_area_draw; + art->listener = action_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= action_header_area_init; - art->draw= action_header_area_draw; - art->listener= action_header_area_listener; + art->init = action_header_area_init; + art->draw = action_header_area_draw; + art->listener = action_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= action_channel_area_init; - art->draw= action_channel_area_draw; - art->listener= action_channel_area_listener; + art->init = action_channel_area_init; + art->draw = action_channel_area_draw; + art->listener = action_channel_area_listener; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 20d5257a62f..d1c2c1e092f 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -63,15 +63,15 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" // own include static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) { PointerRNA *ptr; int a; - for (a=0; a<path->len; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (RNA_struct_is_a(ptr->type, type)) { CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); @@ -87,8 +87,8 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) PointerRNA *ptr; int a; - for (a=0; a<path->len; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (RNA_struct_is_a(ptr->type, type)) return ptr; @@ -101,7 +101,7 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) static int buttons_context_path_scene(ButsContextPath *path) { - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* this one just verifies */ return RNA_struct_is_a(ptr->type, &RNA_Scene); @@ -113,7 +113,7 @@ static int buttons_context_path_world(ButsContextPath *path) { Scene *scene; World *world; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) world, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_World)) { @@ -121,8 +121,8 @@ static int buttons_context_path_world(ButsContextPath *path) } /* if we have a scene, use the scene's world */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; - world= scene->world; + scene = path->ptr[path->len - 1].data; + world = scene->world; if (world) { RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); @@ -143,7 +143,7 @@ static int buttons_context_path_object(ButsContextPath *path) { Scene *scene; Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) object, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Object)) { @@ -151,8 +151,8 @@ static int buttons_context_path_object(ButsContextPath *path) } /* if we have a scene, use the scene's active object */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; - ob= (scene->basact)? scene->basact->object: NULL; + scene = path->ptr[path->len - 1].data; + ob = (scene->basact) ? scene->basact->object : NULL; if (ob) { RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); @@ -169,7 +169,7 @@ static int buttons_context_path_object(ButsContextPath *path) static int buttons_context_path_data(ButsContextPath *path, int type) { Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1; @@ -182,7 +182,7 @@ static int buttons_context_path_data(ButsContextPath *path, int type) else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; /* try to get an object in the path, no pinning supported here */ else if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && (type == -1 || type == ob->type)) { RNA_id_pointer_create(ob->data, &path->ptr[path->len]); @@ -201,7 +201,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) Object *ob; if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) return 1; @@ -213,7 +213,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) static int buttons_context_path_material(ButsContextPath *path, int for_texture) { Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; Material *ma; /* if we already have a (pinned) material, we're done */ @@ -222,17 +222,17 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture) } /* if we have an object, use the object material slot */ else if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; if (for_texture && give_current_material_texture_node(ma)) return 1; - ma= give_node_material(ma); + ma = give_node_material(ma); if (ma) { RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; @@ -252,11 +252,11 @@ static int buttons_context_path_bone(ButsContextPath *path) /* if we have an armature, get the active bone */ if (buttons_context_path_data(path, OB_ARMATURE)) { - arm= path->ptr[path->len-1].data; + arm = path->ptr[path->len - 1].data; if (arm->edbo) { if (arm->act_edbone) { - edbo= arm->act_edbone; + edbo = arm->act_edbone; RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); path->len++; return 1; @@ -277,7 +277,7 @@ static int buttons_context_path_bone(ButsContextPath *path) static int buttons_context_path_pose_bone(ButsContextPath *path) { - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) PoseBone, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { @@ -286,15 +286,15 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) /* if we have an armature, get the active bone */ if (buttons_context_path_object(path)) { - Object *ob= path->ptr[path->len-1].data; - bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */ + Object *ob = path->ptr[path->len - 1].data; + bArmature *arm = ob->data; /* path->ptr[path->len-1].data - works too */ if (ob->type != OB_ARMATURE || arm->edbo) { return 0; } else { if (arm->act_bone) { - bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, arm->act_bone->name); if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; @@ -313,7 +313,7 @@ static int buttons_context_path_particle(ButsContextPath *path) { Object *ob; ParticleSystem *psys; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have (pinned) particle settings, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { @@ -321,10 +321,10 @@ static int buttons_context_path_particle(ButsContextPath *path) } /* if we have an object, get the active particle system */ if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && ob->type == OB_MESH) { - psys= psys_get_current(ob); + psys = psys_get_current(ob); RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); path->len++; @@ -339,8 +339,8 @@ static int buttons_context_path_particle(ButsContextPath *path) static int buttons_context_path_brush(ButsContextPath *path) { Scene *scene; - Brush *br= NULL; - PointerRNA *ptr= &path->ptr[path->len-1]; + Brush *br = NULL; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) brush, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { @@ -348,10 +348,10 @@ static int buttons_context_path_brush(ButsContextPath *path) } /* if we have a scene, use the toolsettings brushes */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; + scene = path->ptr[path->len - 1].data; if (scene) - br= paint_brush(paint_get_active(scene)); + br = paint_brush(paint_get_active(scene)); if (br) { RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); @@ -369,7 +369,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur { if (ct) { /* new shading system */ - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; ID *id; /* if we already have a (pinned) texture, we're done */ @@ -379,7 +379,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur if (!ct->user) return 0; - id= ct->user->id; + id = ct->user->id; if (id) { if (GS(id->name) == ID_BR) @@ -411,7 +411,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur World *wo; ParticleSystem *psys; Tex *tex; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; int orig_len = path->len; /* if we already have a (pinned) texture, we're done */ @@ -420,10 +420,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try brush */ if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { - br= path->ptr[path->len-1].data; + br = path->ptr[path->len - 1].data; if (br) { - tex= give_current_brush_texture(br); + tex = give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -432,10 +432,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try world */ if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { - wo= path->ptr[path->len-1].data; + wo = path->ptr[path->len - 1].data; - if (wo && GS(wo->id.name)==ID_WO) { - tex= give_current_world_texture(wo); + if (wo && GS(wo->id.name) == ID_WO) { + tex = give_current_world_texture(wo); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -444,19 +444,19 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try particles */ if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { - if (path->ptr[path->len-1].type == &RNA_ParticleSettings) { - ParticleSettings *part = path->ptr[path->len-1].data; + if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) { + ParticleSettings *part = path->ptr[path->len - 1].data; - tex= give_current_particle_texture(part); + tex = give_current_particle_texture(part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; return 1; } else { - psys= path->ptr[path->len-1].data; + psys = path->ptr[path->len - 1].data; - if (psys && psys->part && GS(psys->part->id.name)==ID_PA) { - tex= give_current_particle_texture(psys->part); + if (psys && psys->part && GS(psys->part->id.name) == ID_PA) { + tex = give_current_particle_texture(psys->part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -466,10 +466,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try material */ if (buttons_context_path_material(path, 1)) { - ma= path->ptr[path->len-1].data; + ma = path->ptr[path->len - 1].data; if (ma) { - tex= give_current_material_texture(ma); + tex = give_current_material_texture(ma); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -478,10 +478,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try lamp */ if (buttons_context_path_data(path, OB_LAMP)) { - la= path->ptr[path->len-1].data; + la = path->ptr[path->len - 1].data; if (la) { - tex= give_current_lamp_texture(la); + tex = give_current_lamp_texture(la); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -491,10 +491,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur /* try brushes again in case of no material, lamp, etc */ path->len = orig_len; if (buttons_context_path_brush(path)) { - br= path->ptr[path->len-1].data; + br = path->ptr[path->len - 1].data; if (br) { - tex= give_current_brush_texture(br); + tex = give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -510,17 +510,17 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); ID *id; int found; memset(path, 0, sizeof(*path)); - path->flag= flag; + path->flag = flag; path->tex_ctx = sbuts->texture_context; /* if some ID datablock is pinned, set the root pointer */ if (sbuts->pinid) { - id= sbuts->pinid; + id = sbuts->pinid; RNA_id_pointer_create(id, &path->ptr[0]); path->len++; @@ -528,7 +528,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma /* no pinned root, use scene as root */ if (path->len == 0) { - id= (ID*)CTX_data_scene(C); + id = (ID *)CTX_data_scene(C); RNA_id_pointer_create(id, &path->ptr[0]); path->len++; } @@ -538,41 +538,41 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma switch (mainb) { case BCONTEXT_SCENE: case BCONTEXT_RENDER: - found= buttons_context_path_scene(path); + found = buttons_context_path_scene(path); break; case BCONTEXT_WORLD: - found= buttons_context_path_world(path); + found = buttons_context_path_world(path); break; case BCONTEXT_OBJECT: case BCONTEXT_PHYSICS: case BCONTEXT_CONSTRAINT: - found= buttons_context_path_object(path); + found = buttons_context_path_object(path); break; case BCONTEXT_MODIFIER: - found= buttons_context_path_modifier(path); + found = buttons_context_path_modifier(path); break; case BCONTEXT_DATA: - found= buttons_context_path_data(path, -1); + found = buttons_context_path_data(path, -1); break; case BCONTEXT_PARTICLE: - found= buttons_context_path_particle(path); + found = buttons_context_path_particle(path); break; case BCONTEXT_MATERIAL: - found= buttons_context_path_material(path, 0); + found = buttons_context_path_material(path, 0); break; case BCONTEXT_TEXTURE: - found= buttons_context_path_texture(path, sbuts->texuser); + found = buttons_context_path_texture(path, sbuts->texuser); break; case BCONTEXT_BONE: - found= buttons_context_path_bone(path); + found = buttons_context_path_bone(path); if (!found) - found= buttons_context_path_data(path, OB_ARMATURE); + found = buttons_context_path_data(path, OB_ARMATURE); break; case BCONTEXT_BONE_CONSTRAINT: - found= buttons_context_path_pose_bone(path); + found = buttons_context_path_pose_bone(path); break; default: - found= 0; + found = 0; break; } @@ -581,7 +581,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma static int buttons_shading_context(const bContext *C, int mainb) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) return 1; @@ -593,7 +593,7 @@ static int buttons_shading_context(const bContext *C, int mainb) static int buttons_shading_new_context(const bContext *C, int flag) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (flag & (1 << BCONTEXT_MATERIAL)) return BCONTEXT_MATERIAL; @@ -609,29 +609,29 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) { ButsContextPath *path; PointerRNA *ptr; - int a, pflag= 0, flag= 0; + int a, pflag = 0, flag = 0; buttons_texture_context_compute(C, sbuts); if (!sbuts->path) - sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); + sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); - path= sbuts->path; + path = sbuts->path; /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ - for (a=0; a<BCONTEXT_TOT; a++) { + for (a = 0; a < BCONTEXT_TOT; a++) { if (buttons_context_path(C, path, a, pflag)) { - flag |= (1<<a); + flag |= (1 << a); /* setting icon for data context */ if (a == BCONTEXT_DATA) { - ptr= &path->ptr[path->len-1]; + ptr = &path->ptr[path->len - 1]; if (ptr->type) - sbuts->dataicon= RNA_struct_ui_icon(ptr->type); + sbuts->dataicon = RNA_struct_ui_icon(ptr->type); else - sbuts->dataicon= ICON_EMPTY_DATA; + sbuts->dataicon = ICON_EMPTY_DATA; } } } @@ -639,21 +639,21 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) /* always try to use the tab that was explicitly * set to the user, so that once that context comes * back, the tab is activated again */ - sbuts->mainb= sbuts->mainbuser; + sbuts->mainb = sbuts->mainbuser; /* in case something becomes invalid, change */ if ((flag & (1 << sbuts->mainb)) == 0) { if (sbuts->flag & SB_SHADING_CONTEXT) { /* try to keep showing shading related buttons */ - sbuts->mainb= buttons_shading_new_context(C, flag); + sbuts->mainb = buttons_shading_new_context(C, flag); } else if (flag & BCONTEXT_OBJECT) { - sbuts->mainb= BCONTEXT_OBJECT; + sbuts->mainb = BCONTEXT_OBJECT; } else { - for (a=0; a<BCONTEXT_TOT; a++) { + for (a = 0; a < BCONTEXT_TOT; a++) { if (flag & (1 << a)) { - sbuts->mainb= a; + sbuts->mainb = a; break; } } @@ -664,9 +664,9 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) if (!(flag & (1 << sbuts->mainb))) { if (flag & (1 << BCONTEXT_OBJECT)) - sbuts->mainb= BCONTEXT_OBJECT; + sbuts->mainb = BCONTEXT_OBJECT; else - sbuts->mainb= BCONTEXT_SCENE; + sbuts->mainb = BCONTEXT_SCENE; } if (buttons_shading_context(C, sbuts->mainb)) @@ -674,7 +674,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) else sbuts->flag &= ~SB_SHADING_CONTEXT; - sbuts->pathflag= flag; + sbuts->pathflag = flag; } /************************* Context Callback ************************/ @@ -684,12 +684,13 @@ const char *buttons_context_dir[] = { "meta_ball", "lamp", "speaker", "camera", "material", "material_slot", "texture", "texture_slot", "texture_user", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", - "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL}; + "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL +}; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts?sbuts->path:NULL; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts ? sbuts->path : NULL; if (!path) return 0; @@ -744,7 +745,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "texture")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (ct) { /* new shading system */ @@ -758,15 +759,15 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "material_slot")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr) { - Object *ob= ptr->data; + Object *ob = ptr->data; if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { /* a valid actcol isn't ensured [#27526] */ - int matnr= ob->actcol-1; - if (matnr < 0) matnr= 0; + int matnr = ob->actcol - 1; + if (matnr < 0) matnr = 0; CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]); } } @@ -774,20 +775,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "texture_user")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (!ct) - return -1; /* old shading system (found but not available) */ + return -1; /* old shading system (found but not available) */ if (ct->user && ct->user->ptr.data) { - ButsTextureUser *user= ct->user; + ButsTextureUser *user = ct->user; CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data); } return 1; } else if (CTX_data_equals(member, "texture_node")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (ct) { /* new shading system */ @@ -800,11 +801,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r /* old shading system */ PointerRNA *ptr; - if ((ptr=get_pointer_type(path, &RNA_Material))) { - Material *ma= ptr->data; + if ((ptr = get_pointer_type(path, &RNA_Material))) { + Material *ma = ptr->data; if (ma) { - bNode *node= give_current_material_texture_node(ma); + bNode *node = give_current_material_texture_node(ma); CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } } @@ -813,14 +814,14 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r } } else if (CTX_data_equals(member, "texture_slot")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; PointerRNA *ptr; if (ct) - return 0; /* new shading system */ + return 0; /* new shading system */ - if ((ptr=get_pointer_type(path, &RNA_Material))) { - Material *ma= ptr->data; + if ((ptr = get_pointer_type(path, &RNA_Material))) { + Material *ma = ptr->data; /* if we have a node material, get slot from material in material node */ if (ma && ma->use_nodes && ma->nodetree) { @@ -829,7 +830,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if (give_current_material_texture_node(ma)) return 0; - ma= give_node_material(ma); + ma = give_node_material(ma); if (ma) CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); else @@ -839,26 +840,26 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); } } - else if ((ptr=get_pointer_type(path, &RNA_Lamp))) { - Lamp *la= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_Lamp))) { + Lamp *la = ptr->data; if (la) CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]); } - else if ((ptr=get_pointer_type(path, &RNA_World))) { - World *wo= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_World))) { + World *wo = ptr->data; if (wo) CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); } - else if ((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ - Brush *br= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ + Brush *br = ptr->data; if (br) CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex); } - else if ((ptr=get_pointer_type(path, &RNA_ParticleSystem))) { - ParticleSettings *part= ((ParticleSystem *)ptr->data)->part; + else if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) { + ParticleSettings *part = ((ParticleSystem *)ptr->data)->part; if (part) CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]); @@ -883,59 +884,59 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "particle_system_editable")) { - if (PE_poll((bContext*)C)) + if (PE_poll((bContext *)C)) set_pointer_type(path, result, &RNA_ParticleSystem); else CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); return 1; } else if (CTX_data_equals(member, "cloth")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth); CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); return 1; } } else if (CTX_data_equals(member, "soft_body")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody); CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md); return 1; } } else if (CTX_data_equals(member, "fluid")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Fluidsim); CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); return 1; } } else if (CTX_data_equals(member, "smoke")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Smoke); CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); return 1; } } else if (CTX_data_equals(member, "collision")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Collision); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Collision); CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md); return 1; } @@ -945,11 +946,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "dynamic_paint")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_DynamicPaint); CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); return 1; } @@ -965,21 +966,21 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); if (sbuts->flag & SB_PIN_CONTEXT) { - sbuts->pinid= buttons_context_id_path(C); + sbuts->pinid = buttons_context_id_path(C); } else - sbuts->pinid= NULL; + sbuts->pinid = NULL; ED_area_tag_redraw(CTX_wm_area(C)); } void buttons_context_draw(const bContext *C, uiLayout *layout) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts->path; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts->path; uiLayout *row; uiBlock *block; uiBut *but; @@ -990,28 +991,28 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (!path) return; - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutGetBlock(row); + block = uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); but = uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed"); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); - for (a=0; a<path->len; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (a != 0) uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); if (ptr->data) { - icon= RNA_struct_ui_icon(ptr->type); - name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); + icon = RNA_struct_ui_icon(ptr->type); + name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if (name) { if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) - uiItemLDrag(row, ptr, "", icon); /* save some space */ + uiItemLDrag(row, ptr, "", icon); /* save some space */ else uiItemLDrag(row, ptr, name, icon); @@ -1033,24 +1034,24 @@ void buttons_context_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); + pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); strcpy(pt->idname, "BUTTONS_PT_context"); strcpy(pt->label, "Context"); - pt->draw= buttons_panel_context; - pt->flag= PNL_NO_HEADER; + pt->draw = buttons_panel_context; + pt->flag = PNL_NO_HEADER; BLI_addtail(&art->paneltypes, pt); } ID *buttons_context_id_path(const bContext *C) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts->path; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts->path; PointerRNA *ptr; int a; if (path->len) { - for (a=path->len-1; a>=0; a--) { - ptr= &path->ptr[a]; + for (a = path->len - 1; a >= 0; a--) { + ptr = &path->ptr[a]; /* pin particle settings instead of system, since only settings are an idblock*/ if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 2385bfd75b7..661f7ad7d0f 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -51,8 +51,8 @@ #include "buttons_intern.h" -#define B_CONTEXT_SWITCH 101 -#define B_BUTSPREVIEW 102 +#define B_CONTEXT_SWITCH 101 +#define B_BUTSPREVIEW 102 static void set_texture_context(bContext *C, SpaceButs *sbuts) { @@ -63,7 +63,7 @@ static void set_texture_context(bContext *C, SpaceButs *sbuts) case BCONTEXT_DATA: { Object *ob = CTX_data_active_object(C); - if (ob && ob->type==OB_LAMP) + if (ob && ob->type == OB_LAMP) sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; break; } @@ -78,7 +78,7 @@ static void set_texture_context(bContext *C, SpaceButs *sbuts) static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); if (!sbuts) /* editor type switch */ return; @@ -90,28 +90,28 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) set_texture_context(C, sbuts); - sbuts->preview= 1; + sbuts->preview = 1; break; } - sbuts->mainbuser= sbuts->mainb; + sbuts->mainbuser = sbuts->mainb; } -#define BUT_UNIT_X (UI_UNIT_X+2) +#define BUT_UNIT_X (UI_UNIT_X + 2) void buttons_header_buttons(const bContext *C, ARegion *ar) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); uiBlock *block; uiBut *but; - int xco, yco= 2; + int xco, yco = 2; buttons_context_compute(C, sbuts); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); - xco= ED_area_header_switchbutton(C, block, yco); + xco = ED_area_header_switchbutton(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSS); @@ -122,8 +122,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockBeginAlign(block); #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ - if (sbuts->pathflag & (1<<_ctx)) { \ - but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ + if (sbuts->pathflag & (1 << _ctx)) { \ + but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ uiButClearFlag(but, UI_BUT_UNDO); \ } \ @@ -143,12 +143,12 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) #undef BUTTON_HEADER_CTX - xco+= BUT_UNIT_X; + xco += BUT_UNIT_X; 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), ar->v2d.tot.ymax - ar->v2d.tot.ymin); uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 8d0f84cf70f..5700d361e15 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -47,17 +47,17 @@ struct uiLayout; struct wmOperatorType; /* buts->scaflag */ -#define BUTS_SENS_SEL 1 -#define BUTS_SENS_ACT 2 -#define BUTS_SENS_LINK 4 -#define BUTS_CONT_SEL 8 -#define BUTS_CONT_ACT 16 -#define BUTS_CONT_LINK 32 -#define BUTS_ACT_SEL 64 -#define BUTS_ACT_ACT 128 -#define BUTS_ACT_LINK 256 -#define BUTS_SENS_STATE 512 -#define BUTS_ACT_STATE 1024 +#define BUTS_SENS_SEL 1 +#define BUTS_SENS_ACT 2 +#define BUTS_SENS_LINK 4 +#define BUTS_CONT_SEL 8 +#define BUTS_CONT_ACT 16 +#define BUTS_CONT_LINK 32 +#define BUTS_ACT_SEL 64 +#define BUTS_ACT_ACT 128 +#define BUTS_ACT_LINK 256 +#define BUTS_SENS_STATE 512 +#define BUTS_ACT_STATE 1024 /* context data */ diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index ec1c74013e0..c29a8c3934e 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -56,22 +56,22 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" /* own include */ /********************** toolbox operator *********************/ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - bScreen *sc= CTX_wm_screen(C); - SpaceButs *sbuts= CTX_wm_space_buts(C); + bScreen *sc = CTX_wm_screen(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); PointerRNA ptr; uiPopupMenu *pup; uiLayout *layout; RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - pup= uiPupMenuBegin(C, "Align", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Align", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumR(layout, &ptr, "align"); uiPupMenuEnd(C, pup); @@ -99,15 +99,15 @@ typedef struct FileBrowseOp { static int file_browse_exec(bContext *C, wmOperator *op) { - FileBrowseOp *fbo= op->customdata; + FileBrowseOp *fbo = op->customdata; ID *id; char *str, path[FILE_MAX]; - const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; + const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_struct_property_is_set(op->ptr, path_prop)==0 || fbo==NULL) + if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) return OPERATOR_CANCELLED; - str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); + str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { @@ -119,7 +119,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); if (BLI_is_dir(path)) { - str = MEM_reallocN(str, strlen(str)+2); + str = MEM_reallocN(str, strlen(str) + 2); BLI_add_slash(str); } else @@ -133,7 +133,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) /* special, annoying exception, filesel on redo panel [#26618] */ { - wmOperator *redo_op= WM_operator_last_redo(C); + wmOperator *redo_op = WM_operator_last_redo(C); if (redo_op) { if (fbo->ptr.data == redo_op->ptr->data) { ED_undo_operator_repeat(C, redo_op); @@ -149,7 +149,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) static int file_browse_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } @@ -171,7 +171,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) if (!prop) return OPERATOR_CANCELLED; - str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); + str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); /* useful yet irritating feature, Shift+Click to open the file * Alt+Click to browse a folder in the OS's browser */ @@ -179,9 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) PointerRNA props_ptr; if (event->alt) { - char *lslash= BLI_last_slash(str); + char *lslash = BLI_last_slash(str); if (lslash) - *lslash= '\0'; + *lslash = '\0'; } @@ -194,11 +194,11 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else { - const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); - fbo->ptr= ptr; - fbo->prop= prop; - op->customdata= fbo; + const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; + fbo = MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); + fbo->ptr = ptr; + fbo->prop = prop; + op->customdata = fbo; RNA_string_set(op->ptr, path_prop, str); MEM_freeN(str); @@ -230,7 +230,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->cancel = file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ @@ -247,5 +247,5 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) ot->cancel = file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index ba37cb8a892..5c5c24f7bc1 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -68,17 +68,17 @@ #include "../interface/interface_intern.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" // own include /************************* Texture User **************************/ static void buttons_texture_user_property_add(ListBase *users, ID *id, - PointerRNA ptr, PropertyRNA *prop, - const char *category, int icon, const char *name) + PointerRNA ptr, PropertyRNA *prop, + const char *category, int icon, const char *name) { ButsTextureUser *user = MEM_callocN(sizeof(ButsTextureUser), "ButsTextureUser"); - user->id= id; + user->id = id; user->ptr = ptr; user->prop = prop; user->category = category; @@ -90,12 +90,12 @@ static void buttons_texture_user_property_add(ListBase *users, ID *id, } static void buttons_texture_user_node_add(ListBase *users, ID *id, - bNodeTree *ntree, bNode *node, - const char *category, int icon, const char *name) + bNodeTree *ntree, bNode *node, + const char *category, int icon, const char *name) { ButsTextureUser *user = MEM_callocN(sizeof(ButsTextureUser), "ButsTextureUser"); - user->id= id; + user->id = id; user->ntree = ntree; user->node = node; user->category = category; @@ -107,12 +107,12 @@ static void buttons_texture_user_node_add(ListBase *users, ID *id, } static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, - bNodeTree *ntree, const char *category) + bNodeTree *ntree, const char *category) { bNode *node; if (ntree) { - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ @@ -121,10 +121,10 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, /* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */ buttons_texture_user_node_add(users, id, ntree, node, - category, RNA_struct_ui_icon(ptr.type), node->name); + category, RNA_struct_ui_icon(ptr.type), node->name); } else if (node->type == NODE_GROUP && node->id) { - buttons_texture_users_find_nodetree(users, id, (bNodeTree*)node->id, category); + buttons_texture_users_find_nodetree(users, id, (bNodeTree *)node->id, category); } } } @@ -140,48 +140,48 @@ static void buttons_texture_modifier_foreach(void *userData, Object *ob, Modifie prop = RNA_struct_find_property(&ptr, propname); buttons_texture_user_property_add(users, &ob->id, ptr, prop, - "Modifiers", RNA_struct_ui_icon(ptr.type), md->name); + "Modifiers", RNA_struct_ui_icon(ptr.type), md->name); } static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceButs *sbuts) { - Scene *scene= NULL; - Object *ob= NULL; - Material *ma= NULL; - Lamp *la= NULL; - World *wrld= NULL; - Brush *brush= NULL; + Scene *scene = NULL; + Object *ob = NULL; + Material *ma = NULL; + Lamp *la = NULL; + World *wrld = NULL; + Brush *brush = NULL; ID *pinid = sbuts->pinid; /* get data from context */ if (pinid) { if (GS(pinid->name) == ID_SCE) - scene= (Scene*)pinid; + scene = (Scene *)pinid; else if (GS(pinid->name) == ID_OB) - ob= (Object*)pinid; + ob = (Object *)pinid; else if (GS(pinid->name) == ID_LA) - la= (Lamp*)pinid; + la = (Lamp *)pinid; else if (GS(pinid->name) == ID_WO) - wrld= (World*)pinid; + wrld = (World *)pinid; else if (GS(pinid->name) == ID_MA) - ma= (Material*)pinid; + ma = (Material *)pinid; else if (GS(pinid->name) == ID_BR) - brush= (Brush*)pinid; + brush = (Brush *)pinid; } if (!scene) - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if (!(pinid || pinid == &scene->id)) { - ob= (scene->basact)? scene->basact->object: NULL; - wrld= scene->world; - brush= paint_brush(paint_get_active(scene)); + ob = (scene->basact) ? scene->basact->object : NULL; + wrld = scene->world; + brush = paint_brush(paint_get_active(scene)); } if (ob && ob->type == OB_LAMP && !la) - la= ob->data; + la = ob->data; if (ob && !ma) - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); /* fill users */ users->first = users->last = NULL; @@ -194,7 +194,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World"); if (ob) { - ParticleSystem *psys= psys_get_current(ob); + ParticleSystem *psys = psys_get_current(ob); MTex *mtex; int a; @@ -204,7 +204,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* particle systems */ if (psys) { /* todo: these slots are not in the UI */ - for (a=0; a<MAX_MTEX; a++) { + for (a = 0; a < MAX_MTEX; a++) { mtex = psys->part->mtex[a]; if (mtex) { @@ -215,7 +215,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &psys->part->id, ptr, prop, - "Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); + "Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); } } } @@ -229,7 +229,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &ob->id, ptr, prop, - "Fields", ICON_FORCE_TEXTURE, "Texture Field"); + "Fields", ICON_FORCE_TEXTURE, "Texture Field"); } } @@ -239,10 +239,10 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * PropertyRNA *prop; RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mtex, &ptr); - prop= RNA_struct_find_property(&ptr, "texture"); + prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &brush->id, ptr, prop, - "Brush", ICON_BRUSH_DATA, brush->id.name+2); + "Brush", ICON_BRUSH_DATA, brush->id.name + 2); } } @@ -250,22 +250,22 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) { /* gatheravailable texture users in context. runs on every draw of * properties editor, before the buttons are created. */ - ButsContextTexture *ct= sbuts->texuser; - Scene *scene= CTX_data_scene(C); + ButsContextTexture *ct = sbuts->texuser; + Scene *scene = CTX_data_scene(C); - if (!scene_use_new_shading_nodes(scene)) { + if (!BKE_scene_use_new_shading_nodes(scene)) { if (ct) { BLI_freelistN(&ct->users); MEM_freeN(ct); - sbuts->texuser= NULL; + sbuts->texuser = NULL; } return; } if (!ct) { - ct= MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); - sbuts->texuser= ct; + ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); + sbuts->texuser = ct; } else { BLI_freelistN(&ct->users); @@ -275,7 +275,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* set one user as active based on active index */ if (ct->index >= BLI_countlist(&ct->users)) - ct->index= 0; + ct->index = 0; ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; @@ -287,7 +287,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* get texture datablock pointer if it's a property */ texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop); - tex = (RNA_struct_is_a(texptr.type, &RNA_Texture))? texptr.data: NULL; + tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } @@ -296,7 +296,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* detect change of active texture node in same node tree, in that * case we also automatically switch to the other node */ - for (user=ct->users.first; user; user=user->next) { + for (user = ct->users.first; user; user = user->next) { if (user->ntree == ct->user->ntree && user->node != ct->user->node) { if (user->node->flag & NODE_ACTIVE_TEXTURE) { ct->user = user; @@ -313,8 +313,8 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) { /* callback when selecting a texture user in the menu */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; - ButsTextureUser *user = (ButsTextureUser*)user_p; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; + ButsTextureUser *user = (ButsTextureUser *)user_p; PointerRNA texptr; Tex *tex; @@ -328,7 +328,7 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) } else { texptr = RNA_property_pointer_get(&user->ptr, user->prop); - tex = (RNA_struct_is_a(texptr.type, &RNA_Texture))? texptr.data: NULL; + tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } @@ -341,27 +341,27 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS { /* callback when opening texture user selection menu, to create buttons. */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; uiBlock *block = uiLayoutGetBlock(layout); const char *last_category = NULL; - for (user=ct->users.first; user; user=user->next) { + for (user = ct->users.first; user; user = user->next) { uiBut *but; char name[UI_MAX_NAME_STR]; /* add label per category */ if (!last_category || strcmp(last_category, user->category) != 0) { uiItemL(layout, user->category, ICON_NONE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } /* create button */ BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); - but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, ""); + but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, ""); uiButSetNFunc(but, template_texture_select, MEM_dupallocN(user), NULL); last_category = user->category; @@ -374,7 +374,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) * gathered before drawing in ButsContextTexture, we merely need to * display the current item. */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; ButsTextureUser *user; @@ -384,7 +384,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) return; /* get current user */ - user= ct->user; + user = ct->user; if (!user) { uiItemL(layout, "No textures in context.", ICON_NONE); @@ -396,15 +396,15 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) if (user->icon) { but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL, - user->icon, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else { but = uiDefMenuBut(block, template_texture_user_menu, NULL, - name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } /* some cosmetic tweaks */ - but->type= MENU; + but->type = MENU; but->flag |= UI_TEXT_LEFT; but->flag &= ~UI_ICON_SUBMENU; } @@ -414,13 +414,13 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) static void template_texture_show(bContext *C, void *data_p, void *prop_p) { SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; if (!ct) return; - for (user=ct->users.first; user; user=user->next) + for (user = ct->users.first; user; user = user->next) if (user->ptr.data == data_p && user->prop == prop_p) break; @@ -429,9 +429,9 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p) template_texture_select(C, user, NULL); /* change context */ - sbuts->mainb= BCONTEXT_TEXTURE; - sbuts->mainbuser= sbuts->mainb; - sbuts->preview= 1; + sbuts->mainb = BCONTEXT_TEXTURE; + sbuts->mainbuser = sbuts->mainb; + sbuts->preview = 1; /* redraw editor */ ED_area_tag_redraw(CTX_wm_area(C)); @@ -442,7 +442,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope { /* button to quickly show texture in texture tab */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; /* only show button in other tabs in properties editor */ @@ -450,7 +450,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope return; /* find corresponding texture user */ - for (user=ct->users.first; user; user=user->next) + for (user = ct->users.first; user; user = user->next) if (user->ptr.data == ptr->data && user->prop == prop) break; @@ -460,7 +460,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope uiBut *but; but = uiDefIconBut(block, BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab"); + NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab"); uiButSetFunc(but, template_texture_show, user->ptr.data, user->prop); } } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 7e9ccdfb414..d1737fcd065 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -55,7 +55,7 @@ #include "ED_render.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" /* own include */ /* ******************** default callbacks for buttons space ***************** */ @@ -64,30 +64,30 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) ARegion *ar; SpaceButs *sbuts; - sbuts= MEM_callocN(sizeof(SpaceButs), "initbuts"); - sbuts->spacetype= SPACE_BUTS; - sbuts->align= BUT_VERTICAL; + sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts"); + sbuts->spacetype = SPACE_BUTS; + sbuts->align = BUT_VERTICAL; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for buts"); + ar = MEM_callocN(sizeof(ARegion), "header for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_TOP; #if 0 /* context area */ - ar= MEM_callocN(sizeof(ARegion), "context area for buts"); + ar = MEM_callocN(sizeof(ARegion), "context area for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_TOP; #endif /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for buts"); + ar = MEM_callocN(sizeof(ARegion), "main area for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; return (SpaceLink *)sbuts; } @@ -95,13 +95,13 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void buttons_free(SpaceLink *sl) { - SpaceButs *sbuts= (SpaceButs*) sl; + SpaceButs *sbuts = (SpaceButs *) sl; if (sbuts->path) MEM_freeN(sbuts->path); if (sbuts->texuser) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; BLI_freelistN(&ct->users); MEM_freeN(ct); } @@ -110,24 +110,24 @@ static void buttons_free(SpaceLink *sl) /* spacetype; init callback */ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* auto-align based on size */ if (sbuts->align == BUT_AUTO || !sbuts->align) { if (sa->winx > sa->winy) - sbuts->align= BUT_HORIZONTAL; + sbuts->align = BUT_HORIZONTAL; else - sbuts->align= BUT_VERTICAL; + sbuts->align = BUT_VERTICAL; } } static SpaceLink *buttons_duplicate(SpaceLink *sl) { - SpaceButs *sbutsn= MEM_dupallocN(sl); + SpaceButs *sbutsn = MEM_dupallocN(sl); /* clear or remove stuff from old */ - sbutsn->path= NULL; - sbutsn->texuser= NULL; + sbutsn->path = NULL; + sbutsn->texuser = NULL; return (SpaceLink *)sbutsn; } @@ -146,8 +146,8 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) static void buttons_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceButs *sbuts= CTX_wm_space_buts(C); - int vertical= (sbuts->align == BUT_VERTICAL); + SpaceButs *sbuts = CTX_wm_space_buts(C); + int vertical = (sbuts->align == BUT_VERTICAL); buttons_context_compute(C, sbuts); @@ -178,8 +178,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) ED_region_panels(C, ar, vertical, "bone_constraint", sbuts->mainb); - sbuts->re_align= 0; - sbuts->mainbo= sbuts->mainb; + sbuts->re_align = 0; + sbuts->mainbo = sbuts->mainb; } static void buttons_operatortypes(void) @@ -205,7 +205,7 @@ static void buttons_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) static void buttons_header_area_draw(const bContext *C, ARegion *ar) { /* clear */ - UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); + UI_ThemeClearColor(ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ @@ -221,7 +221,7 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar) * showing that button set, to reduce unnecessary drawing. */ static void buttons_area_redraw(ScrArea *sa, short buttons) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* if the area's current button set is equal to the one to redraw */ if (sbuts->mainb == buttons) @@ -231,7 +231,7 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) /* reused! */ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -243,11 +243,11 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_FRAME: /* any buttons area can have animated properties so redraw all */ ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_OB_ACTIVE: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_KEYINGSET: buttons_area_redraw(sa, BCONTEXT_SCENE); @@ -265,7 +265,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_TRANSFORM: buttons_area_redraw(sa, BCONTEXT_OBJECT); - buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ + buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: buttons_area_redraw(sa, BCONTEXT_DATA); @@ -280,7 +280,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); else buttons_area_redraw(sa, BCONTEXT_MODIFIER); - buttons_area_redraw(sa, BCONTEXT_PHYSICS); + buttons_area_redraw(sa, BCONTEXT_PHYSICS); break; case ND_CONSTRAINT: buttons_area_redraw(sa, BCONTEXT_CONSTRAINT); @@ -289,7 +289,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_PARTICLE: if (wmn->action == NA_EDITED) buttons_area_redraw(sa, BCONTEXT_PARTICLE); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_DRAW: buttons_area_redraw(sa, BCONTEXT_OBJECT); @@ -298,7 +298,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_SHADING: case ND_SHADING_DRAW: /* currently works by redraws... if preview is set, it (re)starts job */ - sbuts->preview= 1; + sbuts->preview = 1; break; default: /* Not all object RNA props have a ND_ notifier (yet) */ @@ -321,17 +321,17 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_SHADING_DRAW: case ND_NODES: /* currently works by redraws... if preview is set, it (re)starts job */ - sbuts->preview= 1; + sbuts->preview = 1; break; } break; case NC_WORLD: buttons_area_redraw(sa, BCONTEXT_WORLD); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_LAMP: buttons_area_redraw(sa, BCONTEXT_DATA); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_BRUSH: buttons_area_redraw(sa, BCONTEXT_TEXTURE); @@ -339,7 +339,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_TEXTURE: case NC_IMAGE: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_SPACE: if (wmn->data == ND_SPACE_PROPERTIES) @@ -358,17 +358,17 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_NODE: - if (wmn->action==NA_SELECTED) { + if (wmn->action == NA_SELECTED) { ED_area_tag_redraw(sa); /* new active node, update texture preview */ if (sbuts->mainb == BCONTEXT_TEXTURE) - sbuts->preview= 1; + sbuts->preview = 1; } break; /* Listener for preview render, when doing an global undo. */ case NC_WINDOW: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_LINESTYLE: ED_area_tag_redraw(sa); @@ -383,39 +383,39 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_buttons(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype buttons"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype buttons"); ARegionType *art; - st->spaceid= SPACE_BUTS; + st->spaceid = SPACE_BUTS; strncpy(st->name, "Buttons", BKE_ST_MAXNAME); - st->new= buttons_new; - st->free= buttons_free; - st->init= buttons_init; - st->duplicate= buttons_duplicate; - st->operatortypes= buttons_operatortypes; - st->keymap= buttons_keymap; - st->listener= buttons_area_listener; - st->context= buttons_context; + st->new = buttons_new; + st->free = buttons_free; + st->init = buttons_init; + st->duplicate = buttons_duplicate; + st->operatortypes = buttons_operatortypes; + st->keymap = buttons_keymap; + st->listener = buttons_area_listener; + st->context = buttons_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); art->regionid = RGN_TYPE_WINDOW; - art->init= buttons_main_area_init; - art->draw= buttons_main_area_draw; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->init = buttons_main_area_init; + art->draw = buttons_main_area_draw; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); buttons_context_register(art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= buttons_header_area_init; - art->draw= buttons_header_area_draw; + art->init = buttons_header_area_init; + art->draw = buttons_header_area_draw; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 5761a285d72..18f191a46a6 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -165,9 +165,10 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) block = uiLayoutAbsoluteBlock(layout); - scopes->track_preview_height = (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height; + 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, scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, + scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } /********************* Marker Template ************************/ @@ -213,7 +214,7 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) marker->flag = cb->marker_flag; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } static void marker_block_handler(bContext *C, void *arg_cb, int event) @@ -227,12 +228,12 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) marker = BKE_tracking_ensure_marker(cb->track, cb->framenr); if (event == B_MARKER_POS) { - marker->pos[0] = cb->marker_pos[0]/width; - marker->pos[1] = cb->marker_pos[1]/height; + marker->pos[0] = cb->marker_pos[0] / width; + marker->pos[1] = cb->marker_pos[1] / height; /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } @@ -278,17 +279,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min); - dim[0] = cb->track_search[0]/width; - dim[1] = cb->track_search[1]/height; + dim[0] = cb->track_search[0] / width; + dim[1] = cb->track_search[1] / height; sub_v2_v2(dim, search_dim); mul_v2_fl(dim, 0.5f); - cb->track->search_min[0]-= dim[0]; - cb->track->search_min[1]-= dim[1]; + cb->track->search_min[0] -= dim[0]; + cb->track->search_min[1] -= dim[1]; - cb->track->search_max[0]+= dim[0]; - cb->track->search_max[1]+= dim[1]; + cb->track->search_max[0] += dim[0]; + cb->track->search_max[1] += dim[1]; BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); @@ -314,16 +315,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } if (ok) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, cb->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, cb->clip); } -void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) +void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, + PointerRNA *trackptr, int compact) { PropertyRNA *prop; uiBlock *block; @@ -375,7 +377,8 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P else tip = "Marker is enabled at current frame"; - bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip); + bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, + &cb->marker_flag, 0, 0, 1, 0, tip); uiButSetNFunc(bt, marker_update_cb, cb, NULL); } else { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 574eb5b2570..84209f7b744 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -122,13 +122,13 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); if (sel) - UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha)); + UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); else glColor4f(0.91f, 0.91f, 0.91f, alpha); diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 9b9190e3e05..0fd17523425 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -100,7 +100,7 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) current_channel_index++; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -129,7 +129,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot) ot->poll = dopesheet_select_channel_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 33bc67db8e4..f92f639586d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -87,7 +87,7 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); - BLF_position(fontid, x+2.0f, y+2.0f, 0.0f); + BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); BLF_draw(fontid, numstr, sizeof(numstr)); } @@ -128,7 +128,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc int framenr; MovieTrackingMarker *marker; - while (a<track->markersnr) { + while (a < track->markersnr) { if (track->markers[a].framenr >= i) break; @@ -191,7 +191,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx; UI_ThemeColor(TH_CFRAME); - glRecti(x, 0, x+framelen, 8); + glRecti(x, 0, x + framelen, 8); clip_draw_curfra_label(sc, x, 8.0f); } @@ -267,7 +267,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, * be binder fallback to simple draw pixels solution */ if (need_fallback) { /* set zoom */ - glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y); + glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); @@ -346,7 +346,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin b = count; i = framenr; - while (i <= framenr+count) { + while (i <= framenr + count) { marker = BKE_tracking_get_marker(track, i); if (!marker || marker->flag & MARKER_DISABLED) @@ -357,7 +357,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin curindex = b; add_v2_v2v2(path[b++], marker->pos, track->offset); - ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); + ED_clip_point_undistorted_pos(sc, path[b - 1], path[b - 1]); } else break; @@ -414,7 +414,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin glPointSize(1.0f); } -static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height) +static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int width, int height) { int tiny = sc->flag & SC_SHOW_TINY_MARKER; int show_search = FALSE; @@ -434,7 +435,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (tiny) glPointSize(3.0f); else glPointSize(4.0f); glBegin(GL_POINTS); @@ -513,7 +514,8 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float } } -static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height, int act, int sel) +static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int width, int height, int act, int sel) { int tiny = sc->flag & SC_SHOW_TINY_MARKER; int show_search = 0; @@ -521,8 +523,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra track_colors(track, act, col, scol); - px[0]= 1.0f / width / sc->zoom; - px[1]= 1.0f / height / sc->zoom; + px[0] = 1.0f / width / sc->zoom; + px[1] = 1.0f / height / sc->zoom; /* marker position and offset position */ if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { @@ -548,7 +550,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra add_v2_v2v2(pos, marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (!tiny) glPointSize(2.0f); @@ -768,18 +770,18 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* search re-sizing triangle */ x = track->search_max[0]; y = track->search_min[1]; - tdx = searchdx*2.0f; - tdy = searchdy*2.0f; + tdx = searchdx * 2.0f; + tdy = searchdy * 2.0f; if (outline) { tdx += px[0]; @@ -788,12 +790,12 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } - if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT)==sel || outline)) { + if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { if (!outline) { if (track->pat_flag & SELECT) glColor3fv(scol); @@ -814,10 +816,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* pattern re-sizing triangle */ @@ -834,8 +836,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } @@ -845,8 +847,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glLineWidth(1.0f); } -static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int act, - int width, int height, float zoomx, float zoomy) +static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int act, int width, int height, float zoomx, float zoomy) { char str[128] = {0}, state[64] = {0}; float dx = 0.0f, dy = 0.0f, fontsize, pos[3]; @@ -971,7 +973,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* count */ track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) @@ -988,7 +990,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1009,7 +1011,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (sc->flag & SC_SHOW_TRACK_PATH) { track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) + if ((track->flag & TRACK_HIDDEN) == 0) draw_track_path(sc, clip, track); track = track->next; @@ -1020,7 +1022,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1044,7 +1046,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { int act = track == act_track; marker = BKE_tracking_get_marker(track, framenr); @@ -1066,7 +1068,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* active marker would be displayed on top of everything else */ if (act_track) { - if ((act_track->flag & TRACK_HIDDEN)==0) { + if ((act_track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(act_track, framenr); if (MARKER_VISIBLE(sc, act_track, marker)) { @@ -1096,7 +1098,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (MARKER_VISIBLE(sc, track, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); - vec[3]=1; + vec[3] = 1; mul_v4_m4v4(pos, mat, vec); @@ -1111,7 +1113,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, sub_v2_v2(vec, npos); - if (len_v2(vec)< 3.0f) + if (len_v2(vec) < 3.0f) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); @@ -1165,7 +1167,8 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, MEM_freeN(marker_pos); } -static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int width, int height, float zoomx, float zoomy) +static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, + int width, int height, float zoomx, float zoomy) { float x, y; const int n = 10; @@ -1199,9 +1202,9 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { if (a < 2) - val[a][a%2] = FLT_MAX; + val[a][a % 2] = FLT_MAX; else - val[a][a%2] = -FLT_MAX; + val[a][a % 2] = -FLT_MAX; } zero_v2(pos); @@ -1213,10 +1216,10 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { int ok; - if (a<2) - ok = tpos[a%2] < val[a][a%2]; + if (a < 2) + ok = tpos[a % 2] < val[a][a % 2]; else - ok = tpos[a%2] > val[a][a%2]; + ok = tpos[a % 2] > val[a][a % 2]; if (ok) { copy_v2_v2(val[a], tpos); @@ -1310,11 +1313,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid pos[0] = stroke->points[i].x * width; pos[1] = stroke->points[i].y * height * aspy; - npos[0] = stroke->points[i+1].x * width; - npos[1] = stroke->points[i+1].y * height * aspy; + npos[0] = stroke->points[i + 1].x * width; + npos[1] = stroke->points[i + 1].y * height * aspy; len = len_v2v2(pos, npos); - steps = ceil(len/5.0f); + steps = ceil(len / 5.0f); /* we want to distort only long straight lines */ if (stroke->totpoints == 2) { @@ -1323,11 +1326,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } sub_v2_v2v2(dpos, npos, pos); - mul_v2_fl(dpos, 1.0f/steps); + mul_v2_fl(dpos, 1.0f / steps); for (j = 0; j <= steps; j++) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); - glVertex2f(tpos[0]/width, tpos[1]/(height*aspy)); + glVertex2f(tpos[0] / width, tpos[1] / (height*aspy)); add_v2_v2(pos, dpos); } @@ -1434,7 +1437,7 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) if (onlyv2d) { /* if manual calibration is used then grease pencil data is already * drawed in draw_distortion */ - if ((sc->flag & SC_MANUAL_CALIBRATION)==0 || sc->mode != SC_MODE_DISTORTION) { + if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || sc->mode != SC_MODE_DISTORTION) { ibuf = ED_space_clip_get_buffer(sc); if (ibuf) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index bd34a51819c..b3ac535ab9d 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -162,7 +162,7 @@ void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *c } if (C) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); } MovieClip *ED_space_clip(SpaceClip *sc) @@ -220,8 +220,8 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) ED_space_clip_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)(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); } void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -317,7 +317,8 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height)); + clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -337,7 +338,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) newzoom = 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)); - if (fit || sc->zoom>newzoom) + if (fit || sc->zoom > newzoom) sc->zoom = newzoom; } @@ -455,16 +456,11 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) if (need_rebind) { int width = ibuf->x, height = ibuf->y; - float *frect = NULL, *fscalerect = NULL; - unsigned int *rect = NULL, *scalerect = NULL; int need_recreate = 0; if (width > GL_MAX_TEXTURE_SIZE || height > GL_MAX_TEXTURE_SIZE) return 0; - rect = ibuf->rect; - frect = ibuf->rect_float; - /* if image resolution changed (e.g. switched to proxy display) texture need to be recreated */ need_recreate = context->image_width != ibuf->x || context->image_height != ibuf->y; @@ -497,10 +493,13 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) glBindTexture(GL_TEXTURE_2D, context->texture); } - if (frect) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, width, height, 0, GL_RGBA, GL_FLOAT, frect); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + if (ibuf->rect_float) { + if (ibuf->rect == NULL) + IMB_rect_from_float(ibuf); + } + + if (ibuf->rect) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); /* store settings */ context->texture_allocated = 1; @@ -508,11 +507,6 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) context->image_width = ibuf->x; context->image_height = ibuf->y; context->framenr = sc->user.framenr; - - if (fscalerect) - MEM_freeN(fscalerect); - if (scalerect) - MEM_freeN(scalerect); } else { /* displaying exactly the same image which was loaded t oa texture, diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 9f9bdcb6cd2..853a7d7cad1 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -81,7 +81,7 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float glPushMatrix(); glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); glCallList(displist); glPopMatrix(); @@ -166,7 +166,8 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) /* draw graph lines */ glEnable(GL_BLEND); - clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb); + clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, + tracking_segment_start_cb, tracking_segment_end_cb); glDisable(GL_BLEND); /* selected knot handles on top of curves */ @@ -183,10 +184,10 @@ static void draw_frame_curves(SpaceClip *sc) glColor3f(0.0f, 0.0f, 1.0f); - for (i = 0; i<reconstruction->camnr; i++) { + for (i = 0; i < reconstruction->camnr; i++) { MovieReconstructedCamera *camera = &reconstruction->cameras[i]; - if (lines && camera->framenr!=prevfra+1) { + if (lines && camera->framenr != prevfra + 1) { glEnd(); lines = 0; } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index efe48cd4b36..10692ada5d9 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -144,7 +144,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr float d = dx * dx + dy * dy; if (data->marker == NULL || d < data->min_dist) { - float co[2]= {marker->framenr, val}; + float co[2] = {marker->framenr, val}; data->track = track; data->marker = marker; @@ -252,7 +252,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } if (sel) - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -358,7 +358,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, border_select_cb, NULL, NULL); if (userdata.change) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -430,7 +430,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -447,7 +447,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -481,7 +481,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** delete knot operator ********************/ @@ -522,7 +522,7 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** view all operator ********************/ @@ -662,7 +662,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -686,7 +686,7 @@ void CLIP_OT_graph_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index b05d204b07b..117e599cbbb 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -93,8 +93,8 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { ED_space_clip_size(sc, &width, &height); - sc->xof += ((location[0] - 0.5f) * width-sc->xof) * (sc->zoom-oldzoom) / sc->zoom; - sc->yof += ((location[1] - 0.5f) * height-sc->yof) * (sc->zoom-oldzoom) / sc->zoom; + sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; + sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } @@ -164,7 +164,8 @@ static int open_exec(bContext *C, wmOperator *op) if (op->customdata) MEM_freeN(op->customdata); - BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported movie clip format"); + BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, + errno ? strerror(errno) : "Unsupported movie clip format"); return OPERATOR_CANCELLED; } @@ -188,7 +189,7 @@ static int open_exec(bContext *C, wmOperator *op) ED_space_clip_set(C, screen, sc, clip); } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_ADDED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_ADDED, clip); MEM_freeN(op->customdata); @@ -233,10 +234,11 @@ void CLIP_OT_open(wmOperatorType *ot) ot->cancel = open_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* reload clip operator *********************/ @@ -250,7 +252,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) BKE_movieclip_reload(clip); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -500,7 +502,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) switch (event->type) { case MOUSEMOVE: - factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f; + factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -529,7 +531,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom"; ot->idname = "CLIP_OT_view_zoom"; - ot->description = "Zoom on/out the view"; + ot->description = "Zoom in/out the view"; /* api callbacks */ ot->exec = view_zoom_exec; @@ -539,7 +541,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* properties */ RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX, @@ -586,7 +588,8 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in screen coordinates", -10.0f, 10.0f); } static int view_zoom_out_exec(bContext *C, wmOperator *op) @@ -627,7 +630,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** view zoom ratio operator *********************/ @@ -781,7 +785,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) /* do updates */ sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } static int change_frame_exec(bContext *C, wmOperator *op) @@ -867,7 +871,7 @@ void CLIP_OT_change_frame(wmOperatorType *ot) ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -904,16 +908,16 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto int size_nr = undistort ? 1 : 0; if (size_flag & size_flags[size_nr][0]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_25; if (size_flag & size_flags[size_nr][1]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_50; if (size_flag & size_flags[size_nr][2]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_75; if (size_flag & size_flags[size_nr][3]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_100; return build_count; } @@ -958,7 +962,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if (clip->source != MCLIP_SRC_MOVIE) BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0); - BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1); + BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, + build_undistort_sizes, build_undistort_count, 1); if (*stop || G.afbreek) break; @@ -986,7 +991,7 @@ static void proxy_endjob(void *pjv) BKE_movieclip_reload(pj->clip); - WM_main_add_notifier(NC_MOVIECLIP|ND_DISPLAY, pj->clip); + WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, pj->clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1015,7 +1020,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) } WM_jobs_customdata(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); G.afbreek = 0; @@ -1057,7 +1062,7 @@ static int mode_set_exec(bContext *C, wmOperator *op) sc->mode = mode; } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CLIP, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); return OPERATOR_FINISHED; } @@ -1093,14 +1098,15 @@ void ED_operatormacros_clip(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and move it on movie"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", + "Add new marker and move it on movie", OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and slide it with mouse until mouse button release"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", + "Add new marker and slide it with mouse until mouse button release", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "release_confirm", TRUE); diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index da8bf8fedd9..3ffba75f2ef 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -151,7 +151,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) BLI_insertlinkafter(&sa->regionbase, artool, arprops); arprops->regiontype = RGN_TYPE_TOOL_PROPS; - arprops->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; } return artool; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 2545106d132..4142c30d825 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -190,20 +190,21 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); if (update_stab) { tracking->stabilization.ok = FALSE; - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } DAG_id_tag_update(&clip->id, 0); if (has_bundle) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); } -void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker) +void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, + MovieTrackingTrack *track, MovieTrackingMarker *marker) { if (track->markersnr == 1) { clip_delete_track(C, clip, tracksbase, track); @@ -211,7 +212,7 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, Movi else { BKE_tracking_delete_marker(track, marker->framenr); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } } @@ -253,7 +254,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 1c0d2db91a9..a3e17d420b3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -81,7 +81,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) if (sc->view == SC_VIEW_DOPESHEET) { ar->v2d.tot.xmin = -10.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(sa->winx); ar->v2d.tot.ymax = 0.0f; @@ -95,7 +95,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.minzoom = 0.01f; ar->v2d.maxzoom = 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.keepzoom = V2D_LOCKZOOM_Y; ar->v2d.keepofs = V2D_KEEPOFS_Y; @@ -116,8 +116,8 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); ar->v2d.minzoom = 0.0f; ar->v2d.maxzoom = 0.0f; @@ -232,7 +232,8 @@ static SpaceLink *clip_new(const bContext *C) sc = MEM_callocN(sizeof(SpaceClip), "initclip"); sc->spacetype = SPACE_CLIP; - sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; + sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION | + SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES; sc->zoom = 1.0f; sc->path_length = 20; sc->scopes.track_preview_height = 120; @@ -256,7 +257,7 @@ static SpaceLink *clip_new(const bContext *C) BLI_addtail(&sc->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_PROPS; - ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; /* properties view */ ar = MEM_callocN(sizeof(ARegion), "properties for clip"); @@ -369,12 +370,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SCREEN: - if (wmn->data ==ND_ANIMPLAY) { + if (wmn->data == ND_ANIMPLAY) { ED_area_tag_redraw(sa); } break; case NC_SPACE: - if (wmn->data ==ND_SPACE_CLIP) { + if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -512,7 +513,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", FALSE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", TRUE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); @@ -560,16 +561,16 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* jump to special frame */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 0); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 1); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 2); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 3); /* "timeline" */ @@ -645,7 +646,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); @@ -690,7 +691,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); @@ -708,7 +709,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", TRUE); /* toggle */ } -const char *clip_context_dir[]= {"edit_movieclip", NULL}; +const char *clip_context_dir[] = {"edit_movieclip", NULL}; static int clip_context(const bContext *C, const char *member, bContextDataResult *result) { @@ -879,8 +880,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = TRUE; } - if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) { - ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) { + ar_tool_props->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; view_changed = TRUE; } } @@ -984,8 +985,8 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) ar->v2d.mask.ymax = winy; /* which part of the image space do we see? */ - x1 = ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f; - y1 = ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f; + x1 = ar->winrct.xmin + (winx - sc->zoom * w) / 2.0f; + y1 = ar->winrct.ymin + (winy - sc->zoom * h) / 2.0f; x1 -= sc->zoom * sc->xof; y1 -= sc->zoom * sc->yof; @@ -1146,7 +1147,8 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) /* time grid */ unit = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, + V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -1298,11 +1300,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data ==ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if (wmn->action ==NA_EDITED) + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1336,7 +1338,7 @@ void ED_spacetype_clip(void) art->init = clip_main_area_init; art->draw = clip_main_area_draw; art->listener = clip_main_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); @@ -1347,7 +1349,7 @@ void ED_spacetype_clip(void) art->init = clip_preview_area_init; art->draw = clip_preview_area_draw; art->listener = clip_preview_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); @@ -1355,7 +1357,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->init = clip_properties_area_init; art->draw = clip_properties_area_draw; art->listener = clip_properties_area_listener; @@ -1366,7 +1368,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1378,7 +1380,7 @@ void ED_spacetype_clip(void) art->regionid = RGN_TYPE_TOOL_PROPS; art->prefsizex = 0; art->prefsizey = 120; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1390,7 +1392,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; art->init = clip_header_area_init; art->draw = clip_header_area_draw; @@ -1403,7 +1405,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip channels region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_channels_area_listener; art->init = clip_channels_area_init; art->draw = clip_channels_area_draw; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 825415764f1..fc93bcc0409 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -116,7 +116,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) sc->xlockof = 0; sc->ylockof = 0; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -145,7 +145,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX, @@ -190,7 +190,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** delete marker operator *********************/ @@ -211,7 +211,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); if (marker) { - has_selection |= track->markersnr>1; + has_selection |= track->markersnr > 1; clip_delete_marker(C, clip, tracksbase, track, marker); } @@ -241,7 +241,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** slide marker operator *********************/ @@ -357,8 +357,8 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + tdx && co[1] >= crn[1] - tdy && co[1] <= crn[1] + dy; } else { - crn[0] = marker->pos[0]+min[0]; - crn[1] = marker->pos[1]+max[1]; + crn[0] = marker->pos[0] + min[0]; + crn[1] = marker->pos[1] + max[1]; inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + dx && co[1] >= crn[1] - dy && co[1] <= crn[1] + dy; } @@ -374,7 +374,7 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki add_v2_v2v2(pos, marker->pos, track->offset); dx = 12.0f / width / sc->zoom; - dy = 12.0f / height /sc->zoom; + dy = 12.0f / height / sc->zoom; dx = MIN2(dx, (track->pat_max[0] - track->pat_min[0]) / 2.0f); dy = MIN2(dy, (track->pat_max[1] - track->pat_min[1]) / 2.0f); @@ -421,21 +421,26 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) if ((marker->flag & MARKER_DISABLED) == 0) { if (!customdata) if (mouse_on_offset(sc, track, marker, co, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, + SLIDE_ACTION_POS, width, height); if (sc->flag & SC_SHOW_MARKER_SEARCH) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_OFFSET, width, height); else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_SIZE, width, height); } if (!customdata && (sc->flag & SC_SHOW_MARKER_PATTERN)) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_OFFSET, width, height); if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_SIZE, width, height); } if (customdata) @@ -465,7 +470,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) hide_cursor(C); WM_event_add_modal_handler(C, op); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_RUNNING_MODAL; } @@ -490,7 +495,7 @@ static void cancel_mouse_slide(SlideMarkerData *data) else { int a; - for (a = 0; a<data->track->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -527,8 +532,8 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) /* no break! update area size */ case MOUSEMOVE: - mdelta[0] = event->mval[0]-data->mval[0]; - mdelta[1] = event->mval[1]-data->mval[1]; + mdelta[0] = event->mval[0] - data->mval[0]; + mdelta[1] = event->mval[1] - data->mval[1]; dx = mdelta[0] / data->width / sc->zoom; @@ -554,7 +559,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) data->marker->flag &= ~MARKER_TRACKED; } - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); DAG_id_tag_update(&sc->clip->id, 0); } else { @@ -580,7 +585,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) else { int a; - for (a = 0; a<data->track->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d); sub_v2_v2v2(data->offset, data->soff, d); @@ -591,7 +596,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); break; @@ -613,7 +618,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) show_cursor(C); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_CANCELLED; } @@ -634,7 +639,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->modal = slide_marker_modal; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_GRAB_POINTER|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, @@ -657,10 +662,10 @@ static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, fl static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy) { - return mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+max[0], pos[1]+min[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+min[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+max[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+max[0], pos[1]+min[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy); + return mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + max[0], pos[1] + min[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + min[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + max[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy); } static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) @@ -671,9 +676,9 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac ED_space_clip_size(sc, &width, &height); - epsx = MIN4(track->pat_min[0]-track->search_min[0], track->search_max[0]-track->pat_max[0], + epsx = MIN4(track->pat_min[0] - track->search_min[0], track->search_max[0] - track->pat_max[0], fabsf(track->pat_min[0]), fabsf(track->pat_max[0])) / 2; - epsy = MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1], + epsy = MIN4(track->pat_min[1] - track->search_min[1], track->search_max[1] - track->pat_max[1], fabsf(track->pat_min[1]), fabsf(track->pat_max[1])) / 2; epsx = MAX2(epsx, 2.0f / width); @@ -684,7 +689,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac return TRACK_AREA_SEARCH; } - if ((marker->flag & MARKER_DISABLED)== 0) { + if ((marker->flag & MARKER_DISABLED) == 0) { if (sc->flag & SC_SHOW_MARKER_PATTERN) if (mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) return TRACK_AREA_PAT; @@ -692,8 +697,11 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac epsx = 12.0f / width; epsy = 12.0f / height; - if (fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) + if (fabsf(co[0] - marker->pos[0] - track->offset[0]) < epsx && + fabsf(co[1] - marker->pos[1] - track->offset[1]) <= epsy) + { return TRACK_AREA_POINT; + } } return TRACK_AREA_NONE; @@ -702,7 +710,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) { float d1, d2, d3, d4; - float p[2] = {co[0]-pos[0], co[1]-pos[1]}; + float p[2] = {co[0] - pos[0], co[1] - pos[1]}; float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}, v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; @@ -726,8 +734,9 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) { float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX; - d1 = sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ - (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ + /* distance to marker point */ + d1 = sqrtf((co[0] - marker->pos[0] - cur->offset[0]) * (co[0] - marker->pos[0] - cur->offset[0]) + + (co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1])); /* distance to pattern boundbox */ if (sc->flag & SC_SHOW_MARKER_PATTERN) @@ -740,7 +749,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas /* choose minimal distance. useful for cases of overlapped markers. */ dist = MIN3(d1, d2, d3); - if (track == NULL || dist<mindist) { + if (track == NULL || dist < mindist) { track = cur; mindist = dist; } @@ -791,7 +800,7 @@ static int mouse_select(bContext *C, float co[2], int extend) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -821,7 +830,7 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) clip->tracking.act_track = slidedata->track; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); MEM_freeN(slidedata); @@ -890,7 +899,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if (MARKER_VISIBLE(sc, track, marker)) { if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { - BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); } else if (!extend) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); @@ -906,7 +915,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -981,7 +990,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) { - BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); change = TRUE; } @@ -993,7 +1002,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1015,7 +1024,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); @@ -1057,7 +1066,7 @@ static int select_all_exec(bContext *C, wmOperator *op) track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1092,7 +1101,7 @@ static int select_all_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1109,7 +1118,7 @@ void CLIP_OT_select_all(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -1133,7 +1142,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) marker = BKE_tracking_get_marker(track, sc->user.framenr); if (group == 0) { /* Keyframed */ - ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED)==0; + ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED) == 0; } else if (group == 1) { /* Estimated */ ok = marker->framenr != sc->user.framenr; @@ -1174,7 +1183,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -1202,7 +1211,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1254,10 +1263,10 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); int hidden = 0; - if ((sc->flag & SC_SHOW_MARKER_PATTERN)==0) + if ((sc->flag & SC_SHOW_MARKER_PATTERN) == 0) hidden |= TRACK_AREA_PAT; - if ((sc->flag & SC_SHOW_MARKER_SEARCH)==0) + if ((sc->flag & SC_SHOW_MARKER_SEARCH) == 0) hidden |= TRACK_AREA_SEARCH; if (hidden) { @@ -1284,7 +1293,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { BKE_tracking_ensure_marker(track, framenr); if (track->frames_limit) { @@ -1391,15 +1400,15 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo if (!BKE_tracking_next(tmj->context)) break; - exec_time = PIL_check_seconds_timer()-start_time; + exec_time = PIL_check_seconds_timer() - start_time; if (tmj->delay > (float)exec_time) - PIL_sleep_ms(tmj->delay-(float)exec_time); + PIL_sleep_ms(tmj->delay - (float)exec_time); } else if (!BKE_tracking_next(tmj->context)) break; *do_update = TRUE; - *progress = (float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); + *progress = (float)(framenr - tmj->sfra) / (tmj->efra - tmj->sfra); if (tmj->backwards) framenr--; @@ -1435,7 +1444,7 @@ static void track_markers_freejob(void *tmv) MEM_freeN(tmj); - WM_main_add_notifier(NC_SCENE|ND_FRAME, tmj->scene); + WM_main_add_notifier(NC_SCENE | ND_FRAME, tmj->scene); } static int track_markers_exec(bContext *C, wmOperator *op) @@ -1450,7 +1459,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) int sequence = RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; track_init_markers(sc, clip, &frames_limit); @@ -1462,8 +1471,10 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* limit frames to be tracked by user setting */ if (frames_limit) { - if (backwards) efra = MAX2(efra, sfra-frames_limit); - else efra = MIN2(efra, sfra+frames_limit); + if (backwards) + efra = MAX2(efra, sfra - frames_limit); + else + efra = MIN2(efra, sfra + frames_limit); } if (!track_markers_check_direction(backwards, framenr, efra)) @@ -1489,8 +1500,8 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* update scene current frame to the lastes tracked frame */ scene->r.cfra = framenr; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -1513,7 +1524,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve if (clip->tracking_context) return OPERATOR_CANCELLED; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; if (!sequence) @@ -1534,8 +1545,10 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ - if (tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); - else WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0); + if (tmj->delay > 0) + WM_jobs_timer(steve, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); + else + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); @@ -1554,7 +1567,7 @@ static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *eve { /* no running tracking, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1691,8 +1704,8 @@ static void solve_camera_freejob(void *scv) DAG_id_tag_update(&clip->id, 0); - WM_main_add_notifier(NC_MOVIECLIP|NA_EVALUATED, clip); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, NULL); + WM_main_add_notifier(NC_MOVIECLIP | NA_EVALUATED, clip); + WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, NULL); /* update active clip displayed in scene buttons */ WM_main_add_notifier(NC_SCENE, scene); @@ -1753,12 +1766,12 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even /* hide reconstruction statistics from previous solve */ reconstruction->flag &= ~TRACKING_RECONSTRUCTED; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); /* setup job */ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); WM_jobs_customdata(steve, scj, solve_camera_freejob); - WM_jobs_timer(steve, 0.1, NC_MOVIECLIP|NA_EVALUATED, 0); + WM_jobs_timer(steve, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); G.afbreek = 0; @@ -1776,7 +1789,7 @@ static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *even { /* no running solver, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1802,7 +1815,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear solution operator *********************/ @@ -1832,8 +1845,8 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); return OPERATOR_FINISHED; } @@ -1850,7 +1863,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear track operator *********************/ @@ -1878,7 +1891,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1902,7 +1915,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "action", clear_path_actions, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1921,7 +1934,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr); if (action == 0) @@ -1936,7 +1949,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1960,7 +1973,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); @@ -1973,13 +1986,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera = scene->camera; Base *base; - if (camera && object_get_movieclip(scene, camera, 0)==clip) + if (camera && BKE_object_movieclip_get(scene, camera, 0) == clip) return camera; base = scene->base.first; while (base) { if (base->object->type == OB_CAMERA) { - if (object_get_movieclip(scene, base->object, 0)==clip) { + if (BKE_object_movieclip_get(scene, base->object, 0) == clip) { camera = base->object; break; } @@ -2069,7 +2082,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat if (!found) { Object *cam = data->camera ? data->camera : scene->camera; - where_is_object_mat(scene, cam, invmat); + BKE_object_where_is_calc_mat4(scene, cam, invmat); } mult_m4_m4m4(invmat, invmat, data->invmat); @@ -2144,7 +2157,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) track = track->next; } - mul_v3_fl(median, 1.0f/selected_count); + mul_v3_fl(median, 1.0f / selected_count); BKE_get_tracking_mat(scene, camera, mat); @@ -2162,8 +2175,8 @@ static int set_origin_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2180,7 +2193,7 @@ void CLIP_OT_set_origin(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "use_median", 0, "Use Median", "Set origin to median point of selected bundles"); @@ -2196,7 +2209,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb int flip = FALSE; float mat[4][4], vec[3], obmat[4][4], dvec[3]; - object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, obmat); BKE_get_tracking_mat(scene, camera, mat); mul_v3_m4v3(vec, mat, track->bundle_pos); @@ -2254,7 +2267,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb else { copy_v3_v3(mat[1], vec); - if (is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2]) < 1e-3f) { mat[1][2] = 0.0f; mat[2][0] = 0.0f; mat[2][1] = 0.0f; mat[2][2] = 1.0f; cross_v3_v3v3(mat[0], mat[1], mat[2]); @@ -2281,7 +2294,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb if (!flip) { float lmat[4][4], ilmat[4][4], rmat[3][3]; - object_rot_to_mat3(ob, rmat); + BKE_object_rot_to_mat3(ob, rmat); invert_m3(rmat); mul_m4_m4m3(mat, mat, rmat); @@ -2296,7 +2309,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb } } - object_apply_mat4(ob, mat, 0, 0); + BKE_object_apply_mat4(ob, mat, 0, 0); } static int set_plane_exec(bContext *C, wmOperator *op) @@ -2318,7 +2331,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ - if (count_selected_bundles(C)!=3) { + if (count_selected_bundles(C) != 3) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); return OPERATOR_CANCELLED; @@ -2339,7 +2352,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) /* get 3 bundles to use as reference */ track = tracksbase->first; - while (track && tot<3) { + while (track && tot < 3) { if (track->flag & TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); @@ -2383,30 +2396,30 @@ static int set_plane_exec(bContext *C, wmOperator *op) if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { invert_m4(mat); - object_to_mat4(object, obmat); + BKE_object_to_mat4(object, obmat); mult_m4_m4m4(mat, mat, obmat); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ - if (object->loc[2]<0) { + if (object->loc[2] < 0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); } } else { - object_apply_mat4(object, mat, 0, 0); + BKE_object_apply_mat4(object, mat, 0, 0); } - where_is_object(scene, object); + BKE_object_where_is_calc(scene, object); set_axis(scene, object, clip, tracking_object, axis_track, 'X'); DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2429,7 +2442,7 @@ void CLIP_OT_set_plane(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "plane", plane_items, 0, "Plane", "Plane to be used for orientation"); @@ -2449,7 +2462,7 @@ static int set_axis_exec(bContext *C, wmOperator *op) ListBase *tracksbase; int axis = RNA_enum_get(op->ptr, "axis"); - if (count_selected_bundles(C)!=1) { + if (count_selected_bundles(C) != 1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); return OPERATOR_CANCELLED; @@ -2477,8 +2490,8 @@ static int set_axis_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2501,7 +2514,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "axis", axis_actions, 0, "Axis", "Axis to use to align bundle along"); @@ -2551,7 +2564,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) sub_v3_v3(vec[0], vec[1]); - if (len_v3(vec[0])>1e-5f) { + if (len_v3(vec[0]) > 1e-5f) { scale = dist / len_v3(vec[0]); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { @@ -2561,7 +2574,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) else if (!scale_solution) { Object *solver_camera = object_solver_camera(scene, object); - object->size[0] = object->size[1] = object->size[2] = 1.0f/scale; + object->size[0] = object->size[1] = object->size[2] = 1.0f / scale; if (solver_camera) { object->size[0] /= solver_camera->size[0]; @@ -2578,8 +2591,8 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) if (object) DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); } return OPERATOR_FINISHED; @@ -2614,7 +2627,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2666,7 +2679,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) ot->poll = set_solution_scale_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2686,10 +2699,10 @@ static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) if (width == 0 || height == 0) return OPERATOR_CANCELLED; - clip->tracking.camera.principal[0] = ((float)width)/2.0f; - clip->tracking.camera.principal[1] = ((float)height)/2.0f; + clip->tracking.camera.principal[0] = ((float)width) / 2.0f; + clip->tracking.camera.principal[1] = ((float)height) / 2.0f; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -2706,7 +2719,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** hide tracks operator *********************/ @@ -2745,7 +2758,7 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2762,7 +2775,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected tracks"); @@ -2787,7 +2800,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2804,7 +2817,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** detect features operator *********************/ @@ -2862,7 +2875,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2886,7 +2899,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_frame_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "placement", placement_items, 0, "Placement", "Placement for detected features"); @@ -2914,8 +2927,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op) delta = pos == 1 ? 1 : -1; - while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { - MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr+delta); + while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) { + MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr + delta); if (!marker || marker->flag & MARKER_DISABLED) break; @@ -2933,7 +2946,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) a += delta; - while (a+delta >= SFRA && a+delta <= EFRA) { + while (a + delta >= SFRA && a + delta <= EFRA) { MovieReconstructedCamera *cam; cam = BKE_tracking_get_reconstructed_camera(tracking, object, a); @@ -2953,10 +2966,10 @@ static int frame_jump_exec(bContext *C, wmOperator *op) CFRA = sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2981,7 +2994,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "position", position_items, 0, "Position", "Position to jump to"); @@ -3021,7 +3034,7 @@ static int join_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3038,7 +3051,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** lock tracks operator *********************/ @@ -3064,7 +3077,7 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -3088,7 +3101,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute"); @@ -3121,7 +3134,7 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -3138,7 +3151,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** add 2d stabilization tracks operator *********************/ @@ -3155,7 +3168,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB) == 0) { track->flag |= TRACK_USE_2D_STAB; stab->tot_track++; @@ -3169,7 +3182,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3187,7 +3200,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove 2d stabilization tracks operator *********************/ @@ -3211,7 +3224,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->act_track--; stab->tot_track--; - if (stab->act_track<0) + if (stab->act_track < 0) stab->act_track = 0; update = 1; @@ -3229,7 +3242,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3247,7 +3260,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** select 2d stabilization tracks operator *********************/ @@ -3273,7 +3286,7 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) } if (update) - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3290,7 +3303,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** set 2d stabilization rotation track operator *********************/ @@ -3309,7 +3322,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3327,7 +3340,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clean tracks operator *********************/ @@ -3342,30 +3355,30 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) if (del) new_markers = MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for (a = 0; a<markersnr; a++) { + for (a = 0; a < markersnr; a++) { int end = 0; if (prev == -1) { - if ((markers[a].flag & MARKER_DISABLED)==0) + if ((markers[a].flag & MARKER_DISABLED) == 0) prev = a; else start_disabled = 1; } if (prev >= 0) { - end = a == markersnr-1; - end |= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || - markers[a].flag & MARKER_DISABLED); + end = a == markersnr - 1; + end |= (a < markersnr - 1) && (markers[a].framenr != markers[a + 1].framenr - 1 || + markers[a].flag & MARKER_DISABLED); } if (end) { int segok = 1, len = 0; - if (a != prev && markers[a].framenr != markers[a-1].framenr+1) - len = a-prev; + if (a != prev && markers[a].framenr != markers[a - 1].framenr + 1) + len = a - prev; else if (markers[a].flag & MARKER_DISABLED) - len = a-prev; - else len = a-prev+1; + len = a - prev; + else len = a - prev + 1; if (frames) { if (len < frames) { @@ -3386,7 +3399,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) /* place disabled marker in front of current segment */ if (start_disabled) { - memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; new_markers[count].flag |= MARKER_DISABLED; @@ -3394,7 +3407,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) start_disabled = 0; } - memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, t * sizeof(MovieTrackingMarker)); count += t; } else if (markers[a].flag & MARKER_DISABLED) { @@ -3443,11 +3456,11 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) while (track) { next = track->next; - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { int ok = 1; ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) && - (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE)==0 || track->error < error); + (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE) == 0 || track->error < error); if (!ok) { if (action == TRACKING_CLEAN_SELECT) { @@ -3476,7 +3489,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3518,7 +3531,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", @@ -3538,7 +3551,7 @@ static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_new_object(tracking, "Object"); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3555,7 +3568,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove tracking object *********************/ @@ -3576,7 +3589,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) BKE_tracking_remove_object(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3593,7 +3606,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** copy tracks to clipboard operator *********************/ @@ -3647,7 +3660,7 @@ static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_clipboard_paste_tracks(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3664,5 +3677,5 @@ void CLIP_OT_paste_tracks(wmOperatorType *ot) ot->poll = paste_tracks_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 33588cc0923..c0abd094e62 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -58,6 +58,7 @@ void CONSOLE_OT_history_append(struct wmOperatorType *ot); void CONSOLE_OT_scrollback_append(struct wmOperatorType *ot); void CONSOLE_OT_clear(struct wmOperatorType *ot); +void CONSOLE_OT_clear_line(struct wmOperatorType *ot); void CONSOLE_OT_history_cycle(struct wmOperatorType *ot); void CONSOLE_OT_copy(struct wmOperatorType *ot); void CONSOLE_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ef036b071be..5d63a223c08 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -519,6 +519,39 @@ void CONSOLE_OT_delete(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", console_delete_type_items, DEL_NEXT_CHAR, "Type", "Which part of the text to delete"); } +static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); + + if (ci->len == 0) { + return OPERATOR_CANCELLED; + } + + console_history_add(C, ci); + console_history_add(C, NULL); + + console_textview_update_rect(sc, ar); + + ED_area_tag_redraw(CTX_wm_area(C)); + + console_scroll_bottom(ar); + + return OPERATOR_FINISHED; +} + +void CONSOLE_OT_clear_line(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear Line"; + ot->description = "Clear the line and store in history"; + ot->idname = "CONSOLE_OT_clear_line"; + + /* api callbacks */ + ot->exec = console_clear_line_exec; + ot->poll = ED_operator_console_active; +} /* the python exec operator uses this */ static int console_clear_exec(bContext *C, wmOperator *op) @@ -571,7 +604,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); - ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */ + ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevents crashes when no command line */ short reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ int prev_len = ci->len; @@ -584,7 +617,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) console_history_free(sc, ci_prev); } - if (reverse) { /* last item in mistory */ + if (reverse) { /* last item in history */ ci = sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 39757aa393a..a25606db2b3 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -250,8 +250,9 @@ static void console_operatortypes(void) /* for use by python only */ WM_operatortype_append(CONSOLE_OT_history_append); WM_operatortype_append(CONSOLE_OT_scrollback_append); - - WM_operatortype_append(CONSOLE_OT_clear); + + WM_operatortype_append(CONSOLE_OT_clear); + WM_operatortype_append(CONSOLE_OT_clear_line); WM_operatortype_append(CONSOLE_OT_history_cycle); WM_operatortype_append(CONSOLE_OT_copy); WM_operatortype_append(CONSOLE_OT_paste); @@ -312,6 +313,8 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); + WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", RETKEY, KM_PRESS, KM_SHIFT, 0); + #ifdef WITH_PYTHON WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0c94bff8803..28ac674f079 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -391,8 +391,8 @@ void fsmenu_read_system(struct FSMenu* fsmenu) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction - | kLSSharedFileListDoNotMountVolumes, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr) continue; @@ -440,8 +440,8 @@ void fsmenu_read_system(struct FSMenu* fsmenu) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction - | kLSSharedFileListDoNotMountVolumes, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr) continue; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 8bc2eda7e33..ddcd46ba817 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -67,12 +67,12 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* XXX */ /* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */ -#define UI_FLT_MAX 10000.0f +#define UI_FLT_MAX 10000.0f /* ******************* graph editor space & buttons ************** */ @@ -98,7 +98,7 @@ static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu) { bAnimContext ac; - bAnimListElem *elem= NULL; + bAnimListElem *elem = NULL; /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) * to work correctly is able to be correctly retrieved. There's no point showing empty panels? @@ -107,14 +107,14 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** return 0; /* try to find 'active' F-Curve */ - elem= get_active_fcurve_channel(&ac); + elem = get_active_fcurve_channel(&ac); if (elem == NULL) return 0; if (fcu) - *fcu= (FCurve*)elem->data; + *fcu = (FCurve *)elem->data; if (ale) - *ale= elem; + *ale = elem; else MEM_freeN(elem); @@ -131,9 +131,9 @@ static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* Graph Editor View Settings */ static void graph_panel_view(const bContext *C, Panel *pa) { - bScreen *sc= CTX_wm_screen(C); - SpaceIpo *sipo= CTX_wm_space_graph(C); - Scene *scene= CTX_data_scene(C); + bScreen *sc = CTX_wm_screen(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); + Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; uiLayout *col, *sub, *row; @@ -142,21 +142,21 @@ static void graph_panel_view(const bContext *C, Panel *pa) RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col= uiLayoutColumn(pa->layout, 0); - uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); + col = uiLayoutColumn(pa->layout, 0); + uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - sub= uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); - - sub= uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - row= uiLayoutSplit(sub, 0.7, 1); - uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); - uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - row= uiLayoutSplit(sub, 0.7, 1); - uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); - uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); + + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + row = uiLayoutSplit(sub, 0.7, 1); + uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); + uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); + row = uiLayoutSplit(sub, 0.7, 1); + uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); + uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); } /* ******************* active F-Curve ************** */ @@ -175,7 +175,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) if (!graph_panel_context(C, &ale, &fcu)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); /* F-Curve pointer */ @@ -183,26 +183,26 @@ static void graph_panel_properties(const bContext *C, Panel *pa) /* user-friendly 'name' for F-Curve */ /* TODO: only show the path if this is invalid? */ - col= uiLayoutColumn(layout, 0); - icon= getname_anim_fcurve(name, ale->id, fcu); - uiItemL(col, name, icon); + col = uiLayoutColumn(layout, 0); + icon = getname_anim_fcurve(name, ale->id, fcu); + uiItemL(col, name, icon); /* RNA-Path Editing - only really should be enabled when things aren't working */ - col= uiLayoutColumn(layout, 1); - uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)!=0); - uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); - uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); + uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); + uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); /* color settings */ - col= uiLayoutColumn(layout, 1); - uiItemL(col, IFACE_("Display Color:"), ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - row= uiLayoutRow(col, 1); - uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); + row = uiLayoutRow(col, 1); + uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - sub= uiLayoutRow(row, 1); - uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM)); - uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); + sub = uiLayoutRow(row, 1); + uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); + uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); MEM_freeN(ale); } @@ -226,13 +226,13 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT * - this is a reasonable assumption, given that whenever anyone * wants to edit numerically, there is likely to only be 1 vert selected */ - for (i=0, b=fcu->bezt; i < fcu->totvert; i++, b++) { + for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) { if (BEZSELECTED(b)) { /* found * - 'previous' is either the one before, of the keyframe itself (which is still fine) * XXX: we can just make this null instead if needed */ - *prevbezt = (i > 0) ? b-1 : b; + *prevbezt = (i > 0) ? b - 1 : b; *bezt = b; return 1; @@ -246,7 +246,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT /* update callback for active keyframe properties - base updates stuff */ static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr)) { - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); const short use_handle = !(sipo->flag & SIPO_NOHANDLES); FCurve *fcu = (FCurve *)fcu_ptr; @@ -265,8 +265,8 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* by changing to aligned handles, these can now be moved... */ - bezt->h1= HD_ALIGN; - bezt->h2= HD_ALIGN; + bezt->h1 = HD_ALIGN; + bezt->h2 = HD_ALIGN; } /* now call standard updates */ @@ -307,56 +307,56 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* interpolation */ - col= uiLayoutColumn(layout, 0); - uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 0); + uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); /* numerical coordinate editing - * - we use the button-versions of the calls so that we can attach special update handlers - * and unit conversion magic that cannot be achieved using a purely RNA-approach + * - we use the button-versions of the calls so that we can attach special update handlers + * and unit conversion magic that cannot be achieved using a purely RNA-approach */ // XXX: - col= uiLayoutColumn(layout, 1); - /* keyframe itself */ - { - uiItemL(col, IFACE_("Key:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } - - /* previous handle - only if previous was Bezier interpolation */ - if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { - uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } - - /* next handle - only if current is Bezier interpolation */ - if (bezt->ipo == BEZT_IPO_BEZ) { - uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } + col = uiLayoutColumn(layout, 1); + /* keyframe itself */ + { + uiItemL(col, IFACE_("Key:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } + + /* previous handle - only if previous was Bezier interpolation */ + if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { + uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } + + /* next handle - only if current is Bezier interpolation */ + if (bezt->ipo == BEZT_IPO_BEZ) { + uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } } else { if ((fcu->bezt == NULL) && (fcu->modifiers.first)) { @@ -378,12 +378,12 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) /* ******************* drivers ******************************** */ -#define B_IPO_DEPCHANGE 10 +#define B_IPO_DEPCHANGE 10 static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); switch (event) { case B_IPO_DEPCHANGE: @@ -394,19 +394,19 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e /* force an update of depsgraph */ DAG_ids_flush_update(bmain, 0); } - break; + break; } /* default for now */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); // XXX could use better notifier + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier } /* callback to remove the active driver */ -static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg)) +static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg)) { - bAnimListElem *ale= (bAnimListElem *)ale_v; - ID *id= ale->id; - FCurve *fcu= ale->data; + bAnimListElem *ale = (bAnimListElem *)ale_v; + ID *id = ale->id; + FCurve *fcu = ale->data; ReportList *reports = CTX_wm_reports(C); /* try to get F-Curve that driver lives on, and ID block which has this AnimData */ @@ -418,29 +418,29 @@ static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg)) } /* callback to add a target variable to the active driver */ -static void driver_add_var_cb (bContext *UNUSED(C), void *driver_v, void *UNUSED(arg)) +static void driver_add_var_cb(bContext *UNUSED(C), void *driver_v, void *UNUSED(arg)) { - ChannelDriver *driver= (ChannelDriver *)driver_v; + ChannelDriver *driver = (ChannelDriver *)driver_v; /* add a new variable */ driver_add_new_variable(driver); } /* callback to remove target variable from active driver */ -static void driver_delete_var_cb (bContext *UNUSED(C), void *driver_v, void *dvar_v) +static void driver_delete_var_cb(bContext *UNUSED(C), void *driver_v, void *dvar_v) { - ChannelDriver *driver= (ChannelDriver *)driver_v; - DriverVar *dvar= (DriverVar *)dvar_v; + ChannelDriver *driver = (ChannelDriver *)driver_v; + DriverVar *dvar = (DriverVar *)dvar_v; /* remove the active variable */ driver_free_variable(driver, dvar); } /* callback to reset the driver's flags */ -static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg)) +static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg)) { - FCurve *fcu= (FCurve *)fcu_v; - ChannelDriver *driver= fcu->driver; + FCurve *fcu = (FCurve *)fcu_v; + ChannelDriver *driver = fcu->driver; /* clear invalid flags */ fcu->flag &= ~FCURVE_DISABLED; // XXX? @@ -450,7 +450,7 @@ static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUS /* drivers panel poll */ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) { - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); if (sipo->mode != SIPO_MODE_DRIVERS) return 0; @@ -461,7 +461,7 @@ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) /* settings for 'single property' driver variable type */ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; + DriverTarget *dtar = &dvar->targets[0]; PointerRNA dtar_ptr; uiLayout *row, *col; @@ -469,8 +469,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* Target ID */ - row= uiLayoutRow(layout, 0); - uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); + row = uiLayoutRow(layout, 0); + uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); /* Target Property */ // TODO: make this less technical... @@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - col= uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, 1); /* rna path */ uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path")); } @@ -489,8 +489,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* settings for 'rotation difference' driver variable type */ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - DriverTarget *dtar2= &dvar->targets[1]; + DriverTarget *dtar = &dvar->targets[0]; + DriverTarget *dtar2 = &dvar->targets[1]; Object *ob1 = (Object *)dtar->id; Object *ob2 = (Object *)dtar2->id; PointerRNA dtar_ptr, dtar2_ptr; @@ -501,32 +501,32 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); - if (dtar->id && ob1->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob1->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); - if (dtar2->id && ob2->pose) { - PointerRNA tar_ptr; + if (dtar2->id && ob2->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); - uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); + uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } } /* settings for 'location difference' driver variable type */ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - DriverTarget *dtar2= &dvar->targets[1]; + DriverTarget *dtar = &dvar->targets[0]; + DriverTarget *dtar2 = &dvar->targets[1]; Object *ob1 = (Object *)dtar->id; Object *ob2 = (Object *)dtar2->id; PointerRNA dtar_ptr, dtar2_ptr; @@ -537,35 +537,35 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); - if (dtar->id && ob1->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob1->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); + uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); - if (dtar2->id && ob2->pose) { - PointerRNA tar_ptr; + if (dtar2->id && ob2->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); - uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); + uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE); + uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE); } /* settings for 'transform channel' driver variable type */ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; + DriverTarget *dtar = &dvar->targets[0]; Object *ob = (Object *)dtar->id; PointerRNA dtar_ptr; uiLayout *col, *sub; @@ -574,19 +574,19 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* properties */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); - if (dtar->id && ob->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - sub= uiLayoutColumn(layout, 1); - uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); - uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); + sub = uiLayoutColumn(layout, 1); + uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); + uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } /* driver settings for active F-Curve (only for 'Drivers' mode) */ @@ -605,125 +605,125 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* Get settings from context */ if (!graph_panel_context(C, &ale, &fcu)) return; - driver= fcu->driver; + driver = fcu->driver; /* set event handler for panel */ - block= uiLayoutGetBlock(pa->layout); // xxx? + block = uiLayoutGetBlock(pa->layout); // xxx? uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ - col= uiLayoutColumn(pa->layout, 0); - block= uiLayoutGetBlock(col); - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10*UI_UNIT_X, 22, - NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); - uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); - - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10*UI_UNIT_X, 18, - NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); - uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); + col = uiLayoutColumn(pa->layout, 0); + block = uiLayoutGetBlock(col); + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, + NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); + uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); + + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18, + NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); + uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - col= uiLayoutColumn(pa->layout, 1); - block= uiLayoutGetBlock(col); - uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); - - /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ - if (driver->type == DRIVER_TYPE_PYTHON) { - /* expression */ - uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); - - /* errors? */ - if (driver->flag & DRIVER_FLAG_INVALID) - uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR); - } - else { - /* errors? */ - if (driver->flag & DRIVER_FLAG_INVALID) - uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); - } + col = uiLayoutColumn(pa->layout, 1); + block = uiLayoutGetBlock(col); + uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); + + /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ + if (driver->type == DRIVER_TYPE_PYTHON) { + /* expression */ + uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); + + /* errors? */ + if (driver->flag & DRIVER_FLAG_INVALID) + uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR); + } + else { + /* errors? */ + if (driver->flag & DRIVER_FLAG_INVALID) + uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); + } - col= uiLayoutColumn(pa->layout, 1); - /* debug setting */ - uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); + col = uiLayoutColumn(pa->layout, 1); + /* debug setting */ + uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); - /* value of driver */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - uiLayout *row= uiLayoutRow(col, 1); - char valBuf[32]; + /* value of driver */ + if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + uiLayout *row = uiLayoutRow(col, 1); + char valBuf[32]; - uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); + uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); - uiItemL(row, valBuf, ICON_NONE); - } + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); + uiItemL(row, valBuf, ICON_NONE); + } /* add driver variables */ - col= uiLayoutColumn(pa->layout, 0); - block= uiLayoutGetBlock(col); - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10*UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); - uiButSetFunc(but, driver_add_var_cb, driver, NULL); + col = uiLayoutColumn(pa->layout, 0); + block = uiLayoutGetBlock(col); + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); + uiButSetFunc(but, driver_add_var_cb, driver, NULL); /* loop over targets, drawing them */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; uiLayout *box, *row; /* sub-layout column for this variable's settings */ - col= uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, 1); /* header panel */ - box= uiLayoutBox(col); - /* first row context info for driver */ - RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - - row= uiLayoutRow(box, 0); - block= uiLayoutGetBlock(row); - /* variable name */ - uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); - - /* remove button */ - uiBlockSetEmboss(block, UI_EMBOSSN); - but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); - uiButSetFunc(but, driver_delete_var_cb, driver, dvar); - uiBlockSetEmboss(block, UI_EMBOSS); - - /* variable type */ - row= uiLayoutRow(box, 0); - uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); + box = uiLayoutBox(col); + /* first row context info for driver */ + RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); + + row = uiLayoutRow(box, 0); + block = uiLayoutGetBlock(row); + /* variable name */ + uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); + + /* remove button */ + uiBlockSetEmboss(block, UI_EMBOSSN); + but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); + uiButSetFunc(but, driver_delete_var_cb, driver, dvar); + uiBlockSetEmboss(block, UI_EMBOSS); + + /* variable type */ + row = uiLayoutRow(box, 0); + uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ - box= uiLayoutBox(col); - /* controls to draw depends on the type of variable */ - switch (dvar->type) { - case DVAR_TYPE_SINGLE_PROP: /* single property */ - graph_panel_driverVar__singleProp(box, ale->id, dvar); - break; - case DVAR_TYPE_ROT_DIFF: /* rotational difference */ - graph_panel_driverVar__rotDiff(box, ale->id, dvar); - break; - case DVAR_TYPE_LOC_DIFF: /* location difference */ - graph_panel_driverVar__locDiff(box, ale->id, dvar); - break; - case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ - graph_panel_driverVar__transChan(box, ale->id, dvar); - break; - } - - /* value of variable */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - char valBuf[32]; - - box= uiLayoutBox(col); - row= uiLayoutRow(box, 1); - uiItemL(row, IFACE_("Value:"), ICON_NONE); - - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); - uiItemL(row, valBuf, ICON_NONE); - } + box = uiLayoutBox(col); + /* controls to draw depends on the type of variable */ + switch (dvar->type) { + case DVAR_TYPE_SINGLE_PROP: /* single property */ + graph_panel_driverVar__singleProp(box, ale->id, dvar); + break; + case DVAR_TYPE_ROT_DIFF: /* rotational difference */ + graph_panel_driverVar__rotDiff(box, ale->id, dvar); + break; + case DVAR_TYPE_LOC_DIFF: /* location difference */ + graph_panel_driverVar__locDiff(box, ale->id, dvar); + break; + case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ + graph_panel_driverVar__transChan(box, ale->id, dvar); + break; + } + + /* value of variable */ + if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + char valBuf[32]; + + box = uiLayoutBox(col); + row = uiLayoutRow(box, 1); + uiItemL(row, IFACE_("Value:"), ICON_NONE); + + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); + uiItemL(row, valBuf, ICON_NONE); + } } /* cleanup */ @@ -733,7 +733,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* ******************* f-modifiers ******************************** */ /* all the drawing code is in editors/animation/fmodifier_ui.c */ -#define B_FMODIFIER_REDRAW 20 +#define B_FMODIFIER_REDRAW 20 static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event) { @@ -755,27 +755,27 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) if (!graph_panel_context(C, &ale, &fcu)) return; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL); /* 'add modifier' button at top of panel */ { - row= uiLayoutRow(pa->layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(pa->layout, 0); + block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a 'add modifier' operator uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), 10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); /* copy/paste (as sub-row)*/ - row= uiLayoutRow(row, 1); - uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); - uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); + row = uiLayoutRow(row, 1); + uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); + uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } /* draw each modifier */ - for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { - col= uiLayoutColumn(pa->layout, 1); + for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { + col = uiLayoutColumn(pa->layout, 1); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } @@ -789,47 +789,47 @@ void graph_buttons_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); strcpy(pt->idname, "GRAPH_PT_view"); strcpy(pt->label, N_("View Properties")); - pt->draw= graph_panel_view; + pt->draw = graph_panel_view; pt->flag |= PNL_DEFAULT_CLOSED; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_properties"); strcpy(pt->label, N_("Active F-Curve")); - pt->draw= graph_panel_properties; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_properties; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_key_properties"); strcpy(pt->label, N_("Active Keyframe")); - pt->draw= graph_panel_key_properties; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_key_properties; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"); strcpy(pt->idname, "GRAPH_PT_drivers"); strcpy(pt->label, N_("Drivers")); - pt->draw= graph_panel_drivers; - pt->poll= graph_panel_drivers_poll; + pt->draw = graph_panel_drivers; + pt->poll = graph_panel_drivers_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers"); strcpy(pt->idname, "GRAPH_PT_modifiers"); strcpy(pt->label, N_("Modifiers")); - pt->draw= graph_panel_modifiers; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_modifiers; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); } static int graph_properties(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= graph_has_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = graph_has_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index e772e2856c1..ddca0030cf5 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -84,11 +84,11 @@ static float fcurve_display_alpha(FCurve *fcu) /* Envelope -------------- */ // TODO: draw a shaded poly showing the region of influence too!!! -static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) +static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + 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 * (v2d->cur.xmax - v2d->cur.xmin); int i; /* draw two black lines showing the standard reference levels */ @@ -96,11 +96,11 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) setlinestyle(5); glBegin(GL_LINES); - glVertex2f(v2d->cur.xmin, env->midval+env->min); - glVertex2f(v2d->cur.xmax, env->midval+env->min); + glVertex2f(v2d->cur.xmin, env->midval + env->min); + glVertex2f(v2d->cur.xmax, env->midval + env->min); - glVertex2f(v2d->cur.xmin, env->midval+env->max); - glVertex2f(v2d->cur.xmax, env->midval+env->max); + glVertex2f(v2d->cur.xmin, env->midval + env->max); + glVertex2f(v2d->cur.xmax, env->midval + env->max); glEnd(); // GL_LINES setlinestyle(0); @@ -114,7 +114,7 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) * drawing bugs that some drivers have (probably legacy ones only though) */ bglBegin(GL_POINTS); - for (i=0, fed=env->data; i < env->totvert; i++, fed++) { + for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* only draw if visible * - min/max here are fixed, not relative */ @@ -134,10 +134,10 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) /* Points ---------------- */ /* helper func - draw keyframe vertices only for an F-Curve */ -static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel) +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); + BezTriple *bezt = fcu->bezt; + const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin); int i; /* we use bgl points not standard gl points, to workaround vertex @@ -174,18 +174,18 @@ static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ -static void draw_fcurve_handle_control (float x, float y, float xscale, float yscale, float hsize) +static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize) { - static GLuint displist=0; + static GLuint displist = 0; /* initialize round circle shape */ if (displist == 0) { GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - qobj = gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0, 0.7, 8, 1); gluDeleteQuadric(qobj); @@ -195,26 +195,26 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* draw! */ glCallList(displist); /* restore view transform */ - glScalef(xscale/hsize, yscale/hsize, 1.0); + glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); } /* helper func - draw handle vertices only for an F-Curve (if it is not protected) */ -static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only) +static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only) { - BezTriple *bezt= fcu->bezt; + BezTriple *bezt = fcu->bezt; BezTriple *prevbezt = NULL; float hsize, xscale, yscale; int i; /* get view settings */ - hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); + hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); UI_view2d_getscale(v2d, &xscale, &yscale); /* set handle color */ @@ -222,10 +222,10 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v else UI_ThemeColor(TH_HANDLE_VERTEX); /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) { + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) { /* Draw the editmode handles for a bezier curve (others don't have handles) * if their selection status matches the selection status we're drawing for * - first handle only if previous beztriple was bezier-mode @@ -234,31 +234,31 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v * Also, need to take into account whether the keyframe was selected * if a Graph Editor option to only show handles of selected keys is on. */ - if ( !sel_handle_only || BEZSELECTED(bezt) ) { - if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) { - if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/ + if (!sel_handle_only || BEZSELECTED(bezt) ) { + if ( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) { + if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize); } - if (bezt->ipo==BEZT_IPO_BEZ) { - if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/ + if (bezt->ipo == BEZT_IPO_BEZ) { + if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize); } } } - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } /* helper func - set color to draw F-Curve data with */ -static void set_fcurve_vertex_color (FCurve *fcu, short sel) +static void set_fcurve_vertex_color(FCurve *fcu, short sel) { /* Fade the 'intensity' of the vertices based on the selection of the curves too */ - int alphaOffset= (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); + int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); /* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */ - if ((fcu->flag & FCURVE_PROTECTED)==0) { + if ((fcu->flag & FCURVE_PROTECTED) == 0) { /* Curve's points ARE BEING edited */ if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset); @@ -271,14 +271,14 @@ static void set_fcurve_vertex_color (FCurve *fcu, short sel) } -static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only) +static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; /* only draw points if curve is visible - * - draw unselected points before selected points as separate passes to minimise color-changing overhead + * - draw unselected points before selected points as separate passes to minimise color-changing overhead * (XXX dunno if this is faster than drawing all in one pass though) - * and also to make sure in the case of overlapping points that the selected is always visible + * and also to make sure in the case of overlapping points that the selected is always visible * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ @@ -308,14 +308,14 @@ static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, shor static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) { /* don't draw handle lines if handles are not to be shown */ - if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */ - (fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */ -#if 0 /* handles can still be selected and handle types set, better draw - campbell */ - (fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */ + if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */ + (fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */ +#if 0 /* handles can still be selected and handle types set, better draw - campbell */ + (fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */ #endif - ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */ - (fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */ - ) + ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */ + (fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */ + ) { return 0; } @@ -326,7 +326,7 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) /* draw lines for F-Curve handles only (this is only done in EditMode) * note: draw_fcurve_handles_check must be checked before running this. */ -static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) +static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) { int sel, b; @@ -339,13 +339,13 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) /* slightly hacky, but we want to draw unselected points before selected ones * so that selected points are clearly visible */ - for (sel= 0; sel < 2; sel++) { - BezTriple *bezt=fcu->bezt, *prevbezt=NULL; - int basecol= (sel)? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; + for (sel = 0; sel < 2; sel++) { + BezTriple *bezt = fcu->bezt, *prevbezt = NULL; + int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; float *fp; unsigned char col[4]; - for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) { + for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) { /* if only selected keyframes can get their handles shown, * check that keyframe is selected */ @@ -355,50 +355,50 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) } /* draw handle with appropriate set of colors if selection is ok */ - if ((bezt->f2 & SELECT)==sel) { - fp= bezt->vec[0]; + if ((bezt->f2 & SELECT) == sel) { + fp = bezt->vec[0]; /* only draw first handle if previous segment had handles */ - if ((!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) { + if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { UI_GetThemeColor3ubv(basecol + bezt->h1, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } /* only draw second handle if this segment is bezier */ if (bezt->ipo == BEZT_IPO_BEZ) { UI_GetThemeColor3ubv(basecol + bezt->h2, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp+3); glVertex2fv(fp+6); + glVertex2fv(fp + 3); glVertex2fv(fp + 6); } } else { /* only draw first handle if previous segment was had handles, and selection is ok */ - if ( ((bezt->f1 & SELECT)==sel) && - ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) ) + if ( ((bezt->f1 & SELECT) == sel) && + ( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) ) { - fp= bezt->vec[0]; + fp = bezt->vec[0]; UI_GetThemeColor3ubv(basecol + bezt->h1, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } /* only draw second handle if this segment is bezier, and selection is ok */ - if ( ((bezt->f3 & SELECT)==sel) && - (bezt->ipo == BEZT_IPO_BEZ) ) + if ( ((bezt->f3 & SELECT) == sel) && + (bezt->ipo == BEZT_IPO_BEZ) ) { - fp= bezt->vec[1]; + fp = bezt->vec[1]; UI_GetThemeColor3ubv(basecol + bezt->h2, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } } } @@ -413,21 +413,21 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ -static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize) +static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize) { - static GLuint displist=0; + static GLuint displist = 0; /* initialize X shape */ if (displist == 0) { - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glBegin(GL_LINES); - glVertex2f(-0.7f, -0.7f); - glVertex2f(+0.7f, +0.7f); + glVertex2f(-0.7f, -0.7f); + glVertex2f(+0.7f, +0.7f); - glVertex2f(-0.7f, +0.7f); - glVertex2f(+0.7f, -0.7f); + glVertex2f(-0.7f, +0.7f); + glVertex2f(+0.7f, -0.7f); glEnd(); // GL_LINES glEndList(); @@ -435,52 +435,52 @@ static void draw_fcurve_sample_control (float x, float y, float xscale, float ys /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* draw! */ glCallList(displist); /* restore view transform */ - glScalef(xscale/hsize, yscale/hsize, 1.0); + glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); } /* helper func - draw keyframe vertices only for an F-Curve */ -static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu) +static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) { FPoint *first, *last; float hsize, xscale, yscale; /* get view settings */ - hsize= UI_GetThemeValuef(TH_VERTEX_SIZE); + hsize = UI_GetThemeValuef(TH_VERTEX_SIZE); UI_view2d_getscale(&ar->v2d, &xscale, &yscale); /* set vertex color */ - if (fcu->flag & (FCURVE_ACTIVE|FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI); + if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); /* get verts */ - first= fcu->fpt; - last= (first) ? (first + (fcu->totvert-1)) : (NULL); + first = fcu->fpt; + last = (first) ? (first + (fcu->totvert - 1)) : (NULL); /* draw */ if (first && last) { /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize); draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize); glDisable(GL_BLEND); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); } } /* Curve ---------------- */ /* helper func - just draw the F-Curve by sampling the visible region (for drawing curves with modifiers) */ -static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid) +static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid) { ChannelDriver *driver; float samplefreq, ctime; @@ -496,33 +496,33 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2 /* disable any drivers temporarily */ - driver= fcu->driver; - fcu->driver= NULL; + driver = fcu->driver; + fcu->driver = NULL; /* compute unit correction factor */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); /* Note about sampling frequency: - * Ideally, this is chosen such that we have 1-2 pixels = 1 segment + * Ideally, this is chosen such that we have 1-2 pixels = 1 segment * which means that our curves can be as smooth as possible. However, - * this does mean that curves may not be fully accurate (i.e. if they have - * sudden spikes which happen at the sampling point, we may have problems). - * Also, this may introduce lower performance on less densely detailed curves,' + * this does mean that curves may not be fully accurate (i.e. if they have + * sudden spikes which happen at the sampling point, we may have problems). + * Also, this may introduce lower performance on less densely detailed curves,' * though it is impossible to predict this from the modifiers! * * If the automatically determined sampling frequency is likely to cause an infinite * loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value - * chosen here is just the coarsest value which still looks reasonable... + * chosen here is just the coarsest value which still looks reasonable... */ - /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ - // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? - samplefreq= dx / U.v2d_min_gridsize; - if (samplefreq < 0.00001f) samplefreq= 0.00001f; + /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ + // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? + samplefreq = dx / U.v2d_min_gridsize; + if (samplefreq < 0.00001f) samplefreq = 0.00001f; /* the start/end times are simply the horizontal extents of the 'cur' rect */ - stime= v2d->cur.xmin; - etime= v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ + stime = v2d->cur.xmin; + etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ /* at each sampling interval, add a new vertex @@ -531,22 +531,22 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2 */ glBegin(GL_LINE_STRIP); - for (ctime= stime; ctime <= etime; ctime += samplefreq) + for (ctime = stime; ctime <= etime; ctime += samplefreq) glVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac); glEnd(); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* helper func - draw a samples-based F-Curve */ -static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) +static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) { - FPoint *prevfpt= fcu->fpt; - FPoint *fpt= prevfpt + 1; + FPoint *prevfpt = fcu->fpt; + FPoint *fpt = prevfpt + 1; float fac, v[2]; - int b= fcu->totvert-1; + int b = fcu->totvert - 1; glBegin(GL_LINE_STRIP); @@ -555,18 +555,18 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { - v[0]= v2d->cur.xmin; + v[0] = v2d->cur.xmin; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ - v[1]= prevfpt->vec[1]; + v[1] = prevfpt->vec[1]; } else { /* extrapolate linear dosnt use the handle, use the next points center instead */ - fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]); - if (fac) fac= 1.0f/fac; - v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]); + fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); + if (fac) fac = 1.0f / fac; + v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } glVertex2fv(v); @@ -583,7 +583,7 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi glVertex2fv(prevfpt->vec); /* get next pointers */ - prevfpt= fpt; + prevfpt = fpt; fpt++; /* last point? */ @@ -593,19 +593,19 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevfpt->vec[0] < v2d->cur.xmax) { - v[0]= v2d->cur.xmax; + v[0] = v2d->cur.xmax; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* based on last keyframe's value */ - v[1]= prevfpt->vec[1]; + v[1] = prevfpt->vec[1]; } else { /* extrapolate linear dosnt use the handle, use the previous points center instead */ - fpt = prevfpt-1; - fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]); - if (fac) fac= 1.0f/fac; - v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]); + fpt = prevfpt - 1; + fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); + if (fac) fac = 1.0f / fac; + v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } glVertex2fv(v); @@ -618,14 +618,14 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi } /* helper func - draw one repeat of an F-Curve */ -static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) +static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) { - BezTriple *prevbezt= fcu->bezt; - BezTriple *bezt= prevbezt+1; + BezTriple *prevbezt = fcu->bezt; + BezTriple *bezt = prevbezt + 1; float v1[2], v2[2], v3[2], v4[2]; float *fp, data[120]; - float fac= 0.0f; - int b= fcu->totvert-1; + float fac = 0.0f; + int b = fcu->totvert - 1; int resol; glBegin(GL_LINE_STRIP); @@ -636,24 +636,24 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { /* left-side of view comes before first keyframe, so need to extend as not cyclic */ - v1[0]= v2d->cur.xmin; + v1[0] = v2d->cur.xmin; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ - v1[1]= prevbezt->vec[1][1]; + v1[1] = prevbezt->vec[1][1]; } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the next points center instead */ - fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]); + fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ - fac= (prevbezt->vec[0][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[0][1]-prevbezt->vec[1][1]); + fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]); } glVertex2fv(v1); @@ -661,28 +661,28 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* if only one keyframe, add it now */ if (fcu->totvert == 1) { - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } /* draw curve between first and last keyframe (if there are enough to do so) */ // TODO: optimize this to not have to calc stuff out of view too? while (b--) { - if (prevbezt->ipo==BEZT_IPO_CONST) { + if (prevbezt->ipo == BEZT_IPO_CONST) { /* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); - v1[0]= bezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = bezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* Linear interpolation: just add one point (which should add a new line segment) */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } else { @@ -693,74 +693,74 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* resol depends on distance between points (not just horizontal) OR is a fixed high res */ // TODO: view scale should factor into this someday too... if (fcu->driver) - resol= 32; + resol = 32; else - resol= (int)(5.0f*len_v2v2(bezt->vec[1], prevbezt->vec[1])); + resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1])); if (resol < 2) { /* only draw one */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } else { /* clamp resolution to max of 32 */ // NOTE: higher values will crash - if (resol > 32) resol= 32; + if (resol > 32) resol = 32; - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; - v2[0]= prevbezt->vec[2][0]; - v2[1]= prevbezt->vec[2][1]; - - v3[0]= bezt->vec[0][0]; - v3[1]= bezt->vec[0][1]; - v4[0]= bezt->vec[1][0]; - v4[1]= bezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; + v2[0] = prevbezt->vec[2][0]; + v2[1] = prevbezt->vec[2][1]; + + v3[0] = bezt->vec[0][0]; + v3[1] = bezt->vec[0][1]; + v4[0] = bezt->vec[1][0]; + v4[1] = bezt->vec[1][1]; correct_bezpart(v1, v2, v3, v4); - BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float)*3); - BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data+1, resol, sizeof(float)*3); + BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); + BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); - for (fp= data; resol; resol--, fp+= 3) + for (fp = data; resol; resol--, fp += 3) glVertex2fv(fp); } } /* get next pointers */ - prevbezt= bezt; + prevbezt = bezt; bezt++; /* last point? */ if (b == 0) { - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } } /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevbezt->vec[1][0] < v2d->cur.xmax) { - v1[0]= v2d->cur.xmax; + v1[0] = v2d->cur.xmax; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* based on last keyframe's value */ - v1[1]= prevbezt->vec[1][1]; + v1[1] = prevbezt->vec[1][1]; } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the previous points center instead */ - bezt = prevbezt-1; - fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]); + bezt = prevbezt - 1; + fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ - fac= (prevbezt->vec[2][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[2][1]-prevbezt->vec[1][1]); + fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]); } glVertex2fv(v1); @@ -786,13 +786,13 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) glLineWidth(3.0f); /* anti-aliased lines for less jagged appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); /* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */ - for (fcu= sipo->ghostCurves.first; fcu; fcu= fcu->next) { + for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) { /* set whatever color the curve has set - * - this is set by the function which creates these + * - this is set by the function which creates these * - draw with a fixed opacity of 2 */ glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f); @@ -805,7 +805,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) setlinestyle(0); glLineWidth(1.0f); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -819,18 +819,18 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid int filter; /* build list of curves to draw */ - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL)); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* for each curve: * draw curve, then handle-lines, and finally vertices in this order so that - * the data will be layered correctly + * the data will be layered correctly */ - for (ale=anim_data.first; ale; ale=ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - FModifier *fcm= find_active_fmodifier(&fcu->modifiers); - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + FModifier *fcm = find_active_fmodifier(&fcu->modifiers); + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* map keyframes for drawing if scaled F-Curve */ if (adt) @@ -868,7 +868,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } /* anti-aliased lines for less jagged appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); /* draw F-Curve */ @@ -890,7 +890,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid setlinestyle(0); glLineWidth(1.0); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -953,35 +953,35 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f, height; + View2D *v2d = &ar->v2d; + float y = 0.0f, height; size_t items; - int i=0; + int i = 0; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ - { /* first pass: just the standard GL-drawing for backdrop + text */ - y= (float)ACHANNEL_FIRST; + { /* first pass: just the standard GL-drawing for backdrop + text */ + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc); @@ -991,23 +991,23 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) y -= ACHANNEL_STEP; } } - { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)ACHANNEL_FIRST; + y = (float)ACHANNEL_FIRST; /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 5f8281fda5b..7371202b4fb 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -90,21 +90,21 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa int filter; /* get data to filter, from Dopesheet */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - if (xmin) *xmin= 999999999.0f; - if (xmax) *xmax= -999999999.0f; - if (ymin) *ymin= 999999999.0f; - if (ymax) *ymax= -999999999.0f; + if (xmin) *xmin = 999999999.0f; + if (xmax) *xmax = -999999999.0f; + if (ymin) *ymin = 999999999.0f; + if (ymax) *ymax = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float txmin, txmax, tymin, tymax; float unitFac; @@ -113,20 +113,20 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa /* apply NLA scaling */ if (adt) { - txmin= BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); - txmax= BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); + txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); + txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); } /* apply unit corrections */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); tymin *= unitFac; tymax *= unitFac; /* try to set cur using these values, if they're more extreme than previously set values */ - if ((xmin) && (txmin < *xmin)) *xmin= txmin; - if ((xmax) && (txmax > *xmax)) *xmax= txmax; - if ((ymin) && (tymin < *ymin)) *ymin= tymin; - if ((ymax) && (tymax > *ymax)) *ymax= tymax; + if ((xmin) && (txmin < *xmin)) *xmin = txmin; + if ((xmax) && (txmax > *xmax)) *xmax = txmax; + if ((ymin) && (tymin < *ymin)) *ymin = tymin; + if ((ymax) && (tymax > *ymax)) *ymax = tymax; } /* ensure that the extents are not too extreme that view implodes...*/ @@ -139,16 +139,16 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa else { /* set default range */ if (ac->scene) { - if (xmin) *xmin= (float)ac->scene->r.sfra; - if (xmax) *xmax= (float)ac->scene->r.efra; + if (xmin) *xmin = (float)ac->scene->r.sfra; + if (xmax) *xmax = (float)ac->scene->r.efra; } else { - if (xmin) *xmin= -5; - if (xmax) *xmax= 100; + if (xmin) *xmin = -5; + if (xmax) *xmax = 100; } - if (ymin) *ymin= -5; - if (ymax) *ymax= 5; + if (ymin) *ymin = -5; + if (ymax) *ymax = 5; } } @@ -166,17 +166,17 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (ac.scene == NULL) return OPERATOR_CANCELLED; else - scene= ac.scene; + scene = ac.scene; /* set the range directly */ get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE); scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(min + 0.5f); - scene->r.pefra= (int)floor(max + 0.5f); + scene->r.psfra = (int)floor(min + 0.5f); + scene->r.pefra = (int)floor(max + 0.5f); /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -193,7 +193,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** View-All Operator ****************** */ @@ -207,16 +207,16 @@ static int graphkeys_viewall(bContext *C, const short selOnly) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, selOnly); - extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra= 0.1f * (v2d->cur.ymax - v2d->cur.ymin); + extra = 0.1f * (v2d->cur.ymax - v2d->cur.ymin); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; @@ -255,7 +255,7 @@ void GRAPH_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void GRAPH_OT_view_selected(wmOperatorType *ot) @@ -270,7 +270,7 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Create Ghost-Curves Operator *********************** */ @@ -279,9 +279,9 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) */ /* Bake each F-Curve into a set of samples, and store as a ghost curve */ -static void create_ghost_curves (bAnimContext *ac, int start, int end) +static void create_ghost_curves(bAnimContext *ac, int start, int end) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -296,51 +296,51 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end) } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - FCurve *gcu= MEM_callocN(sizeof(FCurve), "Ghost FCurve"); - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - ChannelDriver *driver= fcu->driver; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + FCurve *gcu = MEM_callocN(sizeof(FCurve), "Ghost FCurve"); + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + ChannelDriver *driver = fcu->driver; FPoint *fpt; float unitFac; int cfra; /* disable driver so that it don't muck up the sampling process */ - fcu->driver= NULL; + fcu->driver = NULL; /* calculate unit-mapping factor */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); /* create samples, but store them in a new curve * - we cannot use fcurve_store_samples() as that will only overwrite the original curve */ - gcu->fpt= fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "Ghost FPoint Samples"); - gcu->totvert= end - start + 1; + gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples"); + gcu->totvert = end - start + 1; /* use the sampling callback at 1-frame intervals from start to end frames */ - for (cfra= start; cfra <= end; cfra++, fpt++) { - float cfrae= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + for (cfra = start; cfra <= end; cfra++, fpt++) { + float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - fpt->vec[0]= cfrae; - fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac; + fpt->vec[0] = cfrae; + fpt->vec[1] = fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac; } /* set color of ghost curve * - make the color slightly darker */ - gcu->color[0]= fcu->color[0] - 0.07f; - gcu->color[1]= fcu->color[1] - 0.07f; - gcu->color[2]= fcu->color[2] - 0.07f; + gcu->color[0] = fcu->color[0] - 0.07f; + gcu->color[1] = fcu->color[1] - 0.07f; + gcu->color[2] = fcu->color[2] - 0.07f; /* store new ghost curve */ BLI_addtail(&sipo->ghostCurves, gcu); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* admin and redraws */ @@ -360,9 +360,9 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op) return OPERATOR_CANCELLED; /* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */ - v2d= &ac.ar->v2d; - start= (int)v2d->cur.xmin; - end= (int)v2d->cur.xmax; + v2d = &ac.ar->v2d; + start = (int)v2d->cur.xmin; + end = (int)v2d->cur.xmax; /* bake selected curves into a ghost curve */ create_ghost_curves(&ac, start, end); @@ -385,7 +385,7 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; // todo: add props for start/end frames } @@ -401,7 +401,7 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - sipo= (SpaceIpo *)ac.sl; + sipo = (SpaceIpo *)ac.sl; /* if no ghost curves, don't do anything */ if (sipo->ghostCurves.first == NULL) @@ -428,7 +428,7 @@ void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -451,11 +451,11 @@ static void insert_graph_keys(bAnimContext *ac, short mode) int filter; ReportList *reports = ac->reports; - Scene *scene= ac->scene; + Scene *scene = ac->scene; short flag = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -464,20 +464,20 @@ static void insert_graph_keys(bAnimContext *ac, short mode) flag = ANIM_get_keyframing_flags(scene, 1); /* insert keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float cfra; /* adjust current frame for NLA-mapping */ if (adt) - cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else - cfra= (float)CFRA; + cfra = (float)CFRA; /* if there's an id */ if (ale->id) - insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } @@ -497,7 +497,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* which channels to affect? */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* insert keyframes */ insert_graph_keys(&ac, mode); @@ -506,7 +506,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -524,7 +524,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", ""); @@ -532,7 +532,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot) /* ******************** Click-Insert Keyframes Operator ************************* */ -static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) +static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) { bAnimContext ac; bAnimListElem *ale; @@ -545,7 +545,7 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get active F-Curve 'anim-list-element' */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); if (ELEM(NULL, ale, ale->data)) { if (ale) MEM_freeN(ale); return OPERATOR_CANCELLED; @@ -557,12 +557,12 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) */ if (fcurve_is_keyframable(fcu)) { /* get frame and value from props */ - frame= RNA_float_get(op->ptr, "frame"); - val= RNA_float_get(op->ptr, "value"); + frame = RNA_float_get(op->ptr, "frame"); + val = RNA_float_get(op->ptr, "value"); /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */ - adt= ANIM_nla_mapping_get(&ac, ale); - frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); + adt = ANIM_nla_mapping_get(&ac, ale); + frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); /* apply inverse unit-mapping to value to get correct value for F-Curves */ val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1); @@ -584,13 +584,13 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) MEM_freeN(ale); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; } -static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, wmEvent *evt) { bAnimContext ac; ARegion *ar; @@ -603,11 +603,11 @@ static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent * return OPERATOR_CANCELLED; /* store mouse coordinates in View2D space, into the operator's properties */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; - mval[0]= (evt->x - ar->winrct.xmin); - mval[1]= (evt->y - ar->winrct.ymin); + mval[0] = (evt->x - ar->winrct.xmin); + mval[1] = (evt->y - ar->winrct.ymin); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -631,7 +631,7 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100); @@ -641,20 +641,20 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) /* ******************** Copy/Paste Keyframes Operator ************************* */ /* NOTE: the backend code for this is shared with the dopesheet editor */ -static short copy_graph_keys (bAnimContext *ac) +static short copy_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* clear buffer first */ free_anim_copybuf(); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* copy keyframes */ - ok= copy_animedit_keys(ac, &anim_data); + ok = copy_animedit_keys(ac, &anim_data); /* clean up */ BLI_freelistN(&anim_data); @@ -662,18 +662,18 @@ static short copy_graph_keys (bAnimContext *ac) return ok; } -static short paste_graph_keys (bAnimContext *ac, - const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) +static short paste_graph_keys(bAnimContext *ac, + const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ - ok= paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); + ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); /* clean up */ BLI_freelistN(&anim_data); @@ -713,7 +713,7 @@ void GRAPH_OT_copy(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -722,15 +722,15 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const eKeyPasteOffset offset_mode= RNA_enum_get(op->ptr, "offset"); - const eKeyMergeMode merge_mode= RNA_enum_get(op->ptr, "merge"); + const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); + const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* ac.reports by default will be the global reports list, which won't show warnings */ - ac.reports= op->reports; + ac.reports = op->reports; /* paste keyframes - non-zero return means an error occurred while trying to paste */ if (paste_graph_keys(&ac, offset_mode, merge_mode)) { @@ -741,7 +741,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -759,7 +759,7 @@ void GRAPH_OT_paste(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); @@ -767,18 +767,18 @@ void GRAPH_OT_paste(wmOperatorType *ot) /* ******************** Duplicate Keyframes Operator ************************* */ -static void duplicate_graph_keys (bAnimContext *ac) +static void duplicate_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { duplicate_fcurve_keys((FCurve *)ale->key_data); } @@ -803,7 +803,7 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -828,7 +828,7 @@ void GRAPH_OT_duplicate(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -836,20 +836,20 @@ void GRAPH_OT_duplicate(wmOperatorType *ot) /* ******************** Delete Keyframes Operator ************************* */ -static void delete_graph_keys (bAnimContext *ac) +static void delete_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ale->adt; /* delete selected keyframes only */ delete_fcurve_keys(fcu); @@ -880,7 +880,7 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -898,23 +898,23 @@ void GRAPH_OT_delete(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clean Keyframes Operator ************************* */ -static void clean_graph_keys (bAnimContext *ac, float thresh) +static void clean_graph_keys(bAnimContext *ac, float thresh) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) clean_fcurve((FCurve *)ale->key_data, thresh); /* free temp data */ @@ -933,7 +933,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get cleaning threshold */ - thresh= RNA_float_get(op->ptr, "threshold"); + thresh = RNA_float_get(op->ptr, "threshold"); /* clean keyframes */ clean_graph_keys(&ac, thresh); @@ -942,7 +942,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -960,7 +960,7 @@ void GRAPH_OT_clean(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); @@ -970,29 +970,29 @@ void GRAPH_OT_clean(wmOperatorType *ot) /* This operator bakes the data of the selected F-Curves to F-Points */ /* Bake each F-Curve into a set of samples */ -static void bake_graph_curves (bAnimContext *ac, int start, int end) +static void bake_graph_curves(bAnimContext *ac, int start, int end) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - ChannelDriver *driver= fcu->driver; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + ChannelDriver *driver = fcu->driver; /* disable driver so that it don't muck up the sampling process */ - fcu->driver= NULL; + fcu->driver = NULL; /* create samples */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* admin and redraws */ @@ -1004,7 +1004,7 @@ static void bake_graph_curves (bAnimContext *ac, int start, int end) static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - Scene *scene= NULL; + Scene *scene = NULL; int start, end; /* get editor data */ @@ -1013,9 +1013,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) /* for now, init start/end from preview-range extents */ // TODO: add properties for this - scene= ac.scene; - start= PSFRA; - end= PEFRA; + scene = ac.scene; + start = PSFRA; + end = PEFRA; /* bake keyframes */ bake_graph_curves(&ac, start, end); @@ -1025,7 +1025,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) /* set notifier that keyframes have changed */ // NOTE: some distinction between order/number of keyframes and type should be made? - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1043,7 +1043,7 @@ void GRAPH_OT_bake(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; // todo: add props for start/end frames } @@ -1069,9 +1069,9 @@ typedef struct tSoundBakeInfo { /* Sampling callback used to determine the value from the sound to * save in the F-Curve at the specified frame */ -static float fcurve_samplingcb_sound (FCurve *UNUSED(fcu), void *data, float evaltime) +static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float evaltime) { - tSoundBakeInfo *sbi= (tSoundBakeInfo *)data; + tSoundBakeInfo *sbi = (tSoundBakeInfo *)data; int position = evaltime - sbi->cfra; if ((position < 0) || (position >= sbi->length)) @@ -1090,7 +1090,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) int filter; tSoundBakeInfo sbi; - Scene *scene= NULL; + Scene *scene = NULL; int start, end; char path[FILE_MAX]; @@ -1101,20 +1101,20 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); - scene= ac.scene; /* current scene */ + scene = ac.scene; /* current scene */ /* store necessary data for the baking steps */ sbi.samples = AUD_readSoundBuffer(path, - RNA_float_get(op->ptr, "low"), - RNA_float_get(op->ptr, "high"), - RNA_float_get(op->ptr, "attack"), - RNA_float_get(op->ptr, "release"), - RNA_float_get(op->ptr, "threshold"), - RNA_boolean_get(op->ptr, "accumulate"), - RNA_boolean_get(op->ptr, "use_additive"), - RNA_boolean_get(op->ptr, "square"), - RNA_float_get(op->ptr, "sthreshold"), - FPS, &sbi.length); + RNA_float_get(op->ptr, "low"), + RNA_float_get(op->ptr, "high"), + RNA_float_get(op->ptr, "attack"), + RNA_float_get(op->ptr, "release"), + RNA_float_get(op->ptr, "threshold"), + RNA_boolean_get(op->ptr, "accumulate"), + RNA_boolean_get(op->ptr, "use_additive"), + RNA_boolean_get(op->ptr, "square"), + RNA_float_get(op->ptr, "sthreshold"), + FPS, &sbi.length); if (sbi.samples == NULL) { BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); @@ -1126,12 +1126,12 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) end = CFRA + sbi.length - 1; /* filter anim channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through all selected F-Curves, replacing its data with the sound samples */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* sample the sound */ fcurve_store_samples(fcu, &sbi, start, end, fcurve_samplingcb_sound); @@ -1147,7 +1147,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that 'keyframes' have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1163,7 +1163,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op) #endif //WITH_AUDASPACE -static int graphkeys_sound_bake_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; @@ -1187,10 +1187,10 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1); @@ -1208,18 +1208,18 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) */ /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ -static void sample_graph_keys (bAnimContext *ac) +static void sample_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) sample_fcurve((FCurve *)ale->key_data); /* admin and redraws */ @@ -1243,7 +1243,7 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1260,7 +1260,7 @@ void GRAPH_OT_sample(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1270,8 +1270,8 @@ void GRAPH_OT_sample(wmOperatorType *ot) /* ******************** Set Extrapolation-Type Operator *********************** */ /* defines for make/clear cyclic extrapolation tools */ -#define MAKE_CYCLIC_EXPO -1 -#define CLEAR_CYCLIC_EXPO -2 +#define MAKE_CYCLIC_EXPO -1 +#define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ static EnumPropertyItem prop_graphkeys_expo_types[] = { @@ -1291,16 +1291,16 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; if (mode >= 0) { /* just set mode setting */ - fcu->extend= mode; + fcu->extend = mode; } else { /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation @@ -1315,7 +1315,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) } else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ - FModifier *fcm, *fcn=NULL; + FModifier *fcm, *fcn = NULL; for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; @@ -1343,7 +1343,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setexpo_graph_keys(&ac, mode); @@ -1352,7 +1352,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1370,7 +1370,7 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", ""); @@ -1384,16 +1384,16 @@ static void setipo_graph_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); /* cleanup */ @@ -1412,7 +1412,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setipo_graph_keys(&ac, mode); @@ -1421,7 +1421,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1439,7 +1439,7 @@ void GRAPH_OT_interpolation_type(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); @@ -1454,18 +1454,18 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode); - KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); + KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { @@ -1489,7 +1489,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ sethandles_graph_keys(&ac, mode); @@ -1498,12 +1498,12 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } - void GRAPH_OT_handle_type (wmOperatorType *ot) +void GRAPH_OT_handle_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Handle Type"; @@ -1516,7 +1516,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); @@ -1536,39 +1536,39 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) typedef struct tEulerFilter { struct tEulerFilter *next, *prev; - ID *id; /* ID-block which owns the channels */ - FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ - char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ + ID *id; /* ID-block which owns the channels */ + FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ + char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ } tEulerFilter; -static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) +static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; ListBase eulers = {NULL, NULL}; - tEulerFilter *euf= NULL; - int groups=0, failed=0; + tEulerFilter *euf = NULL; + int groups = 0, failed = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* The process is done in two passes: - * 1) Sets of three related rotation curves are identified from the selected channels, + * 1) Sets of three related rotation curves are identified from the selected channels, * and are stored as a single 'operation unit' for the next step * 2) Each set of three F-Curves is processed for each keyframe, with the values being - * processed as necessary + * processed as necessary */ /* step 1: extract only the rotation f-curves */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; /* check if this is an appropriate F-Curve @@ -1579,8 +1579,8 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) continue; else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) { BKE_reportf(op->reports, RPT_WARNING, - "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", - (ale->id)? ale->id->name:"<No ID>", fcu->rna_path, fcu->array_index); + "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", + (ale->id) ? ale->id->name : "<No ID>", fcu->rna_path, fcu->array_index); continue; } @@ -1588,19 +1588,19 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) * so if the paths or the ID's don't match up, then a curve needs to be added * to a new group */ - if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path)==0)) { + if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path) == 0)) { /* this should be fine to add to the existing group then */ - euf->fcurves[fcu->array_index]= fcu; + euf->fcurves[fcu->array_index] = fcu; } else { /* just add to a new block */ - euf= MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); + euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); BLI_addtail(&eulers, euf); groups++; - euf->id= ale->id; + euf->id = ale->id; euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */ - euf->fcurves[fcu->array_index]= fcu; + euf->fcurves[fcu->array_index] = fcu; } } BLI_freelistN(&anim_data); @@ -1613,7 +1613,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) /* step 2: go through each set of curves, processing the values at each keyframe * - it is assumed that there must be a full set of keyframes at each keyframe position */ - for (euf= eulers.first; euf; euf= euf->next) { + for (euf = eulers.first; euf; euf = euf->next) { int f; /* sanity check: ensure that there are enough F-Curves to work on in this group */ @@ -1621,11 +1621,11 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { /* report which components are missing */ BKE_reportf(op->reports, RPT_WARNING, - "Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'", - (euf->fcurves[0]==NULL)? "X":"", - (euf->fcurves[1]==NULL)? "Y":"", - (euf->fcurves[2]==NULL)? "Z":"", - euf->id->name, euf->rna_path); + "Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'", + (euf->fcurves[0] == NULL) ? "X" : "", + (euf->fcurves[1] == NULL) ? "Y" : "", + (euf->fcurves[2] == NULL) ? "Z" : "", + euf->id->name, euf->rna_path); /* keep track of number of failed sets, and carry on to next group */ failed++; @@ -1636,7 +1636,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) // FIXME: there are more complicated methods that will be needed to fix more cases than just some for (f = 0; f < 3; f++) { FCurve *fcu = euf->fcurves[f]; - BezTriple *bezt, *prev=NULL; + BezTriple *bezt, *prev = NULL; unsigned int i; /* skip if not enough vets to do a decent analysis of... */ @@ -1644,7 +1644,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) continue; /* prev follows bezt, bezt = "current" point to be fixed */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, prev=bezt, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, prev = bezt, bezt++) { /* our method depends on determining a "difference" from the previous vert */ if (prev == NULL) continue; @@ -1661,7 +1661,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) bezt->vec[2][1] += fac; } } - else /* if (prev->vec[1][1] < bezt->vec[1][1]) */ { + else { /* if (prev->vec[1][1] < bezt->vec[1][1]) */ while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) { bezt->vec[0][1] -= fac; bezt->vec[1][1] -= fac; @@ -1677,20 +1677,20 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) /* updates + finishing warnings */ if (failed == groups) { BKE_report(op->reports, RPT_ERROR, - "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); return OPERATOR_CANCELLED; } else { if (failed) { BKE_report(op->reports, RPT_ERROR, - "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); } /* validate keyframes after editing */ ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done at last */ return OPERATOR_FINISHED; @@ -1709,7 +1709,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Jump to Selected Frames Operator *********************** */ @@ -1718,7 +1718,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditData ked; @@ -1731,11 +1731,11 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) memset(&ked, 0, sizeof(KeyframeEditData)); /* loop over action data, averaging values */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(&ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(&ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); @@ -1749,24 +1749,24 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|ANIM_UNITCONV_ONLYKEYS); + ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS); } BLI_freelistN(&anim_data); /* set the new current frame and cursor values, based on the average time and value */ if (ked.i1) { - SpaceIpo *sipo= (SpaceIpo *)ac.sl; - Scene *scene= ac.scene; + SpaceIpo *sipo = (SpaceIpo *)ac.sl; + Scene *scene = ac.scene; /* take the average values, rounding to the nearest int for the current frame */ - CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f); - SUBFRA= 0.f; - sipo->cursorVal= ked.f2 / (float)ked.i1; + CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f); + SUBFRA = 0.f; + sipo->cursorVal = ked.f2 / (float)ked.i1; } /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -1783,7 +1783,7 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Keyframes Operator *********************** */ @@ -1810,26 +1810,26 @@ static void snap_graph_keys(bAnimContext *ac, short mode) KeyframeEditFunc edit_cb; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_snap(mode); + edit_cb = ANIM_editkeyframes_snap(mode); memset(&ked, 0, sizeof(KeyframeEditData)); - ked.scene= ac->scene; + ked.scene = ac->scene; if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) { - ked.list.first= (ac->markers) ? ac->markers->first : NULL; - ked.list.last= (ac->markers) ? ac->markers->last : NULL; + ked.list.first = (ac->markers) ? ac->markers->first : NULL; + ked.list.last = (ac->markers) ? ac->markers->last : NULL; } else if (mode == GRAPHKEYS_SNAP_VALUE) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - ked.f1= (sipo) ? sipo->cursorVal : 0.0f; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; } /* snap keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); @@ -1861,7 +1861,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get snapping mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* snap keyframes */ snap_graph_keys(&ac, mode); @@ -1870,7 +1870,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1888,7 +1888,7 @@ void GRAPH_OT_snap(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", ""); @@ -1917,37 +1917,37 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) KeyframeEditFunc edit_cb; /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_mirror(mode); + edit_cb = ANIM_editkeyframes_mirror(mode); memset(&ked, 0, sizeof(KeyframeEditData)); - ked.scene= ac->scene; + ked.scene = ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? if (mode == GRAPHKEYS_MIRROR_MARKER) { - TimeMarker *marker= NULL; + TimeMarker *marker = NULL; /* find first selected marker */ - marker= ED_markers_get_first_selected(ac->markers); + marker = ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) - ked.f1= (float)marker->frame; + ked.f1 = (float)marker->frame; else return; } else if (mode == GRAPHKEYS_MIRROR_VALUE) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - ked.f1= (sipo) ? sipo->cursorVal : 0.0f; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); @@ -1961,7 +1961,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS|ANIM_UNITCONV_RESTORE); + ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE); } BLI_freelistN(&anim_data); @@ -1979,7 +1979,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get mirroring mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* mirror keyframes */ mirror_graph_keys(&ac, mode); @@ -1988,7 +1988,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2006,7 +2006,7 @@ void GRAPH_OT_mirror(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", ""); @@ -2026,11 +2026,11 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* smooth keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* For now, we can only smooth by flattening handles AND smoothing curve values. * Perhaps the mode argument could be removed, as that functionality is offerred through * Snap->Flatten Handles anyway. @@ -2043,7 +2043,7 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2060,7 +2060,7 @@ void GRAPH_OT_smooth(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -2069,19 +2069,19 @@ void GRAPH_OT_smooth(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ /* present a special customised popup menu for this, with some filtering */ -static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int graph_fmodifier_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1); uiPopupMenu *pup; uiLayout *layout; int i; - pup= uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE); + layout = uiPupMenuLayout(pup); /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); PointerRNA props_ptr; /* check if modifier is valid for this context */ @@ -2089,11 +2089,11 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU continue; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE, - NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); - /* the only thing that gets set from the menu is the type of F-Modifier to add */ + props_ptr = uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE, + NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + /* the only thing that gets set from the menu is the type of F-Modifier to add */ RNA_enum_set(&props_ptr, "type", i); - /* the following properties are just repeats of existing ones... */ + /* the following properties are just repeats of existing ones... */ RNA_boolean_set(&props_ptr, "only_active", RNA_boolean_get(op->ptr, "only_active")); } uiItemS(layout); @@ -2116,23 +2116,23 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get type of modifier to add */ - type= RNA_enum_get(op->ptr, "type"); + type = RNA_enum_get(op->ptr, "type"); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (RNA_boolean_get(op->ptr, "only_active")) - filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled? + filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled? else - filter |= (ANIMFILTER_SEL|ANIMFILTER_CURVE_VISIBLE); + filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add f-modifier to each curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; FModifier *fcm; /* add F-Modifier of specified type to active F-Curve, and make it the active one */ - fcm= add_fmodifier(&fcu->modifiers, type); + fcm = add_fmodifier(&fcu->modifiers, type); if (fcm) set_active_fmodifier(&fcu->modifiers, fcm); else { @@ -2165,7 +2165,7 @@ void GRAPH_OT_fmodifier_add(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); @@ -2188,14 +2188,14 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) free_fmodifiers_copybuf(); /* get the active F-Curve */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); /* if this exists, call the copy F-Modifiers API function */ if (ale && ale->data) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: when 'active' vs 'all' boolean is added, change last param! - ok= ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); + ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); /* free temp data now */ MEM_freeN(ale); @@ -2222,7 +2222,7 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); @@ -2235,19 +2235,19 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: do we want to replace existing modifiers? add user pref for that! ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0); @@ -2262,7 +2262,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2284,7 +2284,7 @@ void GRAPH_OT_fmodifier_paste(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index d7274b07985..47b55ae90ab 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -70,14 +70,14 @@ void GRAPH_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ enum { - GRAPHKEYS_LRSEL_TEST = 0, + GRAPHKEYS_LRSEL_TEST = 0, GRAPHKEYS_LRSEL_LEFT, GRAPHKEYS_LRSEL_RIGHT } eGraphKeys_LeftRightSelect_Mode; /* defines for column-select mode */ enum { - GRAPHKEYS_COLUMNSEL_KEYS = 0, + GRAPHKEYS_COLUMNSEL_KEYS = 0, GRAPHKEYS_COLUMNSEL_CFRA, GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, @@ -86,7 +86,7 @@ enum { /* ***************************************** */ /* graph_edit.c */ -void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected); +void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected); void GRAPH_OT_previewrange_set(struct wmOperatorType *ot); void GRAPH_OT_view_all(struct wmOperatorType *ot); @@ -172,4 +172,3 @@ void graphedit_operatortypes(void); #endif /* __GRAPH_INTERN_H__ */ - diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 2887fa1c881..62aebcb4edc 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -69,22 +69,22 @@ /* Set the new frame number */ static void graphview_cursor_apply(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceIpo *sipo= CTX_wm_space_graph(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); /* adjust the frame * NOTE: sync this part of the code with ANIM_OT_change_frame */ - CFRA= RNA_int_get(op->ptr, "frame"); - SUBFRA=0.f; + CFRA = RNA_int_get(op->ptr, "frame"); + SUBFRA = 0.f; sound_seek_scene(bmain, scene); /* set the cursor value */ - sipo->cursorVal= RNA_float_get(op->ptr, "value"); + sipo->cursorVal = RNA_float_get(op->ptr, "value"); /* send notifiers - notifiers for frame should force an update for both vars ok... */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* ... */ @@ -101,7 +101,7 @@ static int graphview_cursor_exec(bContext *C, wmOperator *op) /* set the operator properties from the initial event */ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); float viewx, viewy; /* abort if not active region (should not really be possible) */ @@ -112,8 +112,8 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *even UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); /* store the values in the operator properties */ - /* frame is rounded to the nearest int, since frames are ints */ - RNA_int_set(op->ptr, "frame", (int)floor(viewx+0.5f)); + /* frame is rounded to the nearest int, since frames are ints */ + RNA_int_set(op->ptr, "frame", (int)floor(viewx + 0.5f)); RNA_float_set(op->ptr, "value", viewy); } @@ -153,7 +153,7 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, wmEvent *event) /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ - if (event->val==KM_RELEASE) + if (event->val == KM_RELEASE) return OPERATOR_FINISHED; break; } @@ -175,7 +175,7 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -198,7 +198,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_ghost_curves_clear); /* keyframes */ - /* selection */ + /* selection */ WM_operatortype_append(GRAPH_OT_clickselect); WM_operatortype_append(GRAPH_OT_select_all_toggle); WM_operatortype_append(GRAPH_OT_select_border); @@ -208,7 +208,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_select_less); WM_operatortype_append(GRAPH_OT_select_leftright); - /* editing */ + /* editing */ WM_operatortype_append(GRAPH_OT_snap); WM_operatortype_append(GRAPH_OT_mirror); WM_operatortype_append(GRAPH_OT_frame_jump); @@ -241,9 +241,10 @@ void ED_operatormacros_graph(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); @@ -253,7 +254,7 @@ void ED_operatormacros_graph(void) /* ************************** registration - keymaps **********************************/ -static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; @@ -261,95 +262,95 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.show_handles"); - /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons - * This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values - */ + /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons + * This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values + */ WM_keymap_add_item(keymap, "GRAPH_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); /* graph_select.c - selection tools */ - /* click-select */ + /* click-select */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); /* select left/right */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); - /* deselect all */ + /* deselect all */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); - RNA_boolean_set(kmi->ptr, "include_handles", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "include_handles", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - RNA_boolean_set(kmi->ptr, "include_handles", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "include_handles", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); - RNA_boolean_set(kmi->ptr, "include_handles", TRUE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - RNA_boolean_set(kmi->ptr, "include_handles", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "include_handles", TRUE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "include_handles", TRUE); - /* column select */ + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN); - /* select more/less */ + /* select more/less */ WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - /* select linked */ + /* select linked */ WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0); /* graph_edit.c */ - /* snap - current frame to selected keys */ - // TODO: maybe since this is called jump, we're better to have it on <something>-J? - WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* snap - current frame to selected keys */ + // TODO: maybe since this is called jump, we're better to have it on <something>-J? + WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - /* menu + single-step transform */ + /* menu + single-step transform */ WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); @@ -357,7 +358,7 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); - /* destructive */ + /* destructive */ WM_keymap_add_item(keymap, "GRAPH_OT_clean", OKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); @@ -369,27 +370,27 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "GRAPH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - /* insertkey */ + /* insertkey */ WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); - /* copy/paste */ + /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); - /* auto-set range */ - WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + /* auto-set range */ + WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - /* F-Modifiers */ - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* F-Modifiers */ + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "only_active", FALSE); /* animation module */ - /* channels list - * NOTE: these operators were originally for the channels list, but are added here too for convenience... - */ + /* channels list + * NOTE: these operators were originally for the channels list, but are added here too for convenience... + */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); /* transform system */ @@ -408,7 +409,7 @@ void graphedit_keymap(wmKeyConfig *keyconf) /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0); - /* extrapolation works on channels, not keys */ + /* extrapolation works on channels, not keys */ WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); /* channels */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 7c72fa0834d..33e32363cf5 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -76,48 +76,48 @@ /* Deselects keyframes in the Graph Editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all + * - test: check if select or deselect all * - sel: how to select keyframes * 0 = deselect * 1 = select * 2 = invert * - do_channels: whether to affect selection status of channels */ -static void deselect_graph_keys (bAnimContext *ac, short test, short sel, short do_channels) +static void deselect_graph_keys(bAnimContext *ac, short test, short sel, short do_channels) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - KeyframeEditData ked= {{NULL}}; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; /* determine type-based settings */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* init BezTriple looping data */ - test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } } /* convert sel to selectmode, and use that to get editor */ - sel_cb= ANIM_editkeyframes_select(sel); + sel_cb = ANIM_editkeyframes_select(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* Keyframes First */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); @@ -161,7 +161,7 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) deselect_graph_keys(&ac, 1, SELECT_ADD, TRUE); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -178,7 +178,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -186,7 +186,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION) + * -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE) * -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE) @@ -197,16 +197,16 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) * this, and allow handles to be considered independently too. * Also, for convenience, handles should get same status as keyframe (if it was within bounds). */ -static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles) +static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter, mapping_flag; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ @@ -214,29 +214,29 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing/validation funcs */ - select_cb= ANIM_editkeyframes_select(selectmode); - ok_cb= ANIM_editkeyframes_ok(mode); + select_cb = ANIM_editkeyframes_select(selectmode); + ok_cb = ANIM_editkeyframes_ok(mode); /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - ked.data= &rectf; + ked.data = &rectf; /* treat handles separately? */ if (incl_handles) { ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES; - mapping_flag= 0; + mapping_flag = 0; } else - mapping_flag= ANIM_UNITCONV_ONLYKEYS; + mapping_flag = ANIM_UNITCONV_ONLYKEYS; /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag); @@ -245,19 +245,19 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho * guess when a callback might use something different */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles==0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); /* set horizontal range (if applicable) * NOTE: these values are only used for x-range and y-range but not region - * (which uses ked.data, i.e. rectf) + * (which uses ked.data, i.e. rectf) */ if (mode != BEZT_OK_VALUERANGE) { - ked.f1= rectf.xmin; - ked.f2= rectf.xmax; + ked.f1 = rectf.xmin; + ked.f2 = rectf.xmax; } else { - ked.f1= rectf.ymin; - ked.f2= rectf.ymax; + ked.f1 = rectf.ymin; + ked.f2 = rectf.ymax; } /* firstly, check if any keyframes will be hit by this */ @@ -275,10 +275,10 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho /* un-apply NLA mapping from all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles==0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|mapping_flag); + ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag); } /* cleanup */ @@ -291,7 +291,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; short incl_handles; int extend; @@ -300,7 +300,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, TRUE); @@ -308,10 +308,10 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * - 'gesture_mode' from the operator specifies how to select * - 'include_handles' from the operator specifies whether to include handles in the selection */ - if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT) - selectmode= SELECT_ADD; + if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT) + selectmode = SELECT_ADD; else - selectmode= SELECT_SUBTRACT; + selectmode = SELECT_SUBTRACT; incl_handles = RNA_boolean_get(op->ptr, "include_handles"); @@ -329,18 +329,18 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= BEZT_OK_FRAMERANGE; + mode = BEZT_OK_FRAMERANGE; else - mode= BEZT_OK_VALUERANGE; + mode = BEZT_OK_VALUERANGE; } else - mode= BEZT_OK_REGION; + mode = BEZT_OK_REGION; /* apply borderselect action */ borderselect_graphkeys(&ac, rect, mode, selectmode, incl_handles); /* send notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -361,7 +361,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -392,14 +392,14 @@ static EnumPropertyItem prop_column_select_types[] = { /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c * should de-duplicate - campbell */ -static void markers_selectkeys_between (bAnimContext *ac) +static void markers_selectkeys_between(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; float min, max; /* get extreme markers */ @@ -408,19 +408,19 @@ static void markers_selectkeys_between (bAnimContext *ac) max += 0.5f; /* get editing funcs + data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); - ked.f1= min; - ked.f2= max; + ked.f1 = min; + ked.f2 = max; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys in-between */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -438,13 +438,13 @@ static void markers_selectkeys_between (bAnimContext *ac) /* Selects all visible keyframes in the same frames as the specified elements */ -static void columnselect_graph_keys (bAnimContext *ac, short mode) +static void columnselect_graph_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked; @@ -455,10 +455,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) /* build list of columns */ switch (mode) { case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); BLI_freelistN(&anim_data); @@ -466,10 +466,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ - ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - ce->cfra= (float)CFRA; + ce->cfra = (float)CFRA; break; case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ @@ -481,24 +481,24 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) } /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(SELECT_ADD); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ - for (ce= ked.list.first; ce; ce= ce->next) { + for (ce = ked.list.first; ce; ce = ce->next) { /* set frame for validation callback to refer to */ - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); /* select elements with frame number matching cfraelem */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -522,7 +522,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* action to take depends on the mode */ - mode= RNA_enum_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); @@ -530,7 +530,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) columnselect_graph_keys(&ac, mode); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -547,7 +547,7 @@ void GRAPH_OT_select_column(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); @@ -555,11 +555,11 @@ void GRAPH_OT_select_column(wmOperatorType *ot) /* ******************** Select Linked Operator *********************** */ -static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -571,11 +571,11 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { @@ -588,7 +588,7 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -605,15 +605,15 @@ void GRAPH_OT_select_linked(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ -static void select_moreless_graph_keys (bAnimContext *ac, short mode) +static void select_moreless_graph_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -622,22 +622,22 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* init selmap building data */ - build_cb= ANIM_editkeyframes_buildselmap(mode); + build_cb = ANIM_editkeyframes_buildselmap(mode); memset(&ked, 0, sizeof(KeyframeEditData)); /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; /* build up map of whether F-Curve's keyframes should be selected or not */ - ked.data= MEM_callocN(fcu->totvert, "selmap graphEdit"); + ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); /* based on this map, adjust the selection status of the keyframes */ @@ -645,7 +645,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* free the selmap used here */ MEM_freeN(ked.data); - ked.data= NULL; + ked.data = NULL; } /* Cleanup */ @@ -654,7 +654,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* ----------------- */ -static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -666,7 +666,7 @@ static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_graph_keys(&ac, SELMAP_MORE); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -683,12 +683,12 @@ void GRAPH_OT_select_more(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ----------------- */ -static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -700,7 +700,7 @@ static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_graph_keys(&ac, SELMAP_LESS); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -717,7 +717,7 @@ void GRAPH_OT_select_less(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select Left/Right Operator ************************* */ @@ -733,19 +733,19 @@ static EnumPropertyItem prop_graphkeys_leftright_select_types[] = { /* --------------------------------- */ -static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode) +static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; - Scene *scene= ac->scene; + KeyframeEditData ked = {{NULL}}; + Scene *scene = ac->scene; /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -754,8 +754,8 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short } /* set callbacks and editing data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(select_mode); if (leftright == GRAPHKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; @@ -767,12 +767,12 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -789,7 +789,7 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short /* ----------------- */ -static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) +static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -801,9 +801,9 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == GRAPHKEYS_LRSEL_TEST) @@ -813,12 +813,12 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) graphkeys_select_leftright(&ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -829,9 +829,9 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve /* handle mode-based testing */ if (leftright == GRAPHKEYS_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -854,12 +854,12 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) ot->description = "Select keyframes to the left or the right of the current frame"; /* api callbacks */ - ot->invoke= graphkeys_select_leftright_invoke; + ot->invoke = graphkeys_select_leftright_invoke; ot->exec = graphkeys_select_leftright_exec; ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", ""); @@ -880,26 +880,26 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) typedef struct tNearestVertInfo { struct tNearestVertInfo *next, *prev; - FCurve *fcu; /* F-Curve that keyframe comes from */ + FCurve *fcu; /* F-Curve that keyframe comes from */ - BezTriple *bezt; /* keyframe to consider */ - FPoint *fpt; /* sample point to consider */ + BezTriple *bezt; /* keyframe to consider */ + FPoint *fpt; /* sample point to consider */ - short hpoint; /* the handle index that we hit (eHandleIndex) */ - short sel; /* whether the handle is selected or not */ - int dist; /* distance from mouse to vert */ + short hpoint; /* the handle index that we hit (eHandleIndex) */ + short sel; /* whether the handle is selected or not */ + int dist; /* distance from mouse to vert */ } tNearestVertInfo; /* Tags for the type of graph vert that we have */ typedef enum eGraphVertIndex { - NEAREST_HANDLE_LEFT = -1, + NEAREST_HANDLE_LEFT = -1, NEAREST_HANDLE_KEY, NEAREST_HANDLE_RIGHT } eGraphVertIndex; /* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */ // TODO: perhaps this should depend a bit on the size that the user set the vertices to be? -#define GVERTSEL_TOL 10 +#define GVERTSEL_TOL 10 /* ....... */ @@ -908,13 +908,13 @@ typedef enum eGraphVertIndex { static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt) { if (sipo->flag & SIPO_NOHANDLES) return 0; - if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt)==0) return 0; + if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt) == 0) return 0; return 1; } /* check if the given vertex is within bounds or not */ // TODO: should we return if we hit something? -static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2]) +static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2]) { /* Keyframes or Samples? */ if (bezt) { @@ -922,16 +922,16 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f /* convert from data-space to screen coordinates * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle, - * needed to access the relevant vertex coordinates in the 3x3 - * 'vec' matrix + * needed to access the relevant vertex coordinates in the 3x3 + * 'vec' matrix */ - UI_view2d_view_to_region(v2d, bezt->vec[hpoint+1][0], bezt->vec[hpoint+1][1], &screen_co[0], &screen_co[1]); + UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]); /* check if distance from mouse cursor to vert in screen space is within tolerance */ - // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... + // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... //dist = len_v2v2(mval, screen_co); - dist = sqrt((mval[0] - screen_co[0])*(mval[0] - screen_co[0]) + - (mval[1] - screen_co[1])*(mval[1] - screen_co[1])); + dist = sqrt((mval[0] - screen_co[0]) * (mval[0] - screen_co[0]) + + (mval[1] - screen_co[1]) * (mval[1] - screen_co[1])); if (dist <= GVERTSEL_TOL) { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; @@ -941,7 +941,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f if ((nvi) && (nvi->fcu == fcu)) { /* replace if we are closer, or if equal and that one wasn't selected but we are... */ if ( (nvi->dist > dist) || ((nvi->sel == 0) && BEZSELECTED(bezt)) ) - replace= 1; + replace = 1; } /* add new if not replacing... */ if (replace == 0) @@ -953,7 +953,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f nvi->hpoint = hpoint; nvi->dist = dist; - nvi->sel= BEZSELECTED(bezt); // XXX... should this use the individual verts instead? + nvi->sel = BEZSELECTED(bezt); // XXX... should this use the individual verts instead? /* add to list of matches if appropriate... */ if (replace == 0) @@ -966,27 +966,27 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f } /* helper for find_nearest_fcurve_vert() - build the list of nearest matches */ -static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ListBase *matches) +static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - View2D *v2d= &ac->ar->v2d; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + View2D *v2d = &ac->ar->v2d; /* get curves to search through * - if the option to only show keyframes that belong to selected F-Curves is enabled, * include the 'only selected' flag... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); @@ -996,17 +996,17 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); if (fcu->bezt) { - BezTriple *bezt1=fcu->bezt, *prevbezt=NULL; + BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL; int i; - for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) { + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) { /* keyframe */ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval); /* handles - only do them if they're visible */ if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) { /* first handle only visible if previous segment had handles */ - if ((!prevbezt && (bezt1->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) { + if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval); } @@ -1035,7 +1035,7 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], } /* helper for find_nearest_fcurve_vert() - get the best match to use */ -static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) +static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) { tNearestVertInfo *nvi = NULL; short found = 0; @@ -1047,7 +1047,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) /* if list only has 1 item, remove it from the list and return */ if (matches->first == matches->last) { /* need to remove from the list, otherwise it gets freed and then we can't return it */ - nvi= matches->first; + nvi = matches->first; BLI_remlink(matches, nvi); return nvi; @@ -1066,7 +1066,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) else { /* if vert is selected, we've got what we want... */ if (nvi->sel) - found= 1; + found = 1; } } @@ -1081,7 +1081,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) /* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates) * NOTE: the match info found must still be freed */ -static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int mval[2]) +static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2]) { ListBase matches = {NULL, NULL}; tNearestVertInfo *nvi; @@ -1090,7 +1090,7 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m get_nearest_fcurve_verts_list(ac, mval, &matches); /* step 2: find the best vert */ - nvi= get_best_nearest_fcurve_vert(&matches); + nvi = get_best_nearest_fcurve_vert(&matches); BLI_freelistN(&matches); @@ -1101,11 +1101,11 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m /* ------------------- */ /* option 1) select keyframe directly under mouse */ -static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_mode, short curves_only) +static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_mode, short curves_only) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; tNearestVertInfo *nvi; - BezTriple *bezt= NULL; + BezTriple *bezt = NULL; /* find the beztriple that we're selecting, and the handle that was clicked on */ nvi = find_nearest_fcurve_vert(ac, mval); @@ -1117,7 +1117,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* deselect all other curves? */ if (select_mode == SELECT_REPLACE) { /* reset selection mode */ - select_mode= SELECT_ADD; + select_mode = SELECT_ADD; /* deselect all other keyframes (+ F-Curves too) */ deselect_graph_keys(ac, 0, SELECT_SUBTRACT, TRUE); @@ -1132,10 +1132,10 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* if points can be selected on this F-Curve */ // TODO: what about those with no keyframes? - if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED)==0)) { + if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) { /* only if there's keyframe */ if (nvi->bezt) { - bezt= nvi->bezt; /* used to check bezt seletion is set */ + bezt = nvi->bezt; /* used to check bezt seletion is set */ /* depends on selection mode */ if (select_mode == SELECT_INVERT) { /* keyframe - invert select of all */ @@ -1182,7 +1182,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ memset(&ked, 0, sizeof(KeyframeEditData)); /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); + select_cb = ANIM_editkeyframes_select(select_mode); /* select all keyframes */ ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL); @@ -1212,7 +1212,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */ /* needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY) otherwise the active flag won't be set [#26452] */ if (nvi->fcu->flag & FCURVE_SELECTED) { - int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, ANIMTYPE_FCURVE); } @@ -1224,9 +1224,9 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* (see graphkeys_select_leftright) */ /* Option 3) Selects all visible keyframes in the same frame as the mouse click */ -static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short select_mode) +static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short select_mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -1245,14 +1245,14 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short /* get frame number on which elements should be selected */ // TODO: should we restrict to integer frames only? if (nvi->bezt) - selx= nvi->bezt->vec[1][0]; + selx = nvi->bezt->vec[1][0]; else if (nvi->fpt) - selx= nvi->fpt->vec[0]; + selx = nvi->fpt->vec[0]; /* if select mode is replace, deselect all keyframes first */ - if (select_mode==SELECT_REPLACE) { + if (select_mode == SELECT_REPLACE) { /* reset selection mode to add to selection */ - select_mode= SELECT_ADD; + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -1264,23 +1264,23 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short memset(&ked, 0, sizeof(KeyframeEditData)); /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else - ked.f1= selx; + ked.f1 = selx; /* select elements with frame number matching cfra */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -1306,9 +1306,9 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out action to take */ if (RNA_boolean_get(op->ptr, "column")) { @@ -1325,10 +1325,10 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev } /* set notifier that keyframe selection (and also channel selection in some cases) has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void GRAPH_OT_clickselect(wmOperatorType *ot) diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 46c886b7d3c..93dfd3644dd 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -54,7 +54,7 @@ #include "ED_anim_api.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* ************************************************************** */ /* Active F-Curve */ @@ -65,17 +65,17 @@ * * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome */ -bAnimListElem *get_active_fcurve_channel (bAnimContext *ac) +bAnimListElem *get_active_fcurve_channel(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE); + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* We take the first F-Curve only, since some other ones may have had 'active' flag set * if they were from linked data. */ if (items) { - bAnimListElem *ale= (bAnimListElem *)anim_data.first; + bAnimListElem *ale = (bAnimListElem *)anim_data.first; /* remove first item from list, then free the rest of the list and return the stored one */ BLI_remlink(&anim_data, ale); @@ -97,7 +97,7 @@ int graphop_visible_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; short found = 0; @@ -114,13 +114,13 @@ int graphop_visible_keyframes_poll(bContext *C) /* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable * stopping on the first successful match */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; - for (ale = anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; /* visible curves for selection must fulfill the following criteria: * - it has bezier keyframes @@ -146,7 +146,7 @@ int graphop_editable_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; short found = 0; @@ -163,13 +163,13 @@ int graphop_editable_keyframes_poll(bContext *C) /* loop over the editable F-Curves, and see if they're suitable * stopping on the first successful match */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; - for (ale = anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; /* editable curves must fulfill the following criteria: * - it has bezier keyframes @@ -195,8 +195,8 @@ int graphop_active_fcurve_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; - ScrArea *sa= CTX_wm_area(C); - short has_fcurve= 0; + ScrArea *sa = CTX_wm_area(C); + short has_fcurve = 0; /* firstly, check if in Graph Editor */ // TODO: also check for region? @@ -208,15 +208,15 @@ int graphop_active_fcurve_poll(bContext *C) return 0; /* try to get the Active F-Curve */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); if (ale == NULL) return 0; /* free temp data... */ - has_fcurve= ((ale->data) && (ale->type == ANIMTYPE_FCURVE)); + has_fcurve = ((ale->data) && (ale->type == ANIMTYPE_FCURVE)); if (has_fcurve) { - FCurve *fcu= (FCurve *)ale->data; - has_fcurve= (fcu->flag & FCURVE_VISIBLE)!=0; + FCurve *fcu = (FCurve *)ale->data; + has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0; } MEM_freeN(ale); @@ -230,7 +230,7 @@ int graphop_selected_fcurve_poll(bContext *C) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; @@ -246,7 +246,7 @@ int graphop_selected_fcurve_poll(bContext *C) /* get the editable + selected F-Curves, and as long as we got some, we can return * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 1b60a0a39ac..ffff86df4eb 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -61,7 +61,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* ******************** manage regions ********************* */ @@ -69,20 +69,20 @@ ARegion *graph_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after main */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for graph"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for graph"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; @@ -94,71 +94,71 @@ ARegion *graph_has_buttons_region(ScrArea *sa) static SpaceLink *graph_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceIpo *sipo; /* Graph Editor - general stuff */ - sipo= MEM_callocN(sizeof(SpaceIpo), "init graphedit"); - sipo->spacetype= SPACE_IPO; + sipo = MEM_callocN(sizeof(SpaceIpo), "init graphedit"); + sipo->spacetype = SPACE_IPO; - sipo->autosnap= SACTSNAP_FRAME; + sipo->autosnap = SACTSNAP_FRAME; /* allocate DopeSheet data for Graph Editor */ - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)scene; + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)scene; /* settings for making it easier by default to just see what you're interested in tweaking */ sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; sipo->flag |= SIPO_SELVHANDLESONLY; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "header for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channels */ - ar= MEM_callocN(sizeof(ARegion), "channels area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "channels area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); /* ui buttons */ - ar= MEM_callocN(sizeof(ARegion), "buttons area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "buttons area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "main area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = 0.0f; ar->v2d.tot.ymin = (float)scene->r.sfra - 10.0f; ar->v2d.tot.xmax = (float)scene->r.efra; ar->v2d.tot.ymax = 10.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= FLT_MIN; - ar->v2d.min[1]= FLT_MIN; + ar->v2d.min[0] = FLT_MIN; + ar->v2d.min[1] = FLT_MIN; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); - ar->v2d.keeptot= 0; + ar->v2d.keeptot = 0; return (SpaceLink *)sipo; } @@ -166,7 +166,7 @@ static SpaceLink *graph_new(const bContext *C) /* not spacelink itself */ static void graph_free(SpaceLink *sl) { - SpaceIpo *si= (SpaceIpo *)sl; + SpaceIpo *si = (SpaceIpo *)sl; if (si->ads) { BLI_freelistN(&si->ads->chanbase); @@ -181,12 +181,12 @@ static void graph_free(SpaceLink *sl) /* spacetype; init callback */ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first; + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* init dopesheet data if non-existant (i.e. for old files) */ if (sipo->ads == NULL) { - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } ED_area_tag_refresh(sa); @@ -194,11 +194,11 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *graph_duplicate(SpaceLink *sl) { - SpaceIpo *sipon= MEM_dupallocN(sl); + SpaceIpo *sipon = MEM_dupallocN(sl); /* clear or remove stuff from old */ BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves); - sipon->ads= MEM_dupallocN(sipon->ads); + sipon->ads = MEM_dupallocN(sipon->ads); return (SpaceLink *)sipon; } @@ -220,13 +220,13 @@ static void graph_main_area_init(wmWindowManager *wm, ARegion *ar) static void graph_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; float col[3]; - short unitx=0, unity=V2D_UNIT_VALUES, flag=0; + short unitx = 0, unity = V2D_UNIT_VALUES, flag = 0; /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); @@ -236,8 +236,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unitx= (sipo->flag & SIPO_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); + unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); /* draw data */ @@ -260,29 +260,29 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_grid_free(grid); /* horizontal component of value-cursor (value line before the current frame line) */ - if ((sipo->flag & SIPO_NODRAWCURSOR)==0) { + if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) { float vec[2]; /* Draw a green line to indicate the cursor value */ - vec[1]= sipo->cursorVal; + vec[1] = sipo->cursorVal; UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50); glLineWidth(2.0); glEnable(GL_BLEND); glBegin(GL_LINE_STRIP); - vec[0]= v2d->cur.xmin; - glVertex2fv(vec); + vec[0] = v2d->cur.xmin; + glVertex2fv(vec); - vec[0]= v2d->cur.xmax; - glVertex2fv(vec); + vec[0] = v2d->cur.xmax; + glVertex2fv(vec); glEnd(); // GL_LINE_STRIP glDisable(GL_BLEND); } /* current frame */ - if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((sipo->flag & SIPO_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ @@ -297,8 +297,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - // FIXME: args for scrollers depend on the type of data being shown... - scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); + // FIXME: args for scrollers depend on the type of data being shown... + scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -319,7 +319,7 @@ static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar) static void graph_channel_area_draw(const bContext *C, ARegion *ar) { bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -332,14 +332,14 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { - graph_draw_channel_names((bContext*)C, &ac, ar); + graph_draw_channel_names((bContext *)C, &ac, ar); } /* reset view matrix */ UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -418,7 +418,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } @@ -427,7 +427,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) /* editor level listener */ static void graph_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first; + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -440,7 +440,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_SCENE: switch (wmn->data) { - case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -453,7 +453,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_OBJECT: switch (wmn->data) { - case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_BONE_ACTIVE: sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -472,16 +472,16 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } - break; + break; case NC_SPACE: if (wmn->data == ND_SPACE_GRAPH) ED_area_tag_redraw(sa); break; - // XXX: restore the case below if not enough updates occur... - //default: - // if (wmn->data==ND_KEYS) - // ED_area_tag_redraw(sa); + // XXX: restore the case below if not enough updates occur... + //default: + // if (wmn->data==ND_KEYS) + // ED_area_tag_redraw(sa); } } @@ -498,13 +498,13 @@ static void graph_refresh(const bContext *C, ScrArea *sa) { } - break; + break; case SIPO_MODE_DRIVERS: /* drivers only */ { } - break; + break; } /* region updates? */ @@ -528,15 +528,15 @@ static void graph_refresh(const bContext *C, ScrArea *sa) int i; /* build list of F-Curves which will be visible as channels in channel-region - * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a - * mismatch between channel-colors and the drawn curves + * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a + * mismatch between channel-colors and the drawn curves */ - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_NODUPLIS); - items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop over F-Curves, assigning colors */ - for (ale=anim_data.first, i=0; ale; ale= ale->next, i++) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + FCurve *fcu = (FCurve *)ale->data; /* set color of curve here */ switch (fcu->color_mode) { @@ -551,7 +551,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. * TODO: find a way to module the hue so that not all curves have same color... */ - float *col= fcu->color; + float *col = fcu->color; switch (fcu->array_index) { case 0: @@ -569,7 +569,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) break; } } - break; + break; case FCURVE_COLOR_AUTO_RAINBOW: default: @@ -579,7 +579,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) */ getcolor_fcurve_rainbow(i, items, fcu->color); } - break; + break; } } @@ -591,10 +591,10 @@ static void graph_refresh(const bContext *C, ScrArea *sa) /* only called once, from space/spacetypes.c */ void ED_spacetype_ipo(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype ipo"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo"); ARegionType *art; - st->spaceid= SPACE_IPO; + st->spaceid = SPACE_IPO; strncpy(st->name, "Graph", BKE_ST_MAXNAME); st->new = graph_new; @@ -612,7 +612,7 @@ void ED_spacetype_ipo(void) art->init = graph_main_area_init; art->draw = graph_main_area_draw; art->listener = graph_region_listener; - art->keymapflag = ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); @@ -620,7 +620,7 @@ void ED_spacetype_ipo(void) art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = graph_region_listener; art->init = graph_header_area_init; art->draw = graph_header_area_draw; @@ -631,7 +631,7 @@ void ED_spacetype_ipo(void) art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200 + V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */ - art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->listener = graph_region_listener; art->init = graph_channel_area_init; art->draw = graph_channel_area_draw; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ecbd9a4033a..de171bc45f8 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -146,7 +146,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, /* the frame number, even if we cant */ if (ima->source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - const int framenr = BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); ofs += sprintf(str + ofs, ", Frame: %d", framenr); } @@ -430,7 +430,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) if (ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); - BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bbc12520978..58fbceb999d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -833,7 +833,7 @@ static int image_open_exec(bContext *C, wmOperator *op) errno = 0; - ima = BKE_add_image_file(str); + ima = BKE_image_load_exists(str); if (!ima) { if (op->customdata) MEM_freeN(op->customdata); @@ -1150,7 +1150,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ - ibuf->planes = BKE_alphatest_ibuf(ibuf) ? 32 : 24; + ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24; } } @@ -1167,7 +1167,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI BKE_image_release_renderresult(scene, ima); } else { - if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { + if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { ok = TRUE; } } @@ -1528,7 +1528,7 @@ static int image_new_exec(bContext *C, wmOperator *op) if (!alpha) color[3] = 1.0f; - ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); + ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); if (!ima) return OPERATOR_CANCELLED; @@ -2173,7 +2173,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Curves Point"; ot->idname = "IMAGE_OT_curves_point_set"; - ot->description = "Set black or white point for curves"; + ot->description = "Set black point or white point for curves"; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2408,7 +2408,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) if (tex->type == TEX_IMAGE && tex->ima) { if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { if (tex->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&tex->iuser, cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, cfra, 0); } } } @@ -2423,12 +2423,12 @@ void ED_image_update_frame(const Main *mainp, int cfra) BGpic *bgpic; for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) if (bgpic->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, cfra, 0); } else if (sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = sa->spacedata.first; if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, cfra, 0); } else if (sa->spacetype == SPACE_NODE) { SpaceNode *snode = sa->spacedata.first; @@ -2440,7 +2440,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) ImageUser *iuser = node->storage; if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) if (iuser->flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(iuser, cfra, 0); + BKE_image_user_frame_calc(iuser, cfra, 0); } } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 447028b8bef..9e0f538056c 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -590,7 +590,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima = ED_space_image(sima); if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ; @@ -599,7 +599,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) struct BMEditMesh *em = me->edit_btmesh; int sloppy = 1; /* partially selected face is ok */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, get image from material */ BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 0cc212f9c34..7870e64228a 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -107,7 +107,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totcurve += totob; if (ob->disp.first) - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; @@ -124,7 +124,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) case OB_MBALL: { int tot = 0, totf = 0; - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 184357344e1..97b6c32d81d 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1084,7 +1084,7 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co { /* check that bone exist in the active object */ if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, posechannel); + bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, posechannel); if (pchan) { bConstraint *con= BLI_findstring(&pchan->constraints, constraint_name, offsetof(bConstraint, name)); if (con) { @@ -4789,7 +4789,7 @@ void logic_buttons(bContext *C, ARegion *ar) } if (ob==NULL) return; -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); @@ -4833,7 +4833,7 @@ void logic_buttons(bContext *C, ARegion *ar) ob= (Object *)idar[a]; // uiClearButLock(); -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if ( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* presume it is only objects for now */ @@ -4970,7 +4970,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; a<count; a++) { ob= (Object *)idar[a]; // uiClearButLock(); -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if ( (ob->scavisflag & OB_VIS_SENS) == 0) continue; @@ -5051,7 +5051,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; a<count; a++) { ob= (Object *)idar[a]; // uiClearButLock(); -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; /* presume it is only objects for now */ diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 93105c39f39..1caf1075ae6 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -152,7 +152,7 @@ static void logic_free(SpaceLink *UNUSED(sl)) // Spacelogic *slogic= (SpaceLogic*) sl; // if (slogic->gpd) -// XXX free_gpencil_data(slogic->gpd); +// XXX BKE_gpencil_free(slogic->gpd); } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 17be87052c4..bbb6e7992f7 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -62,13 +62,13 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* ******************* nla editor space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_NOP 1 +#define B_REDR 2 /* -------------- */ @@ -81,16 +81,16 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event) } /* default for now */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM, NULL); } static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_ptr, PointerRNA *strip_ptr) { bAnimContext ac; - bAnimListElem *ale= NULL; + bAnimListElem *ale = NULL; ListBase anim_data = {NULL, NULL}; - short found=0; + short found = 0; int filter; /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) @@ -103,15 +103,15 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA * - we need the channels flag to get the active AnimData block when there are no NLA Tracks */ // XXX: double-check active! - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_NLATRACK: /* NLA Track - The primary data type which should get caught */ { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* found it, now set the pointers */ if (adt_ptr) { @@ -124,18 +124,18 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA } if (strip_ptr) { /* NLA-Strip pointer */ - NlaStrip *strip= BKE_nlastrip_find_active(nlt); + NlaStrip *strip = BKE_nlastrip_find_active(nlt); RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, strip_ptr); } - found= 1; + found = 1; } - break; + break; - case ANIMTYPE_SCENE: /* Top-Level Widgets doubling up as datablocks */ + case ANIMTYPE_SCENE: /* Top-Level Widgets doubling up as datablocks */ case ANIMTYPE_OBJECT: case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -157,11 +157,11 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA /* set found status to -1, since setting to 1 would break the loop * and potentially skip an active NLA-Track in some cases... */ - found= -1; + found = -1; } } } - break; + break; } if (found > 0) @@ -209,7 +209,7 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) if (ptr.data == NULL) return 0; - strip= ptr.data; + strip = ptr.data; return (strip->type == NLASTRIP_TYPE_CLIP); } @@ -223,7 +223,7 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) if (ptr.data == NULL) return 0; - strip= ptr.data; + strip = ptr.data; if (strip->type == NLASTRIP_TYPE_SOUND) return 0; @@ -234,11 +234,11 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* -------------- */ /* active AnimData */ -static void nla_panel_animdata (const bContext *C, Panel *pa) +static void nla_panel_animdata(const bContext *C, Panel *pa) { PointerRNA adt_ptr; /* AnimData *adt; */ - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; @@ -248,32 +248,32 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* adt= adt_ptr.data; */ - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Active Action Properties ------------------------------------- */ /* action */ - row= uiLayoutRow(layout, 1); - uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators + row = uiLayoutRow(layout, 1); + uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); } /* active NLA-Track */ -static void nla_panel_track (const bContext *C, Panel *pa) +static void nla_panel_track(const bContext *C, Panel *pa) { PointerRNA nlt_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; @@ -281,19 +281,19 @@ static void nla_panel_track (const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, &nlt_ptr, NULL)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Info - Active NLA-Context:Track ---------------------- */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); + row = uiLayoutRow(layout, 1); + uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); } /* generic settings for active NLA-Strip */ static void nla_panel_properties(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *column, *row, *sub; uiBlock *block; short showEvalProps = 1; @@ -301,20 +301,20 @@ static void nla_panel_properties(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Strip Properties ------------------------------------- */ /* strip type */ - row= uiLayoutColumn(layout, 1); - uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? - uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); + row = uiLayoutColumn(layout, 1); + uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? + uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); /* strip extents */ - column= uiLayoutColumn(layout, 1); - uiItemL(column, "Strip Extents:", ICON_NONE); - uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiItemL(column, "Strip Extents:", ICON_NONE); + uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); /* Evaluation-Related Strip Properties ------------------ */ @@ -325,31 +325,31 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); - uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - - sub= uiLayoutColumn(column, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); - uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); - uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == 0); + uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? + + sub = uiLayoutColumn(column, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == 0); + uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); + uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); } } @@ -358,7 +358,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) static void nla_panel_actclip(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *column, *row; uiBlock *block; @@ -366,35 +366,35 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Strip Properties ------------------------------------- */ /* action pointer */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? - column= uiLayoutColumn(layout, 1); - uiItemL(column, "Action Extents:", ICON_NONE); - uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); - uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); - uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); + column = uiLayoutColumn(layout, 1); + uiItemL(column, "Action Extents:", ICON_NONE); + uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); + uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); + uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); /* action usage */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time")==0); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "repeat", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == 0); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "repeat", 0, NULL, ICON_NONE); } /* evaluation settings for active NLA-Strip */ static void nla_panel_evaluation(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *col, *sub; uiBlock *block; @@ -402,22 +402,22 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - col= uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, 1); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - sub= uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, 1); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); - col= uiLayoutColumn(layout, 1); - sub= uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, 1); + sub = uiLayoutRow(col, 0); uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - sub= uiLayoutRow(col, 0); + sub = uiLayoutRow(col, 0); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } @@ -434,30 +434,30 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* check context and also validity of pointer */ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - strip= strip_ptr.data; + strip = strip_ptr.data; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* 'add modifier' button at top of panel */ { - row= uiLayoutRow(pa->layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(pa->layout, 0); + block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator // FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected) uiDefButO(block, BUT, "NLA_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), 10, 0, 150, 20, - TIP_("Adds a new F-Modifier for the active NLA Strip")); + TIP_("Adds a new F-Modifier for the active NLA Strip")); /* copy/paste (as sub-row)*/ - row= uiLayoutRow(row, 1); - uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); - uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); + row = uiLayoutRow(row, 1); + uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); + uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } /* draw each modifier */ - for (fcm= strip->modifiers.first; fcm; fcm= fcm->next) { - col= uiLayoutColumn(pa->layout, 1); + for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { + col = uiLayoutColumn(pa->layout, 1); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } @@ -470,54 +470,54 @@ void nla_buttons_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel animdata"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel animdata"); strcpy(pt->idname, "NLA_PT_animdata"); strcpy(pt->label, "Animation Data"); - pt->draw= nla_panel_animdata; - pt->poll= nla_animdata_panel_poll; - pt->flag= PNL_DEFAULT_CLOSED; + pt->draw = nla_panel_animdata; + pt->poll = nla_animdata_panel_poll; + pt->flag = PNL_DEFAULT_CLOSED; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel track"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel track"); strcpy(pt->idname, "NLA_PT_track"); strcpy(pt->label, "Active Track"); - pt->draw= nla_panel_track; - pt->poll= nla_track_panel_poll; + pt->draw = nla_panel_track; + pt->poll = nla_track_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); strcpy(pt->idname, "NLA_PT_properties"); strcpy(pt->label, "Active Strip"); - pt->draw= nla_panel_properties; - pt->poll= nla_strip_panel_poll; + pt->draw = nla_panel_properties; + pt->poll = nla_strip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); strcpy(pt->idname, "NLA_PT_actionclip"); strcpy(pt->label, "Action Clip"); - pt->draw= nla_panel_actclip; - pt->poll= nla_strip_actclip_panel_poll; + pt->draw = nla_panel_actclip; + pt->poll = nla_strip_actclip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel evaluation"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel evaluation"); strcpy(pt->idname, "NLA_PT_evaluation"); strcpy(pt->label, "Evaluation"); - pt->draw= nla_panel_evaluation; - pt->poll= nla_strip_eval_panel_poll; + pt->draw = nla_panel_evaluation; + pt->poll = nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); strcpy(pt->idname, "NLA_PT_modifiers"); strcpy(pt->label, "Modifiers"); - pt->draw= nla_panel_modifiers; - pt->poll= nla_strip_eval_panel_poll; + pt->draw = nla_panel_modifiers; + pt->poll = nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); } static int nla_properties(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= nla_has_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = nla_has_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 69e1e089bf6..11a39693168 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -61,7 +61,7 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* *********************************************** */ /* Operators for NLA channels-list which need to be different from the standard Animation Editor ones */ @@ -74,22 +74,22 @@ * --> Most channels are now selection only... */ -static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode) +static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; int notifierFlags = 0; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -104,8 +104,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)ale->data; - AnimData *adt= sce->adt; + Scene *sce = (Scene *)ale->data; + AnimData *adt = sce->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { @@ -118,23 +118,23 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho if (adt) adt->flag |= ADT_UI_SELECTED; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_OBJECT: { - bDopeSheet *ads= (bDopeSheet *)ac->data; - Scene *sce= (Scene *)ads->source; - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ob->adt; + bDopeSheet *ads = (bDopeSheet *)ac->data; + Scene *sce = (Scene *)ads->source; + Base *base = (Base *)ale->data; + Object *ob = base->object; + AnimData *adt = ob->adt; if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ base->flag ^= SELECT; - ob->flag= base->flag; + ob->flag = base->flag; if (adt) adt->flag ^= ADT_UI_SELECTED; } @@ -143,10 +143,10 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho /* deselect all */ // TODO: should this deselect all other types of channels too? - for (b= sce->base.first; b; b= b->next) { + for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; - b->object->flag= b->flag; - if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED|ADT_UI_ACTIVE); + b->object->flag = b->flag; + if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } /* select object now */ @@ -159,13 +159,13 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho adt->flag |= ADT_UI_ACTIVE; /* notifiers - channel was selected */ - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -199,47 +199,47 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ale->adt->flag |= ADT_UI_ACTIVE; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; short offset; /* offset for start of channel (on LHS of channel-list) */ if (ale->id) { /* special exception for materials and particles */ if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) - offset= 21 + NLACHANNEL_BUTTON_WIDTH; + offset = 21 + NLACHANNEL_BUTTON_WIDTH; else - offset= 14; + offset = 14; } else - offset= 0; + offset = 0; - if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { /* toggle protection (only if there's a toggle there) */ nlt->flag ^= NLATRACK_PROTECTED; /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - else if (x >= (v2d->cur.xmax-2*NLACHANNEL_BUTTON_WIDTH)) { + else if (x >= (v2d->cur.xmax - 2 * NLACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ nlt->flag ^= NLATRACK_MUTED; /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - else if (x <= ((NLACHANNEL_BUTTON_WIDTH*2)+offset)) { + else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) { /* toggle 'solo' */ BKE_nlatrack_solo_toggle(adt, nlt); /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } else if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection */ @@ -258,19 +258,19 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); /* notifier flags - channel was selected */ - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } - break; + break; case ANIMTYPE_NLAACTION: { - AnimData *adt= BKE_animdata_from_id(ale->id); + AnimData *adt = BKE_animdata_from_id(ale->id); - if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ // TODO: make this use the operator instead of calling the function directly - // however, calling the operator requires that we supply the args, and that works with proper buttons only + // however, calling the operator requires that we supply the args, and that works with proper buttons only BKE_nla_action_pushdown(adt); } else { @@ -282,7 +282,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho notifierFlags |= ND_NLA_ACTCHANGE; } } - break; + break; default: if (G.debug & G_DEBUG) @@ -315,15 +315,15 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - snla= (SpaceNla *)ac.sl; - ar= ac.ar; - v2d= &ar->v2d; + snla = (SpaceNla *)ac.sl; + ar = ac.ar; + v2d = &ar->v2d; /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out which channel user clicked in * Note: although channels technically start at y= NLACHANNEL_FIRST, we need to adjust by half a channel's height @@ -334,10 +334,10 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); /* handle mouse-click in the relevant channel then */ - notifierFlags= mouse_nla_channels(&ac, x, channel_index, selectmode); + notifierFlags = mouse_nla_channels(&ac, x, channel_index, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|notifierFlags, NULL); + WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); return OPERATOR_FINISHED; } @@ -354,7 +354,7 @@ void NLA_OT_channels_click(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY @@ -366,7 +366,7 @@ void NLA_OT_channels_click(wmOperatorType *ot) /* ******************** Add Tracks Operator ***************************** */ /* Add NLA Tracks to the same AnimData block as a selected track, or above the selected tracks */ -static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) +static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -375,21 +375,21 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) int filter; AnimData *lastAdt = NULL; - short above_sel= RNA_boolean_get(op->ptr, "above_selected"); + short above_sel = RNA_boolean_get(op->ptr, "above_selected"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add tracks... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* check if just adding a new track above this one, * or whether we're adding a new one to the top of the stack that this one belongs to @@ -401,7 +401,7 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) else if ((lastAdt == NULL) || (adt != lastAdt)) { /* add one track to the top of the owning AnimData's stack, then don't add anymore to this stack */ add_nlatrack(adt, NULL); - lastAdt= adt; + lastAdt = adt; } } } @@ -410,7 +410,7 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -428,7 +428,7 @@ void NLA_OT_tracks_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one"); @@ -437,7 +437,7 @@ void NLA_OT_tracks_add(wmOperatorType *ot) /* ******************** Delete Tracks Operator ***************************** */ /* Delete selected NLA Tracks */ -static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -450,14 +450,14 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete tracks */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* if track is currently 'solo', then AnimData should have its * 'has solo' flag disabled @@ -474,7 +474,7 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -492,7 +492,7 @@ void NLA_OT_delete_tracks(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index d331415bc46..c12cd6f2d39 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -66,7 +66,7 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* *********************************************** */ @@ -77,29 +77,29 @@ /* get colors for drawing Action-Line * NOTE: color returned includes fine-tuned alpha! */ -static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) +static void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) { if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { // greenish color (same as tweaking strip) - hardcoded for now - color[0]= 0.30f; - color[1]= 0.95f; - color[2]= 0.10f; - color[3]= 0.30f; + color[0] = 0.30f; + color[1] = 0.95f; + color[2] = 0.10f; + color[3] = 0.30f; } else { if (act) { // reddish color - hardcoded for now - color[0]= 0.8f; - color[1]= 0.2f; - color[2]= 0.0f; - color[3]= 0.4f; + color[0] = 0.8f; + color[1] = 0.2f; + color[2] = 0.0f; + color[3] = 0.4f; } else { // greyish-red color - hardcoded for now - color[0]= 0.6f; - color[1]= 0.5f; - color[2]= 0.5f; - color[3]= 0.3f; + color[0] = 0.6f; + color[1] = 0.5f; + color[2] = 0.5f; + color[3] = 0.3f; } } @@ -109,7 +109,7 @@ static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) } /* draw the keyframes in the specified Action */ -static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax) +static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax) { DLRBT_Tree keys; ActKeyColumn *ak; @@ -132,13 +132,13 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, color[3] *= 2.5f; glColor4fv(color); - /* - draw a rect from the first to the last frame (no extra overlaps for now) + /* - draw a rect from the first to the last frame (no extra overlaps for now) * that is slightly stumpier than the track background (hardcoded 2-units here) */ - f1= ((ActKeyColumn *)keys.first)->cfra; - f2= ((ActKeyColumn *)keys.last)->cfra; + f1 = ((ActKeyColumn *)keys.first)->cfra; + f2 = ((ActKeyColumn *)keys.last)->cfra; - glRectf(f1, ymin+2, f2, ymax-2); + glRectf(f1, ymin + 2, f2, ymax - 2); /* get View2D scaling factor */ @@ -150,7 +150,7 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, /* just draw each keyframe as a simple dot (regardless of the selection status) * - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction */ - for (ak= keys.first; ak; ak= ak->next) + for (ak = keys.first; ak; ak = ak->next) draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f); /* free icons */ @@ -160,23 +160,23 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, /* Strips (Proper) ---------------------- */ /* get colors for drawing NLA-Strips */ -static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float color[3]) +static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float color[3]) { if (strip->type == NLASTRIP_TYPE_TRANSITION) { /* Transition Clip */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bright blue color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.18f; - color[1]= 0.46f; - color[2]= 0.86f; + color[0] = 0.18f; + color[1] = 0.46f; + color[2] = 0.86f; } else { /* normal, unselected strip - use (hardly noticeable) blue tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.11f; - color[1]= 0.15f; - color[2]= 0.19f; + color[0] = 0.11f; + color[1] = 0.15f; + color[2] = 0.19f; } } else if (strip->type == NLASTRIP_TYPE_META) { @@ -185,16 +185,16 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bold purple color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.41f; - color[1]= 0.13f; - color[2]= 0.59f; + color[0] = 0.41f; + color[1] = 0.13f; + color[2] = 0.59f; } else { /* normal, unselected strip - use (hardly noticeable) dark purple tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.20f; - color[1]= 0.15f; - color[2]= 0.26f; + color[0] = 0.20f; + color[1] = 0.15f; + color[2] = 0.26f; } } else if (strip->type == NLASTRIP_TYPE_SOUND) { @@ -202,16 +202,16 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bright teal color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.12f; - color[1]= 0.48f; - color[2]= 0.48f; + color[0] = 0.12f; + color[1] = 0.48f; + color[2] = 0.48f; } else { /* normal, unselected strip - use (hardly noticeable) teal tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.17f; - color[1]= 0.24f; - color[2]= 0.24f; + color[0] = 0.17f; + color[1] = 0.24f; + color[2] = 0.24f; } } else { @@ -221,18 +221,18 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co * however, this case should be skipped for when not in EditMode... */ // FIXME: hardcoded temp-hack colors - color[0]= 0.3f; - color[1]= 0.95f; - color[2]= 0.1f; + color[0] = 0.3f; + color[1] = 0.95f; + color[2] = 0.1f; } else if (strip->flag & NLASTRIP_FLAG_TWEAKUSER) { /* alert user that this strip is also used by the tweaking track (this is set when going into * 'editmode' for that strip), since the edits made here may not be what the user anticipated */ // FIXME: hardcoded temp-hack colors - color[0]= 0.85f; - color[1]= 0.0f; - color[2]= 0.0f; + color[0] = 0.85f; + color[1] = 0.0f; + color[2] = 0.0f; } else if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected strip - use theme color for selected */ @@ -246,7 +246,7 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co } /* helper call for drawing influence/time control curves for a given NLA-strip */ -static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) +static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) { const float yheight = ymaxc - yminc; @@ -261,39 +261,39 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) /* influence -------------------------- */ if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { - FCurve *fcu= list_find_fcurve(&strip->fcurves, "influence", 0); + FCurve *fcu = list_find_fcurve(&strip->fcurves, "influence", 0); float cfra; /* plot the curve (over the strip's main region) */ glBegin(GL_LINE_STRIP); - /* sample at 1 frame intervals, and draw - * - min y-val is yminc, max is y-maxc, so clamp in those regions - */ - for (cfra= strip->start; cfra <= strip->end; cfra += 1.0f) { - float y= evaluate_fcurve(fcu, cfra); // assume this to be in 0-1 range - glVertex2f(cfra, ((y*yheight)+yminc)); - } + /* sample at 1 frame intervals, and draw + * - min y-val is yminc, max is y-maxc, so clamp in those regions + */ + for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) { + float y = evaluate_fcurve(fcu, cfra); // assume this to be in 0-1 range + glVertex2f(cfra, ((y * yheight) + yminc)); + } glEnd(); // GL_LINE_STRIP } else { /* use blend in/out values only if both aren't zero */ - if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f))==0) { + if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) { glBegin(GL_LINE_STRIP); - /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ - if (IS_EQF(strip->blendin, 0.0f) == 0) { - glVertex2f(strip->start, yminc); - glVertex2f(strip->start + strip->blendin, ymaxc); - } - else - glVertex2f(strip->start, ymaxc); + /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ + if (IS_EQF(strip->blendin, 0.0f) == 0) { + glVertex2f(strip->start, yminc); + glVertex2f(strip->start + strip->blendin, ymaxc); + } + else + glVertex2f(strip->start, ymaxc); - /* end of strip */ - if (IS_EQF(strip->blendout, 0.0f) == 0) { - glVertex2f(strip->end - strip->blendout, ymaxc); - glVertex2f(strip->end, yminc); - } - else - glVertex2f(strip->end, ymaxc); + /* end of strip */ + if (IS_EQF(strip->blendout, 0.0f) == 0) { + glVertex2f(strip->end - strip->blendout, ymaxc); + glVertex2f(strip->end, yminc); + } + else + glVertex2f(strip->end, ymaxc); glEnd(); // GL_LINE_STRIP } } @@ -307,9 +307,9 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) } /* main call for drawing a single NLA-strip */ -static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) { - short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); + short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); float color[3]; /* get color of strip */ @@ -335,34 +335,34 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* draw the rect to the edge of the screen */ glBegin(GL_QUADS); - glVertex2f(v2d->cur.xmin, yminc); - glVertex2f(v2d->cur.xmin, ymaxc); - glVertex2f(strip->start, ymaxc); - glVertex2f(strip->start, yminc); + glVertex2f(v2d->cur.xmin, yminc); + glVertex2f(v2d->cur.xmin, ymaxc); + glVertex2f(strip->start, ymaxc); + glVertex2f(strip->start, yminc); glEnd(); } - /* no break needed... */ + /* no break needed... */ /* this only draws after the strip */ case NLASTRIP_EXTEND_HOLD_FORWARD: /* only need to try and draw if the next strip doesn't occur immediately after */ - if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end)==0)) { + if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) { /* set the drawing color to the color of the strip, but this time less faint */ glColor4f(color[0], color[1], color[2], 0.3f); /* draw the rect to the next strip or the edge of the screen */ glBegin(GL_QUADS); - glVertex2f(strip->end, yminc); - glVertex2f(strip->end, ymaxc); + glVertex2f(strip->end, yminc); + glVertex2f(strip->end, ymaxc); - if (strip->next) { - glVertex2f(strip->next->start, ymaxc); - glVertex2f(strip->next->start, yminc); - } - else { - glVertex2f(v2d->cur.xmax, ymaxc); - glVertex2f(v2d->cur.xmax, yminc); - } + if (strip->next) { + glVertex2f(strip->next->start, ymaxc); + glVertex2f(strip->next->start, yminc); + } + else { + glVertex2f(v2d->cur.xmax, ymaxc); + glVertex2f(v2d->cur.xmax, yminc); + } glEnd(); } break; @@ -385,7 +385,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr glColor4f(color[0], color[1], color[2], 0.1f); glEnable(GL_BLEND); - glRectf(strip->start, yminc, strip->end, ymaxc); + glRectf(strip->start, yminc, strip->end, ymaxc); glDisable(GL_BLEND); } @@ -417,7 +417,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ - if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f)==0) { + if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; int i; @@ -429,20 +429,20 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) - fdrawline(repeatPos, yminc+4, repeatPos, ymaxc-4); + fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { NlaStrip *cs; - float y= (ymaxc-yminc)/2.0f + yminc; + float y = (ymaxc - yminc) / 2.0f + yminc; /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ - for (cs= strip->strips.first; cs; cs= cs->next) { + for (cs = strip->strips.first; cs; cs = cs->next) { /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ - if ((cs->prev) && IS_EQF(cs->prev->end, cs->start)==0) + if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0) fdrawline(cs->start, y, cs->start, ymaxc); /* draw end-line if not the last strip @@ -458,9 +458,9 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr } /* add the relevant text to the cache of text-strings to draw in pixelspace */ -static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) { - short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); + short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); char str[256]; char col[4]; float xofs; @@ -475,18 +475,18 @@ static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ - if (strip->flag & (NLASTRIP_FLAG_ACTIVE|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_TWEAKUSER)) { - col[0]= col[1]= col[2]= 0; + if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) { + col[0] = col[1] = col[2] = 0; } else { - col[0]= col[1]= col[2]= 255; + col[0] = col[1] = col[2] = 255; } /* text opacity depends on whether if there's a solo'd track, this isn't it */ if (notSolo == 0) - col[3]= 255; + col[3] = 255; else - col[3]= 128; + col[3] = 128; /* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */ if ((strip->end - strip->start) <= 5.0f) @@ -523,13 +523,13 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * - 1 dp is compromise between lack of precision (ints only, as per sequencer) * while also preserving some accuracy, since we do use floats */ - /* start frame */ + /* start frame */ BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); - UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, numstr, col); + UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, col); - /* end frame */ + /* end frame */ BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); - UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, numstr, col); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, col); } /* ---------------------- */ @@ -540,49 +540,49 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); + height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT(snla)); + y = (float)(-NLACHANNEL_HEIGHT(snla)); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* data to draw depends on the type of channel */ switch (ale->type) { case ANIMTYPE_NLATRACK: { - AnimData *adt= ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; int index; /* draw each strip in the track (if visible) */ - for (strip=nlt->strips.first, index=1; strip; strip=strip->next, index++) { + for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { /* draw the visualisation of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); @@ -598,11 +598,11 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) } } } - break; + break; case ANIMTYPE_NLAACTION: { - AnimData *adt= ale->adt; + AnimData *adt = ale->adt; float color[4]; /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, @@ -618,27 +618,27 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw slightly shifted up for greater separation from standard channels, * but also slightly shorter for some more contrast when viewing the strips */ - glRectf(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); /* draw keyframes in the action */ - nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc+NLACHANNEL_SKIP, ymaxc-NLACHANNEL_SKIP); + nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); /* draw 'embossed' lines above and below the strip for effect */ - /* white base-lines */ + /* white base-lines */ glLineWidth(2.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.3); - fdrawline(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, yminc+NLACHANNEL_SKIP); - fdrawline(v2d->cur.xmin, ymaxc-NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); - /* black top-lines */ + /* black top-lines */ glLineWidth(1.0f); glColor3f(0.0f, 0.0f, 0.0f); - fdrawline(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, yminc+NLACHANNEL_SKIP); - fdrawline(v2d->cur.xmin, ymaxc-NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); glDisable(GL_BLEND); } - break; + break; } } @@ -655,40 +655,40 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* old code for drawing NLA channels using GL only */ // TODO: depreceate this code... -static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) +static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { SpaceNla *snla = (SpaceNla *)ac->sl; bAnimListElem *ale; float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ - for (ale= anim_data->first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); - const float ydatac= (float)(y - 7); + for (ale = anim_data->first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + const float ydatac = (float)(y - 7); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { AnimData *adt = ale->adt; - short indent= 0, offset= 0, sel= 0, group= 0, nonSolo= 0; - int expand= -1, protect = -1, special= -1, mute = -1; + short indent = 0, offset = 0, sel = 0, group = 0, nonSolo = 0; + int expand = -1, protect = -1, special = -1, mute = -1; char name[128]; - short doDraw=0; + short doDraw = 0; /* determine what needs to be drawn */ switch (ale->type) { case ANIMTYPE_NLATRACK: /* NLA Track */ { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* 'solo' as the 'special' button? */ if (nlt->flag & NLATRACK_SOLO) - special= ICON_SOLO_ON; + special = ICON_SOLO_ON; else - special= ICON_SOLO_OFF; + special = ICON_SOLO_OFF; /* if this track is active and we're tweaking it, don't draw these toggles */ // TODO: need a special macro for this... @@ -708,7 +708,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { if ((nlt->flag & NLATRACK_SOLO) == 0) { /* tag for special non-solo handling; also hide the mute toggles */ - nonSolo= 1; + nonSolo = 1; mute = 0; } } @@ -717,26 +717,26 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie BLI_strncpy(name, nlt->name, sizeof(name)); // draw manually still - doDraw= 1; + doDraw = 1; } - break; + break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ { - bAction *act= (bAction *)ale->data; + bAction *act = (bAction *)ale->data; group = 5; special = ICON_ACTION; if (act) - BLI_snprintf(name, sizeof(name), "%s", act->id.name+2); + BLI_snprintf(name, sizeof(name), "%s", act->id.name + 2); else BLI_strncpy(name, "<No Action>", sizeof(name)); // draw manually still - doDraw= 1; + doDraw = 1; } - break; + break; default: /* handled by standard channel-drawing API */ // draw backdrops only... @@ -749,8 +749,8 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if (ale->id) { /* special exception for textures */ if (GS(ale->id->name) == ID_TE) { - offset= 14; - indent= 1; + offset = 14; + indent = 1; } /* special exception for nodetrees */ else if (GS(ale->id->name) == ID_NT) { @@ -760,30 +760,32 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie case NTREE_SHADER: { /* same as for textures */ - offset= 14; - indent= 1; + offset = 14; + indent = 1; } - break; + break; case NTREE_TEXTURE: { /* even more */ - offset= 21; - indent= 1; + offset = 21; + indent = 1; } - break; + break; default: /* normal will do */ - offset= 14; + offset = 14; break; } } - else - offset= 14; + else { + offset = 14; + } + } + else { + offset = 0; } - else - offset= 0; /* now, start drawing based on this information */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -799,12 +801,12 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie } else { /* if a track is being solo'd, action is ignored, so draw less boldly (alpha lower) */ - float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK))? 0.3f : 1.0f; + float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f; if (ale->data) - glColor4f(0.8f, 0.2f, 0.0f, alpha); // reddish color - hardcoded for now + glColor4f(0.8f, 0.2f, 0.0f, alpha); // reddish color - hardcoded for now else - glColor4f(0.6f, 0.5f, 0.5f, alpha); // greyish-red color - hardcoded for now + glColor4f(0.6f, 0.5f, 0.5f, alpha); // greyish-red color - hardcoded for now } offset += 7 * indent; @@ -815,35 +817,35 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* draw slightly shifted up vertically to look like it has more separation from other channels, * but we then need to slightly shorten it so that it doesn't look like it overlaps */ - uiDrawBox(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); + uiDrawBox(GL_POLYGON, x + offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8); /* clear group value, otherwise we cause errors... */ group = 0; } else { /* NLA tracks - darker color if not solo track when we're showing solo */ - UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0)? 20 : -20)); + UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20)); indent += group; offset += 7 * indent; glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)v2d->cur.xmax, ymaxc); - glVertex2f((float)v2d->cur.xmax, yminc); + glVertex2f(x + offset, yminc); + glVertex2f(x + offset, ymaxc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); glEnd(); } /* draw expand/collapse triangle */ if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); + UI_icon_draw(x + offset, ydatac, expand); offset += 17; } /* draw special icon indicating certain data-types */ if (special > -1) { /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); + UI_icon_draw(x + offset, ydatac, special); offset += 17; } glDisable(GL_BLEND); @@ -854,7 +856,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie else UI_ThemeColor(TH_TEXT); offset += 3; - UI_DrawString(x+offset, y-4, name); + UI_DrawString(x + offset, y - 4, name); /* reset offset - for RHS of panel */ offset = 0; @@ -866,18 +868,18 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* draw protect 'lock' */ if (protect > -1) { offset = 16; - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, protect); } /* draw mute 'eye' */ if (mute > -1) { offset += 16; - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute); } /* draw NLA-action line 'status-icons' - only when there's an action */ if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; + AnimData *adt = ale->adt; offset += 16; @@ -886,28 +888,28 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ // for now, use pin icon to symbolise this if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_PINNED); else - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_UNPINNED); - fdrawline((float)(v2d->cur.xmax-offset), yminc, - (float)(v2d->cur.xmax-offset), ymaxc); + fdrawline((float)(v2d->cur.xmax - offset), yminc, + (float)(v2d->cur.xmax - offset), ymaxc); offset += 16; /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT); } else { /* XXX firstly draw a little rect to help identify that it's different from the toggles */ glBegin(GL_LINE_LOOP); - glVertex2f((float)v2d->cur.xmax-offset-1, y-7); - glVertex2f((float)v2d->cur.xmax-offset-1, y+9); - glVertex2f((float)v2d->cur.xmax-1, y+9); - glVertex2f((float)v2d->cur.xmax-1, y-7); + glVertex2f((float)v2d->cur.xmax - offset - 1, y - 7); + glVertex2f((float)v2d->cur.xmax - offset - 1, y + 9); + glVertex2f((float)v2d->cur.xmax - 1, y + 9); + glVertex2f((float)v2d->cur.xmax - 1, y - 7); glEnd(); // GL_LINES /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)v2d->cur.xmax-offset, ydatac, ICON_FREEZE); + UI_icon_draw((float)v2d->cur.xmax - offset, ydatac, ICON_FREEZE); } } @@ -927,22 +929,22 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); + height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ @@ -951,29 +953,29 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* draw channels */ - { /* first pass: backdrops + oldstyle drawing */ - y= (float)(-NLACHANNEL_HEIGHT(snla)); + { /* first pass: backdrops + oldstyle drawing */ + y = (float)(-NLACHANNEL_HEIGHT(snla)); draw_nla_channel_list_gl(ac, &anim_data, v2d, y); } - { /* second pass: UI widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: UI widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)(-NLACHANNEL_HEIGHT(snla)); + y = (float)(-NLACHANNEL_HEIGHT(snla)); /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); /* loop through channels, and set up drawing depending on their type */ - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 994021db9ff..8a7e2a8a904 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -69,7 +69,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include #include "nla_private.h" // FIXME... maybe this shouldn't be included? /* *********************************************** */ @@ -80,12 +80,12 @@ void ED_nla_postop_refresh(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); /* get blocks to work on */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* performing auto-blending, extend-mode validation, etc. */ BKE_nla_validate_state(ale->data); } @@ -102,21 +102,21 @@ void ED_nla_postop_refresh(bAnimContext *ac) * as if it were the normal Active-Action of its AnimData block. */ -static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) +static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ok=0; + int ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -126,8 +126,8 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) } /* for each AnimData block with NLA-data, try setting it in tweak-mode */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ale->data; /* try entering tweakmode if valid */ ok += BKE_nla_tweakmode_enter(adt); @@ -144,7 +144,7 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) ac.scene->flag |= SCE_NLA_EDIT_ON; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } else { BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweakmode on"); @@ -167,12 +167,12 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------- */ -static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) +static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -185,7 +185,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -195,8 +195,8 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) } /* for each AnimData block with NLA-data, try exitting tweak-mode */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ale->data; /* try entering tweakmode if valid */ BKE_nla_tweakmode_exit(adt); @@ -213,7 +213,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) ac.scene->flag &= ~SCE_NLA_EDIT_ON; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } /* done */ @@ -232,7 +232,7 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_on; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -241,24 +241,24 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot) /* *************************** Calculate Range ************************** */ /* Get the min/max strip extents */ -static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, const short onlySel) +static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const short onlySel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* get data to filter */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - *min= 999999999.0f; - *max= -999999999.0f; + *min = 999999999.0f; + *max = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; @@ -278,12 +278,12 @@ static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, cons else { /* set default range */ if (ac->scene) { - *min= (float)ac->scene->r.sfra; - *max= (float)ac->scene->r.efra; + *min = (float)ac->scene->r.sfra; + *max = (float)ac->scene->r.efra; } else { - *min= -5; - *max= 100; + *min = -5; + *max = 100; } } } @@ -299,12 +299,12 @@ static int nlaedit_viewall(bContext *C, const short onlySel) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* 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 * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -347,7 +347,7 @@ void NLA_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void NLA_OT_view_selected(wmOperatorType *ot) @@ -362,7 +362,7 @@ void NLA_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -373,7 +373,7 @@ void NLA_OT_view_selected(wmOperatorType *ot) /* add the specified action as new strip */ -static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) +static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) { bAnimContext ac; Scene *scene; @@ -391,11 +391,11 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - scene= ac.scene; - cfra= (float)CFRA; + scene = ac.scene; + cfra = (float)CFRA; /* get action to use */ - act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); @@ -405,15 +405,15 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) else if (act->idroot == 0) { /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ BKE_reportf(op->reports, RPT_WARNING, - "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", - act->id.name+2); + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name + 2); } /* get a list of the editable tracks being shown in the NLA * - this is limited to active ones for now, but could be expanded to */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); - items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); + items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) { BKE_report(op->reports, RPT_ERROR, "No active track(s) to add strip to"); @@ -421,33 +421,33 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) } /* for every active track, try to add strip to free space in track or to the top of the stack if no space */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; - NlaStrip *strip= NULL; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaStrip *strip = NULL; /* sanity check: only apply actions of the right type for this ID * NOTE: in the case that this hasn't been set, we've already warned the user about this already */ if ((act->idroot) && (act->idroot != GS(ale->id->name))) { BKE_reportf(op->reports, RPT_ERROR, - "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", - act->id.name+2, ale->id->name); + "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", + act->id.name + 2, ale->id->name); continue; } /* create a new strip, and offset it to start on the current frame */ - strip= add_nlastrip(act); + strip = add_nlastrip(act); - strip->end += (cfra - strip->start); - strip->start = cfra; + strip->end += (cfra - strip->start); + strip->start = cfra; /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -462,7 +462,7 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -483,11 +483,11 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - // TODO: this would be nicer as an ID-pointer... - prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + // TODO: this would be nicer as an ID-pointer... + prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); RNA_def_enum_funcs(prop, RNA_action_itemf); ot->prop = prop; } @@ -495,7 +495,7 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) /* ******************** Add Transition Operator ***************************** */ /* Add a new transition strip between selected strips */ -static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) +static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -510,23 +510,23 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *s1, *s2; /* get initial pair of strips */ if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) continue; - s1= nlt->strips.first; - s2= s1->next; + s1 = nlt->strips.first; + s2 = s1->next; /* loop over strips */ - for (; s1 && s2; s1=s2, s2=s2->next) { + for (; s1 && s2; s1 = s2, s2 = s2->next) { NlaStrip *strip; /* check if both are selected */ @@ -537,7 +537,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) continue; /* make sure neither one is a transition * - although this is impossible to create with the standard tools, - * the user may have altered the settings + * the user may have altered the settings */ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) continue; @@ -546,25 +546,25 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) continue; /* allocate new strip */ - strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); + strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); BLI_insertlinkafter(&nlt->strips, s1, strip); /* set the type */ - strip->type= NLASTRIP_TYPE_TRANSITION; + strip->type = NLASTRIP_TYPE_TRANSITION; /* generic settings * - selected flag to highlight this to the user * - auto-blends to ensure that blend in/out values are automatically * determined by overlaps of strips */ - strip->flag = NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_AUTO_BLENDS; + strip->flag = NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_AUTO_BLENDS; /* range is simply defined as the endpoints of the adjacent strips */ - strip->start = s1->end; - strip->end = s2->start; + strip->start = s1->end; + strip->end = s2->start; /* scale and repeat aren't of any use, but shouldn't ever be 0 */ - strip->scale= 1.0f; + strip->scale = 1.0f; strip->repeat = 1.0f; /* auto-name it */ @@ -584,7 +584,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -607,13 +607,13 @@ void NLA_OT_transition_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Add Sound Clip Operator ***************************** */ /* Add a new sound clip */ -static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -632,16 +632,16 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) cfra = CFRA; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, add sound clips if it belongs to a speaker */ // TODO: what happens if there aren't any tracks... well that's a more general problem for later - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { Object *ob = (Object *)ale->id; /* may not be object until we actually check! */ AnimData *adt = ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* does this belong to speaker - assumed to live on Object level only */ @@ -649,17 +649,17 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* create a new strip, and offset it to start on the current frame */ - strip= add_nla_soundstrip(ac.scene, ob->data); + strip = add_nla_soundstrip(ac.scene, ob->data); - strip->start += cfra; - strip->end += cfra; + strip->start += cfra; + strip->end += cfra; /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -674,7 +674,7 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -692,14 +692,14 @@ void NLA_OT_soundclip_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Add Meta-Strip Operator ***************************** */ /* Add new meta-strips incorporating the selected strips */ /* add the specified action as new strip */ -static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -712,20 +712,20 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip; /* create meta-strips from the continuous chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 0); /* name the metas */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* auto-name this strip if selected (that means it is a meta) */ if (strip->flag & NLASTRIP_FLAG_SELECT) BKE_nlastrip_validate_name(adt, strip); @@ -736,7 +736,7 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -754,13 +754,13 @@ void NLA_OT_meta_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Remove Meta-Strip Operator ***************************** */ /* Separate out the strips held by the selected meta-strips */ -static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -773,12 +773,12 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; /* clear all selected meta-strips, regardless of whether they are temporary or not */ BKE_nlastrips_clear_metas(&nlt->strips, 1, 0); @@ -788,7 +788,7 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -806,7 +806,7 @@ void NLA_OT_meta_remove(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Duplicate Strips Operator ************************** */ @@ -814,7 +814,7 @@ void NLA_OT_meta_remove(wmOperatorType *ot) * the originals were housed in. */ -static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -829,25 +829,25 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* duplicate strips in tracks starting from the last one so that we're * less likely to duplicate strips we just duplicated... */ - for (ale= anim_data.last; ale; ale= ale->prev) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.last; ale; ale = ale->prev) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip, *nstrip, *next; NlaTrack *track; - for (strip= nlt->strips.first; strip; strip= next) { - next= strip->next; + for (strip = nlt->strips.first; strip; strip = next) { + next = strip->next; /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* make a copy (assume that this is possible) */ - nstrip= copy_nlastrip(strip); + nstrip = copy_nlastrip(strip); /* in case there's no space in the track above, or we haven't got a reference to it yet, try adding */ if (BKE_nlatrack_add_strip(nlt->next, nstrip) == 0) { @@ -855,12 +855,12 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) * - if the current one is the last one, nlt->next will be NULL, which defaults to adding * at the top of the stack anyway... */ - track= add_nlatrack(adt, nlt->next); + track = add_nlatrack(adt, nlt->next); BKE_nlatrack_add_strip(track, nstrip); } /* deselect the original and the active flag */ - strip->flag &= ~(NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE); + strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); /* auto-name newly created strip */ BKE_nlastrip_validate_name(adt, nstrip); @@ -878,7 +878,7 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -910,7 +910,7 @@ void NLA_OT_duplicate(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -919,7 +919,7 @@ void NLA_OT_duplicate(wmOperatorType *ot) /* ******************** Delete Strips Operator ***************************** */ /* Deletes the selected NLA-Strips */ -static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -932,16 +932,16 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, delete all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *nstrip; - for (strip= nlt->strips.first; strip; strip= nstrip) { - nstrip= strip->next; + for (strip = nlt->strips.first; strip; strip = nstrip) { + nstrip = strip->next; /* if selected, delete */ if (strip->flag & NLASTRIP_FLAG_SELECT) { @@ -949,7 +949,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) free_nlastrip(&nlt->strips, strip->prev); if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { - nstrip= nstrip->next; + nstrip = nstrip->next; free_nlastrip(&nlt->strips, strip->next); } @@ -966,7 +966,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -984,17 +984,17 @@ void NLA_OT_delete(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Split Strips Operator ***************************** */ /* Splits the selected NLA-Strips into two strips at the midpoint of the strip */ // TODO's? -// - multiple splits -// - variable-length splits? +// - multiple splits +// - variable-length splits? /* split a given Action-Clip strip */ -static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra) +static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra) { NlaStrip *nstrip; float splitframe, splitaframe; @@ -1004,44 +1004,44 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip */ if ((cfra > strip->start) && (cfra < strip->end)) { /* use the current frame */ - splitframe= cfra; - splitaframe= nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP); + splitframe = cfra; + splitaframe = nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP); } else { /* split in the middle */ float len; - /* strip extents */ - len= strip->end - strip->start; + /* strip extents */ + len = strip->end - strip->start; if (IS_EQF(len, 0.0f)) return; else - splitframe= strip->start + (len / 2.0f); + splitframe = strip->start + (len / 2.0f); - /* action range */ - len= strip->actend - strip->actstart; + /* action range */ + len = strip->actend - strip->actstart; if (IS_EQF(len, 0.0f)) - splitaframe= strip->actend; + splitaframe = strip->actend; else - splitaframe= strip->actstart + (len / 2.0f); + splitaframe = strip->actstart + (len / 2.0f); } /* make a copy (assume that this is possible) and append * it immediately after the current strip */ - nstrip= copy_nlastrip(strip); + nstrip = copy_nlastrip(strip); BLI_insertlinkafter(&nlt->strips, strip, nstrip); /* set the endpoint of the first strip and the start of the new strip * to the splitframe values calculated above */ - strip->end= splitframe; - nstrip->start= splitframe; + strip->end = splitframe; + nstrip->start = splitframe; if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) { /* only do this if we're splitting down the middle... */ - strip->actend= splitaframe; - nstrip->actstart= splitaframe; + strip->actend = splitaframe; + nstrip->actstart = splitaframe; } /* clear the active flag from the copy */ @@ -1052,7 +1052,7 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip } /* split a given Meta strip */ -static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip) +static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip) { /* simply ungroup it for now... */ BKE_nlastrips_clear_metastrip(&nlt->strips, strip); @@ -1060,7 +1060,7 @@ static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip) /* ----- */ -static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1073,17 +1073,17 @@ static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, split all selected strips into two strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip, *next; - for (strip= nlt->strips.first; strip; strip= next) { - next= strip->next; + for (strip = nlt->strips.first; strip; strip = next) { + next = strip->next; /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { @@ -1111,7 +1111,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1129,13 +1129,13 @@ void NLA_OT_split(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Bake Strips Operator ***************************** */ /* Bakes the NLA Strips for the active AnimData blocks */ -static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1149,11 +1149,11 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each AnimData block, bake strips to animdata... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { //BKE_nla_bake(ac.scene, ale->id, ale->data, flag); } @@ -1164,7 +1164,7 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1182,7 +1182,7 @@ void NLA_OT_bake(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -1191,7 +1191,7 @@ void NLA_OT_bake(wmOperatorType *ot) /* ******************** Toggle Muting Operator ************************** */ /* Toggles whether strips are muted or not */ -static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1204,16 +1204,16 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* go over all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* for every selected strip, toggle muting */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { /* just flip the mute flag for now */ // TODO: have a pre-pass to check if mute all or unmute all? @@ -1226,7 +1226,7 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1244,13 +1244,13 @@ void NLA_OT_mute_toggle(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Swap Strips Operator ************************** */ /* Tries to exchange strips within their owner tracks */ -static int nlaedit_swap_exec (bContext *C, wmOperator *op) +static int nlaedit_swap_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1263,15 +1263,15 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* consider each track in turn */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; - NlaStrip *strip, *stripN=NULL; - NlaStrip *sa=NULL, *sb=NULL; + NlaStrip *strip, *stripN = NULL; + NlaStrip *sa = NULL, *sb = NULL; /* make temporary metastrips so that entire islands of selections can be moved around */ BKE_nlastrips_make_metas(&nlt->strips, 1); @@ -1289,7 +1289,7 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) } /* get two selected strips only (these will be metas due to prev step) to operate on - * - only allow swapping 2, as with more the context becomes unclear + * - only allow swapping 2, as with more the context becomes unclear */ for (strip = nlt->strips.first; strip; strip = stripN) { stripN = strip->next; @@ -1314,8 +1314,8 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) if (strip) { /* too many selected warning */ BKE_reportf(op->reports, RPT_WARNING, - "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", - nlt->name); + "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", + nlt->name); } else if (sa == NULL) { /* no warning as this is just a common case, and it may get annoying when doing multiple tracks */ @@ -1323,8 +1323,8 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) else if (sb == NULL) { /* too few selected warning */ BKE_reportf(op->reports, RPT_WARNING, - "Too few clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", - nlt->name); + "Too few clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", + nlt->name); } else { float nsa[2], nsb[2]; @@ -1334,16 +1334,16 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) BLI_remlink(&nlt->strips, sb); /* calculate new extents for strips */ - /* a --> b */ + /* a --> b */ nsa[0] = sb->start; nsa[1] = sb->start + (sa->end - sa->start); - /* b --> a */ + /* b --> a */ nsb[0] = sa->start; nsb[1] = sa->start + (sb->end - sb->start); /* check if the track has room for the strips to be swapped */ if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && - BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) + BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) { /* set new extents for strips then */ sa->start = nsa[0]; @@ -1358,12 +1358,12 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) /* not enough room to swap, so show message */ if ((sa->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) { BKE_report(op->reports, RPT_WARNING, - "Cannot swap selected strips as they will not be able to fit in their new places"); + "Cannot swap selected strips as they will not be able to fit in their new places"); } else { BKE_reportf(op->reports, RPT_WARNING, - "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", - sa->name, sb->name); + "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", + sa->name, sb->name); } } @@ -1383,7 +1383,7 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1401,13 +1401,13 @@ void NLA_OT_swap(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Move Strips Up Operator ************************** */ /* Tries to move the selected strips into the track above if possible. */ -static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1420,15 +1420,15 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* since we're potentially moving strips from lower tracks to higher tracks, we should * loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks */ - for (ale= anim_data.last; ale; ale= ale->prev) { - NlaTrack *nlt= (NlaTrack *)ale->data; - NlaTrack *nltn= nlt->next; + for (ale = anim_data.last; ale; ale = ale->prev) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaTrack *nltn = nlt->next; NlaStrip *strip, *stripn; /* if this track has no tracks after it, skip for now... */ @@ -1436,8 +1436,8 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* for every selected strip, try to move */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track above has room for this strip */ @@ -1457,7 +1457,7 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1475,13 +1475,13 @@ void NLA_OT_move_up(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Move Strips Down Operator ************************** */ /* Tries to move the selected strips into the track above if possible. */ -static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1494,15 +1494,15 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through the tracks in normal order, since we're pushing strips down, * strips won't get operated on twice */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - NlaTrack *nltp= nlt->prev; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaTrack *nltp = nlt->prev; NlaStrip *strip, *stripn; /* if this track has no tracks before it, skip for now... */ @@ -1510,8 +1510,8 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* for every selected strip, try to move */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track below has room for this strip */ @@ -1531,7 +1531,7 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1549,36 +1549,36 @@ void NLA_OT_move_down(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Sync Action Length Operator ***************************** */ /* Recalculate the extents of the action ranges used for the selected strips */ -static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op) +static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - short active_only= RNA_boolean_get(op->ptr, "active"); + short active_only = RNA_boolean_get(op->ptr, "active"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); if (active_only) filter |= ANIMFILTER_ACTIVE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, apply scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip selection/active status check */ if (active_only) { if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) @@ -1607,7 +1607,7 @@ static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1625,7 +1625,7 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) ot->poll = ED_operator_nla_active; // XXX: is this satisfactory... probably requires a check for active strip... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip"); @@ -1635,21 +1635,21 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) /* Reset the scaling of the selected strips to 1.0f */ /* apply scaling to keyframe */ -static short bezt_apply_nlamapping (KeyframeEditData *ked, BezTriple *bezt) +static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt) { /* NLA-strip which has this scaling is stored in ked->data */ - NlaStrip *strip= (NlaStrip *)ked->data; + NlaStrip *strip = (NlaStrip *)ked->data; /* adjust all the times */ - bezt->vec[0][0]= nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP); - bezt->vec[1][0]= nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP); - bezt->vec[2][0]= nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP); + bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP); + bezt->vec[1][0] = nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP); + bezt->vec[2][0] = nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP); /* nothing to return or else we exit */ return 0; } -static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1657,24 +1657,24 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* init the editing data */ /* for each NLA-Track, apply scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { /* if the referenced action is used by other strips, make this strip use its own copy */ @@ -1682,22 +1682,22 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) continue; if (strip->act->id.us > 1) { /* make a copy of the Action to work on */ - bAction *act= copy_action(strip->act); + bAction *act = BKE_action_copy(strip->act); /* set this as the new referenced action, decrementing the users of the old one */ strip->act->id.us--; - strip->act= act; + strip->act = act; } /* setup iterator, and iterate over all the keyframes in the action, applying this scaling */ - ked.data= strip; + ked.data = strip; ANIM_animchanneldata_keyframes_loop(&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve); /* clear scale of strip now that it has been applied, * and recalculate the extents of the action now that it has been scaled * but leave everything else alone */ - strip->scale= 1.0f; + strip->scale = 1.0f; calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); } } @@ -1707,7 +1707,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1725,13 +1725,13 @@ void NLA_OT_apply_scale(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clear Scale Operator ***************************** */ /* Reset the scaling of the selected strips to 1.0f */ -static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1744,15 +1744,15 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, reset scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { PointerRNA strip_ptr; @@ -1770,7 +1770,7 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1788,7 +1788,7 @@ void NLA_OT_clear_scale(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Strips Operator ************************** */ @@ -1803,7 +1803,7 @@ static EnumPropertyItem prop_nlaedit_snap_types[] = { {0, NULL, 0, NULL, NULL} }; -static int nlaedit_snap_exec (bContext *C, wmOperator *op) +static int nlaedit_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1820,18 +1820,18 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* get some necessary vars */ - scene= ac.scene; - secf= (float)FPS; + scene = ac.scene; + secf = (float)FPS; /* since we may add tracks, perform this in reverse order */ - for (ale= anim_data.last; ale; ale= ale->prev) { + for (ale = anim_data.last; ale; ale = ale->prev) { ListBase tmp_strips = {NULL, NULL}; - AnimData *adt= ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *stripn; NlaTrack *track; @@ -1841,37 +1841,37 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) /* apply the snapping to all the temp meta-strips, then put them in a separate list to be added * back to the original only if they still fit */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_TEMP_META) { float start, end; /* get the existing end-points */ - start= strip->start; - end= strip->end; + start = strip->start; + end = strip->end; /* calculate new start position based on snapping mode */ switch (mode) { case NLAEDIT_SNAP_CFRA: /* to current frame */ - strip->start= (float)CFRA; + strip->start = (float)CFRA; break; case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */ - strip->start= floorf(start+0.5f); + strip->start = floorf(start + 0.5f); break; case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */ - strip->start= floorf(start/secf + 0.5f) * secf; + strip->start = floorf(start / secf + 0.5f) * secf; break; case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */ - strip->start= (float)ED_markers_find_nearest_marker_time(ac.markers, start); + strip->start = (float)ED_markers_find_nearest_marker_time(ac.markers, start); break; default: /* just in case... no snapping */ - strip->start= start; + strip->start = start; break; } /* get new endpoint based on start-point (and old length) */ - strip->end= strip->start + (end - start); + strip->end = strip->start + (end - start); /* apply transforms to meta-strip to its children */ BKE_nlameta_flush_transforms(strip); @@ -1883,8 +1883,8 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) } /* try adding each meta-strip back to the track one at a time, to make sure they'll fit */ - for (strip= tmp_strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = tmp_strips.first; strip; strip = stripn) { + stripn = strip->next; /* remove from temp-strips list */ BLI_remlink(&tmp_strips, strip); @@ -1892,7 +1892,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) /* in case there's no space in the current track, try adding */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* need to add a new track above the current one */ - track= add_nlatrack(adt, nlt); + track = add_nlatrack(adt, nlt); BKE_nlatrack_add_strip(track, strip); /* clear temp meta-strips on this new track, as we may not be able to get back to it */ @@ -1911,7 +1911,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1930,7 +1930,7 @@ void NLA_OT_snap(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", ""); @@ -1942,18 +1942,18 @@ void NLA_OT_snap(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ /* present a special customised popup menu for this, with some filtering */ -static int nla_fmodifier_add_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; int i; - pup= uiPupMenuBegin(C, "Add F-Modifier", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Add F-Modifier", ICON_NONE); + layout = uiPupMenuLayout(pup); /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); /* check if modifier is valid for this context */ if (fmi == NULL) @@ -1980,7 +1980,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) int filter; FModifier *fcm; - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); short onlyActive = RNA_boolean_get(op->ptr, "only_active"); /* get editor data */ @@ -1988,24 +1988,24 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* can F-Modifier be added to the current strip? */ if (onlyActive) { /* if not active, cannot add since we're only adding to active strip */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE)==0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) continue; } else { /* strip must be selected, since we're not just doing active */ - if ((strip->flag & NLASTRIP_FLAG_SELECT)==0) + if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) continue; } @@ -2014,14 +2014,14 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) continue; /* add F-Modifier of specified type to selected, and make it the active one */ - fcm= add_fmodifier(&strip->modifiers, type); + fcm = add_fmodifier(&strip->modifiers, type); if (fcm) set_active_fmodifier(&strip->modifiers, fcm); else { BKE_reportf(op->reports, RPT_ERROR, - "Modifier couldn't be added to (%s : %s) (see console for details)", - nlt->name, strip->name); + "Modifier couldn't be added to (%s : %s) (see console for details)", + nlt->name, strip->name); } } } @@ -2030,7 +2030,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -2049,7 +2049,7 @@ void NLA_OT_fmodifier_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); @@ -2063,7 +2063,7 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -2073,17 +2073,17 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) free_fmodifiers_copybuf(); /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* only add F-Modifier if on active strip? */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE)==0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) continue; // TODO: when 'active' vs 'all' boolean is added, change last param! @@ -2112,7 +2112,7 @@ void NLA_OT_fmodifier_copy(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); @@ -2125,22 +2125,22 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: do we want to replace existing modifiers? add user pref for that! ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, 0); } @@ -2153,7 +2153,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) if (ok) { /* set notifier that things have changed */ /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); return OPERATOR_FINISHED; } else { @@ -2174,7 +2174,7 @@ void NLA_OT_fmodifier_paste(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 9d0762ce108..398d2d5f1f4 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -55,7 +55,7 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar); /* defines for left-right select tool */ enum { - NLAEDIT_LRSEL_TEST = -1, + NLAEDIT_LRSEL_TEST = -1, NLAEDIT_LRSEL_NONE, NLAEDIT_LRSEL_LEFT, NLAEDIT_LRSEL_RIGHT @@ -131,7 +131,7 @@ void NLA_OT_delete_tracks(wmOperatorType *ot); /* nla_ops.c */ int nlaop_poll_tweakmode_off(bContext *C); -int nlaop_poll_tweakmode_on (bContext *C); +int nlaop_poll_tweakmode_on(bContext *C); short nlaedit_is_tweakmode_on(bAnimContext *ac); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index b320adc25fb..3a74d0b4c9c 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -53,7 +53,7 @@ #include "RNA_access.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* ************************** poll callbacks for operators **********************************/ @@ -63,7 +63,7 @@ int nlaop_poll_tweakmode_off(bContext *C) Scene *scene; /* for now, we check 2 things: - * 1) active editor must be NLA + * 1) active editor must be NLA * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, * but not all AnimData blocks will be in tweakmode for @@ -72,7 +72,7 @@ int nlaop_poll_tweakmode_off(bContext *C) if (ED_operator_nla_active(C) == 0) return 0; - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; @@ -85,7 +85,7 @@ int nlaop_poll_tweakmode_on(bContext *C) Scene *scene; /* for now, we check 2 things: - * 1) active editor must be NLA + * 1) active editor must be NLA * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, * but not all AnimData blocks will be in tweakmode for @@ -94,7 +94,7 @@ int nlaop_poll_tweakmode_on(bContext *C) if (ED_operator_nla_active(C) == 0) return 0; - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) return 0; @@ -173,119 +173,119 @@ static void nla_keymap_channels(wmKeyMap *keymap) /* NLA-specific (different to standard channels keymap) -------------------------- */ /* selection */ - /* click-select */ - // XXX for now, only leftmouse.... + /* click-select */ + // XXX for now, only leftmouse.... kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); /* channel operations */ - /* add tracks */ + /* add tracks */ kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", FALSE); - kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", TRUE); - /* delete tracks */ + /* delete tracks */ WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", DELKEY, KM_PRESS, 0, 0); } -static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; /* selection */ - /* click select */ + /* click select */ kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); - /* select left/right */ + /* select left/right */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); - /* deselect all */ - /* TODO: uniformize with other select_all ops? */ + /* deselect all */ + /* TODO: uniformize with other select_all ops? */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); /* view*/ - /* auto-set range */ + /* auto-set range */ //WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* editing */ - /* tweakmode - * - enter and exit are separate operators with the same hotkey... - * This works as they use different poll()'s - */ + /* tweakmode + * - enter and exit are separate operators with the same hotkey... + * This works as they use different poll()'s + */ WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); - /* add strips */ + /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); - /* meta-strips */ + /* meta-strips */ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0); - /* duplicate */ + /* duplicate */ WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); - /* delete */ + /* delete */ WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_delete", DELKEY, KM_PRESS, 0, 0); - /* split */ + /* split */ WM_keymap_add_item(keymap, "NLA_OT_split", YKEY, KM_PRESS, 0, 0); - /* toggles */ + /* toggles */ WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0); - /* swap */ + /* swap */ WM_keymap_add_item(keymap, "NLA_OT_swap", FKEY, KM_PRESS, KM_ALT, 0); - /* move up */ + /* move up */ WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0); - /* move down */ + /* move down */ WM_keymap_add_item(keymap, "NLA_OT_move_down", PAGEDOWNKEY, KM_PRESS, 0, 0); - /* apply scale */ + /* apply scale */ WM_keymap_add_item(keymap, "NLA_OT_apply_scale", AKEY, KM_PRESS, KM_CTRL, 0); - /* clear scale */ + /* clear scale */ WM_keymap_add_item(keymap, "NLA_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0); - /* snap */ + /* snap */ WM_keymap_add_item(keymap, "NLA_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - /* add f-modifier */ - WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* add f-modifier */ + WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_NLA); @@ -318,4 +318,3 @@ void nla_keymap(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0); nla_keymap_main(keyconf, keymap); } - diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index cfd4a3202d2..1ba15d529e8 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -57,12 +57,12 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* ******************** Utilities ***************************************** */ /* Convert SELECT_* flags to ACHANNEL_SETFLAG_* flags */ -static short selmodes_to_flagmodes (short sel) +static short selmodes_to_flagmodes(short sel) { /* convert selection modes to selection modes */ switch (sel) { @@ -98,13 +98,13 @@ enum { /* Deselects strips in the NLA Editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all (1) or clear all active (2) + * - test: check if select or deselect all (1) or clear all active (2) * - sel: how to select keyframes * 0 = deselect * 1 = select * 2 = invert */ -static void deselect_nla_strips (bAnimContext *ac, short test, short sel) +static void deselect_nla_strips(bAnimContext *ac, short test, short sel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -113,21 +113,21 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) /* determine type-based settings */ // FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed! - filter= (ANIMFILTER_DATA_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* See if we should be selecting or deselecting */ if (test == DESELECT_STRIPS_TEST) { - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* if any strip is selected, break out, since we should now be deselecting */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } @@ -138,15 +138,15 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) } /* convert selection modes to selection modes */ - smode= selmodes_to_flagmodes(sel); + smode = selmodes_to_flagmodes(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* apply same selection to all strips */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* set selection */ if (test != DESELECT_STRIPS_CLEARACTIVE) ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT); @@ -178,7 +178,7 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -195,7 +195,7 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -203,57 +203,57 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS) - * -> ALT-BKEY - depending on which axis of the region was larger... - * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE) - * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS) + * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS) + * -> ALT-BKEY - depending on which axis of the region was larger... + * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE) + * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS) */ /* defines for borderselect mode */ enum { - NLA_BORDERSEL_ALLSTRIPS = 0, + NLA_BORDERSEL_ALLSTRIPS = 0, NLA_BORDERSEL_FRAMERANGE, NLA_BORDERSEL_CHANNELS, } /* eNLAEDIT_BorderSelect_Mode */; -static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, short selectmode) +static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax=0; + float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax = 0; /* convert border-region to view coordinates */ - UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* convert selection modes to selection modes */ - selectmode= selmodes_to_flagmodes(selectmode); + selectmode = selmodes_to_flagmodes(selectmode); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - ymin= ymax - NLACHANNEL_STEP(snla); + for (ale = anim_data.first; ale; ale = ale->next) { + ymin = ymax - NLACHANNEL_STEP(snla); /* perform vertical suitability check (if applicable) */ if ( (mode == NLA_BORDERSEL_FRAMERANGE) || - !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) + !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting (only if NLA-Track) */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* only select strips if they fall within the required ranges (if applicable) */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if ( (mode == NLA_BORDERSEL_CHANNELS) || BKE_nlastrip_within_bounds(strip, rectf.xmin, rectf.xmax)) { @@ -268,7 +268,7 @@ static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, sh } /* set minimum extent to be the maximum of the next channel */ - ymax= ymin; + ymax = ymin; } /* cleanup */ @@ -281,7 +281,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; int extend; /* get editor data */ @@ -289,7 +289,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_SUBTRACT); @@ -312,18 +312,18 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= NLA_BORDERSEL_FRAMERANGE; + mode = NLA_BORDERSEL_FRAMERANGE; else - mode= NLA_BORDERSEL_CHANNELS; + mode = NLA_BORDERSEL_CHANNELS; } else - mode= NLA_BORDERSEL_ALLSTRIPS; + mode = NLA_BORDERSEL_ALLSTRIPS; /* apply borderselect action */ borderselect_nla_strips(&ac, rect, mode, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -344,7 +344,7 @@ void NLA_OT_select_border(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, 1); @@ -365,13 +365,13 @@ static EnumPropertyItem prop_nlaedit_leftright_select_types[] = { /* ------------------- */ -static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftright, short select_mode) +static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; float xmin, xmax; /* if currently in tweakmode, exit tweakmode first */ @@ -379,8 +379,8 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -398,20 +398,20 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr xmax = MAXFRAMEF; } - select_mode= selmodes_to_flagmodes(select_mode); + select_mode = selmodes_to_flagmodes(select_mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select strips on the side where most data occurs */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* check each strip to see if it is appropriate */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) { ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); } @@ -424,7 +424,7 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr /* ------------------- */ -static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) +static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -436,9 +436,9 @@ static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == NLAEDIT_LRSEL_TEST) @@ -448,12 +448,12 @@ static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) nlaedit_select_leftright(C, &ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int nlaedit_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -464,9 +464,9 @@ static int nlaedit_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* handle mode-based testing */ if (leftright == NLAEDIT_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -494,7 +494,7 @@ void NLA_OT_select_leftright(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_nlaedit_leftright_select_types, NLAEDIT_LRSEL_TEST, "Mode", ""); @@ -505,15 +505,15 @@ void NLA_OT_select_leftright(wmOperatorType *ot) /* ******************** Mouse-Click Select Operator *********************** */ /* select strip directly under mouse */ -static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], short select_mode) +static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale = NULL; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; - Scene *scene= ac->scene; + View2D *v2d = &ac->ar->v2d; + Scene *scene = ac->scene; NlaStrip *strip = NULL; int channel_index; float xmin, xmax, dummy; @@ -527,15 +527,15 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click * (that is the size of keyframe icons, so user should be expecting similar tolerances) */ - UI_view2d_region_to_view(v2d, mval[0]-7, mval[1], &xmin, &dummy); - UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &xmax, &dummy); + UI_view2d_region_to_view(v2d, mval[0] - 7, mval[1], &xmin, &dummy); + UI_view2d_region_to_view(v2d, mval[0] + 7, mval[1], &xmax, &dummy); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* try to get channel */ - ale= BLI_findlink(&anim_data, channel_index); + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n", channel_index); @@ -545,10 +545,10 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], else { /* found some channel - we only really should do somethign when its an Nla-Track */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* loop over NLA-strips in this track, trying to find one which occurs in the necessary bounds */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) break; } @@ -580,7 +580,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], /* Highlight NLA-Track */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; nlt->flag |= NLATRACK_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); @@ -591,7 +591,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], if (ale) { /* select the strip accordingly (if a matching one was found) */ if (strip) { - select_mode= selmodes_to_flagmodes(select_mode); + select_mode = selmodes_to_flagmodes(select_mode); ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); /* if we selected it, we can make it active too @@ -629,18 +629,18 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* select strips based upon mouse position */ mouse_nla_strips(C, &ac, event->mval, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void NLA_OT_click_select(wmOperatorType *ot) @@ -655,7 +655,7 @@ void NLA_OT_click_select(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 27c48d2232f..7c9014bd45f 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -60,7 +60,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* ******************** manage regions ********************* */ @@ -68,20 +68,20 @@ ARegion *nla_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after main */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for nla"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for nla"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; @@ -94,72 +94,72 @@ ARegion *nla_has_buttons_region(ScrArea *sa) static SpaceLink *nla_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); ARegion *ar; SpaceNla *snla; - snla= MEM_callocN(sizeof(SpaceNla), "initnla"); - snla->spacetype= SPACE_NLA; + snla = MEM_callocN(sizeof(SpaceNla), "initnla"); + snla->spacetype = SPACE_NLA; /* allocate DopeSheet data for NLA Editor */ - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); - snla->ads->source= (ID *)scene; + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads->source = (ID *)scene; /* set auto-snapping settings */ snla->autosnap = SACTSNAP_FRAME; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for nla"); + ar = MEM_callocN(sizeof(ARegion), "header for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel list for nla"); + ar = MEM_callocN(sizeof(ARegion), "channel list for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - /* only need to set these settings since this will use the 'stack' configuration */ + /* only need to set these settings since this will use the 'stack' configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* ui buttons */ - ar= MEM_callocN(sizeof(ARegion), "buttons area for nla"); + ar = MEM_callocN(sizeof(ARegion), "buttons area for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for nla"); + ar = MEM_callocN(sizeof(ARegion), "main area for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - ar->v2d.tot.xmin = (float)(SFRA-10); - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.xmax = (float)(EFRA+10); + ar->v2d.tot.xmin = (float)(SFRA - 10); + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + ar->v2d.tot.xmax = (float)(EFRA + 10); ar->v2d.tot.ymax = 0.0f; ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= 10000.0f; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 10000.0f; - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.keepofs= V2D_KEEPOFS_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; return (SpaceLink *)snla; @@ -168,7 +168,7 @@ static SpaceLink *nla_new(const bContext *C) /* not spacelink itself */ static void nla_free(SpaceLink *sl) { - SpaceNla *snla= (SpaceNla*) sl; + SpaceNla *snla = (SpaceNla *) sl; if (snla->ads) { BLI_freelistN(&snla->ads->chanbase); @@ -180,12 +180,12 @@ static void nla_free(SpaceLink *sl) /* spacetype; init callback */ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceNla *snla= (SpaceNla *)sa->spacedata.first; + SpaceNla *snla = (SpaceNla *)sa->spacedata.first; /* init dopesheet data if non-existant (i.e. for old files) */ if (snla->ads == NULL) { - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); - snla->ads->source= (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads->source = (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct } ED_area_tag_refresh(sa); @@ -193,10 +193,10 @@ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *nla_duplicate(SpaceLink *sl) { - SpaceNla *snlan= MEM_dupallocN(sl); + SpaceNla *snlan = MEM_dupallocN(sl); /* clear or remove stuff from old */ - snlan->ads= MEM_dupallocN(snlan->ads); + snlan->ads = MEM_dupallocN(snlan->ads); return (SpaceLink *)snlan; } @@ -209,10 +209,10 @@ static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - /* own channels map first to override some channel keymaps */ + /* own channels map first to override some channel keymaps */ keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - /* now generic channels map for everything else that can apply */ + /* now generic channels map for everything else that can apply */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -224,7 +224,7 @@ static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar) static void nla_channel_area_draw(const bContext *C, ARegion *ar) { bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear and setup matrix */ @@ -242,7 +242,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -265,12 +265,12 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar) static void nla_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceNla *snla= CTX_wm_space_nla(C); + SpaceNla *snla = CTX_wm_space_nla(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - short unit=0, flag=0; + short unit = 0, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -279,8 +279,8 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit= (snla->flag & SNLA_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -296,8 +296,8 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* current frame */ - if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((snla->flag & SNLA_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ @@ -312,7 +312,7 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -371,7 +371,7 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn) } break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); break; } @@ -417,7 +417,7 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -451,7 +451,7 @@ static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn) break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -496,61 +496,61 @@ static void nla_listener(ScrArea *sa, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_nla(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype nla"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla"); ARegionType *art; - st->spaceid= SPACE_NLA; + st->spaceid = SPACE_NLA; strncpy(st->name, "NLA", BKE_ST_MAXNAME); - st->new= nla_new; - st->free= nla_free; - st->init= nla_init; - st->duplicate= nla_duplicate; - st->operatortypes= nla_operatortypes; - st->listener= nla_listener; - st->keymap= nla_keymap; + st->new = nla_new; + st->free = nla_free; + st->init = nla_init; + st->duplicate = nla_duplicate; + st->operatortypes = nla_operatortypes; + st->listener = nla_listener; + st->keymap = nla_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_WINDOW; - art->init= nla_main_area_init; - art->draw= nla_main_area_draw; - art->listener= nla_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->init = nla_main_area_init; + art->draw = nla_main_area_draw; + art->listener = nla_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= nla_header_area_init; - art->draw= nla_header_area_draw; + art->init = nla_header_area_init; + art->draw = nla_header_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= nla_channel_area_init; - art->draw= nla_channel_area_draw; - art->listener= nla_channel_area_listener; + art->init = nla_channel_area_init; + art->draw = nla_channel_area_draw; + art->listener = nla_channel_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: UI buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI; - art->listener= nla_region_listener; - art->init= nla_buttons_area_init; - art->draw= nla_buttons_area_draw; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI; + art->listener = nla_region_listener; + art->init = nla_buttons_area_init; + art->draw = nla_buttons_area_draw; BLI_addhead(&st->regiontypes, art); @@ -559,4 +559,3 @@ void ED_spacetype_nla(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index bfa8111af3e..205202a0658 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1247,7 +1247,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; char numstr[32]; - const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr= BKE_image_user_frame_get(iuser, CFRA, 0); BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr); uiItemL(layout, numstr, ICON_NONE); } @@ -1262,9 +1262,6 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * } col= uiLayoutColumn(layout, 0); - - if (RNA_enum_get(&imaptr, "type")== IMA_TYPE_MULTILAYER) - uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1709,25 +1706,30 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *UNUSED(name), int x, int y, int width) { - NodeImageMultiFileSocket *input = sock->storage; uiLayout *layout, *row; PointerRNA nodeptr, inputptr, imfptr; int imtype; int rx, ry; RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - RNA_pointer_create(&ntree->id, &RNA_NodeImageFileSocket, input, &inputptr); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 0); - - uiItemL(row, input->path, 0); + row = uiLayoutRow(layout, 0); imfptr = RNA_pointer_get(&nodeptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); - /* in multilayer format all socket format details are ignored */ - if (imtype != R_IMF_IMTYPE_MULTILAYER) { + if (imtype == R_IMF_IMTYPE_MULTILAYER) { + NodeImageMultiFileSocket *input = sock->storage; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); + + uiItemL(row, input->layer, 0); + } + else { + NodeImageMultiFileSocket *input = sock->storage; PropertyRNA *imtype_prop; const char *imtype_name; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); + + uiItemL(row, input->path, 0); if (!RNA_boolean_get(&inputptr, "use_node_format")) imfptr = RNA_pointer_get(&inputptr, "format"); @@ -1767,10 +1769,18 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket"); - uiTemplateList(layout, C, ptr, "file_inputs", ptr, "active_input_index", NULL, 0, 0, 0); - active_index = RNA_int_get(ptr, "active_input_index"); - RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_inputs"), active_index, &active_input_ptr); + /* using different collection properties if multilayer format is enabled */ + if (multilayer) { + uiTemplateList(layout, C, ptr, "layer_slots", ptr, "active_input_index", NULL, 0, 0, 0); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"), active_index, &active_input_ptr); + } + else { + uiTemplateList(layout, C, ptr, "file_slots", ptr, "active_input_index", NULL, 0, 0, 0); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"), active_index, &active_input_ptr); + } + /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ + active_input_ptr.id.data = ptr->id.data; row = uiLayoutRow(layout, 1); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1779,19 +1789,25 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C RNA_enum_set(&op_ptr, "direction", 2); if (active_input_ptr.data) { - uiLayout *row, *col; - - col = uiLayoutColumn(layout, 1); - if (multilayer) - uiItemL(col, "Layer Name:", 0); - else + if (multilayer) { + uiLayout *row, *col; + col = uiLayoutColumn(layout, 1); + + uiItemL(col, "Layer:", 0); + row = uiLayoutRow(col, 0); + uiItemR(row, &active_input_ptr, "name", 0, "", 0); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + } + else { + uiLayout *row, *col; + col = uiLayoutColumn(layout, 1); + uiItemL(col, "File Path:", 0); - row = uiLayoutRow(col, 0); - uiItemR(row, &active_input_ptr, "path", 0, "", 0); - uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); - - /* in multilayer format all socket format details are ignored */ - if (!multilayer) { + row = uiLayoutRow(col, 0); + uiItemR(row, &active_input_ptr, "path", 0, "", 0); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + + /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); col = uiLayoutColumn(layout, 1); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5166387d6f4..9e59b3372cb 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -243,8 +243,37 @@ static bNode *editnode_get_active(bNodeTree *ntree) return nodeGetActive(ntree); } -void snode_dag_update(bContext *UNUSED(C), SpaceNode *snode) +static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { + bNode *node; + + if (ntree == lookup) + return 1; + + for (node=ntree->nodes.first; node; node=node->next) + if (node->type == NODE_GROUP && node->id) + if (has_nodetree((bNodeTree*)node->id, lookup)) + return 1; + + return 0; +} + +static void snode_dag_update_group(void *calldata, ID *owner_id, bNodeTree *ntree) +{ + if (has_nodetree(ntree, calldata)) + DAG_id_tag_update(owner_id, 0); +} + +void snode_dag_update(bContext *C, SpaceNode *snode) +{ + Main *bmain = CTX_data_main(C); + + /* for groups, update all ID's using this */ + if (snode->edittree!=snode->nodetree) { + bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); + } + DAG_id_tag_update(snode->id, 0); } @@ -289,7 +318,7 @@ void ED_node_shader_default(Scene *scene, ID *id) Material *ma= (Material*)id; ma->nodetree = ntree; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_DIFFUSE; } @@ -347,7 +376,7 @@ void ED_node_shader_default(Scene *scene, ID *id) nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { sock= in->inputs.first; copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); @@ -585,21 +614,6 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdateID(snode->nodetree, gnode->id); } -static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) -{ - bNode *node; - - if (ntree == lookup) - return 1; - - for (node=ntree->nodes.first; node; node=node->next) - if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) - return 1; - - return 0; -} - void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) { int was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE); @@ -1316,6 +1330,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; + ot->description = "Zoom in/out the brackground image"; /* api callbacks */ ot->exec = backimage_zoom; @@ -1482,6 +1497,7 @@ void NODE_OT_backimage_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Backimage Sample"; ot->idname = "NODE_OT_backimage_sample"; + ot->description = "Use mouse to sample background image"; /* api callbacks */ ot->invoke = sample_invoke; @@ -1593,6 +1609,7 @@ void NODE_OT_resize(wmOperatorType *ot) /* identifiers */ ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; + ot->description = "Resize a node"; /* api callbacks */ ot->invoke = node_resize_invoke; @@ -2547,6 +2564,7 @@ void NODE_OT_link(wmOperatorType *ot) /* identifiers */ ot->name = "Link Nodes"; ot->idname = "NODE_OT_link"; + ot->description = "Use the mouse to create a link between two nodes"; /* api callbacks */ ot->invoke = node_link_invoke; @@ -2666,6 +2684,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->name = "Cut links"; ot->idname = "NODE_OT_links_cut"; + ot->description = "Use the mouse to cut (remove) some links"; ot->invoke = WM_gesture_lines_invoke; ot->modal = WM_gesture_lines_modal; @@ -2711,6 +2730,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) { ot->name = "Detach Links"; ot->idname = "NODE_OT_links_detach"; + ot->description = "Remove all links to selected nodes, and try to connect neighbor nodes together"; ot->exec = detach_links_exec; ot->poll = ED_operator_node_active; @@ -2905,6 +2925,7 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) ot->name = "Read Render Layers"; ot->idname = "NODE_OT_read_renderlayers"; + ot->description = "Read all render layers of all used scenes"; ot->exec = node_read_renderlayers_exec; @@ -2938,6 +2959,7 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) ot->name = "Read Full Sample Layers"; ot->idname = "NODE_OT_read_fullsamplelayers"; + ot->description = "Read all render layers of current scene, in full sample"; ot->exec = node_read_fullsamplelayers_exec; @@ -2986,6 +3008,7 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; + ot->description = "Render current scene, when input node's layer has been changed"; ot->exec = node_render_changed_exec; @@ -3408,7 +3431,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) errno= 0; - ima= BKE_add_image_file(path); + ima= BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); @@ -3418,7 +3441,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) else if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)find_id("IM", name); + ima= (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); @@ -3544,8 +3567,9 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) void NODE_OT_new_node_tree(wmOperatorType *ot) { /* identifiers */ - ot->name = "New node tree"; + ot->name = "New Node Tree"; ot->idname = "NODE_OT_new_node_tree"; + ot->description = "Create a new node tree"; /* api callbacks */ ot->exec = new_node_tree_exec; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 7ddc4bdf857..bb52c1570aa 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -201,7 +201,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) } if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 1c681220016..7d9d7d736f6 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -111,30 +111,31 @@ void ED_operatormacros_node(void) wmOperatorType *ot; wmOperatorTypeMacro *mot; - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", "Duplicate selected nodes and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); /* modified operator call for duplicating with input links */ - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes keeping input links and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", + "Duplicate selected nodes keeping input links and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); RNA_boolean_set(mot->ptr, "keep_inputs", TRUE); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO); - ot->description = "Select node and link it to a viewer node"; + ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", + "Select node and link it to a viewer node", OPTYPE_UNDO); WM_operatortype_macro_define(ot, "NODE_OT_select"); WM_operatortype_macro_define(ot, "NODE_OT_link_viewer"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(mot->ptr, "release_confirm", TRUE); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 13e85c7f74d..785eafeb7c9 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -333,7 +333,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) int compatibility= 0; if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(arg->scene)) + if (BKE_scene_use_new_shading_nodes(arg->scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 042b668c9cc..7813bbcd9a6 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -74,20 +74,20 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (TSELEM_OPEN(tselem, soops)) outliner_height(soops, &te->subtree, h); (*h) += UI_UNIT_Y; - te= te->next; + te = te->next; } } #if 0 // XXX this is currently disabled until te->xend is set correctly static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { // TreeStoreElem *tselem= TREESTORE(te); @@ -97,16 +97,16 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) *w = te->xend; } outliner_width(soops, &te->subtree, w); - te= te->next; + te = te->next; } } #endif static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); // XXX fixme... (currently, we're using a fixed length of 100)! #if 0 if (te->xend) { @@ -114,12 +114,12 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start *w = te->xend; } #endif - if (startx+100 > *w) - *w = startx+100; + if (startx + 100 > *w) + *w = startx + 100; if (TSELEM_OPEN(tselem, soops)) - outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); - te= te->next; + outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X); + te = te->next; } } @@ -136,9 +136,9 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_VIEW) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -153,20 +153,20 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_SELECT) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin); } static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, poin); } static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) @@ -175,31 +175,31 @@ static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *po DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - Bone *bone= (Bone *)poin2; + Bone *bone = (Bone *)poin2; if (bone && (bone->flag & BONE_HIDDEN_P)) bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - EditBone *ebone= (EditBone *)poin2; + EditBone *ebone = (EditBone *)poin2; if (ebone && (ebone->flag & BONE_HIDDEN_A)) ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } @@ -211,7 +211,7 @@ static int group_select_flag(Group *gr) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) + for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; @@ -225,23 +225,23 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) Group *gr = (Group *)poin2; if (group_restrict_flag(gr, flag)) { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { gob->ob->restrictflag &= ~flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); } } else { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { /* not in editmode */ - if (scene->obedit!=gob->ob) { + if (scene->obedit != gob->ob) { gob->ob->restrictflag |= flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } } @@ -266,17 +266,17 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi static void namebutton_cb(bContext *C, void *tsep, char *oldname) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem= tsep; + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + TreeStore *ts = soops->treestore; + TreeStoreElem *tselem = tsep; if (ts && tselem) { - TreeElement *te= outliner_find_tse(soops, tselem); + TreeElement *te = outliner_find_tse(soops, tselem); - if (tselem->type==0) { - test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort + if (tselem->type == 0) { + test_idbutton(tselem->id->name + 2); // library.c, unique name and alpha sort switch (GS(tselem->id->name)) { case ID_MA: @@ -288,11 +288,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) case ID_SCE: WM_event_add_notifier(C, NC_SCENE, NULL); break; default: - WM_event_add_notifier(C, NC_ID|NA_RENAME, NULL); break; + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; } /* Check the library target exists */ if (te->idcode == ID_LI) { - Library *lib= (Library *)tselem->id; + Library *lib = (Library *)tselem->id; char expanded[FILE_MAX]; BKE_library_filepath_set(lib, lib->name); @@ -306,73 +306,73 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } else { switch (tselem->type) { - case TSE_DEFGROUP: - defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object - break; - case TSE_NLA_ACTION: - test_idbutton(tselem->id->name+2); - break; - case TSE_EBONE: - { - bArmature *arm= (bArmature *)tselem->id; - if (arm->edbo) { - EditBone *ebone= te->directdata; - char newname[sizeof(ebone->name)]; - - /* restore bone name */ - BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); - BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); - ED_armature_bone_rename(obedit->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); + case TSE_DEFGROUP: + defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object + break; + case TSE_NLA_ACTION: + test_idbutton(tselem->id->name + 2); + break; + case TSE_EBONE: + { + bArmature *arm = (bArmature *)tselem->id; + if (arm->edbo) { + EditBone *ebone = te->directdata; + char newname[sizeof(ebone->name)]; + + /* restore bone name */ + BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); + BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); + ED_armature_bone_rename(obedit->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT); + } } - } break; - case TSE_BONE: + case TSE_BONE: { - Bone *bone= te->directdata; + Bone *bone = te->directdata; Object *ob; char newname[sizeof(bone->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, bone->name, sizeof(bone->name)); BLI_strncpy(bone->name, oldname, sizeof(bone->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSE_CHANNEL: + case TSE_POSE_CHANNEL: { - bPoseChannel *pchan= te->directdata; + bPoseChannel *pchan = te->directdata; Object *ob; char newname[sizeof(pchan->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSEGRP: + case TSE_POSEGRP: { - Object *ob= (Object *)tselem->id; // id = object - bActionGroup *grp= te->directdata; + Object *ob = (Object *)tselem->id; // id = object + bActionGroup *grp = te->directdata; BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_R_LAYER: - break; + case TSE_R_LAYER: + break; } } tselem->flag &= ~TSE_TEXTBUT; @@ -387,120 +387,120 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar Object *ob = NULL; Group *gr = NULL; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { PointerRNA ptr; ob = (Object *)tselem->id; RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiBlockSetEmboss(block, UI_EMBOSS); } - if (tselem->type==0 && te->idcode==ID_GR) { + if (tselem->type == 0 && te->idcode == ID_GR) { int restrict_bool; gr = (Group *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); } /* scene render layers and passes have toggle-able flags too! */ - else if (tselem->type==TSE_R_LAYER) { + else if (tselem->type == TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + bt = uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_R_PASS) { - int *layflag= te->directdata; - int passflag= 1<<tselem->nr; + else if (tselem->type == TSE_R_PASS) { + int *layflag = te->directdata; + int passflag = 1 << tselem->nr; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass"); + bt = uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - layflag++; /* is lay_xor */ + layflag++; /* is lay_xor */ if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) - bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_MODIFIER) { - ModifierData *md= (ModifierData *)te->directdata; + else if (tselem->type == TSE_MODIFIER) { + ModifierData *md = (ModifierData *)te->directdata; ob = (Object *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } - else if (tselem->type==TSE_POSE_CHANNEL) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + else if (tselem->type == TSE_POSE_CHANNEL) { + bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } - else if (tselem->type==TSE_EBONE) { - EditBone *ebone= (EditBone *)te->directdata; + else if (tselem->type == TSE_EBONE) { + EditBone *ebone = (EditBone *)te->directdata; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); } } @@ -511,23 +511,23 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar static void outliner_draw_rnacols(ARegion *ar, int sizex) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; - float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; - if (miny<v2d->tot.ymin) miny = v2d->tot.ymin; + float miny = v2d->cur.ymin - V2D_SCROLL_HEIGHT; + if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* draw column separator lines */ fdrawline((float)sizex, - v2d->cur.ymax, - (float)sizex, - miny); - - fdrawline((float)sizex+OL_RNA_COL_SIZEX, - v2d->cur.ymax, - (float)sizex+OL_RNA_COL_SIZEX, - miny); + v2d->cur.ymax, + (float)sizex, + miny); + + fdrawline((float)sizex + OL_RNA_COL_SIZEX, + v2d->cur.ymax, + (float)sizex + OL_RNA_COL_SIZEX, + miny); } static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb) @@ -539,21 +539,21 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->type == TSE_RNA_PROPERTY) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem, soops))) ) - uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } else if (tselem->type == TSE_RNA_ARRAY_ELEM) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; - uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } } @@ -563,7 +563,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) { - wmOperatorType *ot= arg2; + wmOperatorType *ot = arg2; wmKeyMapItem *kmi = arg_kmi; if (ot) @@ -572,10 +572,10 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) { - GHashIterator *iter= WM_operatortype_iter(); + GHashIterator *iter = WM_operatortype_iter(); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(iter); if (BLI_strcasestr(ot->idname, str)) { char name[OP_MAX_TYPENAME]; @@ -583,7 +583,7 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar /* display name for menu */ WM_operator_py_idname(name, ot->idname); - if (0==uiSearchItemAdd(items, name, ot, 0)) + if (0 == uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -595,17 +595,17 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) { static char search[OP_MAX_TYPENAME]; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); wmKeyMapItem *kmi = arg_kmi; - wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); uiBlock *block; uiBut *but; /* clear initial search string, then all items show */ - search[0]= 0; + search[0] = 0; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -617,20 +617,20 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; } -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 +#define OL_KM_KEYBOARD 0 +#define OL_KM_MOUSE 1 +#define OL_KM_TWEAK 2 +#define OL_KM_SPECIALS 3 static short keymap_menu_type(short type) { @@ -643,11 +643,11 @@ static short keymap_menu_type(short type) static const char *keymap_type_menu(void) { - static const char string[]= - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) + static const char string[] = + "Event Type%t" + "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) + "|Mouse%x" STRINGIFY(OL_KM_MOUSE) + "|Tweak%x" STRINGIFY(OL_KM_TWEAK) // "|Specials%x" STRINGIFY(OL_KM_SPECIALS) ; @@ -656,25 +656,25 @@ static const char *keymap_type_menu(void) static const char *keymap_mouse_menu(void) { - static const char string[]= - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) + static const char string[] = + "Mouse Event%t" + "|Left Mouse%x" STRINGIFY(LEFTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) + "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) + "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) + "|Select Mouse%x" STRINGIFY(SELECTMOUSE) + "|Mouse Move%x" STRINGIFY(MOUSEMOVE) + "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) + "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) + "|Wheel In%x" STRINGIFY(WHEELINMOUSE) + "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) + "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) + "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) + "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) ; return string; @@ -682,13 +682,13 @@ static const char *keymap_mouse_menu(void) static const char *keymap_tweak_menu(void) { - static const char string[]= - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) + static const char string[] = + "Tweak Event%t" + "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) + "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) + "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) + "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) + "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) ; return string; @@ -696,17 +696,17 @@ static const char *keymap_tweak_menu(void) static const char *keymap_tweak_dir_menu(void) { - static const char string[]= - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) + static const char string[] = + "Tweak Direction%t" + "|Any%x" STRINGIFY(KM_ANY) + "|North%x" STRINGIFY(EVT_GESTURE_N) + "|North-East%x" STRINGIFY(EVT_GESTURE_NE) + "|East%x" STRINGIFY(EVT_GESTURE_E) + "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) + "|South%x" STRINGIFY(EVT_GESTURE_S) + "|South-West%x" STRINGIFY(EVT_GESTURE_SW) + "|West%x" STRINGIFY(EVT_GESTURE_W) + "|North-West%x" STRINGIFY(EVT_GESTURE_NW) ; return string; @@ -716,25 +716,25 @@ static const char *keymap_tweak_dir_menu(void) static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) { wmKeyMapItem *kmi = kmi_v; - short maptype= keymap_menu_type(kmi->type); + short maptype = keymap_menu_type(kmi->type); - if (maptype!=kmi->maptype) { + if (maptype != kmi->maptype) { switch (kmi->maptype) { case OL_KM_KEYBOARD: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; break; case OL_KM_MOUSE: - kmi->type= LEFTMOUSE; - kmi->val= KM_PRESS; + kmi->type = LEFTMOUSE; + kmi->val = KM_PRESS; break; case OL_KM_TWEAK: - kmi->type= EVT_TWEAK_L; - kmi->val= KM_ANY; + kmi->type = EVT_TWEAK_L; + kmi->val = KM_ANY; break; case OL_KM_SPECIALS: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; } ED_region_tag_redraw(CTX_wm_region(C)); } @@ -747,67 +747,67 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { uiBut *but; const char *str; - int xstart= 240; - int butw1= UI_UNIT_X; /* operator */ - int butw2= 90; /* event type, menus */ - int butw3= 43; /* modifiers */ + int xstart = 240; + int butw1 = UI_UNIT_X; /* operator */ + int butw2 = 90; /* event type, menus */ + int butw3 = 43; /* modifiers */ if (tselem->type == TSE_KEYMAP_ITEM) { wmKeyMapItem *kmi = te->directdata; /* modal map? */ - if (kmi->propvalue); + if (kmi->propvalue) ; else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); + uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1, "Assign new Operator"); } - xstart+= butw1+10; + xstart += butw1 + 10; /* map type button */ - kmi->maptype= keymap_menu_type(kmi->type); + kmi->maptype = keymap_menu_type(kmi->type); - str= keymap_type_menu(); - but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type"); + str = keymap_type_menu(); + but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype, 0, 0, 0, 0, "Event type"); uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart+= butw2+5; + xstart += butw2 + 5; /* edit actual event */ switch (kmi->maptype) { case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code"); - xstart+= butw2+5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, "Key code"); + xstart += butw2 + 5; break; case OL_KM_MOUSE: - str= keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Mouse button"); - xstart+= butw2+5; + str = keymap_mouse_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Mouse button"); + xstart += butw2 + 5; break; case OL_KM_TWEAK: - str= keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); - xstart+= butw2+5; - str= keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); - xstart+= butw2+5; + str = keymap_tweak_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); + xstart += butw2 + 5; + str = keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart += butw2 + 5; break; } /* modifiers */ - uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; - uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - xstart+= 5; - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code"); - xstart+= butw3+5; + uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys + 1, butw3 + 5, UI_UNIT_Y - 1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart += butw3 + 5; + uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart += butw3; + xstart += 5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier, "Key Modifier code"); + xstart += butw3 + 5; /* rna property */ if (kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; + uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, ""); xstart += butw2; } (void)xstart; @@ -826,33 +826,33 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa TreeStoreElem *tselem; int spx, dx, len; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->flag & TSE_TEXTBUT) { /* If we add support to rename Sequence. * need change this. */ - if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature + if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature - if (tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); - else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); - else if (tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); - else len= MAX_ID_NAME-2; + if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name); + else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name); + else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name); + else len = MAX_ID_NAME - 2; - dx= (int)UI_GetStringWidth(te->name); - if (dx<100) dx= 100; - spx=te->xs+2*UI_UNIT_X-4; - if (spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; + dx = (int)UI_GetStringWidth(te->name); + if (dx < 100) dx = 100; + spx = te->xs + 2 * UI_UNIT_X - 4; + if (spx + dx + 10 > ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax - spx - 10; - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); + bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx + 10, UI_UNIT_Y - 1, (void *)te->name, 1.0, (float)len, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); /* returns false if button got removed */ - if ( 0 == uiButActiveOnly(C, block, bt) ) + if (0 == uiButActiveOnly(C, block, bt) ) tselem->flag &= ~TSE_TEXTBUT; } } @@ -882,8 +882,8 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) } else { /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ - float ufac= UI_UNIT_X/20.0f; - uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); + float ufac = UI_UNIT_X / 20.0f; + uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x - 3.0f * ufac, arg->y, UI_UNIT_X - 4.0f * ufac, UI_UNIT_Y - 4.0f * ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); if (arg->id) uiButSetDragID(but, arg->id); @@ -896,15 +896,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto struct DrawIconArg arg; /* make function calls a bit compacter */ - arg.block= block; - arg.id= tselem->id; + arg.block = block; + arg.id = tselem->id; arg.xmax = xmax; - arg.x= x; - arg.y= y; - arg.alpha= alpha; + arg.x = x; + arg.y = y; + arg.alpha = alpha; if (tselem->type) { - switch ( tselem->type) { + switch (tselem->type) { case TSE_ANIM_DATA: UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx case TSE_NLA: @@ -930,8 +930,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_PARTICLES); break; case TSE_MODIFIER: { - Object *ob= (Object *)tselem->id; - ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr); + Object *ob = (Object *)tselem->id; + ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); switch (md->type) { case eModifierType_Subsurf: UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; @@ -1033,15 +1033,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if (te->idcode==SEQ_MOVIE) + if (te->idcode == SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); - else if (te->idcode==SEQ_META) + else if (te->idcode == SEQ_META) UI_icon_draw(x, y, ICON_DOT); - else if (te->idcode==SEQ_SCENE) + else if (te->idcode == SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if (te->idcode==SEQ_SOUND) + else if (te->idcode == SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); - else if (te->idcode==SEQ_IMAGE) + else if (te->idcode == SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); else UI_icon_draw(x, y, ICON_PARTICLES); @@ -1054,7 +1054,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto break; case TSE_RNA_STRUCT: if (RNA_struct_is_ID(te->rnaptr.type)) { - arg.id= (ID *)te->rnaptr.data; + arg.id = (ID *)te->rnaptr.data; tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); } else @@ -1065,7 +1065,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else if (GS(tselem->id->name) == ID_OB) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; @@ -1093,7 +1093,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else { - switch ( GS(tselem->id->name)) { + switch (GS(tselem->id->name)) { case ID_SCE: tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; case ID_ME: @@ -1106,7 +1106,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; case ID_LA: { - Lamp *la= (Lamp *)tselem->id; + Lamp *la = (Lamp *)tselem->id; switch (la->type) { case LA_LOCAL: @@ -1161,46 +1161,46 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa TreeStoreElem *tselem; int active; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) break; - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* object hierarchy always, further constrained on level */ - if (level<1 || (tselem->type==0 && te->idcode==ID_OB)) { + if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { /* active blocks get white circle */ - if (tselem->type==0) { - if (te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); - else if (scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? - else active= tree_element_active(C, scene, soops, te, 0); + if (tselem->type == 0) { + if (te->idcode == ID_OB) active = (OBACT == (Object *)tselem->id); + else if (scene->obedit && scene->obedit->data == tselem->id) active = 1; // XXX use context? + else active = tree_element_active(C, scene, soops, te, 0); } - else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); + else active = tree_element_type_active(NULL, scene, soops, te, tselem, 0); if (active) { - float ufac= UI_UNIT_X/20.0f; + float ufac = UI_UNIT_X / 20.0f; uiSetRoundBox(UI_CNR_ALL); glColor4ub(255, 255, 255, 100); - uiRoundBox((float) * offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); + uiRoundBox((float) *offsx - 0.5f * ufac, (float)ys - 1.0f * ufac, (float)*offsx + UI_UNIT_Y - 3.0f * ufac, (float)ys + UI_UNIT_Y - 3.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); glEnable(GL_BLEND); /* roundbox disables */ } tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); - te->xs= (float)*offsx; - te->ys= (float)ys; - te->xend= (short)*offsx+UI_UNIT_X; - te->flag |= TE_ICONROW; // for click + te->xs = (float)*offsx; + te->ys = (float)ys; + te->xend = (short)*offsx + UI_UNIT_X; + te->flag |= TE_ICONROW; // for click (*offsx) += UI_UNIT_X; } /* this tree element always has same amount of branches, so don't draw */ - if (tselem->type!=TSE_R_LAYER) - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); + if (tselem->type != TSE_R_LAYER) + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level + 1, xmax, offsx, ys); } } @@ -1211,11 +1211,11 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i TreeElement *ten; /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); + te->xs = (float)startx; + te->ys = (float)(*starty); - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -1224,17 +1224,17 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene { TreeElement *ten; TreeStoreElem *tselem; - float ufac= UI_UNIT_X/20.0f; - int offsx= 0, active=0; // active=1 active obj, else active data + float ufac = UI_UNIT_X / 20.0f; + int offsx = 0, active = 0; // active=1 active obj, else active data - tselem= TREESTORE(te); + tselem = TREESTORE(te); - if (*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { - int xmax= ar->v2d.cur.xmax; + if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { + int xmax = ar->v2d.cur.xmax; /* icons can be ui buts, we don't want it to overlap with restrict */ - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - xmax-= OL_TOGW+UI_UNIT_X; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + xmax -= OL_TOGW + UI_UNIT_X; glEnable(GL_BLEND); @@ -1242,149 +1242,149 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene * we don't expand items when searching in the datablocks but we * still want to highlight any filter matches. */ - if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && - (tselem->flag & TSE_SEARCHMATCH)) + if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATABLOCKS && soops->search_string[0] != 0)) && + (tselem->flag & TSE_SEARCHMATCH)) { char col[4]; UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col); - col[3]=100; + col[3] = 100; glColor4ubv((GLubyte *)col); - glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } /* colors for active/selected data */ - if (tselem->type==0) { - if (te->idcode==ID_SCE) { + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } } - else if (te->idcode==ID_GR) { + else if (te->idcode == ID_GR) { Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; glColor4ubv((GLubyte *)col); - active= 2; + active = 2; } } - else if (te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + else if (te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; - if (ob==OBACT || (ob->flag & SELECT)) { - char col[4]= {0, 0, 0, 0}; + if (ob == OBACT || (ob->flag & SELECT)) { + char col[4] = {0, 0, 0, 0}; /* outliner active ob: always white text, circle color now similar to view3d */ - active= 2; /* means it draws a color circle */ - if (ob==OBACT) { + active = 2; /* means it draws a color circle */ + if (ob == OBACT) { if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } - active= 1; /* means it draws white text */ + active = 1; /* means it draws white text */ } else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } glColor4ubv((GLubyte *)col); } } - else if (scene->obedit && scene->obedit->data==tselem->id) { + else if (scene->obedit && scene->obedit->data == tselem->id) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } else { if (tree_element_active(C, scene, soops, te, 0)) { glColor4ub(220, 220, 255, 100); - active= 2; + active = 2; } } } else { - if ( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; + if (tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active = 2; glColor4ub(220, 220, 255, 100); } /* active circle */ if (active) { uiSetRoundBox(UI_CNR_ALL); - uiRoundBox((float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); - glEnable(GL_BLEND); /* roundbox disables it */ + uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac, (float)*starty + 2.0f * ufac, (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); + glEnable(GL_BLEND); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies } /* open/close icon, only when sublevels, except for scene */ - if (te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { + if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; - if (tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) + if (tselem->type == 0 && ELEM(te->idcode, ID_OB, ID_SCE)) icon_x = startx; else - icon_x = startx+5*ufac; + icon_x = startx + 5 * ufac; - // icons a bit higher + // icons a bit higher if (TSELEM_OPEN(tselem, soops)) - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_DOWN); else - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_RIGHT); } - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { // icons a bit higher - tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); + tselem_draw_icon(block, xmax, (float)startx + offsx - 0.5f * ufac, (float)*starty + 2.0f * ufac, tselem, te, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } else - offsx+= 2*ufac; + offsx += 2 * ufac; - if (tselem->type==0 && tselem->id->lib) { + if (tselem->type == 0 && tselem->id->lib) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); if (tselem->id->flag & LIB_INDIRECT) - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_INDIRECT); else - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } glDisable(GL_BLEND); /* name */ - if (active==1) UI_ThemeColor(TH_TEXT_HI); + if (active == 1) UI_ThemeColor(TH_TEXT_HI); else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); else UI_ThemeColor(TH_TEXT); - UI_DrawString(startx+offsx, *starty+5*ufac, te->name); + UI_DrawString(startx + offsx, *starty + 5 * ufac, te->name); - offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); + offsx += (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if (!TSELEM_OPEN(tselem, soops)) { if (te->subtree.first) { - if (tselem->type==0 && te->idcode==ID_SCE); - else if (tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ - int tempx= startx+offsx; + if (tselem->type == 0 && te->idcode == ID_SCE) ; + else if (tselem->type != TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ + int tempx = startx + offsx; // divider UI_ThemeColorShade(TH_BACK, -40); - glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4); + glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4); glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty + 2); glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); @@ -1393,21 +1393,21 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)*starty; - te->xend= startx+offsx; + te->xs = (float)startx; + te->ys = (float)*starty; + te->xend = startx + offsx; if (TSELEM_OPEN(tselem, soops)) { - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; - for (ten= te->subtree.first; ten; ten= ten->next) - outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) + outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty); } else { - for (ten= te->subtree.first; ten; ten= ten->next) + for (ten = te->subtree.first; ten; ten = ten->next) outliner_set_coord_tree_element(soops, te, startx, starty); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; } } @@ -1417,30 +1417,30 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeStoreElem *tselem; int y1, y2; - if (lb->first==NULL) return; + if (lb->first == NULL) return; - y1=y2= *starty; /* for vertical lines between objects */ - for (te=lb->first; te; te= te->next) { - y2= *starty; - tselem= TREESTORE(te); + y1 = y2 = *starty; /* for vertical lines between objects */ + for (te = lb->first; te; te = te->next) { + y2 = *starty; + tselem = TREESTORE(te); /* horizontal line? */ - if (tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) - glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); + if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) + glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) - outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); + outliner_draw_hierarchy(soops, &te->subtree, startx + UI_UNIT_X, starty); } /* vertical line */ - te= lb->last; - if (te->parent || lb->first!=lb->last) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { + te = lb->last; + if (te->parent || lb->first != lb->last) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) { - glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); + glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2); } } } @@ -1450,19 +1450,19 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (TSELEM_OPEN(tselem, soops)) if (tselem->type == TSE_RNA_STRUCT) - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, *starty + UI_UNIT_Y - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) - fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); + fdrawline(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (float)*starty + UI_UNIT_Y); } } } @@ -1472,14 +1472,14 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (tselem->flag & TSE_SELECTED) { - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) outliner_draw_selection(ar, soops, &te->subtree, starty); } } @@ -1497,26 +1497,26 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio /* struct marks */ UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); //UI_ThemeColorShade(TH_BACK, -20); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } /* always draw selection fill before hierarchy */ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); glColor3fv(col); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); // grey hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET; - startx= 6; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; + startx = 6; outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); // items themselves - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - startx= 0; - for (te= soops->tree.first; te; te= te->next) { + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + startx = 0; + for (te = soops->tree.first; te; te = te->next) { outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); } } @@ -1527,12 +1527,12 @@ static void outliner_back(ARegion *ar) int ystart; UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti(0, ystart, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } } @@ -1542,36 +1542,36 @@ static void outliner_draw_restrictcols(ARegion *ar) /* background underneath */ UI_ThemeColor(TH_BACK); - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, (int)ar->v2d.cur.ymin-V2D_SCROLL_HEIGHT-1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, (int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* view */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); } /* ****************************************************** */ @@ -1579,13 +1579,13 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *mainvar = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + SpaceOops *soops = CTX_wm_space_outliner(C); uiBlock *block; - int sizey= 0, sizex= 0, sizex_rna= 0; + int sizey = 0, sizex = 0, sizex_rna = 0; outliner_build_tree(mainvar, scene, soops); // always @@ -1594,7 +1594,7 @@ void draw_outliner(const bContext *C) if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { /* RNA has two columns: - * - column 1 is (max_width + OL_RNA_COL_SPACEX) or + * - column 1 is (max_width + OL_RNA_COL_SPACEX) or * (OL_RNA_COL_X), whichever is wider... * - column 2 is fixed at OL_RNA_COL_SIZEX * @@ -1603,13 +1603,13 @@ void draw_outliner(const bContext *C) /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); - sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); + sizex_rna = MAX2(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ if (soops->outlinevis == SO_KEYMAP) - sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50; // XXX this is only really a quick hack to make this wide enough... else - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ @@ -1618,8 +1618,8 @@ void draw_outliner(const bContext *C) /* constant offset for restriction columns */ // XXX this isn't that great yet... - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - sizex += OL_TOGW*3; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + sizex += OL_TOGW * 3; } /* tweak to display last line (when list bigger than window) */ @@ -1632,13 +1632,13 @@ void draw_outliner(const bContext *C) UI_view2d_totRect_set(v2d, sizex, sizey); /* force display to pixel coords */ - v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); + v2d->flag |= (V2D_PIXELOFS_X | V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ UI_view2d_view_ortho(v2d); /* draw outliner stuff (background, hierachy lines and names) */ outliner_back(ar); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 7b200e9593d..04e9cbf24c2 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -75,13 +75,13 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te) { TreeStoreElem *tselem; - int retval= 0; + int retval = 0; - for (te= te->parent; te; te= te->parent) { - tselem= TREESTORE(te); + for (te = te->parent; te; te = te->parent) { + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) { tselem->flag &= ~TSE_CLOSED; - retval= 1; + retval = 1; } } return retval; @@ -92,17 +92,17 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* check if this tree-element was the one we're seeking */ if (te == teFind) { - *found= 1; + *found = 1; return; } /* try to see if sub-tree contains it then */ outliner_open_reveal(soops, &te->subtree, teFind, found); if (*found) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; return; @@ -119,8 +119,8 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) { - if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* all below close/open? */ if (all) { @@ -135,7 +135,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } @@ -146,15 +146,15 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement /* event can enterkey, then it opens/closes */ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int all= RNA_boolean_get(op->ptr, "all"); + int all = RNA_boolean_get(op->ptr, "all"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } @@ -183,12 +183,12 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, { /* can't rename rna datablocks entries */ if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - /* do nothing */; + /* do nothing */; } else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, - TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) { - BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); } else if (ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); @@ -207,27 +207,27 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - ARegion *ar= CTX_wm_region(C); - ReportList *reports= CTX_wm_reports(C); // XXX + ARegion *ar = CTX_wm_region(C); + ReportList *reports = CTX_wm_reports(C); // XXX do_item_rename(ar, te, tselem, reports); } static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { - ReportList *reports= CTX_wm_reports(C); // XXX + ReportList *reports = CTX_wm_reports(C); // XXX - if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* name and first icon */ - if (mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { do_item_rename(ar, te, tselem, reports); } return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, mval)) return 1; } return 0; @@ -235,14 +235,14 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, fmval)) break; } @@ -272,12 +272,12 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) { TreeElement *te; - int level=curlevel, lev; + int level = curlevel, lev; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { - lev= outliner_count_levels(soops, &te->subtree, curlevel+1); - if (lev>level) level= lev; + lev = outliner_count_levels(soops, &te->subtree, curlevel + 1); + if (lev > level) level = lev; } return level; } @@ -288,11 +288,11 @@ int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curl TreeStoreElem *tselem; int level; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - level= outliner_has_one_flag(soops, &te->subtree, flag, curlevel+1); + level = outliner_has_one_flag(soops, &te->subtree, flag, curlevel + 1); if (level) return level; } return 0; @@ -303,9 +303,9 @@ void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (set==0) tselem->flag &= ~flag; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (set == 0) tselem->flag &= ~flag; else tselem->flag |= flag; outliner_set_flag(soops, &te->subtree, flag, set); } @@ -321,7 +321,7 @@ int common_restrict_check(bContext *C, Object *ob) /* Don't allow hide an object in edit mode, * check the bug #22153 and #21609, #23977 */ - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit && obedit == ob) { /* found object is hidden, reset */ if (ob->restrictflag & OB_RESTRICT_VIEW) @@ -342,13 +342,13 @@ int common_restrict_check(bContext *C, Object *ob) void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; Object *ob = (Object *)tselem->id; /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - if (base || (base= object_in_scene(ob, scene))) { + if (base || (base = BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } @@ -357,19 +357,19 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW); } static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -386,36 +386,36 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_visibility_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Selectability ---------------------------------------- */ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_SELECT; + base->object->restrictflag ^= OB_RESTRICT_SELECT; } } void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT); } static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -432,35 +432,35 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_selectability_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Renderability ---------------------------------------- */ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_RENDER; + base->object->restrictflag ^= OB_RESTRICT_RENDER; } } void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER); } static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); return OPERATOR_FINISHED; } @@ -476,7 +476,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_renderability_exec; ot->poll = ED_operator_outliner_active; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -486,8 +486,8 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1)) outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0); @@ -517,9 +517,9 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); @@ -528,7 +528,7 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) soops->storeflag |= SO_TREESTORE_REDRAW; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -555,10 +555,10 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot) static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *so= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; + SpaceOops *so = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; TreeElement *te; int xdelta, ytop; @@ -567,14 +567,14 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) if (OBACT == NULL) return OPERATOR_CANCELLED; - te= outliner_find_id(so, &so->tree, (ID *)OBACT); + 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); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin) / 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 - (v2d->mask.ymax - v2d->mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); @@ -605,16 +605,16 @@ 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 up= 0; + ARegion *ar = CTX_wm_region(C); + int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up = 0; if (RNA_boolean_get(op->ptr, "up")) - up= 1; + up = 1; - if (up == 0) dy= -dy; - ar->v2d.cur.ymin+= dy; - ar->v2d.cur.ymax+= dy; + if (up == 0) dy = -dy; + ar->v2d.cur.ymin += dy; + ar->v2d.cur.ymax += dy; ED_region_tag_redraw(ar); @@ -645,17 +645,17 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) /* recursive helper for function below */ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - *starty-= UI_UNIT_Y; + te->xs = (float)startx; + te->ys = (float)(*starty); + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { TreeElement *ten; - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coordinates_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -665,20 +665,20 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) { TreeElement *te; - int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; - int startx= 0; + int starty = (int)(ar->v2d.tot.ymax) - UI_UNIT_Y; + int startx = 0; - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_set_coordinates_element(soops, te, startx, &starty); } } /* find next element that has this name */ -static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) +static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) { TreeElement *te, *tes; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { int found = outliner_filter_has_name(te, name, flags); if (found) { @@ -694,7 +694,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na return te; } - tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); + tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -705,44 +705,44 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { ReportList *reports = NULL; // CTX_wm_reports(C); - TreeElement *te= NULL; + TreeElement *te = NULL; TreeElement *last_find; TreeStoreElem *tselem; - int ytop, xdelta, prevFound=0; + int ytop, xdelta, prevFound = 0; char name[sizeof(soops->search_string)]; /* get last found tree-element based on stored search_tse */ - last_find= outliner_find_tse(soops, &soops->search_tse); + last_find = outliner_find_tse(soops, &soops->search_tse); /* determine which type of search to do */ if (again && last_find) { /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); - flags= soops->search_flags; + flags = soops->search_flags; /* try to find matching element */ - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); - if (te==NULL) { + te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); + if (te == NULL) { /* no more matches after previous, start from beginning again */ - prevFound= 1; - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + prevFound = 1; + te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); } } else { /* pop up panel - no previous, or user didn't want search after previous */ - name[0]= '\0'; + name[0] = '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { -// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); +// te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); // } // else return; /* XXX RETURN! XXX */ } /* do selection and reveal */ if (te) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem) { /* expand branches so that it will be visible, we need to get correct coordinates */ - if ( outliner_open_back(soops, te)) + if (outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); /* deselect all visible, and select found element */ @@ -750,10 +750,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); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 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 - (ar->v2d.mask.ymax - ar->v2d.mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); @@ -761,10 +761,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so ar->v2d.cur.xmax += xdelta; /* store selection */ - soops->search_tse= *tselem; + soops->search_tse = *tselem; BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); - soops->search_flags= flags; + soops->search_flags = flags; /* redraw */ soops->storeflag |= SO_TREESTORE_REDRAW; @@ -785,34 +785,34 @@ static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curleve TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (open) { - if (curlevel<=level) tselem->flag &= ~TSE_CLOSED; + if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; } else { - if (curlevel>=level) tselem->flag |= TSE_CLOSED; + if (curlevel >= level) tselem->flag |= TSE_CLOSED; } - outliner_openclose_level(soops, &te->subtree, curlevel+1, level, open); + outliner_openclose_level(soops, &te->subtree, curlevel + 1, level, open); } } static int outliner_one_level_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - int add= RNA_boolean_get(op->ptr, "open"); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + int add = RNA_boolean_get(op->ptr, "open"); int level; - level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); - if (add==1) { + level = outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); + if (add == 1) { if (level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); } else { - if (level==0) level= outliner_count_levels(soops, &soops->tree, 0); - if (level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); + if (level == 0) level = outliner_count_levels(soops, &soops->tree, 0); + if (level) outliner_openclose_level(soops, &soops->tree, 1, level - 1, 0); } ED_region_tag_redraw(ar); @@ -845,10 +845,10 @@ static int subtree_has_objects(SpaceOops *soops, ListBase *lb) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) return 1; - if ( subtree_has_objects(soops, &te->subtree)) return 1; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) return 1; + if (subtree_has_objects(soops, &te->subtree)) return 1; } return 0; } @@ -860,15 +860,15 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase TreeStoreElem *tselem; /* open all object elems, close others */ - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); - if (tselem->type==0) { - if (te->idcode==ID_SCE) { - if (tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { + if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; + else tselem->flag &= ~TSE_CLOSED; } - else if (te->idcode==ID_OB) { + else if (te->idcode == ID_OB) { if (subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } @@ -882,9 +882,9 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase /* show entire object level hierarchy */ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); /* recursively open/close levels */ tree_element_show_hierarchy(scene, soops, &soops->tree); @@ -915,9 +915,9 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* specialized poll callback for these operators to work in Datablocks view only */ static int ed_operator_outliner_datablocks_active(bContext *C) { - ScrArea *sa= CTX_wm_area(C); - if ((sa) && (sa->spacetype==SPACE_OUTLINER)) { - SpaceOops *so= CTX_wm_space_outliner(C); + ScrArea *sa = CTX_wm_area(C); + if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { + SpaceOops *so = CTX_wm_space_outliner(C); return (so->outlinevis == SO_DATABLOCKS); } return 0; @@ -929,7 +929,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) * this function does not do that yet */ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, - ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) + ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) { ListBase hierarchy = {NULL, NULL}; LinkData *ld; @@ -937,7 +937,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle TreeStoreElem *tse /* , *tsenext */ /* UNUSED */; PointerRNA *ptr, *nextptr; PropertyRNA *prop; - char *newpath=NULL; + char *newpath = NULL; /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed @@ -946,28 +946,28 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle return; /* Overview of Algorithm: - * 1. Go up the chain of parents until we find the 'root', taking note of the + * 1. Go up the chain of parents until we find the 'root', taking note of the * levels encountered in reverse-order (i.e. items are added to the start of the list * for more convenient looping later) - * 2. Walk down the chain, adding from the first ID encountered + * 2. Walk down the chain, adding from the first ID encountered * (which will become the 'ID' for the KeyingSet Path), and build a - * path as we step through the chain + * path as we step through the chain */ /* step 1: flatten out hierarchy of parents into a flat chain */ - for (tem= te->parent; tem; tem= tem->parent) { - ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); - ld->data= tem; + for (tem = te->parent; tem; tem = tem->parent) { + ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); + ld->data = tem; BLI_addhead(&hierarchy, ld); } /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */ - for (ld= hierarchy.first; ld; ld= ld->next) { + for (ld = hierarchy.first; ld; ld = ld->next) { /* get data */ - tem= (TreeElement *)ld->data; - tse= TREESTORE(tem); - ptr= &tem->rnaptr; - prop= tem->directdata; + tem = (TreeElement *)ld->data; + tse = TREESTORE(tem); + ptr = &tem->rnaptr; + prop = tem->directdata; /* check if we're looking for first ID, or appending to path */ if (*id) { @@ -977,43 +977,43 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_PROPERTY) { if (RNA_property_type(prop) == PROP_POINTER) { /* for pointer we just append property name */ - newpath= RNA_path_append(*path, ptr, prop, 0, NULL); + newpath = RNA_path_append(*path, ptr, prop, 0, NULL); } else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - temnext= (TreeElement*)(ld->next->data); + temnext = (TreeElement *)(ld->next->data); /* tsenext= TREESTORE(temnext); */ /* UNUSED */ - nextptr= &temnext->rnaptr; - name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); + nextptr = &temnext->rnaptr; + name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); if (name) { /* if possible, use name as a key in the path */ - newpath= RNA_path_append(*path, NULL, prop, 0, name); + newpath = RNA_path_append(*path, NULL, prop, 0, name); if (name != buf) MEM_freeN(name); } else { /* otherwise use index */ - int index= 0; + int index = 0; - for (temsub=tem->subtree.first; temsub; temsub=temsub->next, index++) + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) if (temsub == temnext) break; - newpath= RNA_path_append(*path, NULL, prop, index, NULL); + newpath = RNA_path_append(*path, NULL, prop, index, NULL); } - ld= ld->next; + ld = ld->next; } } if (newpath) { if (*path) MEM_freeN(*path); - *path= newpath; - newpath= NULL; + *path = newpath; + newpath = NULL; } } else { @@ -1021,12 +1021,12 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_STRUCT) { /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { - *id= (ID *)ptr->data; + *id = (ID *)ptr->data; /* clear path */ if (*path) { MEM_freeN(*path); - path= NULL; + path = NULL; } } } @@ -1036,13 +1036,13 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* step 3: if we've got an ID, add the current item to the path */ if (*id) { /* add the active property to the path */ - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { /* item is part of an array, so must set the array_index */ - *array_index= te->index; + *array_index = te->index; } else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ @@ -1050,9 +1050,9 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } /* path */ - newpath= RNA_path_append(*path, NULL, prop, 0, NULL); + newpath = RNA_path_append(*path, NULL, prop, 0, NULL); if (*path) MEM_freeN(*path); - *path= newpath; + *path = newpath; } /* free temp data */ @@ -1066,7 +1066,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle * they depend on having RNA paths and/or hierarchies available. */ enum { - DRIVERS_EDITMODE_ADD = 0, + DRIVERS_EDITMODE_ADD = 0, DRIVERS_EDITMODE_REMOVE, } /*eDrivers_EditModes*/; @@ -1078,22 +1078,22 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1104,10 +1104,10 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ - arraylen= RNA_property_array_length(&te->rnaptr, te->directdata); + arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); } else - arraylen= array_index; + arraylen = array_index; /* we should do at least one step */ if (arraylen == array_index) @@ -1122,13 +1122,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* add a new driver with the information obtained (only if valid) */ ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); } - break; + break; case DRIVERS_EDITMODE_REMOVE: { /* remove driver matching the information obtained (only if valid) */ ANIM_remove_driver(reports, id, path, array_index, dflags); } - break; + break; } } @@ -1149,7 +1149,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1159,7 +1159,7 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX return OPERATOR_FINISHED; } @@ -1176,7 +1176,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1184,7 +1184,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1211,7 +1211,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -1221,7 +1221,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) * they depend on having RNA paths and/or hierarchies available. */ enum { - KEYINGSET_EDITMODE_ADD = 0, + KEYINGSET_EDITMODE_ADD = 0, KEYINGSET_EDITMODE_REMOVE, } /*eKeyingSet_EditModes*/; @@ -1231,7 +1231,7 @@ enum { // TODO: should this be an API func? static KeyingSet *verify_active_keyingset(Scene *scene, short add) { - KeyingSet *ks= NULL; + KeyingSet *ks = NULL; /* sanity check */ if (scene == NULL) @@ -1239,13 +1239,13 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* try to find one from scene */ if (scene->active_keyingset > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* add if none found */ // XXX the default settings have yet to evolve - if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + if ((add) && (ks == NULL)) { + ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); } return ks; @@ -1257,22 +1257,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1284,22 +1284,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* add a new path with the information obtained (only if valid) */ // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); - ks->active_path= BLI_countlist(&ks->paths); + ks->active_path = BLI_countlist(&ks->paths); } - break; + break; case KEYINGSET_EDITMODE_REMOVE: { /* find the relevant path, then remove it from the KeyingSet */ - KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); + KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); if (ksp) { /* free path's data */ BKE_keyingset_free_path(ks, ksp); - ks->active_path= 0; + ks->active_path = 0; } } - break; + break; } /* free path, since it had to be generated */ @@ -1317,9 +1317,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (ks == NULL) { @@ -1333,7 +1333,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1350,7 +1350,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1358,9 +1358,9 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (soutliner == NULL) @@ -1370,7 +1370,7 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1387,7 +1387,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Parent Drop Operator *********************** */ @@ -1395,23 +1395,23 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) static int parent_drop_exec(bContext *C, wmOperator *op) { Object *par = NULL, *ob = NULL; - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int partype = -1; char parname[MAX_ID_NAME], childname[MAX_ID_NAME]; - partype= RNA_enum_get(op->ptr, "type"); + partype = RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; } @@ -1419,8 +1419,8 @@ static int parent_drop_exec(bContext *C, wmOperator *op) /* Used for drag and drop parenting */ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* name and first icon */ @@ -1436,10 +1436,10 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * } /* Not it. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return te_valid; } } @@ -1448,24 +1448,24 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *par= NULL; - Object *ob= NULL; - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - TreeElement *te= NULL; - TreeElement *te_found= NULL; + Object *par = NULL; + Object *ob = NULL; + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + TreeElement *te = NULL; + TreeElement *te_found = NULL; char childname[MAX_ID_NAME]; char parname[MAX_ID_NAME]; - int partype= 0; + int partype = 0; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { - te_found= outliner_dropzone_parent(C, event, te, fmval); + for (te = soops->tree.first; te; te = te->next) { + te_found = outliner_dropzone_parent(C, event, te, fmval); if (te_found) break; } @@ -1473,9 +1473,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_set(op->ptr, "parent", te_found->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -1487,20 +1487,20 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); } } else { /* Menu creation */ - uiPopupMenu *pup= uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); PointerRNA ptr; @@ -1513,7 +1513,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); /* par becomes parent, make the associated menus */ - if (par->type==OB_ARMATURE) { + if (par->type == OB_ARMATURE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1549,7 +1549,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Bone"), 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); } - else if (par->type==OB_CURVE) { + else if (par->type == OB_CURVE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1606,7 +1606,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); @@ -1616,15 +1616,15 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); /* Check for row */ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* Ignore drop on scene tree elements */ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { if ((te->idcode == ID_SCE) && - !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) + !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) { return 0; } @@ -1639,11 +1639,11 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, return 1; } - return 0; // ID_OB, but mouse in undefined dropzone. + return 0; // ID_OB, but mouse in undefined dropzone. } /* Not this row. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; @@ -1654,16 +1654,16 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Scene *scene= CTX_data_scene(C); - Object *ob= NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = NULL; char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob= (Object *)find_id("OB", obname); + ob = (Object *)BKE_libblock_find_name(ID_OB, obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); @@ -1683,7 +1683,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index b1990d3054e..d8d10519bd6 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -48,82 +48,82 @@ struct Object; typedef struct TreeElement { struct TreeElement *next, *prev, *parent; ListBase subtree; - float xs, ys; // do selection - int store_index; // offset in tree store - short flag; // flag for non-saved stuff - short index; // index for data arrays - short idcode; // from TreeStore id - short xend; // width of item display, for select + float xs, ys; // do selection + int store_index; // offset in tree store + short flag; // flag for non-saved stuff + short index; // index for data arrays + short idcode; // from TreeStore id + short xend; // width of item display, for select const char *name; - void *directdata; // Armature Bones, Base, Sequence, Strip... - PointerRNA rnaptr; // RNA Pointer + void *directdata; // Armature Bones, Base, Sequence, Strip... + PointerRNA rnaptr; // RNA Pointer } TreeElement; /* TreeElement->flag */ -#define TE_ACTIVE 1 -#define TE_ICONROW 2 -#define TE_LAZY_CLOSED 4 -#define TE_FREE_NAME 8 +#define TE_ACTIVE 1 +#define TE_ICONROW 2 +#define TE_LAZY_CLOSED 4 +#define TE_FREE_NAME 8 /* TreeStoreElem types */ -#define TSE_NLA 1 -#define TSE_NLA_ACTION 2 -#define TSE_DEFGROUP_BASE 3 -#define TSE_DEFGROUP 4 -#define TSE_BONE 5 -#define TSE_EBONE 6 -#define TSE_CONSTRAINT_BASE 7 -#define TSE_CONSTRAINT 8 -#define TSE_MODIFIER_BASE 9 -#define TSE_MODIFIER 10 -#define TSE_LINKED_OB 11 -#define TSE_SCRIPT_BASE 12 -#define TSE_POSE_BASE 13 -#define TSE_POSE_CHANNEL 14 -#define TSE_ANIM_DATA 15 -#define TSE_DRIVER_BASE 16 -#define TSE_DRIVER 17 - -#define TSE_PROXY 18 -#define TSE_R_LAYER_BASE 19 -#define TSE_R_LAYER 20 -#define TSE_R_PASS 21 -#define TSE_LINKED_MAT 22 +#define TSE_NLA 1 +#define TSE_NLA_ACTION 2 +#define TSE_DEFGROUP_BASE 3 +#define TSE_DEFGROUP 4 +#define TSE_BONE 5 +#define TSE_EBONE 6 +#define TSE_CONSTRAINT_BASE 7 +#define TSE_CONSTRAINT 8 +#define TSE_MODIFIER_BASE 9 +#define TSE_MODIFIER 10 +#define TSE_LINKED_OB 11 +#define TSE_SCRIPT_BASE 12 +#define TSE_POSE_BASE 13 +#define TSE_POSE_CHANNEL 14 +#define TSE_ANIM_DATA 15 +#define TSE_DRIVER_BASE 16 +#define TSE_DRIVER 17 + +#define TSE_PROXY 18 +#define TSE_R_LAYER_BASE 19 +#define TSE_R_LAYER 20 +#define TSE_R_PASS 21 +#define TSE_LINKED_MAT 22 /* NOTE, is used for light group */ -#define TSE_LINKED_LAMP 23 -#define TSE_POSEGRP_BASE 24 -#define TSE_POSEGRP 25 -#define TSE_SEQUENCE 26 -#define TSE_SEQ_STRIP 27 -#define TSE_SEQUENCE_DUP 28 +#define TSE_LINKED_LAMP 23 +#define TSE_POSEGRP_BASE 24 +#define TSE_POSEGRP 25 +#define TSE_SEQUENCE 26 +#define TSE_SEQ_STRIP 27 +#define TSE_SEQUENCE_DUP 28 #define TSE_LINKED_PSYS 29 -#define TSE_RNA_STRUCT 30 -#define TSE_RNA_PROPERTY 31 -#define TSE_RNA_ARRAY_ELEM 32 -#define TSE_NLA_TRACK 33 -#define TSE_KEYMAP 34 -#define TSE_KEYMAP_ITEM 35 +#define TSE_RNA_STRUCT 30 +#define TSE_RNA_PROPERTY 31 +#define TSE_RNA_ARRAY_ELEM 32 +#define TSE_NLA_TRACK 33 +#define TSE_KEYMAP 34 +#define TSE_KEYMAP_ITEM 35 /* button events */ -#define OL_NAMEBUTTON 1 +#define OL_NAMEBUTTON 1 /* get TreeStoreElem associated with a TreeElement * < a: (TreeElement) tree element to find stored element for */ -#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL) +#define TREESTORE(a) ((a) ? soops->treestore->data + (a)->store_index : NULL) /* size constants */ -#define OL_Y_OFFSET 2 +#define OL_Y_OFFSET 2 -#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X*3) -#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X*2) -#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X +#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 3) +#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 2) +#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X #define OL_TOGW OL_TOG_RESTRICT_VIEWX -#define OL_RNA_COLX (UI_UNIT_X*15) -#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5f) -#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5f) +#define OL_RNA_COLX (UI_UNIT_X * 15) +#define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f) +#define OL_RNA_COL_SPACEX (UI_UNIT_X * 2.5f) /* Outliner Searching -- @@ -145,7 +145,7 @@ typedef struct TreeElement { #define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE) /* is the currrent element open? if so we also show children */ -#define TSELEM_OPEN(telm,sv) ( (telm->flag & TSE_CLOSED)==0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) +#define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) /* outliner_tree.c ----------------------------------------------- */ @@ -170,7 +170,7 @@ int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soop /* outliner_edit.c ---------------------------------------------- */ void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb, - void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); + void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); int common_restrict_check(struct bContext *C, struct Object *ob); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 00b3979b074..18769476118 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -73,21 +73,21 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se { TreeElement *te; TreeStoreElem *tselem; - int change= 0; + int change = 0; - for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { - tselem= TREESTORE(te); + for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) { + tselem = TREESTORE(te); /* if we've encountered the right item, set its 'Outliner' selection status */ if (*index == 0) { /* this should be the last one, so no need to do anything with index */ - if ((te->flag & TE_ICONROW)==0) { + if ((te->flag & TE_ICONROW) == 0) { /* -1 value means toggle testing for now... */ if (*selecting == -1) { if (tselem->flag & TSE_SELECTED) - *selecting= 0; + *selecting = 0; else - *selecting= 1; + *selecting = 1; } /* set selection */ @@ -103,9 +103,9 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se /* Only try selecting sub-elements if we haven't hit the right element yet * * Hack warning: - * Index must be reduced before supplying it to the sub-tree to try to do - * selection, however, we need to increment it again for the next loop to - * function correctly + * Index must be reduced before supplying it to the sub-tree to try to do + * selection, however, we need to increment it again for the next loop to + * function correctly */ (*index)--; change |= outliner_select(soops, &te->subtree, index, selecting); @@ -124,45 +124,45 @@ static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeSto Scene *sce; /* paranoia check */ - if (te->idcode!=ID_SCE) + if (te->idcode != ID_SCE) return 0; - sce= (Scene *)tselem->id; + sce = (Scene *)tselem->id; if (set) { - sce->r.actlay= tselem->nr; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); + sce->r.actlay = tselem->nr; + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); } else { - return sce->r.actlay==tselem->nr; + return sce->r.actlay == tselem->nr; } return 0; } static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); Scene *sce; Base *base; - Object *ob= NULL; + Object *ob = NULL; /* if id is not object, we search back */ - if (te->idcode==ID_OB) ob= (Object *)tselem->id; + if (te->idcode == ID_OB) ob = (Object *)tselem->id; else { - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==OBACT) return 0; + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == OBACT) return 0; } - if (ob==NULL) return 0; + if (ob == NULL) return 0; - sce= (Scene *)outliner_search_back(soops, te, ID_SCE); + sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } /* find associated base in current scene */ - base= object_in_scene(ob, scene); + base = BKE_scene_base_find(scene, ob); if (base) { - if (set==2) { + if (set == 2) { /* swap select */ if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); @@ -171,17 +171,17 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } else { /* deleselect all */ - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } if (C) { ED_base_object_activate(C, base); /* adds notifier */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } - if (ob!=scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (ob != scene->obedit) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); return 1; } @@ -192,35 +192,35 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); + ob = (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. - if (ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + if (ob == NULL || ob != OBACT || ob->matbits == NULL) return 0; // just paranoia /* searching in ob mat array? */ - tes= te->parent; - if (tes->idcode==ID_OB) { + tes = te->parent; + if (tes->idcode == ID_OB) { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 1; // make ob material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 1; // make ob material active too } else { - if (ob->actcol == te->index+1) + if (ob->actcol == te->index + 1) if (ob->matbits[te->index]) return 1; } } /* or we search for obdata material */ else { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 0; // make obdata material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 0; // make obdata material active too } else { - if (ob->actcol == te->index+1) - if (ob->matbits[te->index]==0) return 1; + if (ob->actcol == te->index + 1) + if (ob->matbits[te->index] == 0) return 1; } } if (set) { - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, NULL); } return 0; } @@ -229,10 +229,10 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo { TreeElement *tep; TreeStoreElem /* *tselem,*/ *tselemp; - Object *ob=OBACT; - SpaceButs *sbuts=NULL; + Object *ob = OBACT; + SpaceButs *sbuts = NULL; - if (ob==NULL) return 0; // no active object + if (ob == NULL) return 0; // no active object /*tselem= TREESTORE(te);*/ /*UNUSED*/ @@ -240,11 +240,11 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo /* XXX removed finding sbuts */ /* where is texture linked to? */ - tep= te->parent; - tselemp= TREESTORE(tep); + tep = te->parent; + tselemp = TREESTORE(tep); - if (tep->idcode==ID_WO) { - World *wrld= (World *)tselemp->id; + if (tep->idcode == ID_WO) { + World *wrld = (World *)tselemp->id; if (set) { if (sbuts) { @@ -252,43 +252,43 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo // XXX sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - wrld->texact= te->index; + wrld->texact = te->index; } else if (tselemp->id == (ID *)(scene->world)) { - if (wrld->texact==te->index) return 1; + if (wrld->texact == te->index) return 1; } } - else if (tep->idcode==ID_LA) { - Lamp *la= (Lamp *)tselemp->id; + else if (tep->idcode == ID_LA) { + Lamp *la = (Lamp *)tselemp->id; if (set) { if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 2; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - la->texact= te->index; + la->texact = te->index; } else { if (tselemp->id == ob->data) { - if (la->texact==te->index) return 1; + if (la->texact == te->index) return 1; } } } - else if (tep->idcode==ID_MA) { - Material *ma= (Material *)tselemp->id; + else if (tep->idcode == ID_MA) { + Material *ma = (Material *)tselemp->id; if (set) { if (sbuts) { //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 0; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - ma->texact= (char)te->index; + ma->texact = (char)te->index; /* also set active material */ - ob->actcol= tep->index+1; + ob->actcol = tep->index + 1; } - else if (tep->flag & TE_ACTIVE) { // this is active material - if (ma->texact==te->index) return 1; + else if (tep->flag & TE_ACTIVE) { // this is active material + if (ma->texact == te->index) return 1; } } @@ -304,8 +304,8 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==NULL || ob!=OBACT) return 0; // just paranoia + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == NULL || ob != OBACT) return 0; // just paranoia if (set) { // XXX extern_set_butspace(F5KEY, 0); @@ -317,7 +317,7 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); + Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); if (set) return 0; @@ -328,22 +328,22 @@ static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOo static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { TreeElement *tep; - TreeStoreElem *tselem=NULL; - Scene *sce=NULL; + TreeStoreElem *tselem = NULL; + Scene *sce = NULL; - tep= te->parent; + tep = te->parent; if (tep) { - tselem= TREESTORE(tep); - sce= (Scene *)tselem->id; + tselem = TREESTORE(tep); + sce = (Scene *)tselem->id; } - if (set) { // make new scene active + if (set) { // make new scene active if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - if (tep==NULL || tselem->id == (ID *)scene) { + if (tep == NULL || tselem->id == (ID *)scene) { if (set) { // XXX extern_set_butspace(F8KEY, 0); } @@ -359,34 +359,34 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * Object *ob; /* id in tselem is object */ - ob= (Object *)tselem->id; + ob = (Object *)tselem->id; if (set) { - BLI_assert(te->index+1 >= 0); - ob->actdef= te->index+1; + BLI_assert(te->index + 1 >= 0); + ob->actdef = te->index + 1; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); } else { - if (ob==OBACT) - if (ob->actdef== te->index+1) return 1; + if (ob == OBACT) + if (ob->actdef == te->index + 1) return 1; } return 0; } static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; if (set) { if (ob->pose) { - ob->pose->active_group= te->index+1; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + ob->pose->active_group = te->index + 1; + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } } else { - if (ob==OBACT && ob->pose) { - if (ob->pose->active_group== te->index+1) return 1; + if (ob == OBACT && ob->pose) { + if (ob->pose->active_group == te->index + 1) return 1; } } return 0; @@ -394,30 +394,30 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; - bArmature *arm= ob->data; - bPoseChannel *pchan= te->directdata; + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + bPoseChannel *pchan = te->directdata; if (set) { if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag - else ED_pose_deselectall(ob, 0); // 0 = deselect + if (set == 2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + else ED_pose_deselectall(ob, 0); // 0 = deselect - if (set==2 && (pchan->bone->flag & BONE_SELECTED)) { + if (set == 2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; } else { pchan->bone->flag |= BONE_SELECTED; - arm->act_bone= pchan->bone; + arm->act_bone = pchan->bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { - if (ob==OBACT && ob->pose) { + if (ob == OBACT && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) return 1; } } @@ -426,29 +426,29 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - bArmature *arm= (bArmature *)tselem->id; - Bone *bone= te->directdata; + bArmature *arm = (bArmature *)tselem->id; + Bone *bone = te->directdata; if (set) { if (!(bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag else ED_pose_deselectall(OBACT, 0); - if (set==2 && (bone->flag & BONE_SELECTED)) { + if (set == 2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; } else { bone->flag |= BONE_SELECTED; - arm->act_bone= bone; + arm->act_bone = bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, OBACT); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT); } } else { - Object *ob= OBACT; + Object *ob = OBACT; - if (ob && ob->data==arm) { + if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) return 1; } } @@ -460,32 +460,32 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { if (sel) { - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; + ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL; + arm->act_edbone = ebone; // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; } else { - ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, scene->obedit); } static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - bArmature *arm= scene->obedit->data; - EditBone *ebone= te->directdata; + bArmature *arm = scene->obedit->data; + EditBone *ebone = te->directdata; - if (set==1) { + if (set == 1) { if (!(ebone->flag & BONE_HIDDEN_A)) { - ED_armature_deselect_all(scene->obedit, 0); // deselect + ED_armature_deselect_all(scene->obedit, 0); // deselect tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } } - else if (set==2) { + else if (set == 2) { if (!(ebone->flag & BONE_HIDDEN_A)) { if (!(ebone->flag & BONE_SELECTED)) { tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); @@ -507,9 +507,9 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); // XXX extern_set_butspace(F9KEY, 0); } @@ -520,9 +520,9 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -533,9 +533,9 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -550,12 +550,12 @@ static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), S static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; - Base *base= object_in_scene(ob, scene); + Object *ob = (Object *)tselem->id; + Base *base = BKE_scene_base_find(scene, ob); if (set) { if (scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); @@ -570,7 +570,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - Sequence *seq= (Sequence*) te->directdata; + Sequence *seq = (Sequence *) te->directdata; if (set) { // XXX select_single_seq(seq, 1); @@ -585,26 +585,26 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(t static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq, *p; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - seq= (Sequence*)te->directdata; - if (set==0) { + seq = (Sequence *)te->directdata; + if (set == 0) { if (seq->flag & SELECT) return(1); return(0); } // XXX select_single_seq(seq, 1); - p= ed->seqbasep->first; + p = ed->seqbasep->first; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } // if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); - p= p->next; + p = p->next; } return(0); } @@ -613,7 +613,7 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, { wmKeyMapItem *kmi = te->directdata; - if (set==0) { + if (set == 0) { if (kmi->flag & KMI_INACTIVE) return 0; return 1; } @@ -663,7 +663,7 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl return tree_element_active_modifier(C, te, tselem, set); case TSE_LINKED_OB: if (set) tree_element_set_active_object(C, scene, soops, te, set); - else if (tselem->id==(ID *)OBACT) return 1; + else if (tselem->id == (ID *)OBACT) return 1; break; case TSE_LINKED_PSYS: return tree_element_active_psys(C, scene, te, tselem, set); @@ -693,14 +693,14 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { - if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - int openclose= 0; + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); + int openclose = 0; /* open close icon */ - if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if ( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) - openclose= 1; + if ((te->flag & TE_ICONROW) == 0) { // hidden icon, no open/close + if (mval[0] > te->xs && mval[0] < te->xs + UI_UNIT_X) + openclose = 1; } if (openclose) { @@ -718,62 +718,62 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa return 1; } /* name and first icon */ - else if (mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + else if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { /* always makes active object */ - if (tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) - tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); + if (tselem->type != TSE_SEQUENCE && tselem->type != TSE_SEQ_STRIP && tselem->type != TSE_SEQUENCE_DUP) + tree_element_set_active_object(C, scene, soops, te, 1 + (extend != 0 && tselem->type == 0)); - if (tselem->type==0) { // the lib blocks + if (tselem->type == 0) { // the lib blocks /* editmode? */ - if (te->idcode==ID_SCE) { - if (scene!=(Scene *)tselem->id) { + if (te->idcode == ID_SCE) { + if (scene != (Scene *)tselem->id) { ED_screen_set_scene(C, CTX_wm_screen(C), (Scene *)tselem->id); } } - else if (te->idcode==ID_GR) { - Group *gr= (Group *)tselem->id; + else if (te->idcode == ID_GR) { + Group *gr = (Group *)tselem->id; GroupObject *gob; if (extend) { - int sel= BA_SELECT; - for (gob= gr->gobject.first; gob; gob= gob->next) { + int sel = BA_SELECT; + for (gob = gr->gobject.first; gob; gob = gob->next) { if (gob->ob->flag & SELECT) { - sel= BA_DESELECT; + sel = BA_DESELECT; break; } } - for (gob= gr->gobject.first; gob; gob= gob->next) { - ED_base_object_select(object_in_scene(gob->ob, scene), sel); + for (gob = gr->gobject.first; gob; gob = gob->next) { + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), sel); } } else { - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } else if (ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); } - else { // rest of types + else { // rest of types tree_element_active(C, scene, soops, te, 1); } } - else tree_element_type_active(C, scene, soops, te, tselem, 1+(extend!=0)); + else tree_element_type_active(C, scene, soops, te, tselem, 1 + (extend != 0)); return 1; } } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; } return 0; @@ -782,23 +782,23 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa /* event can enterkey, then it opens/closes */ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); + int extend = RNA_boolean_get(op->ptr, "extend"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - if ( !ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && - !(soops->flag & SO_HIDE_RESTRICTCOLS) && - (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) + if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + !(soops->flag & SO_HIDE_RESTRICTCOLS) && + (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) { return OPERATOR_CANCELLED; } - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } @@ -806,12 +806,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) ED_undo_push(C, "Outliner click event"); } else { - short selecting= -1; + short selecting = -1; int row; /* get row number - 100 here is just a dummy value since we don't need the column */ UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, - fmval[0], fmval[1], NULL, &row); + fmval[0], fmval[1], NULL, &row); /* select relevant row */ if (outliner_select(soops, &soops->tree, &row, &selecting)) { @@ -847,7 +847,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) /* **************** Border Select Tool ****************** */ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *rectf, TreeElement *te, int gesture_mode) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) { if (gesture_mode == GESTURE_MODAL_SELECT) { @@ -869,13 +869,13 @@ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *re static int outliner_border_select_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); TreeElement *te; rcti rect; rctf rectf; - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -885,11 +885,11 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_item_border_select(scene, soops, &rectf, te, gesture_mode); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -911,7 +911,7 @@ void OUTLINER_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, FALSE); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 89eb51f73ba..a3ed2eac2d5 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -77,31 +77,31 @@ /* ************ SELECTION OPERATIONS ********* */ static void set_operation_types(SpaceOops *soops, ListBase *lb, - int *scenelevel, - int *objectlevel, - int *idlevel, - int *datalevel) + int *scenelevel, + int *objectlevel, + int *idlevel, + int *datalevel) { TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { if (tselem->type) { - if (*datalevel==0) - *datalevel= tselem->type; - else if (*datalevel!=tselem->type) - *datalevel= -1; + if (*datalevel == 0) + *datalevel = tselem->type; + else if (*datalevel != tselem->type) + *datalevel = -1; } else { - int idcode= GS(tselem->id->name); + int idcode = GS(tselem->id->name); switch (idcode) { case ID_SCE: - *scenelevel= 1; + *scenelevel = 1; break; case ID_OB: - *objectlevel= 1; + *objectlevel = 1; break; case ID_ME: case ID_CU: case ID_MB: case ID_LT: @@ -109,9 +109,9 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_MA: case ID_TE: case ID_IP: case ID_IM: case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: - if (*idlevel==0) *idlevel= idcode; - else if (*idlevel!=idcode) *idlevel= -1; - break; + if (*idlevel == 0) *idlevel = idcode; + else if (*idlevel != idcode) *idlevel = -1; + break; } } } @@ -130,62 +130,62 @@ static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNU static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - Material **matar=NULL; - int a, totcol=0; + Material **matar = NULL; + int a, totcol = 0; - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - totcol= ob->totcol; - matar= ob->mat; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + totcol = ob->totcol; + matar = ob->mat; } - else if ( GS(tsep->id->name)==ID_ME) { - Mesh *me= (Mesh *)tsep->id; - totcol= me->totcol; - matar= me->mat; + else if (GS(tsep->id->name) == ID_ME) { + Mesh *me = (Mesh *)tsep->id; + totcol = me->totcol; + matar = me->mat; } - else if ( GS(tsep->id->name)==ID_CU) { - Curve *cu= (Curve *)tsep->id; - totcol= cu->totcol; - matar= cu->mat; + else if (GS(tsep->id->name) == ID_CU) { + Curve *cu = (Curve *)tsep->id; + totcol = cu->totcol; + matar = cu->mat; } - else if ( GS(tsep->id->name)==ID_MB) { - MetaBall *mb= (MetaBall *)tsep->id; - totcol= mb->totcol; - matar= mb->mat; + else if (GS(tsep->id->name) == ID_MB) { + MetaBall *mb = (MetaBall *)tsep->id; + totcol = mb->totcol; + matar = mb->mat; } - for (a=0; a<totcol; a++) { - if (a==te->index && matar[a]) { + for (a = 0; a < totcol; a++) { + if (a == te->index && matar[a]) { matar[a]->id.us--; - matar[a]= NULL; + matar[a] = NULL; } } } static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - MTex **mtex= NULL; + MTex **mtex = NULL; int a; - if ( GS(tsep->id->name)==ID_MA) { - Material *ma= (Material *)tsep->id; - mtex= ma->mtex; + if (GS(tsep->id->name) == ID_MA) { + Material *ma = (Material *)tsep->id; + mtex = ma->mtex; } - else if ( GS(tsep->id->name)==ID_LA) { - Lamp *la= (Lamp *)tsep->id; - mtex= la->mtex; + else if (GS(tsep->id->name) == ID_LA) { + Lamp *la = (Lamp *)tsep->id; + mtex = la->mtex; } - else if ( GS(tsep->id->name)==ID_WO) { - World *wrld= (World *)tsep->id; - mtex= wrld->mtex; + else if (GS(tsep->id->name) == ID_WO) { + World *wrld = (World *)tsep->id; + mtex = wrld->mtex; } else return; - for (a=0; a<MAX_MTEX; a++) { - if (a==te->index && mtex[a]) { + for (a = 0; a < MAX_MTEX; a++) { + if (a == te->index && mtex[a]) { if (mtex[a]->tex) { mtex[a]->tex->id.us--; - mtex[a]->tex= NULL; + mtex[a]->tex = NULL; } } } @@ -193,16 +193,16 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; if (tsep) { - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - ob->dup_group= NULL; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + ob->dup_group = NULL; } } else { - unlink_group(group); + BKE_group_unlink(group); } } @@ -217,16 +217,16 @@ static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme } static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0) { - TreeStoreElem *tsep= TREESTORE(te->parent); + if (tselem->type == 0) { + TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(C, scene, te, tsep, tselem); } } @@ -240,10 +240,10 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops * static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); + if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) { base->flag |= SELECT; base->object->flag |= SELECT; } @@ -251,9 +251,9 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; base->object->flag &= ~SELECT; @@ -262,18 +262,18 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) - base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) + base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { // check also library later - if (scene->obedit==base->object) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (scene->obedit == base->object) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); - te->directdata= NULL; - tselem->id= NULL; + te->directdata = NULL; + tselem->id = NULL; } } @@ -283,7 +283,7 @@ static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(t /* if the ID type has no special local function, * just clear the lib */ if (id_make_local(tselem->id, FALSE) == FALSE) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); id_clear_lib_data(bmain, tselem->id); } } @@ -344,41 +344,41 @@ static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement * static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; GroupObject *gob; Base *base; - for (gob=group->gobject.first; gob; gob=gob->next) { - base= object_in_scene(gob->ob, scene); + for (gob = group->gobject.first; gob; gob = gob->next) { + base = BKE_scene_base_find(scene, gob->ob); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; } else { /* link to scene */ - base= MEM_callocN(sizeof(Base), "add_base"); + base = MEM_callocN(sizeof(Base), "add_base"); BLI_addhead(&scene->base, base); - base->lay= (1<<20)-1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ + base->lay = (1 << 20) - 1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ gob->ob->flag |= SELECT; base->flag = gob->ob->flag; - base->object= gob->ob; + base->object = gob->ob; id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */ } } } void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { // when objects selected in other scenes... dunno if that should be allowed - Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); + Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene_owner && scene_act != scene_owner) { ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner); } @@ -416,7 +416,7 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te FCurve *fcu; /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ - for (fcu = iat->adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; if (fcu->driver) @@ -428,70 +428,70 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + bPoseChannel *pchan = (bPoseChannel *)te->directdata; - if (event==1) + if (event == 1) pchan->bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) pchan->bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) pchan->bone->flag &= ~BONE_HIDDEN_P; } static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - Bone *bone= (Bone *)te->directdata; + Bone *bone = (Bone *)te->directdata; - if (event==1) + if (event == 1) bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) bone->flag &= ~BONE_HIDDEN_P; } static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - EditBone *ebone= (EditBone *)te->directdata; + EditBone *ebone = (EditBone *)te->directdata; - if (event==1) + if (event == 1) ebone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) ebone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { ebone->flag |= BONE_HIDDEN_A; - ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } - else if (event==4) + else if (event == 4) ebone->flag &= ~BONE_HIDDEN_A; } static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) { // Sequence *seq= (Sequence*) te->directdata; - if (event==1) { + if (event == 1) { // XXX select_single_seq(seq, 1); } } static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb, - void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) + void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { operation_cb(event, te, tselem); } } @@ -516,34 +516,34 @@ static EnumPropertyItem prop_object_op_types[] = { static int outliner_object_operation_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { - Scene *sce= scene; // to be able to delete, scenes are set... + if (event == 1) { + Scene *sce = scene; // to be able to delete, scenes are set... outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } - str= "Select Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Select Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==2) { + else if (event == 2) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); - str= "Deselect Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Deselect Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==4) { + else if (event == 4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); /* XXX: tree management normally happens from draw_outliner(), but when @@ -554,31 +554,31 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_cleanup_tree(soops); DAG_scene_sort(bmain, scene); - str= "Delete Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + str = "Delete Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } - else if (event==5) { /* disabled, see above enum (ton) */ + else if (event == 5) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Objects"; + str = "Localized Objects"; } - else if (event==6) { + else if (event == 6) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - str= "Toggle Visibility"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + str = "Toggle Visibility"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); } - else if (event==7) { + else if (event == 7) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - str= "Toggle Selectability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Toggle Selectability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==8) { + else if (event == 8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - str= "Toggle Renderability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + str = "Toggle Renderability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); } - else if (event==9) { + else if (event == 9) { outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename Object"; + str = "Rename Object"; } ED_undo_push(C, str); @@ -619,44 +619,44 @@ static EnumPropertyItem prop_group_op_types[] = { static int outliner_group_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { + if (event == 1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - str= "Unlink group"; + str = "Unlink group"; } - else if (event==2) { + else if (event == 2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Data"; + str = "Localized Data"; } - else if (event==3) { + else if (event == 3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - str= "Link Group Objects to Scene"; + str = "Link Group Objects to Scene"; } - else if (event==4) { + else if (event == 4) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); - str= "Toggle Visibility"; + str = "Toggle Visibility"; } - else if (event==5) { + else if (event == 5) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); - str= "Toggle Selectability"; + str = "Toggle Selectability"; } - else if (event==6) { + else if (event == 6) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); - str= "Toggle Renderability"; + str = "Toggle Renderability"; } - else if (event==7) { + else if (event == 7) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename"; + str = "Rename"; } @@ -711,9 +711,9 @@ static EnumPropertyItem prop_id_op_types[] = { static int outliner_id_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; /* check for invalid states */ @@ -722,7 +722,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_IDOP_UNLINK: @@ -732,25 +732,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; default: @@ -758,7 +758,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_LOCAL: { @@ -766,7 +766,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); ED_undo_push(C, "Localized Data"); } - break; + break; case OUTLINER_IDOP_SINGLE: { @@ -775,14 +775,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; @@ -791,36 +791,36 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_FAKE_ADD: { /* set fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); } - break; + break; case OUTLINER_IDOP_FAKE_CLEAR: { /* clear fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); } - break; + break; case OUTLINER_IDOP_RENAME: { /* rename */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); } - break; + break; default: // invalid - unhandled @@ -828,10 +828,10 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) } /* wrong notifier still... */ - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); // XXX: this is just so that outliner is always up to date - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; } @@ -857,15 +857,15 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) /* **************************************** */ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *lb, ID *newid, - void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) + void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(te, tselem, tsep, newid); } @@ -898,8 +898,8 @@ static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, Tree static int outliner_action_set_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; bAction *act; @@ -909,7 +909,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ - act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); @@ -918,20 +918,20 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) else if (act->idroot == 0) { /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ BKE_reportf(op->reports, RPT_WARNING, - "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", - act->id.name+2); + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name + 2); } /* perform action if valid channel */ if (datalevel == TSE_ANIM_DATA) - outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); else if (idlevel == ID_AC) - outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); else return OPERATOR_CANCELLED; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Set action"); /* done */ @@ -956,8 +956,8 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) ot->flag = 0; /* props */ - // TODO: this would be nicer as an ID-pointer... - prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + // TODO: this would be nicer as an ID-pointer... + prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); RNA_def_enum_funcs(prop, RNA_action_itemf); ot->prop = prop; } @@ -989,8 +989,8 @@ static EnumPropertyItem prop_animdata_op_types[] = { static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; short updateDeps = 0; @@ -998,7 +998,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); if (datalevel != TSE_ANIM_DATA) @@ -1015,14 +1015,14 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) /* clear active action - using standard rules */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case OUTLINER_ANIMOP_REFRESH_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; @@ -1030,7 +1030,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) case OUTLINER_ANIMOP_CLEAR_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); updateDeps = 1; break; @@ -1084,40 +1084,40 @@ static EnumPropertyItem prop_data_op_types[] = { static int outliner_data_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; int event; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if (datalevel==TSE_POSE_CHANNEL) { - if (event>0) { + if (datalevel == TSE_POSE_CHANNEL) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "PoseChannel operation"); } } - else if (datalevel==TSE_BONE) { - if (event>0) { + else if (datalevel == TSE_BONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "Bone operation"); } } - else if (datalevel==TSE_EBONE) { - if (event>0) { + else if (datalevel == TSE_EBONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "EditBone operation"); } } - else if (datalevel==TSE_SEQUENCE) { - if (event>0) { + else if (datalevel == TSE_SEQUENCE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); } } @@ -1151,14 +1151,14 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S { ReportList *reports = CTX_wm_reports(C); // XXX... - if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; + TreeStoreElem *tselem = TREESTORE(te); /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if ( outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) + if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; @@ -1177,16 +1177,16 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); } else if (idlevel) { - if (idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (idlevel == -1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { - if (idlevel==ID_GR) + if (idlevel == ID_GR) WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); else WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); } } else if (datalevel) { - if (datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (datalevel == -1) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { if (datalevel == TSE_ANIM_DATA) WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); @@ -1202,7 +1202,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) return 1; } @@ -1212,15 +1212,15 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 026132e1f16..8a31305d65e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -82,50 +82,50 @@ /* ********************************************************* */ /* Defines */ -#define TS_CHUNK 128 +#define TS_CHUNK 128 /* ********************************************************* */ /* Persistent Data */ static void outliner_storage_cleanup(SpaceOops *soops) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; if (ts) { TreeStoreElem *tselem; - int a, unused= 0; + int a, unused = 0; /* each element used once, for ID blocks with more users to have each a treestore */ - for (a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) tselem->used= 0; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) tselem->used = 0; /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ if (soops->storeflag & SO_TREESTORE_CLEANUP) { - for (a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { - if (tselem->id==NULL) unused++; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { + if (tselem->id == NULL) unused++; } if (unused) { if (ts->usedelem == unused) { MEM_freeN(ts->data); - ts->data= NULL; - ts->usedelem= ts->totelem= 0; + ts->data = NULL; + ts->usedelem = ts->totelem = 0; } else { TreeStoreElem *tsnewar, *tsnew; - tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); - for (a=0, tselem= ts->data; a<ts->usedelem; a++, tselem++) { + tsnew = tsnewar = MEM_mallocN((ts->usedelem - unused) * sizeof(TreeStoreElem), "new tselem"); + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { if (tselem->id) { - *tsnew= *tselem; + *tsnew = *tselem; tsnew++; } } MEM_freeN(ts->data); - ts->data= tsnewar; - ts->usedelem-= unused; - ts->totelem= ts->usedelem; + ts->data = tsnewar; + ts->usedelem -= unused; + ts->totelem = ts->usedelem; } } } @@ -139,45 +139,45 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty int a; /* case 1; no TreeStore */ - if (soops->treestore==NULL) { - soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + if (soops->treestore == NULL) { + soops->treestore = MEM_callocN(sizeof(TreeStore), "treestore"); } - ts= soops->treestore; + ts = soops->treestore; /* check if 'te' is in treestore */ - tselem= ts->data; - for (a=0; a<ts->usedelem; a++, tselem++) { - if (tselem->id==id && tselem->used==0) { - if ((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { - te->store_index= a; - tselem->used= 1; + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if (tselem->id == id && tselem->used == 0) { + if ((type == 0 && tselem->type == 0) || (tselem->type == type && tselem->nr == nr)) { + te->store_index = a; + tselem->used = 1; return; } } } /* add 1 element to treestore */ - if (ts->usedelem==ts->totelem) { + if (ts->usedelem == ts->totelem) { TreeStoreElem *tsnew; - tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); + tsnew = MEM_mallocN((ts->totelem + TS_CHUNK) * sizeof(TreeStoreElem), "treestore data"); if (ts->data) { - memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); + memcpy(tsnew, ts->data, ts->totelem * sizeof(TreeStoreElem)); MEM_freeN(ts->data); } - ts->data= tsnew; - ts->totelem+= TS_CHUNK; + ts->data = tsnew; + ts->totelem += TS_CHUNK; } - tselem= ts->data+ts->usedelem; + tselem = ts->data + ts->usedelem; - tselem->type= type; - if (type) tselem->nr= nr; // we're picky! :) - else tselem->nr= 0; - tselem->id= id; + tselem->type = type; + if (type) tselem->nr = nr; // we're picky! :) + else tselem->nr = 0; + tselem->id = id; tselem->used = 0; - tselem->flag= TSE_CLOSED; - te->store_index= ts->usedelem; + tselem->flag = TSE_CLOSED; + te->store_index = ts->usedelem; ts->usedelem++; } @@ -188,7 +188,7 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty void outliner_free_tree(ListBase *lb) { while (lb->first) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -207,12 +207,12 @@ void outliner_cleanup_tree(SpaceOops *soops) /* Find ith item from the treestore */ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { - TreeElement *te= lb->first, *tes; + TreeElement *te = lb->first, *tes; while (te) { - if (te->store_index==store_index) return te; - tes= outliner_find_tree_element(&te->subtree, store_index); + if (te->store_index == store_index) return te; + tes = outliner_find_tree_element(&te->subtree, store_index); if (tes) return tes; - te= te->next; + te = te->next; } return NULL; } @@ -220,17 +220,17 @@ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) /* tse is not in the treestore, we use its contents to find a match */ TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; TreeStoreElem *tselem; int a; - if (tse->id==NULL) return NULL; + if (tse->id == NULL) return NULL; /* check if 'tse' is in treestore */ - tselem= ts->data; - for (a=0; a<ts->usedelem; a++, tselem++) { - if ((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if (tselem->id==tse->id) { + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if ((tse->type == 0 && tselem->type == 0) || (tselem->type == tse->type && tselem->nr == tse->nr)) { + if (tselem->id == tse->id) { break; } } @@ -247,13 +247,13 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) TreeElement *te, *tes; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0) { - if (tselem->id==id) return te; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0) { + if (tselem->id == id) return te; /* only deeper on scene or object */ - if ( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { - tes= outliner_find_id(soops, &te->subtree, id); + if (te->idcode == ID_OB || te->idcode == ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode == ID_GR)) { + tes = outliner_find_id(soops, &te->subtree, id); if (tes) return tes; } } @@ -265,12 +265,12 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) { TreeStoreElem *tselem; - te= te->parent; + te = te->parent; while (te) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==idcode) return tselem->id; - te= te->parent; + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == idcode) return tselem->id; + te = te->parent; } return NULL; } @@ -280,28 +280,28 @@ ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) /* Prototype, see functions below */ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index); + TreeElement *parent, short type, short index); /* -------------------------------------------------------- */ /* special handling of hierarchical non-lib data */ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, - TreeElement *parent, int *a) + TreeElement *parent, int *a) { - TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); + TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); (*a)++; - te->name= curBone->name; - te->directdata= curBone; + te->name = curBone->name; + te->directdata = curBone; - for (curBone= curBone->childbase.first; curBone; curBone=curBone->next) { + for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } } /* -------------------------------------------------------- */ -#define LOG2I(x) (int)(log(x)/M_LN2) +#define LOG2I(x) (int)(log(x) / M_LN2) static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) { @@ -311,82 +311,82 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* log stuff is to convert bitflags (powers of 2) to small integers, * in order to not overflow short tselem->nr */ - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); - te->name= "Combined"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); + te->name = "Combined"; + te->directdata = &srl->passflag; /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); if (tselem->flag & TSE_CLOSED) return; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); - te->name= "Z"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); - te->name= "Vector"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); - te->name= "Normal"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); - te->name= "UV"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); - te->name= "Mist"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); - te->name= "Index Object"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); - te->name= "Index Material"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); + te->name = "Z"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); - te->name= "Color"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); - te->name= "Diffuse"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); - te->name= "Specular"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); - te->name= "Shadow"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); - te->name= "AO"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); - te->name= "Reflection"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); - te->name= "Refraction"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); - te->name= "Indirect"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); + te->name = "Vector"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); + te->name = "Normal"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); + te->name = "UV"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); - te->name= "Environment"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); + te->name = "Mist"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); - te->name= "Emit"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); + te->name = "Index Object"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); + te->name = "Index Material"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); + te->name = "Color"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); + te->name = "Diffuse"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); + te->name = "Specular"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); + te->name = "Shadow"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); + te->name = "AO"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); + te->name = "Reflection"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); + te->name = "Refraction"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); + te->name = "Indirect"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); + te->name = "Environment"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); + te->name = "Emit"; + te->directdata = &srl->passflag; } #undef LOG2I @@ -394,14 +394,14 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te) { SceneRenderLayer *srl; - TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); int a; - tenla->name= "RenderLayers"; - for (a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { - TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); - tenlay->name= srl->name; - tenlay->directdata= &srl->passflag; + tenla->name = "RenderLayers"; + for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) { + TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); + tenlay->name = srl->name; + tenlay->directdata = &srl->passflag; if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); @@ -428,66 +428,66 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - if (ob->proxy && ob->id.lib==NULL) + if (ob->proxy && ob->id.lib == NULL) outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); if (ob->pose) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - tenla->name= "Pose"; + tenla->name = "Pose"; /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { - int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ + int a = 0, const_index = 1000; /* ensure unique id for bone constraints */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); - ten->name= pchan->name; - ten->directdata= pchan; - pchan->temp= (void *)ten; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); + ten->name = pchan->name; + ten->directdata = pchan; + pchan->temp = (void *)ten; if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; - TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla1->name= "Constraints"; - for (con= pchan->constraints.first; con; con= con->next, const_index++) { - ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); + tenla1->name = "Constraints"; + for (con = pchan->constraints.first; con; con = con->next, const_index++) { + ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); #if 0 /* disabled as it needs to be reworked for recoded constraints system */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten1->name= str; - else if (target) ten1->name= target->id.name+2; - else ten1->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten1->name = str; + else if (target) ten1->name = target->id.name + 2; + else ten1->name = con->name; #endif - ten1->name= con->name; - ten1->directdata= con; + ten1->name = con->name; + ten1->directdata = con; /* possible add all other types links? */ } } } /* make hierarchy */ - ten= tenla->subtree.first; + ten = tenla->subtree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - if (tselem->type==TSE_POSE_CHANNEL) { - pchan= (bPoseChannel *)ten->directdata; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + if (tselem->type == TSE_POSE_CHANNEL) { + pchan = (bPoseChannel *)ten->directdata; if (pchan->parent) { BLI_remlink(&tenla->subtree, ten); - par= (TreeElement *)pchan->parent->temp; + par = (TreeElement *)pchan->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } } - ten= nten; + ten = nten; } } @@ -495,39 +495,39 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->pose->agroups.first) { bActionGroup *agrp; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); - int a= 0; + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); + int a = 0; - tenla->name= "Bone Groups"; - for (agrp=ob->pose->agroups.first; agrp; agrp=agrp->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); - ten->name= agrp->name; - ten->directdata= agrp; + tenla->name = "Bone Groups"; + for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); + ten->name = agrp->name; + ten->directdata = agrp; } } } - for (a=0; a<ob->totcol; a++) + for (a = 0; a < ob->totcol; a++) outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); if (ob->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla->name= "Constraints"; - for (con=ob->constraints.first, a=0; con; con= con->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); + tenla->name = "Constraints"; + for (con = ob->constraints.first, a = 0; con; con = con->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); #if 0 /* disabled due to constraints system targets recode... code here needs review */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten->name= str; - else if (target) ten->name= target->id.name+2; - else ten->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten->name = str; + else if (target) ten->name = target->id.name + 2; + else ten->name = con->name; #endif - ten->name= con->name; - ten->directdata= con; + ten->name = con->name; + ten->directdata = con; /* possible add all other types links? */ } } @@ -538,30 +538,30 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree int index; temod->name = "Modifiers"; - for (index=0, md=ob->modifiers.first; md; index++, md=md->next) { + for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) { TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); - te->name= md->name; + te->name = md->name; te->directdata = md; - if (md->type==eModifierType_Lattice) { - outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_LINKED_OB, 0); + if (md->type == eModifierType_Lattice) { + outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Curve) { - outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Curve) { + outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Armature) { - outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Armature) { + outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Hook) { - outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Hook) { + outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_ParticleSystem) { + else if (md->type == eModifierType_ParticleSystem) { TreeElement *ten; - ParticleSystem *psys= ((ParticleSystemModifierData*) md)->psys; + ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0); ten->directdata = psys; - ten->name = psys->part->id.name+2; + ten->name = psys->part->id.name + 2; } } } @@ -570,13 +570,13 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->defbase.first) { bDeformGroup *defgroup; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); - tenla->name= "Vertex Groups"; - for (defgroup=ob->defbase.first, a=0; defgroup; defgroup=defgroup->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); - ten->name= defgroup->name; - ten->directdata= defgroup; + tenla->name = "Vertex Groups"; + for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); + ten->name = defgroup->name; + ten->directdata = defgroup; } } @@ -589,147 +589,147 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { /* tuck pointer back in object, to construct hierarchy */ - if (GS(id->name)==ID_OB) id->newid= (ID *)te; + if (GS(id->name) == ID_OB) id->newid = (ID *)te; /* expand specific data always */ switch (GS(id->name)) { case ID_LI: { - te->name= ((Library *)id)->name; + te->name = ((Library *)id)->name; } - break; + break; case ID_SCE: { outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te); } - break; + break; case ID_OB: { outliner_add_object_contents(soops, te, tselem, (Object *)id); } - break; + break; case ID_ME: { - Mesh *me= (Mesh *)id; + Mesh *me = (Mesh *)id; int a; if (me->adt) outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); - for (a=0; a<me->totcol; a++) + for (a = 0; a < me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ } - break; + break; case ID_CU: { - Curve *cu= (Curve *)id; + Curve *cu = (Curve *)id; int a; if (cu->adt) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - for (a=0; a<cu->totcol; a++) + for (a = 0; a < cu->totcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); } - break; + break; case ID_MB: { - MetaBall *mb= (MetaBall *)id; + MetaBall *mb = (MetaBall *)id; int a; if (mb->adt) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - for (a=0; a<mb->totcol; a++) + for (a = 0; a < mb->totcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); } - break; + break; case ID_MA: { - Material *ma= (Material *)id; + Material *ma = (Material *)id; int a; if (ma->adt) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - for (a=0; a<MAX_MTEX; a++) { + for (a = 0; a < MAX_MTEX; a++) { if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_TE: { - Tex *tex= (Tex *)id; + Tex *tex = (Tex *)id; if (tex->adt) outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); } - break; + break; case ID_CA: { - Camera *ca= (Camera *)id; + Camera *ca = (Camera *)id; if (ca->adt) outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_LA: { - Lamp *la= (Lamp *)id; + Lamp *la = (Lamp *)id; int a; if (la->adt) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - for (a=0; a<MAX_MTEX; a++) { + for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_SPK: - { - Speaker *spk= (Speaker *)id; + { + Speaker *spk = (Speaker *)id; - if (spk->adt) - outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); - } - break; + if (spk->adt) + outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } + break; case ID_WO: { - World *wrld= (World *)id; + World *wrld = (World *)id; int a; if (wrld->adt) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - for (a=0; a<MAX_MTEX; a++) { + for (a = 0; a < MAX_MTEX; a++) { if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_KE: { - Key *key= (Key *)id; + Key *key = (Key *)id; if (key->adt) outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_AC: { // XXX do we want to be exposing the F-Curves here? //bAction *act= (bAction *)id; } - break; + break; case ID_AR: { - bArmature *arm= (bArmature *)id; - int a= 0; + bArmature *arm = (bArmature *)id; + int a = 0; if (arm->adt) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); @@ -738,115 +738,115 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor EditBone *ebone; TreeElement *ten; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next, a++) { - ten= outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); - ten->directdata= ebone; - ten->name= ebone->name; - ebone->temp= ten; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) { + ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); + ten->directdata = ebone; + ten->name = ebone->name; + ebone->temp = ten; } /* make hierarchy */ - ten= arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; + ten = arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; while (ten) { - TreeElement *nten= ten->next, *par; - ebone= (EditBone *)ten->directdata; + TreeElement *nten = ten->next, *par; + ebone = (EditBone *)ten->directdata; if (ebone->parent) { BLI_remlink(&te->subtree, ten); - par= ebone->parent->temp; + par = ebone->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } } else { /* do not extend Armature when we have posemode */ - tselem= TREESTORE(te->parent); - if ( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); + tselem = TREESTORE(te->parent); + if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) ; else { Bone *curBone; - for (curBone=arm->bonebase.first; curBone; curBone=curBone->next) { + for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); } } } } - break; + break; } } // TODO: this function needs to be split up! It's getting a bit too large... static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index) + TreeElement *parent, short type, short index) { TreeElement *te; TreeStoreElem *tselem; - ID *id= idv; + ID *id = idv; int a = 0; if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - id= ((PointerRNA*)idv)->id.data; - if (!id) id= ((PointerRNA*)idv)->data; + id = ((PointerRNA *)idv)->id.data; + if (!id) id = ((PointerRNA *)idv)->data; } - if (id==NULL) return NULL; + if (id == NULL) return NULL; - te= MEM_callocN(sizeof(TreeElement), "tree elem"); + te = MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ check_persistent(soops, te, id, type, index); - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; - te->parent= parent; - te->index= index; // for data arays - if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); - else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); - else if (type==TSE_ANIM_DATA); + te->parent = parent; + te->index = index; // for data arays + if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) ; + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) ; + else if (type == TSE_ANIM_DATA) ; else { - te->name= id->name+2; // default, can be overridden by Library or non-ID data - te->idcode= GS(id->name); + te->name = id->name + 2; // default, can be overridden by Library or non-ID data + te->idcode = GS(id->name); } - if (type==0) { + if (type == 0) { /* ID datablock */ outliner_add_id_contents(soops, te, tselem, id); } - else if (type==TSE_ANIM_DATA) { + else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; - AnimData *adt= (AnimData *)iat->adt; + AnimData *adt = (AnimData *)iat->adt; /* this element's info */ - te->name= "Animation"; - te->directdata= adt; + te->name = "Animation"; + te->directdata = adt; /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); /* Drivers */ if (adt->drivers.first) { - TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); - ID *lastadded= NULL; + TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); + ID *lastadded = NULL; FCurve *fcu; - ted->name= "Drivers"; + ted->name = "Drivers"; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { - ChannelDriver *driver= fcu->driver; + ChannelDriver *driver = fcu->driver; DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); - lastadded= dtar->id; + lastadded = dtar->id; } } DRIVER_TARGETS_LOOPER_END @@ -857,29 +857,29 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* NLA Data */ if (adt->nla_tracks.first) { - TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); NlaTrack *nlt; - int a= 0; + int a = 0; - tenla->name= "NLA Tracks"; + tenla->name = "NLA Tracks"; - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { - TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); NlaStrip *strip; TreeElement *ten; - int b= 0; + int b = 0; - tenlt->name= nlt->name; + tenlt->name = nlt->name; - for (strip=nlt->strips.first; strip; strip=strip->next, b++) { - ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); - if (ten) ten->directdata= strip; + for (strip = nlt->strips.first; strip; strip = strip->next, b++) { + ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); + if (ten) ten->directdata = strip; } } } } - else if (type==TSE_SEQUENCE) { - Sequence *seq= (Sequence*) idv; + else if (type == TSE_SEQUENCE) { + Sequence *seq = (Sequence *) idv; Sequence *p; /* @@ -887,56 +887,56 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i * only check te->idcode if te->type is equal to zero, * so this is "safe". */ - te->idcode= seq->type; - te->directdata= seq; + te->idcode = seq->type; + te->directdata = seq; - if (seq->type<7) { + if (seq->type < 7) { /* * This work like the sequence. * If the sequence have a name (not default name) * show it, in other case put the filename. */ if (strcmp(seq->name, "SQ")) - te->name= seq->name; + te->name = seq->name; else { if ((seq->strip) && (seq->strip->stripdata)) - te->name= seq->strip->stripdata->name; + te->name = seq->strip->stripdata->name; else - te->name= "SQ None"; + te->name = "SQ None"; } - if (seq->type==SEQ_META) { - te->name= "Meta Strip"; - p= seq->seqbase.first; + if (seq->type == SEQ_META) { + te->name = "Meta Strip"; + p = seq->seqbase.first; while (p) { - outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } else - outliner_add_element(soops, &te->subtree, (void*)seq->strip, te, TSE_SEQ_STRIP, index); + outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); } else - te->name= "Effect"; + te->name = "Effect"; } - else if (type==TSE_SEQ_STRIP) { - Strip *strip= (Strip *)idv; + else if (type == TSE_SEQ_STRIP) { + Strip *strip = (Strip *)idv; if (strip->dir) - te->name= strip->dir; + te->name = strip->dir; else - te->name= "Strip None"; - te->directdata= strip; + te->name = "Strip None"; + te->directdata = strip; } - else if (type==TSE_SEQUENCE_DUP) { - Sequence *seq= (Sequence*)idv; + else if (type == TSE_SEQUENCE_DUP) { + Sequence *seq = (Sequence *)idv; - te->idcode= seq->type; - te->directdata= seq; - te->name= seq->strip->stripdata->name; + te->idcode = seq->type; + te->directdata = seq; + te->name = seq->strip->stripdata->name; } else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; + PointerRNA pptr, propptr, *ptr = (PointerRNA *)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; int a, tot; @@ -944,22 +944,22 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* we do lazy build, for speed and to avoid infinite recusion */ if (ptr->data == NULL) { - te->name= "(empty)"; + te->name = "(empty)"; } else if (type == TSE_RNA_STRUCT) { /* struct */ - te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); + te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); if (te->name) te->flag |= TE_FREE_NAME; else - te->name= RNA_struct_ui_name(ptr->type); + te->name = RNA_struct_ui_name(ptr->type); /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; - iterprop= RNA_struct_iterator_property(ptr->type); - tot= RNA_property_collection_length(ptr, iterprop); + iterprop = RNA_struct_iterator_property(ptr->type); + tot = RNA_property_collection_length(ptr, iterprop); /* auto open these cases */ if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) @@ -967,57 +967,57 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tselem->flag &= ~TSE_CLOSED; if (TSELEM_OPEN(tselem, soops)) { - for (a=0; a<tot; a++) - outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; - te->rnaptr= *ptr; + te->rnaptr = *ptr; } else if (type == TSE_RNA_PROPERTY) { /* property */ - iterprop= RNA_struct_iterator_property(ptr->type); + iterprop = RNA_struct_iterator_property(ptr->type); RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); - prop= propptr.data; - proptype= RNA_property_type(prop); + prop = propptr.data; + proptype = RNA_property_type(prop); - te->name= RNA_property_ui_name(prop); - te->directdata= prop; - te->rnaptr= *ptr; + te->name = RNA_property_ui_name(prop); + te->directdata = prop; + te->rnaptr = *ptr; /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; if (proptype == PROP_POINTER) { - pptr= RNA_property_pointer_get(ptr, prop); + pptr = RNA_property_pointer_get(ptr, prop); if (pptr.data) { if (TSELEM_OPEN(tselem, soops)) - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1); else te->flag |= TE_LAZY_CLOSED; } } else if (proptype == PROP_COLLECTION) { - tot= RNA_property_collection_length(ptr, prop); + tot = RNA_property_collection_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; a<tot; a++) { + for (a = 0; a < tot; a++) { RNA_property_collection_lookup_int(ptr, prop, a, &pptr); - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a); } } else if (tot) te->flag |= TE_LAZY_CLOSED; } else if (ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(ptr, prop); + tot = RNA_property_array_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; a<tot; a++) - outliner_add_element(soops, &te->subtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; @@ -1026,51 +1026,51 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_RNA_ARRAY_ELEM) { char c; - prop= parent->directdata; + prop = parent->directdata; - te->directdata= prop; - te->rnaptr= *ptr; - te->index= index; + te->directdata = prop; + te->rnaptr = *ptr; + te->index = index; - c= RNA_property_array_item_char(prop, index); + c = RNA_property_array_item_char(prop, index); - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); if (c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index+1); + else sprintf((char *)te->name, " %d", index + 1); te->flag |= TE_FREE_NAME; } } else if (type == TSE_KEYMAP) { - wmKeyMap *km= (wmKeyMap *)idv; + wmKeyMap *km = (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; - te->directdata= idv; - te->name= km->idname; + te->directdata = idv; + te->name = km->idname; if (TSELEM_OPEN(tselem, soops)) { - a= 0; + a = 0; for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { - const char *key= WM_key_event_string(kmi->type); + const char *key = WM_key_event_string(kmi->type); if (key[0]) { - wmOperatorType *ot= NULL; + wmOperatorType *ot = NULL; - if (kmi->propvalue); - else ot= WM_operatortype_find(kmi->idname, 0); + if (kmi->propvalue) ; + else ot = WM_operatortype_find(kmi->idname, 0); if (ot || kmi->propvalue) { - TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); + TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - ten->directdata= kmi; + ten->directdata = kmi; if (kmi->propvalue) { - ten->name= "Modal map, not yet"; + ten->name = "Modal map, not yet"; } else { WM_operator_py_idname(opname, ot->idname); - ten->name= BLI_strdup(opname); + ten->name = BLI_strdup(opname); ten->flag |= TE_FREE_NAME; } } @@ -1099,28 +1099,28 @@ static int need_add_seq_dup(Sequence *seq) * First check backward, if we found a duplicate * sequence before this, don't need it, just return. */ - p= seq->prev; + p = seq->prev; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->prev; + p = p->prev; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(2); - p= p->prev; + p = p->prev; } - p= seq->next; + p = seq->next; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(0); - p= p->next; + p = p->next; } return(1); } @@ -1130,16 +1130,16 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t /* TreeElement *ch; */ /* UNUSED */ Sequence *p; - p= seq; + p = seq; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } @@ -1156,22 +1156,22 @@ static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) /* build hierarchy */ // XXX also, set extents here... - te= lb->first; + te = lb->first; while (te) { - ten= te->next; - tselem= TREESTORE(te); + ten = te->next; + tselem = TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + if (tselem->type == 0 && te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); - tep= (TreeElement *)ob->parent->id.newid; + tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); // set correct parent pointers - for (te=tep->subtree.first; te; te= te->next) te->parent= tep; + for (te = tep->subtree.first; te; te = te->next) te->parent = tep; } } - te= ten; + te = ten; } } @@ -1187,20 +1187,20 @@ typedef struct tTreeSort { /* alphabetical comparator */ static int treesort_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; int comp; /* first put objects last (hierarchy) */ - comp= (x1->idcode==ID_OB); - if (x2->idcode==ID_OB) comp+=2; + comp = (x1->idcode == ID_OB); + if (x2->idcode == ID_OB) comp += 2; - if (comp==1) return 1; - else if (comp==2) return -1; - else if (comp==3) { - comp= strcmp(x1->name, x2->name); + if (comp == 1) return 1; + else if (comp == 2) return -1; + else if (comp == 3) { + comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } return 0; @@ -1210,23 +1210,23 @@ static int treesort_alpha(const void *v1, const void *v2) #if 0 static int treesort_obtype_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; /* first put objects last (hierarchy) */ - if (x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; - else if (x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; + if (x1->idcode == ID_OB && x2->idcode != ID_OB) return 1; + else if (x2->idcode == ID_OB && x1->idcode != ID_OB) return -1; else { /* 2nd we check ob type */ - if (x1->idcode==ID_OB && x2->idcode==ID_OB) { + if (x1->idcode == ID_OB && x2->idcode == ID_OB) { if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; else if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; else return 0; } else { - int comp= strcmp(x1->name, x2->name); + int comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } } @@ -1238,40 +1238,40 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; - int totelem=0; + int totelem = 0; - te= lb->last; - if (te==NULL) return; - tselem= TREESTORE(te); + te = lb->last; + if (te == NULL) return; + tselem = TREESTORE(te); /* sorting rules; only object lists or deformgroups */ - if ( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { + if ( (tselem->type == TSE_DEFGROUP) || (tselem->type == 0 && te->idcode == ID_OB)) { /* count first */ - for (te= lb->first; te; te= te->next) totelem++; + for (te = lb->first; te; te = te->next) totelem++; - if (totelem>1) { - tTreeSort *tear= MEM_mallocN(totelem*sizeof(tTreeSort), "tree sort array"); - tTreeSort *tp=tear; - int skip= 0; - - for (te= lb->first; te; te= te->next, tp++) { - tselem= TREESTORE(te); - tp->te= te; - tp->name= te->name; - tp->idcode= te->idcode; - if (tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // don't sort this - tp->id= tselem->id; + if (totelem > 1) { + tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tp = tear; + int skip = 0; + + for (te = lb->first; te; te = te->next, tp++) { + tselem = TREESTORE(te); + tp->te = te; + tp->name = te->name; + tp->idcode = te->idcode; + if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this + tp->id = tselem->id; } /* keep beginning of list */ - for (tp= tear, skip=0; skip<totelem; skip++, tp++) + for (tp = tear, skip = 0; skip < totelem; skip++, tp++) if (tp->idcode) break; - if (skip<totelem) - qsort(tear+skip, totelem-skip, sizeof(tTreeSort), treesort_alpha); + if (skip < totelem) + qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha); - lb->first=lb->last= NULL; - tp= tear; + lb->first = lb->last = NULL; + tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); tp++; @@ -1280,7 +1280,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) } } - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { outliner_sort(soops, &te->subtree); } } @@ -1290,36 +1290,36 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) { #if 0 - int found= 0; + int found = 0; /* determine if match */ if (flags & SO_FIND_CASE_SENSITIVE) { if (flags & SO_FIND_COMPLETE) - found= strcmp(te->name, name) == 0; + found = strcmp(te->name, name) == 0; else - found= strstr(te->name, name) != NULL; + found = strstr(te->name, name) != NULL; } else { if (flags & SO_FIND_COMPLETE) - found= BLI_strcasecmp(te->name, name) == 0; + found = BLI_strcasecmp(te->name, name) == 0; else - found= BLI_strcasestr(te->name, name) != NULL; + found = BLI_strcasestr(te->name, name) != NULL; } #else - int fn_flag= 0; - int found= 0; + int fn_flag = 0; + int found = 0; if ((flags & SO_FIND_CASE_SENSITIVE) == 0) fn_flag |= FNM_CASEFOLD; if (flags & SO_FIND_COMPLETE) { - found= fnmatch(name, te->name, fn_flag)==0; + found = fnmatch(name, te->name, fn_flag) == 0; } else { char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; BLI_snprintf(fn_name, sizeof(fn_name), "*%s*", name); - found= fnmatch(fn_name, te->name, fn_flag)==0; + found = fnmatch(fn_name, te->name, fn_flag) == 0; } return found; #endif @@ -1333,25 +1333,25 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) /* although we don't have any search string, we return TRUE * since the entire tree is ok then... */ - if (soops->search_string[0]==0) + if (soops->search_string[0] == 0) return 1; - for (te= lb->first; te; te= ten) { - ten= te->next; + for (te = lb->first; te; te = ten) { + ten = te->next; - if (0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { + if (0 == outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { /* item isn't something we're looking for, but... - * - if the subtree is expanded, check if there are any matches that can be easily found + * - if the subtree is expanded, check if there are any matches that can be easily found * so that searching for "cu" in the default scene will still match the Cube * - otherwise, we can't see within the subtree and the item doesn't match, * so these can be safely ignored (i.e. the subtree can get freed) */ - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as not a found item */ tselem->flag &= ~TSE_SEARCHMATCH; - if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree)==0) { + if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree) == 0) { outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -1360,7 +1360,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) } } else { - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as a found item - we can then highlight it */ tselem->flag |= TSE_SEARCHMATCH; @@ -1383,14 +1383,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) { Base *base; Object *ob; - TreeElement *te=NULL, *ten; + TreeElement *te = NULL, *ten; TreeStoreElem *tselem; - int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ + int show_opened = (soops->treestore == NULL); /* on first view, we open scenes */ /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful * - this variable is only set once per tree build */ - if (soops->search_string[0]!=0 && soops->outlinevis!=SO_DATABLOCKS) + if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATABLOCKS) soops->search_flags |= SO_SEARCH_RECURSIVE; else soops->search_flags &= ~SO_SEARCH_RECURSIVE; @@ -1402,64 +1402,64 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_storage_cleanup(soops); /* clear ob id.new flags */ - for (ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; + for (ob = mainvar->object.first; ob; ob = ob->id.next) ob->id.newid = NULL; /* options */ if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - for (lib= mainvar->library.first; lib; lib= lib->id.next) { - ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); - lib->id.newid= (ID *)ten; + for (lib = mainvar->library.first; lib; lib = lib->id.next) { + ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); + lib->id.newid = (ID *)ten; } /* make hierarchy */ - ten= soops->tree.first; + ten = soops->tree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - lib= (Library *)tselem->id; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + lib = (Library *)tselem->id; if (lib->parent) { BLI_remlink(&soops->tree, ten); - par= (TreeElement *)lib->parent->id.newid; + par = (TreeElement *)lib->parent->id.newid; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } /* restore newid pointers */ - for (lib= mainvar->library.first; lib; lib= lib->id.next) - lib->id.newid= NULL; + for (lib = mainvar->library.first; lib; lib = lib->id.next) + lib->id.newid = NULL; } else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; - for (sce= mainvar->scene.first; sce; sce= sce->id.next) { - te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); - tselem= TREESTORE(te); - if (sce==scene && show_opened) + for (sce = mainvar->scene.first; sce; sce = sce->id.next) { + te = outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); + tselem = TREESTORE(te); + if (sce == scene && show_opened) tselem->flag &= ~TSE_CLOSED; - for (base= sce->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); - ten->directdata= base; + for (base = sce->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; + for (base = sce->base.first; base; base = base->next) base->object->id.newid = NULL; } } else if (soops->outlinevis == SO_CUR_SCENE) { outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - for (base= scene->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &soops->tree); } else if (soops->outlinevis == SO_VISIBLE) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); } @@ -1469,102 +1469,102 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) Group *group; GroupObject *go; - for (group= mainvar->group.first; group; group= group->id.next) { + for (group = mainvar->group.first; group; group = group->id.next) { if (group->gobject.first) { - te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); + te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - for (go= group->gobject.first; go; go= go->next) { - ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); - ten->directdata= NULL; /* eh, why? */ + for (go = group->gobject.first; go; go = go->next) { + ten = outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); + ten->directdata = NULL; /* eh, why? */ } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; + for (go = group->gobject.first; go; go = go->next) go->ob->id.newid = NULL; } } } else if (soops->outlinevis == SO_SAME_TYPE) { - Object *ob= OBACT; + Object *ob = OBACT; if (ob) { - for (base= scene->base.first; base; base= base->next) { - if (base->object->type==ob->type) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + if (base->object->type == ob->type) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } outliner_make_hierarchy(soops, &soops->tree); } } else if (soops->outlinevis == SO_SELECTED) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) { - if (base==BASACT || (base->flag & SELECT)) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + if (base == BASACT || (base->flag & SELECT)) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } } outliner_make_hierarchy(soops, &soops->tree); } - else if (soops->outlinevis==SO_SEQUENCE) { + else if (soops->outlinevis == SO_SEQUENCE) { Sequence *seq; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int op; - if (ed==NULL) + if (ed == NULL) return; - seq= ed->seqbasep->first; + seq = ed->seqbasep->first; if (!seq) return; while (seq) { - op= need_add_seq_dup(seq); - if (op==1) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); + op = need_add_seq_dup(seq); + if (op == 1) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0); } - else if (op==0) { - ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); + else if (op == 0) { + ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0); outliner_add_seq_dup(soops, seq, ten, 0); } - seq= seq->next; + seq = seq->next; } } - else if (soops->outlinevis==SO_DATABLOCKS) { + else if (soops->outlinevis == SO_DATABLOCKS) { PointerRNA mainptr; RNA_main_pointer_create(mainvar, &mainptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_USERDEF) { + else if (soops->outlinevis == SO_USERDEF) { PointerRNA userdefptr; RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&userdefptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_KEYMAP) { - wmWindowManager *wm= mainvar->wm.first; + else if (soops->outlinevis == SO_KEYMAP) { + wmWindowManager *wm = mainvar->wm.first; wmKeyMap *km; - for (km= wm->defaultconf->keymaps.first; km; km= km->next) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); + for (km = wm->defaultconf->keymaps.first; km; km = km->next) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); } } else { - ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); - if (ten) ten->directdata= BASACT; + ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); + if (ten) ten->directdata = BASACT; } outliner_sort(soops, &soops->tree); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index c2a3affa1b6..3110ff3e29e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -77,20 +77,20 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { /* Ensure item under cursor is valid drop target */ /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return 1; } } @@ -102,30 +102,30 @@ static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "child", id->name+2); + RNA_string_set(drop->ptr, "child", id->name + 2); } static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { //TODO: Check if no parent? /* Ensure location under cursor is valid dropzone */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; } /* Check if mouse cursor is below the tree */ - te= soops->tree.last; - while (((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { - te= te->subtree.last; + te = soops->tree.last; + while (((te->flag & TE_LAZY_CLOSED) == 0) && (te->subtree.last)) { + te = te->subtree.last; } if (fmval[1] < te->ys) return 1; } @@ -136,7 +136,7 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "dragged_obj", id->name+2); + RNA_string_set(drop->ptr, "dragged_obj", id->name + 2); /* Set to simple parent clear type. Avoid menus for drag and drop if possible. * If desired, user can toggle the different "Clear Parent" types in the operator @@ -155,7 +155,7 @@ static void outliner_dropboxes(void) static void outliner_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear */ @@ -168,7 +168,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -234,11 +234,11 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) /* For updating lamp icons, when changing lamp type */ if (wmn->data == ND_LIGHTING_DRAW) ED_region_tag_redraw(ar); - break; + break; case NC_SPACE: if (wmn->data == ND_SPACE_OUTLINER) ED_region_tag_redraw(ar); - break; + break; case NC_ID: if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); @@ -269,7 +269,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case ND_ANIMCHAN: - if (wmn->action==NA_SELECTED) + if (wmn->action == NA_SELECTED) ED_region_tag_redraw(ar); break; } @@ -318,35 +318,35 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) ARegion *ar; SpaceOops *soutliner; - soutliner= MEM_callocN(sizeof(SpaceOops), "initoutliner"); - soutliner->spacetype= SPACE_OUTLINER; + soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner"); + soutliner->spacetype = SPACE_OUTLINER; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for outliner"); + ar = MEM_callocN(sizeof(ARegion), "header for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for outliner"); + ar = MEM_callocN(sizeof(ARegion), "main area for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; - return (SpaceLink*)soutliner; + return (SpaceLink *)soutliner; } /* not spacelink itself */ static void outliner_free(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops*)sl; + SpaceOops *soutliner = (SpaceOops *)sl; outliner_free_tree(&soutliner->tree); if (soutliner->treestore) { @@ -364,11 +364,11 @@ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *outliner_duplicate(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops *)sl; - SpaceOops *soutlinern= MEM_dupallocN(soutliner); + SpaceOops *soutliner = (SpaceOops *)sl; + SpaceOops *soutlinern = MEM_dupallocN(soutliner); - soutlinern->tree.first= soutlinern->tree.last= NULL; - soutlinern->treestore= NULL; + soutlinern->tree.first = soutlinern->tree.last = NULL; + soutlinern->treestore = NULL; return (SpaceLink *)soutlinern; } @@ -376,41 +376,41 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) /* only called once, from space_api/spacetypes.c */ void ED_spacetype_outliner(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_OUTLINER; + st->spaceid = SPACE_OUTLINER; strncpy(st->name, "Outliner", BKE_ST_MAXNAME); - st->new= outliner_new; - st->free= outliner_free; - st->init= outliner_init; - st->duplicate= outliner_duplicate; - st->operatortypes= outliner_operatortypes; - st->keymap= outliner_keymap; - st->dropboxes= outliner_dropboxes; + st->new = outliner_new; + st->free = outliner_free; + st->init = outliner_init; + st->duplicate = outliner_duplicate; + st->operatortypes = outliner_operatortypes; + st->keymap = outliner_keymap; + st->dropboxes = outliner_dropboxes; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= outliner_main_area_init; - art->draw= outliner_main_area_draw; - art->free= outliner_main_area_free; - art->listener= outliner_main_area_listener; + art->init = outliner_main_area_init; + art->draw = outliner_main_area_draw; + art->free = outliner_main_area_free; + art->listener = outliner_main_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= outliner_header_area_init; - art->draw= outliner_header_area_draw; - art->free= outliner_header_area_free; - art->listener= outliner_header_area_listener; + art->init = outliner_header_area_init; + art->draw = outliner_header_area_draw; + art->free = outliner_header_area_free; + art->listener = outliner_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 4ff0c7ba5b3..4e6783e1862 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -46,7 +46,7 @@ #include "ED_screen.h" -#include "script_intern.h" // own include +#include "script_intern.h" // own include #ifdef WITH_PYTHON #include "BPY_extern.h" /* BPY_script_exec */ @@ -58,7 +58,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_PYTHON if (BPY_filepath_exec(C, path, op->reports)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index 0c99d9b34c4..57a1112a832 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -63,6 +63,6 @@ void script_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_keymap_find(keyconf, "Script", SPACE_SCRIPT, 0); /* TODO - this is just while we have no way to load a text datablock */ - RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0)->ptr, "filepath", "test.py"); + RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0)->ptr, "filepath", "test.py"); } diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index bad9a01fbcf..1fbd6f08b34 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -57,7 +57,7 @@ #include "BPY_extern.h" #endif -#include "script_intern.h" // own include +#include "script_intern.h" // own include //static script_run_python(char *funcname, ) @@ -70,22 +70,22 @@ static SpaceLink *script_new(const bContext *UNUSED(C)) ARegion *ar; SpaceScript *sscript; - sscript= MEM_callocN(sizeof(SpaceScript), "initscript"); - sscript->spacetype= SPACE_SCRIPT; + sscript = MEM_callocN(sizeof(SpaceScript), "initscript"); + sscript->spacetype = SPACE_SCRIPT; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for script"); + ar = MEM_callocN(sizeof(ARegion), "header for script"); BLI_addtail(&sscript->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for script"); + ar = MEM_callocN(sizeof(ARegion), "main area for script"); BLI_addtail(&sscript->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; /* channel list region XXX */ @@ -96,7 +96,7 @@ static SpaceLink *script_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void script_free(SpaceLink *sl) { - SpaceScript *sscript= (SpaceScript*) sl; + SpaceScript *sscript = (SpaceScript *) sl; #ifdef WITH_PYTHON /*free buttons references*/ @@ -118,7 +118,7 @@ static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *script_duplicate(SpaceLink *sl) { - SpaceScript *sscriptn= MEM_dupallocN(sl); + SpaceScript *sscriptn = MEM_dupallocN(sl); /* clear or remove stuff from old */ @@ -142,8 +142,8 @@ static void script_main_area_init(wmWindowManager *wm, ARegion *ar) static void script_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceScript *sscript= (SpaceScript*)CTX_wm_space_data(C); - View2D *v2d= &ar->v2d; + SpaceScript *sscript = (SpaceScript *)CTX_wm_space_data(C); + View2D *v2d = &ar->v2d; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -189,37 +189,37 @@ static void script_main_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wm /* only called once, from space/spacetypes.c */ void ED_spacetype_script(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype script"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype script"); ARegionType *art; - st->spaceid= SPACE_SCRIPT; + st->spaceid = SPACE_SCRIPT; strncpy(st->name, "Script", BKE_ST_MAXNAME); - st->new= script_new; - st->free= script_free; - st->init= script_init; - st->duplicate= script_duplicate; - st->operatortypes= script_operatortypes; - st->keymap= script_keymap; + st->new = script_new; + st->free = script_free; + st->init = script_init; + st->duplicate = script_duplicate; + st->operatortypes = script_operatortypes; + st->keymap = script_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype script region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_WINDOW; - art->init= script_main_area_init; - art->draw= script_main_area_draw; - art->listener= script_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D| ED_KEYMAP_UI|ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction + art->init = script_main_area_init; + art->draw = script_main_area_draw; + art->listener = script_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_UI | ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype script region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - art->init= script_header_area_init; - art->draw= script_header_area_draw; + art->init = script_header_area_init; + art->draw = script_header_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 4bc08242020..2c3924e5407 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -106,7 +106,7 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, { if (RNA_struct_find_property(op->ptr, identifier)) { Scene *scene = CTX_data_scene(C); - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { char path[sizeof(last_seq->strip->dir)]; BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); @@ -203,7 +203,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); Scene *sce_seq; @@ -239,11 +239,11 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } @@ -302,7 +302,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); MovieClip *clip; @@ -338,11 +338,11 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seqbase_unique_name_recursive(&ed->seqbase, seq); calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } @@ -401,7 +401,7 @@ void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func) { Scene *scene = CTX_data_scene(C); /* only for sound */ - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); SeqLoadInfo seq_load; Sequence *seq; int tot_files; @@ -412,7 +412,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) deselect_all_seq(scene); - tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + if (RNA_struct_property_is_set(op->ptr, "files")) + tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + else + tot_files = 0; if (tot_files) { /* multiple files */ @@ -450,7 +453,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad return OPERATOR_CANCELLED; } - sort_seq(scene); + BKE_sequencer_sort(scene); seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -572,7 +575,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* cant use the generic function for this */ Scene *scene = CTX_data_scene(C); /* only for sound */ - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); SeqLoadInfo seq_load; Sequence *seq; @@ -613,7 +616,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); /* last active name */ strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR - 1); @@ -675,7 +678,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); Sequence *seq; /* generic strip vars */ Strip *strip; @@ -776,11 +779,11 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) /* not sure if this is needed with update_changed_seq_and_deps. * it was NOT called in blender 2.4x, but wont hurt */ - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 38a5151590e..49fadf300e2 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1062,7 +1062,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) { Scene *scene = CTX_data_scene(C); View2D *v2d = &ar->v2d; - Sequence *last_seq = seq_active_get(scene); + 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); @@ -1122,7 +1122,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) void draw_timeline_seq(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); SpaceSeq *sseq = CTX_wm_space_seq(C); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index b021c233f8c..3d6fbb53e37 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -163,7 +163,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog static void proxy_endjob(void *pjv) { ProxyJob *pj = pjv; - Editing *ed = seq_give_editing(pj->scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(pj->scene, FALSE); LinkData *link; for (link = pj->queue.first; link; link = link->next) { @@ -180,7 +180,7 @@ static void seq_proxy_build_job(const bContext *C) wmJob *steve; ProxyJob *pj; Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ScrArea *sa = CTX_wm_area(C); struct SeqIndexBuildContext *context; LinkData *link; @@ -233,9 +233,9 @@ void seq_rectf(Sequence *seq, rctf *rectf) static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* called from fileselect */ { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); struct SeqEffectHandle sh; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq == NULL || last_seq->type != SEQ_PLUGIN) return; @@ -255,7 +255,7 @@ static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* cal void boundbox_seq(Scene *scene, rctf *rect) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); float min[2], max[2]; @@ -302,7 +302,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return NULL; @@ -334,7 +334,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq, *best_seq = NULL; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int dist, best_dist; best_dist = MAXFRAME * 2; @@ -382,7 +382,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2]) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); float x, y; float pixelx; float handsize; @@ -457,7 +457,7 @@ static int seq_is_predecessor(Sequence *pred, Sequence *seq) void deselect_all_seq(Scene *scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -489,13 +489,13 @@ void recurs_sel_seq(Sequence *seqm) int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq; *error_str = NULL; if (!activeseq) - seq2 = seq_active_get(scene); + seq2 = BKE_sequencer_active_get(scene); for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { @@ -597,14 +597,14 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { Sequence *seq, *seqn; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); seq = lb->first; while (seq) { seqn = seq->next; if ((seq->flag & flag) || deleteall) { BLI_remlink(lb, seq); - if (seq == last_seq) seq_active_set(scene, NULL); + if (seq == last_seq) BKE_sequencer_active_set(scene, NULL); if (seq->type == SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); seq_free_sequence(scene, seq); } @@ -839,7 +839,7 @@ static int cut_seq_list(Scene *scene, ListBase *old, ListBase *new, int cutframe static int insert_gap(Scene *scene, int gap, int cfra) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int done = 0; /* all strips >= cfra are shifted */ @@ -862,7 +862,7 @@ static int insert_gap(Scene *scene, int gap, int cfra) static void UNUSED_FUNCTION(touch_seq_files) (Scene * scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); char str[256]; /* touch all strips with movies */ @@ -894,7 +894,7 @@ static void UNUSED_FUNCTION(touch_seq_files) (Scene * scene) static void set_filter_seq(Scene *scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -918,8 +918,8 @@ static void set_filter_seq(Scene *scene) static void UNUSED_FUNCTION(seq_remap_paths) (Scene * scene) { - Sequence *seq, *last_seq = seq_active_get(scene); - Editing *ed = seq_give_editing(scene, FALSE); + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; @@ -960,7 +960,7 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene * scene) static void UNUSED_FUNCTION(no_gaps) (Scene * scene) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int cfra, first = 0, done; @@ -1001,14 +1001,14 @@ static int seq_get_snaplimit(View2D *v2d) /* Operator functions */ int sequencer_edit_poll(bContext *C) { - return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL); + return (BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL); } #if 0 /* UNUSED */ int sequencer_strip_poll(bContext *C) { Editing *ed; - return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); + return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); } #endif @@ -1016,13 +1016,13 @@ int sequencer_strip_has_path_poll(bContext *C) { Editing *ed; Sequence *seq; - return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); + return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); } int sequencer_view_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); - Editing *ed = seq_give_editing(CTX_data_scene(C), FALSE); + Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE); if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) return 1; @@ -1034,7 +1034,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int snap_frame; @@ -1084,7 +1084,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1125,7 +1125,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot) static int sequencer_mute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int selected; @@ -1172,7 +1172,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot) static int sequencer_unmute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int selected; @@ -1219,7 +1219,7 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot) static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -1252,7 +1252,7 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot) static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -1285,7 +1285,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot) static int sequencer_reload_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int adjust_length = RNA_boolean_get(op->ptr, "adjust_length"); @@ -1331,7 +1331,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); @@ -1355,7 +1355,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene); + Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene); const char *error_msg; if (!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) { @@ -1385,10 +1385,10 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) static int sequencer_effect_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq && (last_seq->type & SEQ_EFFECT)) { return 1; } @@ -1416,7 +1416,7 @@ void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot) static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Sequence *seq, *last_seq = seq_active_get(scene); + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap"); @@ -1459,7 +1459,7 @@ static EnumPropertyItem prop_cut_types[] = { static int sequencer_cut_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int cut_side, cut_hard, cut_frame; ListBase newlist; @@ -1499,7 +1499,7 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) SEQ_END; } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); } if (changed) { @@ -1567,7 +1567,7 @@ static int apply_unique_name_cb(Sequence *seq, void *arg_pt) static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ListBase nseqbase = {NULL, NULL}; @@ -1624,12 +1624,12 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; MetaStack *ms; int nothingSelected = TRUE; - seq = seq_active_get(scene); + seq = BKE_sequencer_active_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; } @@ -1695,7 +1695,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; /* for effects, try to find a replacement input */ @@ -1747,7 +1747,7 @@ void SEQUENCER_OT_offset_clear(wmOperatorType *ot) static int sequencer_separate_images_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *seq_new; Strip *strip_new; @@ -1811,7 +1811,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1843,8 +1843,8 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot) static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *last_seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *last_seq = BKE_sequencer_active_get(scene); MetaStack *ms; if (last_seq && last_seq->type == SEQ_META && last_seq->flag & SELECT) { @@ -1856,7 +1856,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ed->seqbasep = &last_seq->seqbase; - seq_active_set(scene, NULL); + BKE_sequencer_active_set(scene, NULL); } else { @@ -1876,7 +1876,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) for (seq = ed->seqbasep->first; seq; seq = seq->next) calc_sequence(scene, seq); - seq_active_set(scene, ms->parseq); + BKE_sequencer_active_set(scene, ms->parseq); ms->parseq->flag |= SELECT; recurs_sel_seq(ms->parseq); @@ -1911,9 +1911,9 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot) static int sequencer_meta_make_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq, *seqm, *next, *last_seq = seq_active_get(scene); + Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene); int channel_max = 1; if (seqbase_isolated_sel_check(ed->seqbasep) == FALSE) { @@ -1944,7 +1944,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->strip = MEM_callocN(sizeof(Strip), "metastrip"); seqm->strip->us = 1; - seq_active_set(scene, seqm); + BKE_sequencer_active_set(scene, seqm); if (seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); @@ -1987,9 +1987,9 @@ static int seq_depends_on_meta(Sequence *seq, Sequence *seqm) static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */ + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks ed==NULL */ if (last_seq == NULL || last_seq->type != SEQ_META) return OPERATOR_CANCELLED; @@ -2020,7 +2020,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) } } - sort_seq(scene); + BKE_sequencer_sort(scene); seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2225,7 +2225,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) View2D *v2d = UI_view2d_fromcontext(C); ScrArea *area = CTX_wm_area(C); bScreen *sc = CTX_wm_screen(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int xmin = MAXFRAME * 2; @@ -2300,7 +2300,7 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) static int find_next_prev_edit(Scene *scene, int cfra, int side) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL, *frame_seq = NULL; int dist, best_dist; @@ -2427,7 +2427,7 @@ static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) #if 0 static Sequence *sequence_find_parent(Scene *scene, Sequence *child) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *parent = NULL; Sequence *seq; @@ -2447,8 +2447,8 @@ static Sequence *sequence_find_parent(Scene *scene, Sequence *child) static int sequencer_swap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *active_seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *active_seq = BKE_sequencer_active_get(scene); Sequence *seq, *iseq; int side = RNA_enum_get(op->ptr, "side"); @@ -2492,7 +2492,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2524,7 +2524,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) { int retval = OPERATOR_CANCELLED; Scene *scene = CTX_data_scene(C); - Sequence *active_seq = seq_active_get(scene); + Sequence *active_seq = BKE_sequencer_active_get(scene); StripElem *se = NULL; if (active_seq == NULL) @@ -2596,7 +2596,7 @@ static void seq_copy_del_sound(Scene *scene, Sequence *seq) static int sequencer_copy_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; ListBase nseqbase = {NULL, NULL}; @@ -2660,7 +2660,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); /* create if needed */ + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); /* create if needed */ ListBase nseqbase = {NULL, NULL}; int ofs; Sequence *iseq; @@ -2716,7 +2716,7 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) Sequence *seq_other; const char *error_msg; - if (seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { + if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) { BKE_report(op->reports, RPT_ERROR, "Must select 2 strips"); return OPERATOR_CANCELLED; } @@ -2764,7 +2764,7 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot) static int view_ghost_border_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); View2D *v2d = UI_view2d_fromcontext(C); rctf rect; @@ -2856,8 +2856,8 @@ static EnumPropertyItem prop_change_effect_input_types[] = { static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); Sequence **seq_1, **seq_2; @@ -2914,8 +2914,8 @@ void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); const int new_type = RNA_enum_get(op->ptr, "type"); /* free previous effect and init new effect */ @@ -2975,8 +2975,8 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); const int is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); if (seq->type == SEQ_IMAGE) { @@ -3044,7 +3044,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); - Sequence *seq = seq_active_get(scene); + Sequence *seq = BKE_sequencer_active_get(scene); RNA_string_set(op->ptr, "directory", seq->strip->dir); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index e63a3052d26..fd536524c11 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -145,18 +145,18 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot); /* RNA enums, just to be more readable */ enum { - SEQ_SIDE_NONE=0, + SEQ_SIDE_NONE = 0, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT, - SEQ_SIDE_BOTH, + SEQ_SIDE_BOTH }; enum { SEQ_CUT_SOFT, - SEQ_CUT_HARD, + SEQ_CUT_HARD }; enum { SEQ_SELECTED, - SEQ_UNSELECTED, + SEQ_UNSELECTED }; /* defines used internally */ diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 2f5dff961fe..5debeaf79ae 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -275,8 +275,8 @@ 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; @@ -327,8 +327,8 @@ 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; @@ -581,8 +581,8 @@ static void vectorscope_put_cross(unsigned char r, unsigned char g, rgb[2] = (float)b / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); if (r == 0 && g == 0 && b == 0) { r = 255; @@ -632,8 +632,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) rgb[2] = (float)src1[2] / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); } } @@ -682,8 +682,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); } } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 677bab37163..a59570a09e1 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -164,11 +164,11 @@ void select_surround_from_last(Scene *scene) static void UNUSED_FUNCTION(select_single_seq) (Scene * scene, Sequence * seq, int deselect_all) /* BRING BACK */ { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (deselect_all) deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if (seq->strip) @@ -185,7 +185,7 @@ static void UNUSED_FUNCTION(select_single_seq) (Scene * scene, Sequence * seq, i #if 0 static void select_neighbor_from_last(Scene *scene, int lr) { - Sequence *seq = seq_active_get(scene); + Sequence *seq = BKE_sequencer_active_get(scene); Sequence *neighbor; int change = 0; if (seq) { @@ -220,7 +220,7 @@ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; if (action == SEL_TOGGLE) { @@ -281,7 +281,7 @@ void SEQUENCER_OT_select_all(struct wmOperatorType *ot) static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -318,7 +318,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { View2D *v2d = UI_view2d_fromcontext(C); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); short extend = RNA_boolean_get(op->ptr, "extend"); short linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); short left_right = RNA_boolean_get(op->ptr, "left_right"); @@ -406,7 +406,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) deselect_all_seq(scene); if (seq) { - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if (seq->strip) { @@ -557,7 +557,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot) /* run recursively to select linked */ static int select_more_less_seq__internal(Scene *scene, int sel, int linked) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *neighbor; int change = 0; int isel; @@ -758,7 +758,7 @@ void SEQUENCER_OT_select_linked(wmOperatorType *ot) static int sequencer_select_handles_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); + Editing *ed = BKE_sequencer_editing_get(scene, 0); Sequence *seq; int sel_side = RNA_enum_get(op->ptr, "side"); @@ -808,8 +808,8 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) static int sequencer_select_active_side_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); - Sequence *seq_act = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, 0); + Sequence *seq_act = BKE_sequencer_active_get(scene); if (ed == NULL || seq_act == NULL) return OPERATOR_CANCELLED; @@ -846,7 +846,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot) static int sequencer_borderselect_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); View2D *v2d = UI_view2d_fromcontext(C); Sequence *seq; @@ -1094,7 +1094,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) SEQP_BEGIN (ed, seq) { - seq->tmp= NULL; + seq->tmp = NULL; } SEQ_END; @@ -1150,8 +1150,8 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); - Sequence *seq, *actseq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, 0); + Sequence *seq, *actseq = BKE_sequencer_active_get(scene); int type = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index e421ace75a0..4168cb9ac77 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -186,7 +186,7 @@ static void sequencer_free(SpaceLink *UNUSED(sl)) { // SpaceSeq *sseq= (SpaceSequencer*) sl; -// XXX if (sseq->gpd) free_gpencil_data(sseq->gpd); +// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index a07493ef8fc..04408173928 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -167,7 +167,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr, idptr; PropertyRNA *prop; - text = add_empty_text("Text"); + text = BKE_text_add("Text"); /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -236,7 +236,7 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); - text = add_text(str, G.main->name); + text = BKE_text_load(str, G.main->name); if (!text) { if (op->customdata) MEM_freeN(op->customdata); @@ -320,7 +320,7 @@ static int text_reload_exec(bContext *C, wmOperator *op) { Text *text = CTX_data_edit_text(C); - if (!reopen_text(text)) { + if (!BKE_text_reload(text)) { BKE_report(op->reports, RPT_ERROR, "Could not reopen file"); return OPERATOR_CANCELLED; } @@ -379,8 +379,8 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op)) } } - unlink_text(bmain, text); - free_libblock(&bmain->text, text); + BKE_text_unlink(bmain, text); + BKE_libblock_free(&bmain->text, text); text_drawcache_tag_update(st, 1); WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL); @@ -1156,7 +1156,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) } else { new_line[j] = text_check_line[a]; - ++j; + j++; } } new_line[j] = '\0'; @@ -1208,12 +1208,12 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) if (!number) { //found all number of space to equal a tab new_line[extra] = '\t'; a = a + (st->tabnumber - 1); - ++extra; + extra++; } else { //not adding a tab new_line[extra] = text_check_line[a]; - ++extra; + extra++; } } new_line[extra] = '\0'; @@ -1361,7 +1361,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot) /* identifiers */ ot->name = "Move Lines"; ot->idname = "TEXT_OT_move_lines"; - ot->description = "Moves the currently selected line(s) up/down"; + ot->description = "Move the currently selected line(s) up/down"; /* api callbacks */ ot->exec = move_lines_exec; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 43a4a9a1de9..9e44d5207c0 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -73,15 +73,15 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - if (PSFRA < PEFRA) { - glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); - glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } - else { - glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } + if (PSFRA < PEFRA) { + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); + glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } + else { + glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } glDisable(GL_BLEND); UI_ThemeColorShade(TH_BACK, -60); @@ -90,14 +90,14 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); } -#define CACHE_DRAW_HEIGHT 3.0f +#define CACHE_DRAW_HEIGHT 3.0f static void time_draw_cache(SpaceTime *stime, Object *ob) { PTCacheID *pid; ListBase pidlist; SpaceTimeCache *stc = stime->caches.first; - float yoffs=0.f; + float yoffs = 0.f; if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; @@ -106,27 +106,27 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ - for (pid=pidlist.first; pid; pid=pid->next) { + for (pid = pidlist.first; pid; pid = pid->next) { float col[4], *fp; int i, sta = pid->cache->startframe, end = pid->cache->endframe; - int len = (end - sta + 1)*4; + int len = (end - sta + 1) * 4; switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; break; case PTCACHE_TYPE_PARTICLES: - if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; + if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; break; case PTCACHE_TYPE_CLOTH: - if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; + if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; + if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; break; case PTCACHE_TYPE_DYNAMICPAINT: - if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; + if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; break; } @@ -134,7 +134,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) continue; /* make sure we have stc with correct array length */ - if (stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) { + if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) { if (stc) { MEM_freeN(stc->array); } @@ -143,59 +143,59 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) BLI_addtail(&stime->caches, stc); } - stc->array = MEM_callocN(len*2*sizeof(float), "SpaceTimeCache array"); + stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array"); } /* fill the vertex array with a quad for each cached frame */ - for (i=sta, fp=stc->array; i<=end; i++) { - if (pid->cache->cached_frames[i-sta]) { - fp[0] = (float)i-0.5f; + for (i = sta, fp = stc->array; i <= end; i++) { + if (pid->cache->cached_frames[i - sta]) { + fp[0] = (float)i - 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; - fp[0] = (float)i-0.5f; + fp[0] = (float)i - 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; } } glPushMatrix(); - glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0); + glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0); switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: - col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_PARTICLES: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_CLOTH: - col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; + col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; + col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; col[3] = 0.1; break; case PTCACHE_TYPE_DYNAMICPAINT: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; default: BLI_assert(0); - col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; + col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; col[3] = 0.1; } glColor4fv(col); @@ -206,13 +206,13 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { - col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; + col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; } glColor4fv(col); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, stc->array); - glDrawArrays(GL_QUADS, 0, (fp-stc->array)/2); + glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); @@ -240,7 +240,7 @@ static void time_cache_free(SpaceTime *stime) { SpaceTimeCache *stc; - for (stc= stime->caches.first; stc; stc=stc->next) { + for (stc = stime->caches.first; stc; stc = stc->next) { if (stc->array) { MEM_freeN(stc->array); stc->array = NULL; @@ -257,9 +257,9 @@ static void time_cache_refresh(SpaceTime *stime) } /* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */ -static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) +static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe) { - ActKeyColumn *akn= NULL; + ActKeyColumn *akn = NULL; /* sanity checks */ if (ak == NULL) @@ -267,9 +267,9 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* check if this is a match, or whether it is in some subtree */ if (cframe < ak->cfra) - akn= time_cfra_find_ak(ak->left, cframe); + akn = time_cfra_find_ak(ak->left, cframe); else if (cframe > ak->cfra) - akn= time_cfra_find_ak(ak->right, cframe); + akn = time_cfra_find_ak(ak->right, cframe); /* if no match found (or found match), just use the current one */ if (akn == NULL) @@ -281,7 +281,7 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* helper for time_draw_keyframes() */ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) { - bDopeSheet ads= {NULL}; + bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; @@ -311,13 +311,13 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) * - draw within a single GL block to be faster */ glBegin(GL_LINES); - for ( ak=time_cfra_find_ak(keys.root, v2d->cur.xmin); - (ak) && (ak->cfra <= v2d->cur.xmax); - ak=ak->next ) - { - glVertex2f(ak->cfra, v2d->tot.ymin); - glVertex2f(ak->cfra, v2d->tot.ymax); - } + for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin); + (ak) && (ak->cfra <= v2d->cur.xmax); + ak = ak->next) + { + glVertex2f(ak->cfra, v2d->tot.ymin); + glVertex2f(ak->cfra, v2d->tot.ymax); + } glEnd(); // GL_LINES /* free temp stuff */ @@ -327,25 +327,25 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) /* draw keyframe lines for timeline */ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - View2D *v2d= &ar->v2d; - short onlysel= (stime->flag & TIME_ONLYACTSEL); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + View2D *v2d = &ar->v2d; + short onlysel = (stime->flag & TIME_ONLYACTSEL); /* draw scene keyframes first * - don't try to do this when only drawing active/selected data keyframes, * since this can become quite slow */ - if (scene && onlysel==0) { + if (scene && onlysel == 0) { /* set draw color */ glColor3ub(0xDD, 0xA7, 0x00); time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel); } /* draw keyframes from selected objects - * - only do the active object if in posemode (i.e. showing only keyframes for the bones) - * OR the onlysel flag was set, which means that only active object's keyframes should - * be considered + * - only do the active object if in posemode (i.e. showing only keyframes for the bones) + * OR the onlysel flag was set, which means that only active object's keyframes should + * be considered */ glColor3ub(0xDD, 0xD7, 0x00); @@ -357,14 +357,14 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar short active_done = 0; /* draw keyframes from all selected objects */ - CTX_DATA_BEGIN (C, Object*, obsel, selected_objects) + CTX_DATA_BEGIN (C, Object *, obsel, selected_objects) { /* last arg is 0, since onlysel doesn't apply here... */ time_draw_idblock_keyframes(v2d, (ID *)obsel, 0); /* if this object is the active one, set flag so that we don't draw again */ if (obsel == ob) - active_done= 1; + active_done = 1; } CTX_DATA_END; @@ -379,7 +379,7 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) { /* find the main timeline region and refresh cache display*/ - ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_refresh(stime); @@ -410,19 +410,19 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case ND_FRAME_RANGE: - { - ARegion *ar; - Scene *scene = wmn->reference; - - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - ar->v2d.tot.xmin = (float)(SFRA - 4); - ar->v2d.tot.xmax = (float)(EFRA + 4); - break; - } + { + ARegion *ar; + Scene *scene = wmn->reference; + + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.tot.xmin = (float)(SFRA - 4); + ar->v2d.tot.xmax = (float)(EFRA + 4); + break; } } - break; + } + break; } case NC_SPACE: switch (wmn->data) { @@ -456,13 +456,13 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) static void time_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - Scene *scene= CTX_data_scene(C); - SpaceTime *stime= CTX_wm_space_time(C); + Scene *scene = CTX_data_scene(C); + SpaceTime *stime = CTX_wm_space_time(C); Object *obact = CTX_data_active_object(C); - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - int unit, flag=0; + int unit, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -471,9 +471,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS; - grid= UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); - UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS)); + unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; + grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); UI_view2d_grid_free(grid); /* start and end frame */ @@ -481,8 +481,8 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) /* current frame */ flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */ - if ((stime->flag & TIME_DRAWFRAMES)==0) flag |= DRAWCFRA_UNIT_SECONDS; - if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; + if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; + if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); UI_view2d_view_ortho(v2d); @@ -501,7 +501,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -528,7 +528,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } } } @@ -551,7 +551,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data==ND_ANIMPLAY) + if (wmn->data == ND_ANIMPLAY) ED_region_tag_redraw(ar); break; @@ -563,7 +563,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } case NC_SPACE: @@ -577,57 +577,57 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) static SpaceLink *time_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceTime *stime; - stime= MEM_callocN(sizeof(SpaceTime), "inittime"); + stime = MEM_callocN(sizeof(SpaceTime), "inittime"); - stime->spacetype= SPACE_TIME; + stime->spacetype = SPACE_TIME; stime->flag |= TIME_DRAWFRAMES; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for time"); + ar = MEM_callocN(sizeof(ARegion), "header for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for time"); + ar = MEM_callocN(sizeof(ARegion), "main area for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = (float)(SFRA - 4); ar->v2d.tot.ymin = 0.0f; ar->v2d.tot.xmax = (float)(EFRA + 4); ar->v2d.tot.ymax = 50.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 50.0f; + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 50.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= 50.0; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 50.0; - ar->v2d.minzoom= 0.1f; - ar->v2d.maxzoom= 10.0; + ar->v2d.minzoom = 0.1f; + ar->v2d.maxzoom = 10.0; - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - return (SpaceLink*)stime; + return (SpaceLink *)stime; } /* not spacelink itself */ static void time_free(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; + SpaceTime *stime = (SpaceTime *)sl; time_cache_free(stime); } @@ -636,20 +636,20 @@ static void time_free(SpaceLink *sl) /* validate spacedata, add own area level handlers */ static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceTime *stime= (SpaceTime *)sa->spacedata.first; + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_free(stime); /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; - stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); - stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT); + stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT); } static SpaceLink *time_duplicate(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; - SpaceTime *stimen= MEM_dupallocN(stime); + SpaceTime *stime = (SpaceTime *)sl; + SpaceTime *stimen = MEM_dupallocN(stime); stimen->caches.first = stimen->caches.last = NULL; @@ -660,41 +660,41 @@ static SpaceLink *time_duplicate(SpaceLink *sl) /* it defines all callbacks to maintain spaces */ void ED_spacetype_time(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_TIME; + st->spaceid = SPACE_TIME; strncpy(st->name, "Timeline", BKE_ST_MAXNAME); - st->new= time_new; - st->free= time_free; - st->init= time_init; - st->duplicate= time_duplicate; - st->operatortypes= time_operatortypes; - st->keymap= NULL; - st->listener= time_listener; - st->refresh= time_refresh; + st->new = time_new; + st->free = time_free; + st->init = time_init; + st->duplicate = time_duplicate; + st->operatortypes = time_operatortypes; + st->keymap = NULL; + st->listener = time_listener; + st->refresh = time_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; - art->init= time_main_area_init; - art->draw= time_main_area_draw; - art->listener= time_main_area_listener; - art->keymap= time_keymap; + art->init = time_main_area_init; + art->draw = time_main_area_draw; + art->listener = time_main_area_listener; + art->keymap = time_keymap; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= time_header_area_init; - art->draw= time_header_area_draw; - art->listener= time_header_area_listener; + art->init = time_header_area_init; + art->draw = time_header_area_draw; + art->listener = time_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 1c1f7a69865..189c8bfc7d0 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -47,35 +47,35 @@ #include "time_intern.h" /* ****************** Start/End Frame Operators *******************************/ -static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'start' frame for that */ if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; if (PEFRA < frame) { if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_start_frame_set (wmOperatorType *ot) +static void TIME_OT_start_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Start Frame"; @@ -87,39 +87,39 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'end' frame for that */ if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; if (PSFRA > frame) { if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_end_frame_set (wmOperatorType *ot) +static void TIME_OT_end_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set End Frame"; @@ -131,16 +131,16 @@ static void TIME_OT_end_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************ View All Operator *******************************/ -static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= (ar) ? &ar->v2d : NULL; + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = (ar) ? &ar->v2d : NULL; float extra; if (ELEM(NULL, scene, ar)) @@ -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 * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -161,7 +161,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static void TIME_OT_view_all (wmOperatorType *ot) +static void TIME_OT_view_all(wmOperatorType *ot) { /* identifiers */ ot->name = "View All"; @@ -173,7 +173,7 @@ static void TIME_OT_view_all (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** registration **********************************/ diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index ca5b21012aa..f8d942b4fd1 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -88,38 +88,50 @@ void draw_motion_path_instance(Scene *scene, //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; - int sfra, efra, len; - + int sfra, efra, sind, len; /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - int sind; - /* With "Around Current", we only choose frames from around - * the current frame to draw. However, this range is still - * restricted by the limits of the original path. + * the current frame to draw. */ sfra = CFRA - avs->path_bc; efra = CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra = mpath->start_frame; - if (efra > mpath->end_frame) efra = mpath->end_frame; - - len = efra - sfra; - - sind = sfra - mpath->start_frame; - mpv_start = (mpath->points + sind); } else { + /* Use the current display range */ + sfra = avs->path_sf; + efra = avs->path_ef; + } + + /* no matter what, we can only show what is in the cache and no more + * - abort if whole range is past ends of path + * - otherwise clamp endpoints to extents of path + */ + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { + /* whole path is out of bounds */ + return; + } + + if (sfra < mpath->start_frame) { + /* start clamp */ sfra = mpath->start_frame; - efra = sfra + mpath->length; - len = mpath->length; - mpv_start = mpath->points; } - + if (efra > mpath->end_frame) { + /* end clamp */ + efra = mpath->end_frame; + } + + len = efra - sfra; + if (len <= 0) { return; } - + + /* get pointers to parts of path */ + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); + /* draw curve-line of path */ glShadeModel(GL_SMOOTH); @@ -258,7 +270,7 @@ void draw_motion_path_instance(Scene *scene, * unless an option is set to always use the whole action */ if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { - bActionGroup *agrp = action_groups_find_named(adt->action, pchan->name); + bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name); if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 15e6994dfe4..2211b1ddb62 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2338,9 +2338,9 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2352,20 +2352,20 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; ob->ipoflag = ipoflago; } @@ -2415,9 +2415,9 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2431,7 +2431,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); @@ -2439,13 +2439,13 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } @@ -2481,9 +2481,9 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2501,7 +2501,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2516,7 +2516,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2525,13 +2525,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 530b26d566a..b5c44fd1a8c 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -926,14 +926,14 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index) return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, const int draw_flags) { - if ((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); return; } @@ -1002,51 +1002,79 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* Vertex Paint and Weight Paint */ -void draw_mesh_paint(RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; + const short do_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (draw_flags & DRAW_FACE_SELECT) facemask = wpaint__setSolidDrawOptions_facemask; if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { - /* enforce default material settings */ - GPU_enable_material(0, NULL); + + if (do_light) { + /* enforce default material settings */ + GPU_enable_material(0, NULL); - /* but set default spec */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); + /* but set default spec */ + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glColor3ub(120, 120, 120); + glDisable(GL_COLOR_MATERIAL); - /* diffuse */ - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); + /* diffuse */ + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + } dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); + if (do_light) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_disable_material(); + } } else if (ob->mode & OB_MODE_VERTEX_PAINT) { - if (me->mloopcol) + if (me->mloopcol) { dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + } else { glColor3f(1.0f, 1.0f, 1.0f); dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_ALWAYS_SMOOTH); } } /* draw face selection on top */ - if (draw_flags & DRAW_FACE_SELECT) + if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); + } + else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { + + /* weight paint in solid mode, special case. focus on making the weights clear + * rather than the shading, this is also forced in wire view */ + + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); // disable write in zbuffer, selected edge wires show better + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 96); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0xAAAA); + + dm->drawEdges(dm, 1, 1); + + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); + } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index e9b7ef2c6ef..29e6b77e0d4 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -190,7 +190,7 @@ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) return TRUE; /* textured solid */ - if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !scene_use_new_shading_nodes(scene)) + if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !BKE_scene_use_new_shading_nodes(scene)) return TRUE; return FALSE; @@ -332,7 +332,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) return 0; return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); @@ -1740,7 +1740,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base int i; float drawsize; const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); - MovieClip *clip = object_get_movieclip(scene, base->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { @@ -1763,7 +1763,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base scale[2] = 1.0f / len_v3(ob->obmat[2]); BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, - asp, shift, &drawsize, vec); + asp, shift, &drawsize, vec); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); @@ -1924,7 +1924,7 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo Object *obedit = vc->obedit; Lattice *lt = obedit->data; BPoint *bp = lt->editlatt->latt->def; - DispList *dl = find_displist(&obedit->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; @@ -1971,8 +1971,8 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) /* now we default make displist, this will modifiers work for non animated case */ if (ob->disp.first == NULL) - lattice_calc_modifiers(scene, ob); - dl = find_displist(&ob->disp, DL_VERTS); + BKE_lattice_modifiers_calc(scene, ob); + dl = BKE_displist_find(&ob->disp, DL_VERTS); if (is_edit) { lt = lt->editlatt->latt; @@ -2209,9 +2209,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}; @@ -2921,7 +2921,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_v3_fl(vmid, 1.0f / (float)n); \ if (unit->system) \ bUnit_AsString(numstr, sizeof(numstr), \ - (double)(area * unit->scale_length), \ + (double)(area * unit->scale_length), \ 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ else \ BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ @@ -2971,35 +2971,45 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); - for (efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - efa; efa = BM_iter_step(&iter)) - { - BMIter liter; - BMLoop *loop; + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + const int is_face_sel = BM_elem_flag_test(efa, BM_ELEM_SELECT); - BM_face_calc_center_bounds(efa, vmid); + if (is_face_sel || do_moving) { + BMIter liter; + BMLoop *loop; + int cent_ok = FALSE; - for (loop = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa); - loop; loop = BM_iter_step(&liter)) - { - float v1[3], v2[3], v3[3]; + BM_ITER_ELEM(loop, &liter, efa, BM_LOOPS_OF_FACE) { + if (is_face_sel || (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) { + /* yes, we should avoid triple matrix multiply every vertex for 'global' */ + float angle; - copy_v3_v3(v1, loop->prev->v->co); - copy_v3_v3(v2, loop->v->co); - copy_v3_v3(v3, loop->next->v->co); + /* lazy init center calc */ + if (cent_ok == FALSE) { + BM_face_calc_center_bounds(efa, vmid); + cent_ok = TRUE; + } - if (do_global) { - mul_mat3_m4_v3(ob->obmat, v1); - mul_mat3_m4_v3(ob->obmat, v2); - mul_mat3_m4_v3(ob->obmat, v3); - } + if (do_global) { + copy_v3_v3(v1, loop->prev->v->co); + copy_v3_v3(v2, loop->v->co); + copy_v3_v3(v3, loop->next->v->co); - if ( (BM_elem_flag_test(efa, BM_ELEM_SELECT)) || - (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) - { - BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); - interp_v3_v3v3(fvec, vmid, v2, 0.8f); - view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + mul_mat3_m4_v3(ob->obmat, v3); + + angle = angle_v3v3v3(v1, v2, v3); + interp_v3_v3v3(fvec, vmid, v2, 0.8f); + } + else { + angle = angle_v3v3v3(loop->prev->v->co, loop->v->co, loop->v->co); + interp_v3_v3v3(fvec, vmid, loop->v->co, 0.8f); + } + + BLI_snprintf(numstr, sizeof(numstr), "%.3f", RAD2DEGF(angle)); + view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + } } } } @@ -3387,34 +3397,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_SOLID) { - if (is_obact && ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - /* weight paint in solid mode, special case. focus on making the weights clear - * rather than the shading, this is also forced in wire view */ - GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, me->mpoly, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - - glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 96); - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0xAAAA); - - dm->drawEdges(dm, 1, 1); - - bglPolygonOffset(rv3d->dist, 0.0); - glDepthMask(1); - glDisable(GL_LINE_STIPPLE); - glDisable(GL_BLEND); - - GPU_disable_material(); - - /* since we already draw wire as wp guide, don't draw over the top */ - draw_wire = OBDRAW_WIRE_OFF; - } - else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { + if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); @@ -3505,7 +3488,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_PAINT) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + + /* since we already draw wire as wp guide, don't draw over the top */ + draw_wire = OBDRAW_WIRE_OFF; } /* set default draw color back for wire or for draw-extra later on */ @@ -3629,8 +3615,8 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D finalDM->release(finalDM); } else { - /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ - if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb) ? ob->bb : me->bb)) { + /* ob->bb was set by derived mesh system, do NULL check just to be sure */ + if (me->totpoly <= 4 || (ob->bb && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) { glsl = draw_glsl_material(scene, ob, v3d, dt); check_alpha = check_alpha_pass(base); @@ -3947,10 +3933,10 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); index3_nors_incr = 0; - if (displist_has_faces(lb) == 0) { + if (BKE_displist_has_faces(lb) == 0) { if (!render_only) { draw_index_wire = 0; drawDispListwire(lb); @@ -3978,7 +3964,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas index3_nors_incr = 1; } else { - if (!render_only || (render_only && displist_has_faces(lb))) { + if (!render_only || (render_only && BKE_displist_has_faces(lb))) { draw_index_wire = 0; retval = drawDispListwire(lb); draw_index_wire = 1; @@ -3993,7 +3979,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); @@ -4012,9 +3998,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas break; case OB_MBALL: - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { lb = &ob->disp; - if (lb->first == NULL) makeDispListMBall(scene, ob); + if (lb->first == NULL) BKE_displist_make_mball(scene, ob); if (lb->first == NULL) return 1; if (solid) { @@ -4315,7 +4301,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv totpart = psys->totpart; - cfra = BKE_curframe(scene); + cfra = BKE_scene_frame_get(scene); if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL) draw_as = PART_DRAW_DOT; @@ -5530,7 +5516,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } - ++index; + index++; nu = nu->next; } } @@ -5559,7 +5545,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, tekenhandlesN_active(nu); tekenhandlesN(nu, 0, hide_handles); } - ++index; + index++; } draw_editnurb(ob, nurb, 0); draw_editnurb(ob, nurb, 1); @@ -6122,7 +6108,7 @@ static void draw_box(float vec[8][3]) #if 0 static void get_local_bounds(Object *ob, float center[3], float size[3]) { - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb == NULL) { zero_v3(center); @@ -6183,22 +6169,22 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) BoundBox *bb = NULL; if (ob->type == OB_MESH) { - bb = mesh_get_bb(ob); + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); bb = ob->bb; } } } else if (ob->type == OB_ARMATURE) { - bb = BKE_armature_get_bb(ob); + bb = BKE_armature_boundbox_get(ob); } else { drawcube(); @@ -6217,7 +6203,7 @@ static void drawtexspace(Object *ob) float vec[8][3], loc[3], size[3]; if (ob->type == OB_MESH) { - mesh_get_texspace(ob->data, loc, NULL, size); + BKE_mesh_texspace_get(ob->data, loc, NULL, size); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { Curve *cu = ob->data; @@ -6265,7 +6251,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) hasfaces = dm->getNumTessFaces(dm); } else { - hasfaces = displist_has_faces(&ob->disp); + hasfaces = BKE_displist_has_faces(&ob->disp); } if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -6280,7 +6266,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { if ((base->flag & OB_FROMDUPLI) == 0) drawDispListwire(&ob->disp); } @@ -6340,7 +6326,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } } @@ -6465,7 +6451,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) view3d_cached_text_draw_begin(); /* patch? children objects with a timeoffs change the parents. How to solve! */ - /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */ /* draw motion paths (in view space) */ if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -6575,8 +6561,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) zbufoff = 1; dt = OB_SOLID; } - else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) + + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { dt = OB_PAINT; + } glEnable(GL_DEPTH_TEST); } @@ -6604,7 +6592,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ @@ -6677,7 +6665,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) setlinestyle(0); - if (BKE_font_getselection(ob, &selstart, &selend) && cu->selboxes) { + if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { float selboxw; cpack(0xffffff); @@ -7171,7 +7159,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (ct = targets.first; ct; ct = ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) - cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); + cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene)); else unit_m4(ct->matrix); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 72b67c2a716..28fd2c8bc74 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier. + // removed since BKE_image_user_frame_calc is now called in draw_bgpic because screen_ops doesnt call the notifier. #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1025,7 +1025,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) for (; bgpic; bgpic = bgpic->next) { if (bgpic->ima) { Scene *scene = wmn->reference; - BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, scene->r.cfra, 0); } } } @@ -1071,7 +1071,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { - if (0 == object_is_libdata(base->object)) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 13129616843..4a135f91d91 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -83,8 +83,8 @@ /* ******************* view3d space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_NOP 1 +#define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 /* temporary struct for storing transform properties */ @@ -595,7 +595,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { bp->weight = scale_w > 0.0f ? bp->weight * scale_w : - 1.0f + ((1.0f - bp->weight) * scale_w); + 1.0f + ((1.0f - bp->weight) * scale_w); CLAMP(bp->weight, 0.0f, 1.0f); } } @@ -939,7 +939,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) PointerRNA pchanptr; uiLayout *col; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (!pchan) { uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f48b45f9793..682d8950440 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -102,7 +102,7 @@ static void star_stuff_init_func(void) glPointSize(1.0); glBegin(GL_POINTS); } -static void star_stuff_vertex_func(float*i) +static void star_stuff_vertex_func(float *i) { glVertex3fv(i); } @@ -716,7 +716,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glColor4fv(color); glBegin(GL_LINE_LOOP); for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) { - float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f}; + float p[3] = {s *cosf(angle), s * sinf(angle), 0.0f}; if (!upright) { mul_qt_v3(q, p); @@ -847,7 +847,7 @@ static void draw_selected_name(Scene *scene, Object *ob) short offset = 30; /* get name of marker on current frame (if available) */ - markern = scene_find_marker_name(scene, CFRA); + markern = BKE_scene_find_marker_name(scene, CFRA); /* check if there is an object */ if (ob) { @@ -910,7 +910,7 @@ static void draw_selected_name(Scene *scene, Object *ob) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_scene_frame_get(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -1544,7 +1544,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) ima = bgpic->ima; if (ima == NULL) continue; - BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0); + BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); } else { @@ -1552,7 +1552,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) - clip = object_get_movieclip(scene, scene->camera, 1); + clip = BKE_object_movieclip_get(scene, scene->camera, 1); } else clip = bgpic->clip; @@ -1699,7 +1699,7 @@ static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground) } } else { - draw_bgpic(scene, ar, v3d, foreground); + draw_bgpic(scene, ar, v3d, foreground); } } @@ -1861,12 +1861,12 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas * offset feature (used in group-duplicate.blend but no longer works in 2.5) * so for now it should be ok to - campbell */ - if (/* if this is the last no need to make a displist */ + if ( /* if this is the last no need to make a displist */ (dob_next == NULL || dob_next->ob != dob->ob) || /* lamp drawing messes with matrices, could be handled smarter... but this works */ (dob->ob->type == OB_LAMP) || (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp = object_get_boundbox(dob->ob))) + !(bb_tmp = BKE_object_boundbox_get(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2); use_displist = 0; @@ -1876,7 +1876,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas bb = *bb_tmp; /* must make a copy */ /* disable boundbox check for list creation */ - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ unit_m4(dob->ob->obmat); /* obmat gets restored */ @@ -1886,7 +1886,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas glEndList(); use_displist = 1; - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } if (use_displist) { @@ -2043,7 +2043,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) RegionView3D *rv3d = ar->regiondata; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2078,7 +2078,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) U.obcenter_dia = 0; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2297,7 +2297,7 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { if (v3d->drawtype == OB_MATERIAL) mask |= CD_MASK_ORCO; } @@ -2367,7 +2367,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (viewmat) copy_m4_m4(rv3d->viewmat, viewmat); else - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ /* update utilitity matrices */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2556,7 +2556,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* transp and X-ray afterdraw stuff */ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); if (rv3d->rflag & RV3D_CLIPPING) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ea4d28ce32f..60a0d3bf12b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -56,6 +56,8 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_action.h" +#include "BKE_armature.h" #include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ @@ -68,6 +70,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "ED_armature.h" #include "ED_particle.h" #include "ED_screen.h" #include "ED_transform.h" @@ -121,9 +124,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); - object_tfm_protected_backup(root_parent, &obtfm); - object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); - object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); + BKE_object_tfm_protected_backup(root_parent, &obtfm); + BKE_object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + BKE_object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); ob_update = v3d->camera; while (ob_update) { @@ -133,9 +136,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) } } else { - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); @@ -983,12 +986,12 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) /* NDOF utility functions * (should these functions live in this file?) */ -float ndof_to_axis_angle(struct wmNDOFMotionData*ndof, float axis[3]) +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]) { return ndof->dt * normalize_v3_v3(axis, ndof->rvec); } -void ndof_to_quat(struct wmNDOFMotionData*ndof, float q[4]) +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]) { float axis[3]; float angle; @@ -1007,8 +1010,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1159,8 +1162,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -2068,7 +2071,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); } } if (!onedone) { @@ -2214,8 +2217,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (minmax_object_duplis(scene, base->object, min, max) == 0) - minmax_object(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) + BKE_object_minmax(base->object, min, max); /* use if duplis not found */ ok = 1; } @@ -2236,7 +2239,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) size = v3d->near * 1.5f; } } - else /* ortho */ { + else { /* ortho */ if (size < 0.0001f) { /* bounding box was a single point so do not zoom */ ok_dist = 0; @@ -2291,6 +2294,89 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot) ot->flag = 0; } +static int view_lock_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if (v3d) { + ED_view3D_lock_clear(v3d); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_clear(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock Clear"; + ot->description = "Clear all view locking"; + ot->idname = "VIEW3D_OT_view_lock_clear"; + + /* api callbacks */ + ot->exec = view_lock_clear_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + +static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + Object *obact = CTX_data_active_object(C); + + if (v3d) { + + ED_view3D_lock_clear(v3d); + + v3d->ob_centre = obact; /* can be NULL */ + + if (obact && obact->type == OB_ARMATURE) { + if (obact->mode & OB_MODE_POSE) { + bPoseChannel *pcham_act = BKE_pose_channel_active(obact); + if (pcham_act) { + BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); + } + } + else { + EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; + if (ebone_act) { + BLI_strncpy(v3d->ob_centre_bone, ebone_act->name, sizeof(v3d->ob_centre_bone)); + } + } + } + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock to Active"; + ot->description = "Lock the view to the active object/bone"; + ot->idname = "VIEW3D_OT_view_lock_to_active"; + + /* api callbacks */ + ot->exec = view_lock_to_active_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -2851,7 +2937,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) v3d->camera = ob; if (v3d->camera == NULL) - v3d->camera = scene_find_camera(scene); + v3d->camera = BKE_scene_camera_find(scene); /* couldnt find any useful camera, bail out */ if (v3d->camera == NULL) @@ -3094,11 +3180,11 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } bgpic = background_image_add(C); @@ -3671,7 +3757,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - object_apply_mat4(ob, mat, TRUE, TRUE); + BKE_object_apply_mat4(ob, mat, TRUE, TRUE); } BGpic *ED_view3D_background_image_new(View3D *v3d) @@ -3709,3 +3795,11 @@ void ED_view3D_background_image_clear(View3D *v3d) bgpic = next_bgpic; } } + +void ED_view3D_lock_clear(View3D *v3d) +{ + v3d->ob_centre = NULL; + v3d->ob_centre_bone[0] = '\0'; + v3d->ob_centre_cursor = FALSE; + v3d->flag2 &= ~V3D_LOCK_CAMERA; +} diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5b6624889c8..2dab26e7781 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -174,7 +174,7 @@ typedef struct FlyInfo { unsigned char use_freelook; int mval[2]; /* latest 2D mouse values */ - wmNDOFMotionData*ndof; /* latest 3D mouse values */ + wmNDOFMotionData *ndof; /* latest 3D mouse values */ /* fly state state */ float speed; /* the speed the view is moving per redraw */ @@ -366,9 +366,9 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event /* store the original camera loc and rot */ /* TODO. axis angle etc */ - fly->obtfm = object_tfm_backup(ob_back); + fly->obtfm = BKE_object_tfm_backup(ob_back); - where_is_object(fly->scene, fly->v3d->camera); + BKE_object_where_is_calc(fly->scene, fly->v3d->camera); negate_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]); fly->rv3d->dist = 0.0; @@ -429,7 +429,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) ob_back = (fly->root_parent) ? fly->root_parent : fly->v3d->camera; /* store the original camera loc and rot */ - object_tfm_restore(ob_back, fly->obtfm); + BKE_object_tfm_restore(ob_back, fly->obtfm); DAG_id_tag_update(&ob_back->id, OB_RECALC_OB); } @@ -690,7 +690,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien { /* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */ - View3D*v3d = fly->v3d; + View3D *v3d = fly->v3d; Scene *scene = fly->scene; ID *id_key; @@ -709,9 +709,9 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mult_m4_m4m4(diff_mat, view_mat, prev_view_imat); mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat); - object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); - // where_is_object(scene, fly->root_parent); + // BKE_object_where_is_calc(scene, fly->root_parent); ob_update = v3d->camera->parent; while (ob_update) { @@ -724,7 +724,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien else { float view_mat[4][4]; ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); + BKE_object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); id_key = &v3d->camera->id; } @@ -1031,7 +1031,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) /* shorthand for oft-used variables */ wmNDOFMotionData *ndof = fly->ndof; const float dt = ndof->dt; - RegionView3D*rv3d = fly->rv3d; + RegionView3D *rv3d = fly->rv3d; const int flag = U.ndof_flag; #if 0 diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index c4309980b18..a68caeb0719 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -431,9 +431,10 @@ static int object_mode_icon(int mode) EnumPropertyItem *item = object_mode_items; while (item->name != NULL) { - if (item->value == mode) + if (item->value == mode) { return item->icon; - ++item; + } + item++; } return ICON_OBJECT_DATAMODE; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 66b8ceb7a85..f387e1dd844 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -53,9 +53,9 @@ struct wmWindowManager; #define BL_NEAR_CLIP 0.001 /* drawing flags: */ -#define DRAW_PICKING 1 -#define DRAW_CONSTCOLOR 2 -#define DRAW_SCENESET 4 +#define DRAW_PICKING 1 +#define DRAW_CONSTCOLOR 2 +#define DRAW_SCENESET 4 /* draw_mesh_fancy/draw_mesh_textured draw_flags */ #define DRAW_MODIFIERS_PREVIEW 1 @@ -78,6 +78,8 @@ void VIEW3D_OT_ndof_pan(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); +void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); @@ -93,8 +95,8 @@ void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); -void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]); -float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3]); +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]); +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]); /* view3d_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); @@ -103,8 +105,8 @@ void VIEW3D_OT_fly(struct wmOperatorType *ot); /* drawanim.c */ void draw_motion_paths_init(View3D *v3d, struct ARegion *ar); void draw_motion_path_instance(Scene *scene, - struct Object *ob, struct bPoseChannel *pchan, - struct bAnimVizSettings *avs, struct bMotionPath *mpath); + struct Object *ob, struct bPoseChannel *pchan, + struct bAnimVizSettings *avs, struct bMotionPath *mpath); void draw_motion_paths_cleanup(View3D *v3d); @@ -118,23 +120,25 @@ void drawaxes(float size, char drawtype); void view3d_cached_text_draw_begin(void); void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]); -void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]); -#define V3D_CACHE_TEXT_ZBUF (1<<0) -#define V3D_CACHE_TEXT_WORLDSPACE (1<<1) -#define V3D_CACHE_TEXT_ASCII (1<<2) -#define V3D_CACHE_TEXT_GLOBALSPACE (1<<3) -#define V3D_CACHE_TEXT_LOCALCLIP (1<<4) +void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, float mat[][4]); +#define V3D_CACHE_TEXT_ZBUF (1 << 0) +#define V3D_CACHE_TEXT_WORLDSPACE (1 << 1) +#define V3D_CACHE_TEXT_ASCII (1 << 2) +#define V3D_CACHE_TEXT_GLOBALSPACE (1 << 3) +#define V3D_CACHE_TEXT_LOCALCLIP (1 << 4) /* drawarmature.c */ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline); /* drawmesh.c */ -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); -void draw_mesh_paint(RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); /* view3d_draw.c */ void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar); -void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (* func)(void *)); +void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (*func)(void *)); void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); void add_view3d_after(ListBase *lb, Base *base, int flag); @@ -158,12 +162,12 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot); void VIEW3D_OT_game_start(struct wmOperatorType *ot); -int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); +int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundBox *bb); void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); void fly_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 99da487f923..f760254e8d2 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -72,6 +72,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_background_image_add); WM_operatortype_append(VIEW3D_OT_background_image_remove); WM_operatortype_append(VIEW3D_OT_view_selected); + WM_operatortype_append(VIEW3D_OT_view_lock_clear); + WM_operatortype_append(VIEW3D_OT_view_lock_to_active); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_view_center_camera); WM_operatortype_append(VIEW3D_OT_select); @@ -135,7 +137,10 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); - + + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f106fcc268e..d7b03447d5b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1407,7 +1407,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* index of bundle is 1<<16-based. if there's no "bone" index * in hight word, this buffer value belongs to camera,. not to bundle */ if (buffer[4 * i + 3] & 0xFFFF0000) { - MovieClip *clip = object_get_movieclip(scene, basact->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, 0); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; @@ -2055,7 +2055,7 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un /* gets called via generic mouse select operator */ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, Object *obact) { - Mesh*me = obact->data; /* already checked for NULL */ + Mesh *me = obact->data; /* already checked for NULL */ unsigned int index = 0; MVert *mv; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 87edf6a37a0..367b36db583 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -582,7 +582,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(ob->imat, vec); /* Get location of grid point in pose space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* adjust location */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -613,7 +613,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + gridf *floorf(0.5f + ob->obmat[3][2] / gridf); if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -707,7 +707,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if (pchan->bone->layer & arm->layer) { if ((pchan->bone->flag & BONE_CONNECTED) == 0) { /* Get position in pchan (pose) space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* copy new position */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -738,7 +738,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + curs[2]; if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -818,7 +818,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieClip *clip = object_get_movieclip(scene, ob, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, ob, 0); MovieTracking *tracking; MovieTrackingObject *object; int ok = 0; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 733c5c55bfc..95ae0ac971f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -358,11 +358,11 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp = rv3d->persp; } - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -421,9 +421,9 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o copy_v3_v3(obmat_new[3], r_co); /* only touch location */ - object_tfm_protected_backup(camera_ob, &obtfm); - object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); - object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); + BKE_object_tfm_protected_backup(camera_ob, &obtfm); + BKE_object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); /* notifiers */ DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); @@ -567,9 +567,9 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co if (flip_sign) negate_v3(planes[val]); - planes[val][3] = -planes[val][0] * bb->vec[val][0] - - planes[val][1] * bb->vec[val][1] - - planes[val][2] * bb->vec[val][2]; + planes[val][3] = -planes[val][0] * bb->vec[val][0] - + planes[val][1] * bb->vec[val][1] - + planes[val][2] * bb->vec[val][2]; } } @@ -1155,7 +1155,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - where_is_object(scene, v3d->camera); + BKE_object_where_is_calc(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { @@ -1176,7 +1176,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) copy_v3_v3(vec, ob->obmat[3]); if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { - bPoseChannel *pchan = get_pose_channel(ob->pose, v3d->ob_centre_bone); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, v3d->ob_centre_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); @@ -1412,7 +1412,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) } else { if (scene->obedit) { - minmax_object(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max); ok = 1; @@ -1422,7 +1422,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; ok = 1; @@ -1799,8 +1799,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) RestoreState(C, prevwin); //XXX restore_all_scene_cfra(scene_cfra_store); - set_scene_bg(CTX_data_main(C), startscene); - //XXX scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_set_background(CTX_data_main(C), startscene); + //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; #else diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 599d4a559ed..b457d22a712 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -284,7 +284,7 @@ static void createTransTexspace(TransInfo *t) normalize_m3(td->axismtx); invert_m3_m3(td->smtx, td->mtx); - if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { + if (BKE_object_obdata_texspace_get(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { ob->dtx |= OB_TEXSPACE; *texflag &= ~ME_AUTOSPACE; } @@ -424,7 +424,7 @@ static short apply_targetless_ik(Object *ob) bone= parchan->bone; bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */ - armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); + BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { @@ -535,11 +535,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* proper way to get parent transform + own transform + constraints transform */ copy_m3_m4(omat, ob->obmat); - /* New code, using "generic" pchan_to_pose_mat(). */ + /* New code, using "generic" BKE_pchan_to_pose_mat(). */ { float rotscale_mat[4][4], loc_mat[4][4]; - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); if (t->mode == TFM_TRANSLATION) copy_m3_m4(pmat, loc_mat); else @@ -884,7 +884,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone) } } if (wentdeeper==0) { - bPoseChannel *pchan= get_pose_channel(pose, bone->name); + bPoseChannel *pchan= BKE_pose_channel_find_name(pose, bone->name); if (pchan) added+= pose_grab_with_ik_add(pchan); } @@ -953,7 +953,7 @@ static void createTransPose(TransInfo *t, Object *ob) t->total= 0; /* check validity of state */ - arm= get_armature(ob); + arm= BKE_armature_from_object(ob); if ((arm==NULL) || (ob->pose==NULL)) return; if (arm->flag & ARM_RESTPOS) { @@ -2181,7 +2181,7 @@ void flushTransNodes(TransInfo *t) void flushTransSeq(TransInfo *t) { - ListBase *seqbasep= seq_give_editing(t->scene, FALSE)->seqbasep; /* Editing null check already done */ + ListBase *seqbasep= BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */ int a, new_frame, old_start; TransData *td= NULL; TransData2D *td2d= NULL; @@ -3980,7 +3980,7 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData * static void freeSeqData(TransInfo *t) { - Editing *ed= seq_give_editing(t->scene, FALSE); + Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE); if (ed != NULL) { ListBase *seqbasep= ed->seqbasep; @@ -4086,7 +4086,7 @@ static void freeSeqData(TransInfo *t) } } - sort_seq(t->scene); + BKE_sequencer_sort(t->scene); } else { /* Cancelled, need to update the strips display */ @@ -4116,7 +4116,7 @@ static void createTransSeqData(bContext *C, TransInfo *t) View2D *v2d= UI_view2d_fromcontext(C); Scene *scene= t->scene; - Editing *ed= seq_give_editing(t->scene, FALSE); + Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE); TransData *td = NULL; TransData2D *td2d= NULL; TransDataSeq *tdsq= NULL; @@ -4258,15 +4258,15 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) if (skip_invert == 0 && constinv == 0) { if (constinv == 0) - ob->transflag |= OB_NO_CONSTRAINTS; /* where_is_object_time checks this */ + ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */ - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); if (constinv == 0) ob->transflag &= ~OB_NO_CONSTRAINTS; } else - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); td->ob = ob; @@ -4320,7 +4320,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * NOTE: some Constraints, and also Tracking should never get this * done, as it doesn't work well. */ - object_to_mat3(ob, obmtx); + BKE_object_to_mat3(ob, obmtx); copy_m3_m4(totmat, ob->obmat); invert_m3_m3(obinv, totmat); mul_m3_m3m3(td->smtx, obmtx, obinv); @@ -4357,12 +4357,12 @@ static void set_trans_object_base_flags(TransInfo *t) return; /* makes sure base flags and object flags are identical */ - copy_baseflags(t->scene); + BKE_scene_base_flag_to_objects(t->scene); /* handle pending update events, otherwise they got copied below */ for (base= scene->base.first; base; base= base->next) { if (base->object->recalc) - object_handle_update(t->scene, base->object); + BKE_object_handle_update(t->scene, base->object); } for (base= scene->base.first; base; base= base->next) { @@ -4375,7 +4375,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* if parent selected, deselect */ while (parsel) { if (parsel->flag & SELECT) { - Base *parbase = object_in_scene(parsel, scene); + Base *parbase = BKE_scene_base_find(scene, parsel); if (parbase) { /* in rare cases this can fail */ if (TESTBASELIB_BGMODE(v3d, scene, parbase)) { break; @@ -5046,7 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * we need to update the pose otherwise no updates get called during * transform and the auto-ik is not applied. see [#26164] */ struct Object *pose_ob=t->poseobj; - where_is_pose(t->scene, pose_ob); + BKE_pose_where_is(t->scene, pose_ob); } /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ @@ -5141,7 +5141,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* recalculating the frame positions means we loose our original transform if its not auto-keyed [#24451] * this hack re-applies it, which is annoying, only alternatives are... * - don't recalc paths. - * - have an object_handle_update() which gives is the new transform without touching the objects. + * - have an BKE_object_handle_update() which gives is the new transform without touching the objects. * - only recalc paths on auto-keying. * - ED_objects_recalculate_paths could backup/restore transforms. * - re-apply the transform which is simplest in this case. (2 lines below) @@ -5878,7 +5878,7 @@ void createTransData(bContext *C, TransInfo *t) * lines below just check is also visible */ Object *ob_armature= modifiers_isDeformedByArmature(ob); if (ob_armature && ob_armature->mode & OB_MODE_POSE) { - Base *base_arm= object_in_scene(ob_armature, t->scene); + Base *base_arm= BKE_scene_base_find(t->scene, ob_armature); if (base_arm) { View3D *v3d = t->view; if (BASE_VISIBLE(v3d, base_arm)) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index bea1002b5c6..b986bda4c13 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -833,7 +833,7 @@ static void recalcData_view3d(TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ } else - where_is_pose(t->scene, ob); + BKE_pose_where_is(t->scene, ob); } else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { if (t->state != TRANS_CANCEL) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 0f0d1cc8344..b25c76fe193 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -229,8 +229,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], double *angle = mi->data; /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */ - double deler = ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3)) - / (2.0 * ((A*B)?(A*B):1.0)); + double deler = (((dx1 * dx1 + dy1 * dy1) + + (dx2 * dx2 + dy2 * dy2) - + (dx3 * dx3 + dy3 * dy3)) / (2.0 * ((A * B) ? (A * B) : 1.0))); /* ((A*B)?(A*B):1.0) this takes care of potential divide by zero errors */ float dphi; @@ -290,15 +291,12 @@ void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], int mva static void calcSpringFactor(MouseInput *mi) { - mi->factor = (float)sqrt( - ( - ((float)(mi->center[1] - mi->imval[1]))*((float)(mi->center[1] - mi->imval[1])) - + - ((float)(mi->center[0] - mi->imval[0]))*((float)(mi->center[0] - mi->imval[0])) - ) ); - - if (mi->factor==0.0f) + mi->factor = sqrtf(((float)(mi->center[1] - mi->imval[1])) * ((float)(mi->center[1] - mi->imval[1])) + + ((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0]))); + + if (mi->factor == 0.0f) { mi->factor= 1.0f; /* prevent Inf */ + } } void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 093c81c8d37..94f6640ca5b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -203,7 +203,7 @@ int gimbal_axis(Object *ob, float gmat[][3]) { if (ob) { if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan= get_active_posechannel(ob); + bPoseChannel *pchan= BKE_pose_channel_active(ob); if (pchan) { float mat[3][3], tmat[3][3], obmat[3][3]; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fa579293a73..b875886e80a 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -284,7 +284,7 @@ void applyProject(TransInfo *t) } else if (t->flag & T_OBJECT) { td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - object_handle_update(t->scene, td->ob); + BKE_object_handle_update(t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } @@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t) if (t->flag & T_OBJECT) { int i; for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { - struct BoundBox *bb = object_get_boundbox(td->ob); + struct BoundBox *bb = BKE_object_boundbox_get(td->ob); /* use boundbox if possible */ if (bb) { @@ -1303,8 +1303,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { @@ -1709,8 +1709,8 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 5430a9a1c90..b0edc702e48 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -388,7 +388,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 if (mti->deformMatrices && !deformed) continue; - mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0, 0); + mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0); deformed = 1; } } diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 1f1d5a0c0c0..91290829662 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -221,7 +221,7 @@ char handleNumInput(NumInput *n, wmEvent *event) break; case MINUSKEY: if (n->flag & NUM_NO_NEGATIVE) - break; + return 0; if (n->ctrl[idx]) { n->ctrl[idx] *= -1; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b515f30e150..53bf19c04cc 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -186,7 +186,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im return; } - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, assign image in material */ int sloppy = 1; BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 14c8420a8f5..7c05d08a774 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -402,7 +402,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, - 0, NULL, 0, 0, 1); + NULL, SUBSURF_IN_EDIT_MODE); initialDerived->release(initialDerived); @@ -744,6 +744,8 @@ void UV_OT_pack_islands(wmOperatorType *ot) /* identifiers */ ot->name = "Pack Islands"; ot->idname = "UV_OT_pack_islands"; + ot->description = "Transform all islands so that they fill up the UV space as much as possible"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -784,6 +786,8 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) /* identifiers */ ot->name = "Average Islands Scale"; ot->idname = "UV_OT_average_islands_scale"; + ot->description = "Average the size of separate UV islands, based on their area in 3D space"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1178,7 +1182,8 @@ static int unwrap_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh."); /* remember last method for live unwrap */ - scene->toolsettings->unwrapper = method; + if (RNA_struct_property_is_set(op->ptr, "method")) + scene->toolsettings->unwrapper = method; scene->toolsettings->uv_subsurf_level = subsurf_level; @@ -1205,7 +1210,8 @@ void UV_OT_unwrap(wmOperatorType *ot) static EnumPropertyItem method_items[] = { {0, "ANGLE_BASED", 0, "Angle Based", ""}, {1, "CONFORMAL", 0, "Conformal", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Unwrap"; @@ -1323,6 +1329,8 @@ void UV_OT_from_view(wmOperatorType *ot) /* identifiers */ ot->name = "Project From View"; ot->idname = "UV_OT_project_from_view"; + ot->description = "Project the UV vertices of the mesh as seen in current 3D view"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1362,6 +1370,8 @@ void UV_OT_reset(wmOperatorType *ot) /* identifiers */ ot->name = "Reset"; ot->idname = "UV_OT_reset"; + ot->description = "Reset UV projection"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1463,6 +1473,8 @@ void UV_OT_sphere_project(wmOperatorType *ot) /* identifiers */ ot->name = "Sphere Projection"; ot->idname = "UV_OT_sphere_project"; + ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1536,6 +1548,8 @@ void UV_OT_cylinder_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cylinder Projection"; ot->idname = "UV_OT_cylinder_project"; + ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1614,6 +1628,8 @@ void UV_OT_cube_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cube Projection"; ot->idname = "UV_OT_cube_project"; + ot->description = "Project the UV vertices of the mesh over the six faces of a cube"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ |