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/blenkernel/intern/group.c | |
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/blenkernel/intern/group.c')
-rw-r--r-- | source/blender/blenkernel/intern/group.c | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 204b2b08563..ceffe269e85 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -52,7 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_scene.h" /* object_in_scene */ +#include "BKE_scene.h" /* BKE_scene_base_find */ static void free_group_object(GroupObject *go) { @@ -60,21 +60,21 @@ static void free_group_object(GroupObject *go) } -void free_group_objects(Group *group) +void BKE_group_free(Group *group) { /* don't free group itself */ GroupObject *go; while (group->gobject.first) { - go= group->gobject.first; + go = group->gobject.first; BLI_remlink(&group->gobject, go); free_group_object(go); } } -void unlink_group(Group *group) +void BKE_group_unlink(Group *group) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; Object *ob; Scene *sce; @@ -82,28 +82,28 @@ void unlink_group(Group *group) FreestyleLineSet *lineset; ParticleSystem *psys; - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (sce= bmain->scene.first; sce; sce= sce->id.next) { - Base *base= sce->base.first; + for (sce = bmain->scene.first; sce; sce = sce->id.next) { + Base *base = sce->base.first; /* ensure objects are not in this group */ - for (; base; base= base->next) { - if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) { + for (; base; base = base->next) { + if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL) == NULL) { base->object->flag &= ~OB_FROMGROUP; base->flag &= ~OB_FROMGROUP; } } - for (srl= sce->r.layers.first; srl; srl= srl->next) { - if (srl->light_override==group) - srl->light_override= NULL; + for (srl = sce->r.layers.first; srl; srl = srl->next) { + if (srl->light_override == group) + srl->light_override = NULL; for(lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) { if (lineset->group == group) @@ -112,51 +112,51 @@ void unlink_group(Group *group) } } - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->dup_group==group) { - ob->dup_group= NULL; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ + if (ob->dup_group == group) { + ob->dup_group = NULL; +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ { bActionStrip *strip; /* duplicator strips use a group object, we remove it */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) - strip->object= NULL; + strip->object = NULL; } } #endif } - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - if (psys->part->dup_group==group) - psys->part->dup_group= NULL; -#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ - if (psys->part->eff_group==group) - psys->part->eff_group= NULL; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part->dup_group == group) + psys->part->dup_group = NULL; +#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ + if (psys->part->eff_group == group) + psys->part->eff_group = NULL; #endif } } /* group stays in library, but no members */ - free_group_objects(group); - group->id.us= 0; + BKE_group_free(group); + group->id.us = 0; } Group *add_group(const char *name) { Group *group; - group = alloc_libblock(&G.main->group, ID_GR, name); - group->layer= (1<<20)-1; + group = BKE_libblock_alloc(&G.main->group, ID_GR, name); + group->layer = (1 << 20) - 1; return group; } -Group *copy_group(Group *group) +Group *BKE_group_copy(Group *group) { Group *groupn; - groupn= MEM_dupallocN(group); + groupn = MEM_dupallocN(group); BLI_duplicatelist(&groupn->gobject, &group->gobject); return groupn; @@ -167,17 +167,17 @@ static int add_to_group_internal(Group *group, Object *ob) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; /* check if the object has been added already */ - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) return 0; + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 0; } - go= MEM_callocN(sizeof(GroupObject), "groupobject"); + go = MEM_callocN(sizeof(GroupObject), "groupobject"); BLI_addtail(&group->gobject, go); - go->ob= ob; + go->ob = ob; return 1; } @@ -185,10 +185,10 @@ static int add_to_group_internal(Group *group, Object *ob) int add_to_group(Group *group, Object *object, Scene *scene, Base *base) { if (add_to_group_internal(group, object)) { - if ((object->flag & OB_FROMGROUP)==0) { + if ((object->flag & OB_FROMGROUP) == 0) { - if (scene && base==NULL) - base= object_in_scene(object, scene); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag |= OB_FROMGROUP; @@ -207,18 +207,18 @@ static int rem_from_group_internal(Group *group, Object *ob) { GroupObject *go, *gon; int removed = 0; - if (group==NULL) return 0; + if (group == NULL) return 0; - go= group->gobject.first; + go = group->gobject.first; while (go) { - gon= go->next; - if (go->ob==ob) { + gon = go->next; + if (go->ob == ob) { BLI_remlink(&group->gobject, go); free_group_object(go); removed = 1; /* should break here since an object being in a group twice cant happen? */ } - go= gon; + go = gon; } return removed; } @@ -228,8 +228,8 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) if (rem_from_group_internal(group, object)) { /* object can be NULL */ if (object && find_group(object, NULL) == NULL) { - if (scene && base==NULL) - base= object_in_scene(object, scene); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag &= ~OB_FROMGROUP; @@ -247,10 +247,10 @@ int object_in_group(Object *ob, Group *group) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 1; } return 0; @@ -259,14 +259,14 @@ int object_in_group(Object *ob, Group *group) Group *find_group(Object *ob, Group *group) { if (group) - group= group->id.next; + group = group->id.next; else - group= G.main->group.first; + group = G.main->group.first; while (group) { if (object_in_group(ob, group)) return group; - group= group->id.next; + group = group->id.next; } return NULL; } @@ -275,11 +275,11 @@ void group_tag_recalc(Group *group) { GroupObject *go; - if (group==NULL) return; + if (group == NULL) return; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } @@ -292,7 +292,7 @@ int group_is_animated(Object *UNUSED(parent), Group *group) return 1; #endif - for (go= group->gobject.first; go; go= go->next) + for (go = group->gobject.first; go; go = go->next) if (go->ob && go->ob->proxy) return 1; @@ -304,38 +304,38 @@ int group_is_animated(Object *UNUSED(parent), Group *group) /* keep checking nla.c though, in case internal structure of strip changes */ static void group_replaces_nla(Object *parent, Object *target, char mode) { - static ListBase nlastrips={NULL, NULL}; - static bAction *action= NULL; - static int done= 0; + static ListBase nlastrips = {NULL, NULL}; + static bAction *action = NULL; + static int done = 0; bActionStrip *strip, *nstrip; - if (mode=='s') { + if (mode == 's') { - for (strip= parent->nlastrips.first; strip; strip= strip->next) { - if (strip->object==target) { - if (done==0) { + for (strip = parent->nlastrips.first; strip; strip = strip->next) { + if (strip->object == target) { + if (done == 0) { /* clear nla & action from object */ - nlastrips= target->nlastrips; - target->nlastrips.first= target->nlastrips.last= NULL; - action= target->action; - target->action= NULL; + nlastrips = target->nlastrips; + target->nlastrips.first = target->nlastrips.last = NULL; + action = target->action; + target->action = NULL; target->nlaflag |= OB_NLA_OVERRIDE; - done= 1; + done = 1; } - nstrip= MEM_dupallocN(strip); + nstrip = MEM_dupallocN(strip); BLI_addtail(&target->nlastrips, nstrip); } } } - else if (mode=='e') { + else if (mode == 'e') { if (done) { BLI_freelistN(&target->nlastrips); - target->nlastrips= nlastrips; - target->action= action; + target->nlastrips = nlastrips; + target->action = action; - nlastrips.first= nlastrips.last= NULL; /* not needed, but yah... :) */ - action= NULL; - done= 0; + nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */ + action = NULL; + done = 0; } } } @@ -359,33 +359,33 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group int cfrao; /* switch to local time */ - cfrao= scene->r.cfra; + cfrao = scene->r.cfra; /* we need a DAG per group... */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob && go->recalc) { - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; group_replaces_nla(parent, go->ob, 's'); - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); group_replaces_nla(parent, go->ob, 'e'); /* leave recalc tags in case group members are in normal scene */ - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } /* restore */ - scene->r.cfra= cfrao; + scene->r.cfra = cfrao; } else #endif { /* only do existing tags, as set by regular depsgraph */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { if (go->ob->recalc) { - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); } } } @@ -397,17 +397,17 @@ Object *group_get_member_with_action(Group *group, bAction *act) { GroupObject *go; - if (group==NULL || act==NULL) return NULL; + if (group == NULL || act == NULL) return NULL; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (go->ob->action==act) + if (go->ob->action == act) return go->ob; if (go->ob->nlastrips.first) { bActionStrip *strip; - for (strip= go->ob->nlastrips.first; strip; strip= strip->next) { - if (strip->act==act) + for (strip = go->ob->nlastrips.first; strip; strip = strip->next) { + if (strip->act == act) return go->ob; } } @@ -424,21 +424,21 @@ void group_relink_nla_objects(Object *ob) GroupObject *go; bActionStrip *strip; - if (ob==NULL || ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob == NULL || ob->dup_group == NULL) return; + group = ob->dup_group; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (strcmp(go->ob->id.name, strip->object->id.name)==0) + if (strcmp(go->ob->id.name, strip->object->id.name) == 0) break; } } if (go) - strip->object= go->ob; + strip->object = go->ob; else - strip->object= NULL; + strip->object = NULL; } } |