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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
} \
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 \
|
||||
} \
|
||||
|
||||
@@ -80,7 +80,6 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
|
||||
}
|
||||
|
||||
/* scene objects */
|
||||
Object *ob;
|
||||
FOREACH_SCENE_OBJECT(scene, ob)
|
||||
{
|
||||
/* object itself */
|
||||
|
||||
@@ -75,7 +75,6 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
|
||||
}
|
||||
|
||||
/* scene objects */
|
||||
Object *ob;
|
||||
FOREACH_SCENE_OBJECT(scene, ob)
|
||||
{
|
||||
/* object itself */
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user