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:
authorLuca Rood <dev@lucarood.com>2017-04-19 12:31:33 +0300
committerLuca Rood <dev@lucarood.com>2017-04-19 17:52:27 +0300
commit4bee5b80d4c5c3309771424ad40f0a7723c818b1 (patch)
tree5bedfc5c74b22e78741272cb61f3eed37f18f3df /source/blender/editors
parent2f2420709c95c1af27967daa257553edf9096c7a (diff)
Convert direct usages of base defines
This replaces all direct usage of: - FIRSTBASE - LASTBASE - BASACT - OBACT Some usages still remain in legacy utility functions which are called all over the place.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c15
-rw-r--r--source/blender/editors/object/object_relations.c22
-rw-r--r--source/blender/editors/space_image/space_image.c4
-rw-r--r--source/blender/editors/space_logic/logic_window.c27
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c12
6 files changed, 43 insertions, 47 deletions
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 63acb557c52..957048bcc42 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -33,6 +33,7 @@
#include "BKE_context.h"
#include "BKE_sketch.h"
+#include "BKE_layer.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -144,9 +145,8 @@ static RigGraph *TEMPLATE_RIGG = NULL;
void BIF_makeListTemplates(const bContext *C)
{
Object *obedit = CTX_data_edit_object(C);
- Scene *scene = CTX_data_scene(C);
+ SceneLayer *sl = CTX_data_scene_layer(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- BaseLegacy *base;
int index = 0;
if (TEMPLATES_HASH != NULL) {
@@ -156,9 +156,8 @@ void BIF_makeListTemplates(const bContext *C)
TEMPLATES_HASH = BLI_ghash_int_new("makeListTemplates gh");
TEMPLATES_CURRENT = 0;
- for (base = FIRSTBASE; base; base = base->next) {
- Object *ob = base->object;
-
+ FOREACH_OBJECT(sl, ob)
+ {
if (ob != obedit && ob->type == OB_ARMATURE) {
index++;
BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob);
@@ -168,6 +167,7 @@ void BIF_makeListTemplates(const bContext *C)
}
}
}
+ FOREACH_OBJECT_END
}
#if 0 /* UNUSED */
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 505114869ac..8c98d570096 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -56,12 +56,14 @@
#include "DNA_view3d_types.h"
#include "DNA_gpencil_types.h"
+#include "BKE_collection.h"
#include "BKE_context.h"
#include "BKE_curve.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
#include "BKE_gpencil.h"
+#include "BKE_layer.h"
#include "BKE_library.h"
#include "BKE_object.h"
#include "BKE_report.h"
@@ -1121,14 +1123,15 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
const bool norm_weights, const float rad_fac, const bool link_strokes, tGpTimingData *gtd)
{
struct Main *bmain = CTX_data_main(C);
- View3D *v3d = CTX_wm_view3d(C); /* may be NULL */
Scene *scene = CTX_data_scene(C);
+ SceneLayer *sl = CTX_data_scene_layer(C);
+ SceneCollection *sc = CTX_data_scene_collection(C);
bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0);
bGPDstroke *gps, *prev_gps = NULL;
Object *ob;
Curve *cu;
Nurb *nu = NULL;
- BaseLegacy *base_orig = BASACT, *base_new = NULL;
+ Base *base_new = NULL;
float minmax_weights[2] = {1.0f, 0.0f};
/* camera framing */
@@ -1152,7 +1155,8 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
*/
ob = BKE_object_add_only_object(bmain, OB_CURVE, gpl->info);
cu = ob->data = BKE_curve_add(bmain, gpl->info, OB_CURVE);
- base_new = BKE_scene_base_add(scene, ob);
+ BKE_collection_object_add(scene, sc, ob);
+ base_new = BKE_scene_layer_base_find(sl, ob);
cu->flag |= CU_3D;
@@ -1216,9 +1220,8 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
}
/* set the layer and select */
- base_new->lay = ob->lay = base_orig ? base_orig->lay : BKE_screen_view3d_layer_active(v3d, scene);
- base_new->flag_legacy |= SELECT;
- BKE_scene_base_flag_sync_from_base(base_new);
+ base_new->flag |= SELECT;
+ BKE_scene_object_base_flag_sync_from_base(base_new);
}
/* --- */
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index 7095d8406a0..ff62e5f2f37 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -124,6 +124,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
+ SceneLayer *sl = CTX_data_scene_layer(C);
Object *obedit = CTX_data_edit_object(C);
BMVert *eve;
BMIter iter;
@@ -240,7 +241,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
else {
Object workob;
- ob->parent = BASACT->object;
+ ob->parent = BASACT_NEW->object;
if (v3) {
ob->partype = PARVERT3;
ob->par1 = v1 - 1;
@@ -347,7 +348,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
if (ob) {
Object *newob;
- BaseLegacy *newbase, *oldbase = BASACT;
+ BaseLegacy *newbase, *oldbase = BASACT_NEW;
char name[MAX_ID_NAME + 4];
BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2);
@@ -356,7 +357,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op)
newob = BKE_object_add(bmain, scene, sl, OB_EMPTY, name);
/* set layers OK */
- newbase = BASACT; /* BKE_object_add sets active... */
+ newbase = BASACT_NEW; /* BKE_object_add sets active... */
newbase->lay = oldbase->lay;
newob->lay = newbase->lay;
@@ -1763,7 +1764,7 @@ static void new_id_matar(Main *bmain, Material **matar, const int totcol)
}
}
-static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
+static void single_obdata_users(Main *bmain, Scene *scene, SceneLayer *sl, const int flag)
{
Lamp *la;
Curve *cu;
@@ -1773,11 +1774,9 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
ID *id;
int a;
- TODO_LAYER; /* need to use scene->collection base instead of scene->bases */
-
- for (base = FIRSTBASE; base; base = base->next) {
- ob = base->object;
- if (!ID_IS_LINKED_DATABLOCK(ob) && (base->flag_legacy & flag) == flag) {
+ FOREACH_OBJECT_FLAG(scene, sl, flag, ob)
+ {
+ if (!ID_IS_LINKED_DATABLOCK(ob)) {
id = ob->data;
if (id && id->us > 1 && !ID_IS_LINKED_DATABLOCK(id)) {
@@ -1843,6 +1842,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
}
}
}
+ FOREACH_OBJECT_FLAG_END
me = bmain->mesh.first;
while (me) {
@@ -2000,7 +2000,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, const bool full, const bo
single_object_users(bmain, scene, NULL, 0, copy_groups);
if (full) {
- single_obdata_users(bmain, scene, 0);
+ single_obdata_users(bmain, scene, NULL, 0);
single_object_action_users(scene, NULL, 0);
single_mat_users_expand(bmain);
single_tex_users_expand(bmain);
@@ -2319,7 +2319,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op)
}
if (RNA_boolean_get(op->ptr, "obdata")) {
- single_obdata_users(bmain, scene, flag);
+ single_obdata_users(bmain, scene, sl, flag);
}
if (RNA_boolean_get(op->ptr, "material")) {
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index f1176acfa94..754dcc503c4 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -446,6 +446,7 @@ static void image_refresh(const bContext *C, ScrArea *sa)
static void image_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn)
{
Scene *scene = sc->scene;
+ SceneLayer *sl = BKE_scene_layer_context_active(scene);
SpaceImage *sima = (SpaceImage *)sa->spacedata.first;
/* context changes */
@@ -538,8 +539,7 @@ static void image_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn)
case ND_TRANSFORM:
case ND_MODIFIER:
{
- TODO_LAYER_CONTEXT; /* need to use OBACT_NEW */
- Object *ob = OBACT;
+ Object *ob = OBACT_NEW;
if (ob && (ob == wmn->reference) && (ob->mode & OB_MODE_EDIT)) {
if (sima->lock && (sima->flag & SI_DRAWSHADOW)) {
ED_area_tag_refresh(sa);
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index f1a08a45c29..04790f54057 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -460,14 +460,14 @@ static void set_sca_ob(Object *ob)
static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisflag)
{
- BaseLegacy *base;
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *ob, *obt, *obact= CTX_data_active_object(C);
+ Base *base;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ SceneLayer *sl = CTX_data_scene_layer(C);
+ Object *ob, *obt, *obact = CTX_data_active_object(C);
ID **idar;
bSensor *sens;
bController *cont;
- unsigned int lay;
int a, nr, do_it;
/* we need a sorted object list */
@@ -485,19 +485,12 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf
ob= ob->id.next;
}
- /* XXX here it checked 3d lay */
- lay= scene->lay;
-
- base= FIRSTBASE;
- while (base) {
- if (base->lay & lay) {
- if (base->flag_legacy & SELECT) {
- if (scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS;
- if (scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT;
- if (scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT;
- }
+ for (base = FIRSTBASE_NEW; base; base = base->next) {
+ if ((base->flag & BASE_VISIBLED) && (base->flag & SELECT)) {
+ if (scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS;
+ if (scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT;
+ if (scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT;
}
- base= base->next;
}
if (obact) {
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index 0707f728ff7..157467b1aaf 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -98,14 +98,14 @@ static eOLDrawState tree_element_active_renderlayer(
* CTRL+LMB: Select/Deselect object and all cildren
* CTRL+SHIFT+LMB: Add/Remove object and all children
*/
-static void do_outliner_object_select_recursive(Scene *scene, Object *ob_parent, bool select)
+static void do_outliner_object_select_recursive(SceneLayer *sl, Object *ob_parent, bool select)
{
- BaseLegacy *base;
+ Base *base;
- for (base = FIRSTBASE; base; base = base->next) {
+ for (base = FIRSTBASE_NEW; base; base = base->next) {
Object *ob = base->object;
- if ((((ob->restrictflag & OB_RESTRICT_VIEW) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) {
- ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT);
+ if ((((base->flag & BASE_VISIBLED) == 0) && BKE_object_is_child_recursive(ob_parent, ob))) {
+ ED_object_base_select(base, select ? BA_SELECT : BA_DESELECT);
}
}
}
@@ -183,7 +183,7 @@ static eOLDrawState tree_element_set_active_object(
if (recursive) {
/* Recursive select/deselect for Object hierarchies */
- do_outliner_object_select_recursive(scene, ob, (ob->flag & SELECT) != 0);
+ do_outliner_object_select_recursive(sl, ob, (ob->flag & SELECT) != 0);
}
if (set != OL_SETSEL_NONE) {