Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2011-06-21 08:01:51 +0400
committerJoshua Leung <aligorith@gmail.com>2011-06-21 08:01:51 +0400
commit24ca3eb4c42f3dfb4e2b775f53b35e4c4dcd8367 (patch)
treebb566767311f1f3b07a91333023cea24d5b657eb
parenta4178b7a6a1ce804f581c0e3289aa0f912085c78 (diff)
AnimFiltering Code Cleanups - Part 2
* Changed all int's to size_t's, where the int's were used for size of channel list returned * Object vs Base is now passed to filtering functions - was relic from old owner/ownertype code which required access to bases * Found bug in NLA code where filter was being overwritten and then used again as input for some other function unintentionally * Found bug where trying to select a NLA strip would crash if lamp data was around
-rw-r--r--source/blender/editors/animation/anim_filter.c82
-rw-r--r--source/blender/editors/include/ED_anim_api.h2
-rw-r--r--source/blender/editors/space_action/action_draw.c6
-rw-r--r--source/blender/editors/space_graph/graph_draw.c3
-rw-r--r--source/blender/editors/space_graph/graph_utils.c11
-rw-r--r--source/blender/editors/space_graph/space_graph.c3
-rw-r--r--source/blender/editors/space_nla/nla_channels.c3
-rw-r--r--source/blender/editors/space_nla/nla_draw.c6
-rw-r--r--source/blender/editors/space_nla/nla_edit.c3
9 files changed, 64 insertions, 55 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index b42fc47b14c..2343c73921c 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -349,7 +349,7 @@ short ANIM_animdata_get_context (const bContext *C, bAnimContext *ac)
* - ListBase anim_data;
* - bDopeSheet *ads;
* - bAnimListElem *ale;
- * - int items;
+ * - size_t items;
*
* - 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)
@@ -756,7 +756,7 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own
/* 'Only Selected' selected data filtering
* NOTE: when this function returns true, the F-Curve is to be skipped
*/
-static int skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode)
+static size_t skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode)
{
if (GS(owner_id->name) == ID_OB) {
Object *ob= (Object *)owner_id;
@@ -906,10 +906,10 @@ static FCurve *animdata_filter_fcurve_next (bDopeSheet *ads, FCurve *first, bAct
return NULL;
}
-static int animdata_filter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id)
+static size_t animdata_filter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id)
{
FCurve *fcu;
- int items = 0;
+ size_t items = 0;
/* loop over every F-Curve able to be included
* - this for-loop works like this:
@@ -934,12 +934,12 @@ static int animdata_filter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve
return items;
}
-static int animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id)
+static size_t animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id)
{
bAnimListElem *ale=NULL;
bActionGroup *agrp;
FCurve *lastchan=NULL;
- int items = 0;
+ size_t items = 0;
/* don't include anything from this action if it is linked in from another file,
* and we're getting stuff for editing...
@@ -1061,12 +1061,12 @@ static int animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeS
* - 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 int animdata_filter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *UNUSED(ads), AnimData *adt, int filter_mode, ID *owner_id)
+static size_t animdata_filter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *UNUSED(ads), AnimData *adt, int filter_mode, ID *owner_id)
{
bAnimListElem *ale;
NlaTrack *nlt;
NlaTrack *first=NULL, *next=NULL;
- int items = 0;
+ size_t items = 0;
/* if showing channels, include active action */
if (filter_mode & ANIMFILTER_CHANNELS) {
@@ -1131,10 +1131,10 @@ static int animdata_filter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, b
}
/* Include ShapeKey Data for ShapeKey Editor */
-static int 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)
{
bAnimListElem *ale;
- int items = 0;
+ size_t items = 0;
/* check if channels or only F-Curves */
if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) {
@@ -1180,12 +1180,12 @@ static int animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, Key
/* Grab all Grase Pencil datablocks in file */
// TODO: should this be amalgamated with the dopesheet filtering code?
-static int 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)
{
bAnimListElem *ale;
bGPdata *gpd;
bGPDlayer *gpl;
- int items = 0;
+ size_t items = 0;
/* check if filtering types are appropriate */
if (!(filter_mode & (ANIMFILTER_ACTGROUPED|ANIMFILTER_CURVESONLY)))
@@ -1232,12 +1232,12 @@ static int animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int
}
/* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */
-static int animdata_filter_dopesheet_texs (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
+static size_t animdata_filter_dopesheet_texs (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode)
{
- MTex **mtex = NULL;
-
bAnimListElem *ale=NULL;
- int items=0, a=0;
+ MTex **mtex = NULL;
+ size_t items=0;
+ int a=0;
/* get datatype specific data first */
if (owner_id == NULL)
@@ -1317,11 +1317,11 @@ static int animdata_filter_dopesheet_texs (bAnimContext *ac, ListBase *anim_data
return items;
}
-static int animdata_filter_dopesheet_mats (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+static size_t animdata_filter_dopesheet_mats (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
{
bAnimListElem *ale=NULL;
- Object *ob= base->object;
- int items=0, a=0;
+ size_t items=0;
+ int a=0;
/* firstly check that we actuallly have some materials, by gathering all materials in a temp list */
for (a=1; a <= ob->totcol; a++) {
@@ -1392,12 +1392,11 @@ static int animdata_filter_dopesheet_mats (bAnimContext *ac, ListBase *anim_data
return items;
}
-static int animdata_filter_dopesheet_particles (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+static size_t animdata_filter_dopesheet_particles (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
{
bAnimListElem *ale=NULL;
- Object *ob= base->object;
ParticleSystem *psys = ob->particlesystem.first;
- int items= 0;
+ size_t items= 0;
for(; psys; psys=psys->next) {
short ok = 0;
@@ -1437,14 +1436,13 @@ static int animdata_filter_dopesheet_particles (bAnimContext *ac, ListBase *anim
return items;
}
-static int animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode)
+static size_t animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode)
{
bAnimListElem *ale=NULL;
- Object *ob= base->object;
IdAdtTemplate *iat= ob->data;
AnimData *adt= iat->adt;
short type=0, expanded=0;
- int items= 0;
+ size_t items= 0;
/* get settings based on data type */
switch (ob->type) {
@@ -1509,7 +1507,7 @@ static int animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_da
}
/* include data-expand widget? */
- if ((filter_mode & ANIMFILTER_CURVESONLY) == 0) {
+ if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
/* check if filtering by active status */
if ANIMCHANNEL_ACTIVEOK(iat) {
ale= make_new_animlistelem(iat, type, (ID *)iat);
@@ -1542,14 +1540,14 @@ static int animdata_filter_dopesheet_obdata (bAnimContext *ac, ListBase *anim_da
return items;
}
-static int 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)
{
bAnimListElem *ale=NULL;
AnimData *adt = NULL;
Object *ob= base->object;
Key *key= ob_get_key(ob);
short obdata_ok = 0;
- int items = 0;
+ size_t items = 0;
/* add this object as a channel first */
if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
@@ -1674,7 +1672,7 @@ static int animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data,
/* Materials? */
if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT))
- items += animdata_filter_dopesheet_mats(ac, anim_data, ads, base, filter_mode);
+ items += animdata_filter_dopesheet_mats(ac, anim_data, ads, ob, filter_mode);
/* Object Data */
switch (ob->type) {
@@ -1773,23 +1771,23 @@ static int animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data,
break;
}
if (obdata_ok)
- items += animdata_filter_dopesheet_obdata(ac, anim_data, ads, base, filter_mode);
+ items += animdata_filter_dopesheet_obdata(ac, anim_data, ads, ob, filter_mode);
/* particles */
if (ob->particlesystem.first && !(ads->filterflag & ADS_FILTER_NOPART))
- items += animdata_filter_dopesheet_particles(ac, anim_data, ads, base, filter_mode);
+ items += animdata_filter_dopesheet_particles(ac, anim_data, ads, ob, filter_mode);
/* return the number of items added to the list */
return items;
}
-static int 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)
{
World *wo= sce->world;
bNodeTree *ntree= sce->nodetree;
AnimData *adt= NULL;
bAnimListElem *ale;
- int items = 0;
+ size_t items = 0;
/* add scene as a channel first (even if we aren't showing scenes we still need to show the scene's sub-data */
if ((filter_mode & (ANIMFILTER_CURVESONLY|ANIMFILTER_NLATRACKS)) == 0) {
@@ -1951,12 +1949,12 @@ static int animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_dat
}
// 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 int 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;
Base *base;
bAnimListElem *ale;
- int items = 0;
+ size_t items = 0;
/* check that we do indeed have a scene */
if ((ads->source == NULL) || (GS(ads->source->name)!=ID_SCE)) {
@@ -2348,7 +2346,7 @@ static int animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDo
/* Summary track for DopeSheet/Action Editor
* - 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, int *items)
+static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items)
{
bDopeSheet *ads = NULL;
@@ -2392,10 +2390,10 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim
/* ----------- Cleanup API --------------- */
/* Remove entries with invalid types in animation channel list */
-static int animdata_filter_remove_invalid (ListBase *anim_data)
+static size_t animdata_filter_remove_invalid (ListBase *anim_data)
{
bAnimListElem *ale, *next;
- int items = 0;
+ size_t items = 0;
/* only keep entries with valid types */
for (ale= anim_data->first; ale; ale= next) {
@@ -2411,11 +2409,11 @@ static int animdata_filter_remove_invalid (ListBase *anim_data)
}
/* Remove duplicate entries in animation channel list */
-static int animdata_filter_remove_duplis (ListBase *anim_data)
+static size_t animdata_filter_remove_duplis (ListBase *anim_data)
{
bAnimListElem *ale, *next;
GHash *gh;
- int items = 0;
+ size_t items = 0;
/* build new hashtable to efficiently store and retrieve which entries have been
* encountered already while searching
@@ -2457,9 +2455,9 @@ static int animdata_filter_remove_duplis (ListBase *anim_data)
* will be placed for use.
* filter_mode: how should the data be filtered - bitmapping accessed flags
*/
-int ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode, void *data, short datatype)
+size_t ANIM_animdata_filter (bAnimContext *ac, ListBase *anim_data, int filter_mode, void *data, short datatype)
{
- int items = 0;
+ size_t items = 0;
/* only filter data if there's somewhere to put it */
if (data && anim_data) {
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index a8836458fad..be46c237e80 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -299,7 +299,7 @@ typedef enum eAnimFilter_Flags {
/* Obtain list of filtered Animation channels to operate on.
* Returns the number of channels in the list
*/
-int ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mode, void *data, short datatype);
+size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mode, void *data, short datatype);
/* Obtain current anim-data context from Blender Context info.
* Returns whether the operation was successful.
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 1b8a1778707..760db5dd133 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -77,7 +77,8 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
View2D *v2d= &ar->v2d;
float y= 0.0f;
- int items, height;
+ size_t items;
+ int height;
/* build list of channels to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
@@ -166,7 +167,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
AnimData *adt= NULL;
float act_start, act_end, y;
- int height, items;
+ size_t items;
+ int height;
unsigned char col1[3], col2[3];
unsigned char col1a[3], col2a[3];
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 382bb71a592..73ecea8e31e 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -964,7 +964,8 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
View2D *v2d= &ar->v2d;
float y= 0.0f, height;
- int items, i=0;
+ size_t items;
+ int i=0;
/* build list of channels to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index e4509a29a91..e20b4593fa9 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -70,7 +70,7 @@ bAnimListElem *get_active_fcurve_channel (bAnimContext *ac)
{
ListBase anim_data = {NULL, NULL};
int filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE | ANIMFILTER_CURVESONLY);
- int items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ 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.
@@ -99,7 +99,8 @@ int graphop_visible_keyframes_poll (bContext *C)
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
ScrArea *sa= CTX_wm_area(C);
- int filter, items;
+ size_t items;
+ int filter;
short found = 0;
/* firstly, check if in Graph Editor */
@@ -147,7 +148,8 @@ int graphop_editable_keyframes_poll (bContext *C)
bAnimListElem *ale;
ListBase anim_data = {NULL, NULL};
ScrArea *sa= CTX_wm_area(C);
- int filter, items;
+ size_t items;
+ int filter;
short found = 0;
/* firstly, check if in Graph Editor */
@@ -230,7 +232,8 @@ int graphop_selected_fcurve_poll (bContext *C)
bAnimContext ac;
ListBase anim_data = {NULL, NULL};
ScrArea *sa= CTX_wm_area(C);
- int filter, items;
+ size_t items;
+ int filter;
/* firstly, check if in Graph Editor */
// TODO: also check for region?
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 883b476f372..24e196749a8 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -513,8 +513,9 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
if (ANIM_animdata_get_context(C, &ac)) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
+ size_t items;
int filter;
- int items, i;
+ 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
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index 38f680fff07..be050dded45 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -81,13 +81,14 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
int filter;
+
View2D *v2d= &ac->ar->v2d;
int notifierFlags = 0;
/* get the channel that was clicked on */
/* filter channels */
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
- filter= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
+ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* get channel from index */
ale= BLI_findlink(&anim_data, channel_index);
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index c4a3a2324b4..c53eac78b19 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -470,7 +470,8 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar)
View2D *v2d= &ar->v2d;
float y= 0.0f;
- int items, height;
+ size_t items;
+ int height;
/* build list of channels to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
@@ -828,7 +829,8 @@ void draw_nla_channel_list (bContext *C, bAnimContext *ac, ARegion *ar)
View2D *v2d= &ar->v2d;
float y= 0.0f;
- int items, height;
+ size_t items;
+ int height;
/* build list of channels to draw */
filter= (ANIMFILTER_VISIBLE|ANIMFILTER_CHANNELS);
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 77c91b28a63..08607e6183b 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -250,7 +250,8 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op)
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
- int filter, items;
+ size_t items;
+ int filter;
bAction *act;