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
path: root/source
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-02-14 17:46:01 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-02-14 20:21:46 +0300
commit1ff3d5bc9ab7b296b1c60038d45ef4c030403162 (patch)
treeccda1f1d1913aab4268a03699944a11f578b5c4b /source
parentb9762fed932b7f508aec5650fd80679cf635d677 (diff)
Layer Macros: create the instance as part of the macro
Instead of pre-initializing an instance prior to the macro, we do it as part of the macro itself now.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_collection.h8
-rw-r--r--source/blender/blenkernel/BKE_layer.h36
-rw-r--r--source/blender/blenkernel/intern/collection.c2
-rw-r--r--source/blender/blenkernel/intern/library_query.c1
-rw-r--r--source/blender/blenkernel/intern/library_remap.c1
-rw-r--r--source/blender/blenlib/BLI_iterator.h7
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc1
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc1
-rw-r--r--source/blender/draw/engines/clay/clay.c1
-rw-r--r--source/blender/editors/object/object_add.c1
-rw-r--r--source/blender/editors/object/object_relations.c4
-rw-r--r--source/blender/editors/screen/screen_context.c5
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c1
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c7
14 files changed, 28 insertions, 48 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 90904cdfddd..4d5de723dce 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -66,20 +66,20 @@ void BKE_scene_objects_Iterator_begin(struct Iterator *iter, void *data_in);
void BKE_scene_objects_Iterator_next(struct Iterator *iter);
void BKE_scene_objects_Iterator_end(struct Iterator *iter);
-#define FOREACH_SCENE_COLLECTION(scene, _sc) \
+#define FOREACH_SCENE_COLLECTION(scene, _instance) \
ITER_BEGIN(BKE_scene_collections_Iterator_begin, \
BKE_scene_collections_Iterator_next, \
BKE_scene_collections_Iterator_end, \
- scene, SceneCollection, _sc)
+ scene, SceneCollection *, _instance)
#define FOREACH_SCENE_COLLECTION_END \
ITER_END
-#define FOREACH_SCENE_OBJECT(scene, _ob) \
+#define FOREACH_SCENE_OBJECT(scene, _instance) \
ITER_BEGIN(BKE_scene_objects_Iterator_begin, \
BKE_scene_objects_Iterator_next, \
BKE_scene_objects_Iterator_end, \
- scene, Object, _ob)
+ scene, Object *, _instance)
#define FOREACH_SCENE_OBJECT_END \
ITER_END
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 248ceea9b95..db817bb3329 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -136,46 +136,47 @@ void BKE_visible_bases_Iterator_begin(Iterator *iter, void *data_in);
void BKE_visible_bases_Iterator_next(Iterator *iter);
void BKE_visible_bases_Iterator_end(Iterator *iter);
-#define FOREACH_SELECTED_OBJECT(sl, _ob) \
+#define FOREACH_SELECTED_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_selected_objects_Iterator_begin, \
BKE_selected_objects_Iterator_next, \
BKE_selected_objects_Iterator_end, \
- sl, Object, _ob)
+ sl, Object *, _instance)
#define FOREACH_SELECTED_OBJECT_END \
ITER_END
-#define FOREACH_VISIBLE_OBJECT(sl, _ob) \
+#define FOREACH_VISIBLE_OBJECT(sl, _instance) \
ITER_BEGIN(BKE_visible_objects_Iterator_begin, \
BKE_visible_objects_Iterator_next, \
BKE_visible_objects_Iterator_end, \
- sl, Object, _ob)
+ sl, Object *, _instance)
#define FOREACH_VISIBLE_OBJECT_END \
ITER_END
-#define FOREACH_VISIBLE_BASE(sl, _object_base) \
+#define FOREACH_VISIBLE_BASE(sl, _instance) \
ITER_BEGIN(BKE_visible_bases_Iterator_begin, \
BKE_visible_bases_Iterator_next, \
BKE_visible_bases_Iterator_end, \
- sl, Base, _object_base)
+ sl, Base *, _instance)
#define FOREACH_VISIBLE_BASE_END \
ITER_END
-#define FOREACH_OBJECT(sl, _ob) \
+#define FOREACH_OBJECT(sl, _instance) \
{ \
+ Object *_instance; \
Base *base; \
- for (base = sl->object_bases.first; base; base = base->next) { \
- _ob = base->object;
+ for (base = (sl)->object_bases.first; base; base = base->next) { \
+ _instance = base->object;
#define FOREACH_OBJECT_END \
} \
}
-#define FOREACH_OBJECT_FLAG(scene, sl, flag, _ob) \
+#define FOREACH_OBJECT_FLAG(scene, sl, flag, _instance) \
{ \
IteratorBeginCb func_begin; \
IteratorCb func_next, func_end; \
@@ -185,15 +186,15 @@ void BKE_visible_bases_Iterator_end(Iterator *iter);
func_begin = &BKE_selected_objects_Iterator_begin; \
func_next = &BKE_selected_objects_Iterator_next; \
func_end = &BKE_selected_objects_Iterator_end; \
- data_in = sl; \
+ data_in = (sl); \
} \
else { \
func_begin = BKE_scene_objects_Iterator_begin; \
func_next = BKE_scene_objects_Iterator_next; \
func_end = BKE_scene_objects_Iterator_end; \
- data_in = scene; \
+ data_in = (scene); \
} \
- ITER_BEGIN(func_begin, func_next, func_end, data_in, Object, _ob)
+ ITER_BEGIN(func_begin, func_next, func_end, data_in, Object *, _instance)
#define FOREACH_OBJECT_FLAG_END \
@@ -201,16 +202,17 @@ void BKE_visible_bases_Iterator_end(Iterator *iter);
}
/* temporary hacky solution waiting for final depsgraph evaluation */
-#define DEG_OBJECT_ITER(sl_, ob_) \
+#define DEG_OBJECT_ITER(sl_, instance_) \
{ \
+ Object *instance_; \
/* temporary solution, waiting for depsgraph update */ \
BKE_scene_layer_engine_settings_update(sl); \
\
/* flush all the data to objects*/ \
Base *base_; \
- for (base_ = sl->object_bases.first; base_; base_ = base_->next) { \
- ob_ = base_->object; \
- ob_->base_flag = base_->flag;
+ for (base_ = (sl_)->object_bases.first; base_; base_ = base_->next) { \
+ instance_ = base_->object; \
+ instance_->base_flag = base_->flag;
#define DEG_OBJECT_ITER_END \
} \
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 289586153ea..100cbf2dd45 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -214,7 +214,6 @@ void BKE_collection_object_add(Scene *scene, SceneCollection *sc, Object *ob)
*/
void BKE_collection_object_add_from(Scene *scene, Object *ob_src, Object *ob_dst)
{
- SceneCollection *sc;
FOREACH_SCENE_COLLECTION(scene, sc)
{
if (BLI_findptr(&sc->objects, ob_src, offsetof(LinkData, data))) {
@@ -257,7 +256,6 @@ void BKE_collections_object_remove(Main *bmain, Scene *scene, Object *ob, const
{
BKE_scene_remove_rigidbody_object(scene, ob);
- SceneCollection *sc;
FOREACH_SCENE_COLLECTION(scene, sc)
{
BKE_collection_object_remove(bmain, scene, sc, ob, free_us);
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index a071b3202be..c9853f791ce 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -416,7 +416,6 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
CALLBACK_INVOKE(legacy_base->object, IDWALK_CB_USER);
}
- SceneCollection *sc;
FOREACH_SCENE_COLLECTION(scene, sc)
{
for (LinkData *link = sc->objects.first; link; link = link->next) {
diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 9946d1cc81f..76af032c37f 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -289,7 +289,6 @@ static void libblock_remap_data_preprocess(IDRemap *r_id_remap_data)
/* In case we are unlinking... */
if (!r_id_remap_data->old_id) {
/* ... everything from scene. */
- Object *ob_iter;
FOREACH_SCENE_OBJECT(sce, ob_iter)
{
libblock_remap_data_preprocess_scene_object_unlink(
diff --git a/source/blender/blenlib/BLI_iterator.h b/source/blender/blenlib/BLI_iterator.h
index d154b81ac82..26d2728d432 100644
--- a/source/blender/blenlib/BLI_iterator.h
+++ b/source/blender/blenlib/BLI_iterator.h
@@ -36,15 +36,16 @@ typedef struct Iterator {
typedef void (*IteratorCb)(Iterator *iter);
typedef void (*IteratorBeginCb)(Iterator *iter, void *data_in);
-#define ITER_BEGIN(callback_begin, callback_next, callback_end, _data_in, _type, _data_out) \
+#define ITER_BEGIN(callback_begin, callback_next, callback_end, _data_in, _type, _instance) \
{ \
+ _type _instance; \
IteratorCb callback_end_func = callback_end; \
Iterator iter_macro; \
- for (callback_begin(&iter_macro, _data_in); \
+ for (callback_begin(&iter_macro, (_data_in)); \
iter_macro.valid; \
callback_next(&iter_macro)) \
{ \
- _data_out = (_type *) iter_macro.current;
+ _instance = (_type ) iter_macro.current;
#define ITER_END \
} \
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
index c7e8edb122e..f4a191067ca 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc
@@ -80,7 +80,6 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
}
/* scene objects */
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
/* object itself */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
index 2f49d5b1645..f0d70e3871b 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc
@@ -75,7 +75,6 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
}
/* scene objects */
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
/* object itself */
diff --git a/source/blender/draw/engines/clay/clay.c b/source/blender/draw/engines/clay/clay.c
index 31a63cce120..779fd1a6a1d 100644
--- a/source/blender/draw/engines/clay/clay.c
+++ b/source/blender/draw/engines/clay/clay.c
@@ -622,7 +622,6 @@ static void CLAY_create_cache(CLAY_PassList *passes, CLAY_StorageList *stl, cons
}
/* TODO Create hash table of batch based on material id*/
- Object *ob;
DEG_OBJECT_ITER(sl, ob);
{
if ((ob->base_flag & BASE_VISIBLED) == 0) {
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index e7223f6f1ee..97db8458d08 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1876,7 +1876,6 @@ static int convert_exec(bContext *C, wmOperator *op)
if (!keep_original) {
if (mballConverted) {
- Object *ob_mball;
FOREACH_SCENE_OBJECT(scene, ob_mball)
{
if (ob->type == OB_MBALL) {
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index c79c702837a..10439d49787 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1728,7 +1728,6 @@ static void single_object_users(Main *bmain, Scene *scene, View3D *v3d, const in
* button can be functional.*/
void ED_object_single_user(Main *bmain, Scene *scene, Object *ob)
{
- Object *ob_iter;
FOREACH_SCENE_OBJECT(scene, ob_iter)
{
ob_iter->flag &= ~OB_DONE;
@@ -1855,8 +1854,6 @@ static void single_obdata_users(Main *bmain, Scene *scene, const int flag)
static void single_object_action_users(Scene *scene, SceneLayer *sl, const int flag)
{
- Object *ob;
-
FOREACH_OBJECT_FLAG(scene, sl, flag, ob)
if (!ID_IS_LINKED_DATABLOCK(ob)) {
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
@@ -1871,7 +1868,6 @@ static void single_mat_users(Main *bmain, Scene *scene, SceneLayer *sl, const in
Tex *tex;
int a, b;
- Object *ob;
FOREACH_OBJECT_FLAG(scene, sl, flag, ob)
if (!ID_IS_LINKED_DATABLOCK(ob)) {
for (a = 1; a <= ob->totcol; a++) {
diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c
index c82a210725c..0448fba78e6 100644
--- a/source/blender/editors/screen/screen_context.c
+++ b/source/blender/editors/screen/screen_context.c
@@ -97,7 +97,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "visible_objects")) {
- Object *ob;
FOREACH_VISIBLE_OBJECT(sl, ob)
{
CTX_data_id_list_add(result, &ob->id);
@@ -116,7 +115,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_objects")) {
- Object *ob;
FOREACH_SELECTED_OBJECT(sl, ob)
{
CTX_data_id_list_add(result, &ob->id);
@@ -126,7 +124,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if (CTX_data_equals(member, "selected_editable_objects")) {
- Object *ob;
FOREACH_SELECTED_OBJECT(sl, ob)
{
if (0 == BKE_object_is_libdata(ob)) {
@@ -139,7 +136,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
}
else if (CTX_data_equals(member, "editable_objects")) {
/* Visible + Editable, but not necessarily selected */
- Object *ob;
FOREACH_VISIBLE_OBJECT(sl, ob)
{
if (0 == BKE_object_is_libdata(ob)) {
@@ -151,7 +147,6 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
return 1;
}
else if ( CTX_data_equals(member, "visible_bases")) {
- Base *base;
FOREACH_VISIBLE_BASE(sl, base)
{
CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base);
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 12b97504dc7..7b44e9317ba 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -70,7 +70,6 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip)
return camera;
}
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
if (ob->type == OB_CAMERA) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index d296a54d5d4..1ba33970aad 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1724,7 +1724,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
if (sce == scene && show_opened)
tselem->flag &= ~TSE_CLOSED;
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
ten = outliner_add_element(soops, &te->subtree, ob, te, 0, 0);
@@ -1745,7 +1744,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
outliner_add_scene_contents(soops, &soops->tree, scene, NULL);
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
ten = outliner_add_element(soops, &soops->tree, ob, NULL, 0, 0);
@@ -1754,7 +1752,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
outliner_make_hierarchy(&soops->tree);
}
else if (soops->outlinevis == SO_VISIBLE) {
- Object *ob;
FOREACH_VISIBLE_OBJECT(sl, ob)
{
outliner_add_element(soops, &soops->tree, ob, NULL, 0, 0);
@@ -1782,7 +1779,6 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
else if (soops->outlinevis == SO_SAME_TYPE) {
Object *ob_active = OBACT_NEW;
if (ob_active) {
- Object *ob;
FOREACH_SCENE_OBJECT(scene, ob)
{
if (ob->type == ob_active->type) {
@@ -1794,10 +1790,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SceneLayer *sl, SpaceOops
}
}
else if (soops->outlinevis == SO_SELECTED) {
- Object *ob;
FOREACH_SELECTED_OBJECT(sl, ob)
{
- ten = outliner_add_element(soops, &soops->tree, ob, NULL, 0, 0);
+ ten = outliner_add_element(soops, &soops->tree, ob, NULL, 0, 0);
}
FOREACH_SELECTED_OBJECT_END
outliner_make_hierarchy(&soops->tree);