31 if (object->light_linking->receiver_collection ==
nullptr &&
32 object->light_linking->blocker_collection ==
nullptr)
41 if (!object->light_linking) {
47 return object->light_linking->receiver_collection;
49 return object->light_linking->blocker_collection;
85 return new_collection;
99 if (new_collection && !object->light_linking) {
100 object->light_linking = MEM_cnew<LightLinking>(__func__);
103 if (object->light_linking) {
107 object->light_linking->receiver_collection = new_collection;
110 object->light_linking->blocker_collection = new_collection;
117 if (new_collection) {
139 if (collection_object->ob ==
object) {
140 return collection_object;
151 if (collection_child->collection == child) {
152 return collection_child;
172 if (!collection_object) {
173 BLI_assert_msg(0,
"Object was not found after added to the light linking collection");
193 if (!collection_child) {
194 BLI_assert_msg(0,
"Collection was not found after added to the light linking collection");
210 if (id_type ==
ID_OB) {
217 else if (id_type ==
ID_GR) {
219 bmain, collection,
reinterpret_cast<Collection *
>(receiver));
225 if (!collection_light_linking) {
229 collection_light_linking->
link_state = link_state;
242 if (!receiver_collection_child) {
243 BLI_assert_msg(0,
"Receiver child was not found after adding collection to light linking");
247 const ID_Type before_id_type =
GS(before->name);
249 if (before_id_type !=
ID_GR) {
253 BLI_remlink(&collection->children, receiver_collection_child);
254 BLI_addtail(&collection->children, receiver_collection_child);
259 collection,
reinterpret_cast<const Collection *
>(before));
260 if (!before_collection_child) {
265 BLI_remlink(&collection->children, receiver_collection_child);
266 BLI_insertlinkbefore(&collection->children, before_collection_child, receiver_collection_child);
274 if (!receiver_collection_child) {
275 BLI_assert_msg(0,
"Receiver child was not found after adding collection to light linking");
281 if (after_id_type !=
ID_GR) {
285 BLI_remlink(&collection->children, receiver_collection_child);
286 BLI_addtail(&collection->children, receiver_collection_child);
291 collection,
reinterpret_cast<const Collection *
>(after));
292 if (!after_collection_child) {
297 BLI_remlink(&collection->children, receiver_collection_child);
298 BLI_insertlinkafter(&collection->children, after_collection_child, receiver_collection_child);
306 if (!receiver_collection_object) {
308 0,
"Receiver collection object was not found after adding collection to light linking");
312 const ID_Type before_id_type =
GS(before->name);
314 if (before_id_type !=
ID_OB) {
318 BLI_remlink(&collection->gobject, receiver_collection_object);
319 BLI_addhead(&collection->gobject, receiver_collection_object);
324 collection,
reinterpret_cast<const Object *
>(before));
325 if (!before_collection_object) {
330 BLI_remlink(&collection->gobject, receiver_collection_object);
331 BLI_insertlinkbefore(&collection->gobject, before_collection_object, receiver_collection_object);
337 if (!receiver_collection_object) {
339 0,
"Receiver collection object was not found after adding collection to light linking");
345 if (after_id_type !=
ID_OB) {
349 BLI_remlink(&collection->gobject, receiver_collection_object);
350 BLI_addhead(&collection->gobject, receiver_collection_object);
355 collection,
reinterpret_cast<const Object *
>(after));
356 if (!after_collection_object) {
361 BLI_remlink(&collection->gobject, receiver_collection_object);
362 BLI_insertlinkafter(&collection->gobject, after_collection_object, receiver_collection_object);
381 if (id_type ==
ID_OB) {
384 else if (id_type ==
ID_GR) {
405 if (id_type ==
ID_OB) {
408 else if (id_type ==
ID_GR) {
420 if (id_type ==
ID_OB) {
423 else if (id_type ==
ID_GR) {
429 "Cannot unlink unsupported '%s' from light linking collection '%s'",
431 collection->id.name + 2);
436 if (id_type ==
ID_OB) {
480 if (base->object == emitter) {
483 base->flag &= ~BASE_SELECTED;
bool BKE_collection_object_remove(Main *bmain, Collection *collection, Object *ob, bool free_us)
bool BKE_collection_child_remove(Main *bmain, Collection *parent, Collection *child)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
bool BKE_collection_child_add(Main *bmain, Collection *parent, Collection *child)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
#define SNPRINTF(dst, format,...)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
ID and Library types, which are fundamental for SDNA.
Object groups, one object can be in many groups at once.
eCollectionLightLinkingState
Object is a sort of wrapper for general info.
#define OB_TYPE_IS_GEOMETRY(_type)
#define BASE_SELECTED(v3d, base)
Read Guarded memory(de)allocation.
void BKE_light_linking_add_receiver_to_collection_before(Main *bmain, Collection *collection, ID *receiver, const ID *before, const eCollectionLightLinkingState link_state)
static CollectionObject * find_collection_object(const Collection *collection, const Object *object)
Collection * BKE_light_linking_collection_get(const Object *object, const LightLinkingType link_type)
static CollectionLightLinking * light_linking_collection_add_collection(Main *bmain, Collection *collection, Collection *child)
void BKE_light_linking_collection_assign_only(Object *object, Collection *new_collection, const LightLinkingType link_type)
void BKE_light_linking_free_if_empty(Object *object)
bool BKE_light_linking_unlink_id_from_collection(Main *bmain, Collection *collection, ID *id, ReportList *reports)
void BKE_light_linking_add_receiver_to_collection_after(Main *bmain, Collection *collection, ID *receiver, const ID *after, const eCollectionLightLinkingState link_state)
static void order_collection_receiver_before(Collection *collection, Collection *receiver, const ID *before)
static CollectionChild * find_collection_child(const Collection *collection, const Collection *child)
Collection * BKE_light_linking_collection_new(Main *bmain, Object *object, const LightLinkingType link_type)
static CollectionLightLinking * light_linking_collection_add_object(Main *bmain, Collection *collection, Object *object)
void BKE_light_linking_add_receiver_to_collection(Main *bmain, Collection *collection, ID *receiver, const eCollectionLightLinkingState link_state)
void BKE_light_linking_select_receivers_of_emitter(Scene *scene, ViewLayer *view_layer, Object *emitter, const LightLinkingType link_type)
static std::string get_default_collection_name(const Object *object, const LightLinkingType link_type)
static void order_object_receiver_before(Collection *collection, Object *receiver, const ID *before)
void BKE_light_linking_collection_assign(Main *bmain, Object *object, Collection *new_collection, const LightLinkingType link_type)
static void order_object_receiver_after(Collection *collection, Object *receiver, const ID *after)
static void order_collection_receiver_after(Collection *collection, Collection *receiver, const ID *after)
void BKE_light_linking_link_receiver_to_emitter(Main *bmain, Object *emitter, Object *receiver, const LightLinkingType link_type, const eCollectionLightLinkingState link_state)
CollectionLightLinking light_linking
CollectionLightLinking light_linking