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

BKE_layer.h « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 184f7b9afc5357a40621cdb38f84d4b53c555916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * Contributor(s): Dalai Felinto
 *
 * ***** END GPL LICENSE BLOCK *****
 */

#ifndef __BKE_LAYER_H__
#define __BKE_LAYER_H__

/** \file blender/blenkernel/BKE_layer.h
 *  \ingroup bke
 */

#include "BKE_collection.h"

#ifdef __cplusplus
extern "C" {
#endif

#define TODO_LAYER_SYNC /* syncing of SceneCollection and LayerCollection trees*/
#define TODO_LAYER_SYNC_FILTER /* syncing of filter_objects across all trees */
#define TODO_LAYER_OVERRIDE /* CollectionOverride */
#define TODO_LAYER_CONTEXT /* get/set current (context) SceneLayer */
#define TODO_LAYER_BASE /* Base to ObjectBase related TODO */
#define TODO_LAYER_OPERATORS /* collection mamanger and property panel operators */
#define TODO_LAYER /* generic todo */

struct CollectionEngineSettings;
struct LayerCollection;
struct ID;
struct ListBase;
struct Main;
struct Object;
struct ObjectBase;
struct RenderEngine;
struct Scene;
struct SceneCollection;
struct SceneLayer;

struct SceneLayer *BKE_scene_layer_add(struct Scene *scene, const char *name);

bool BKE_scene_layer_remove(struct Main *bmain, struct Scene *scene, struct SceneLayer *sl);

void BKE_scene_layer_free(struct SceneLayer *sl);

void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine);

void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag);

struct SceneLayer *BKE_scene_layer_find_from_collection(struct Scene *scene, struct LayerCollection *lc);
struct ObjectBase *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob);
void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl);
void BKE_scene_layer_base_select(struct SceneLayer *sl, struct ObjectBase *selbase);
void BKE_scene_layer_base_flag_recalculate(struct SceneLayer *sl);

void BKE_layer_collection_free(struct SceneLayer *sl, struct LayerCollection *lc);

struct LayerCollection *BKE_layer_collection_active(struct SceneLayer *sl);

int BKE_layer_collection_count(struct SceneLayer *sl);

int BKE_layer_collection_findindex(struct SceneLayer *sl, struct LayerCollection *lc);

struct LayerCollection *BKE_collection_link(struct SceneLayer *sl, struct SceneCollection *sc);

void BKE_collection_unlink(struct SceneLayer *sl, struct LayerCollection *lc);

bool BKE_scene_layer_has_collection(struct SceneLayer *sl, struct SceneCollection *sc);
bool BKE_scene_has_object(struct Scene *scene, struct Object *ob);

/* syncing */

void BKE_layer_sync_new_scene_collection(struct Scene *scene, const struct SceneCollection *sc_parent, struct SceneCollection *sc);
void BKE_layer_sync_object_link(struct Scene *scene, struct SceneCollection *sc, struct Object *ob);
void BKE_layer_sync_object_unlink(struct Scene *scene, struct SceneCollection *sc, struct Object *ob);

/* override */

void BKE_collection_override_datablock_add(struct LayerCollection *lc, const char *data_path, struct ID *id);

/* engine settings */
typedef void (*CollectionEngineSettingsCB)(struct RenderEngine *engine, struct CollectionEngineSettings *ces);
struct CollectionEngineSettings *BKE_layer_collection_engine_get(struct LayerCollection *lc, const char *engine_name);
void BKE_layer_collection_engine_settings_callback_register(struct Main *bmain, const char *engine_name, CollectionEngineSettingsCB func);
void BKE_layer_collection_engine_settings_callback_free(void);
void BKE_layer_collection_engine_settings_create(struct ListBase *lb, const char *engine_name);
void BKE_layer_collection_engine_settings_free(struct ListBase *lb);

void BKE_collection_engine_property_add_float(struct CollectionEngineSettings *ces, const char *name, float value);
void BKE_collection_engine_property_add_int(struct CollectionEngineSettings *ces, const char *name, int value);
struct CollectionEngineProperty *BKE_collection_engine_property_get(struct CollectionEngineSettings *ces, const char *name);
int BKE_collection_engine_property_value_get_int(struct CollectionEngineSettings *ces, const char *name);
int BKE_collection_engine_property_value_get_float(struct CollectionEngineSettings *ces, const char *name);
void BKE_collection_engine_property_value_set_int(struct CollectionEngineSettings *ces, const char *name, int value);
void BKE_collection_engine_property_value_set_float(struct CollectionEngineSettings *ces, const char *name, float value);

/* iterators */

void BKE_selected_objects_Iterator_begin(Iterator *iter, void *data_in);
void BKE_selected_objects_Iterator_next(Iterator *iter);
void BKE_selected_objects_Iterator_end(Iterator *iter);

void BKE_visible_objects_Iterator_begin(Iterator *iter, void *data_in);
void BKE_visible_objects_Iterator_next(Iterator *iter);
void BKE_visible_objects_Iterator_end(Iterator *iter);

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)                                      \
	ITER_BEGIN(BKE_selected_objects_Iterator_begin,                           \
	           BKE_selected_objects_Iterator_next,                            \
	           BKE_selected_objects_Iterator_end,                             \
	           sl, _ob)

#define FOREACH_SELECTED_OBJECT_END                                           \
	ITER_END

#define FOREACH_VISIBLE_OBJECT(sl, _ob)                                       \
	ITER_BEGIN(BKE_visible_objects_Iterator_begin,                            \
	           BKE_visible_objects_Iterator_next,                             \
	           BKE_visible_objects_Iterator_end,                              \
	           sl, _ob)

#define FOREACH_VISIBLE_OBJECT_END                                            \
	ITER_END


#define FOREACH_VISIBLE_BASE(sl, _object_base)                                \
	ITER_BEGIN(BKE_visible_bases_Iterator_begin,                              \
	           BKE_visible_bases_Iterator_next,                               \
	           BKE_visible_bases_Iterator_end,                                \
	           sl, _object_base)

#define FOREACH_VISIBLE_BASE_END                                              \
	ITER_END


#define FOREACH_OBJECT(sl, _ob)                                               \
{                                                                             \
	ObjectBase *base;                                                         \
	for (base = sl->object_bases.first; base; base = base->next) {            \
	    _ob = base->object;

#define FOREACH_OBJECT_END                                                    \
    }                                                                         \
}

#define FOREACH_OBJECT_FLAG(scene, sl, flag, _ob)                             \
{                                                                             \
	IteratorBeginCb func_begin;                                               \
	IteratorCb func_next, func_end;                                           \
	void *data_in;                                                            \
	                                                                          \
	if (flag == SELECT) {                                                     \
	    func_begin = &BKE_selected_objects_Iterator_begin;                    \
	    func_next = &BKE_selected_objects_Iterator_next;                      \
	    func_end = &BKE_selected_objects_Iterator_end;                        \
	    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;                                                      \
    }                                                                         \
	ITER_BEGIN(func_begin, func_next, func_end, data_in, _ob)


#define FOREACH_OBJECT_FLAG_END                                               \
	ITER_END                                                                  \
}

/* temporary hacky solution waiting for final depsgraph evaluation */
#define DEG_OBJECT_ITER(sl_, ob_)                                             \
{                                                                             \
	/* flush all the data to objects*/                                        \
	ObjectBase *base_;					                                      \
	for (base_ = sl->object_bases.first; base_; base_ = base_->next) {        \
	    ob_ = base_->object;			                                      \
	    ob_->base_flag = base_->flag;

#define DEG_OBJECT_ITER_END                                                   \
    }                                                                         \
}

#ifdef __cplusplus
}
#endif

#endif /* __BKE_LAYER_H__ */