Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/collection.c
| Show First 20 Lines • Show All 1,119 Lines • ▼ Show 20 Lines | void BKE_collection_object_move( | ||||
| else { | else { | ||||
| /* Adding will fail if object is already in collection. | /* Adding will fail if object is already in collection. | ||||
| * However we still need to remove it from the other collections. */ | * However we still need to remove it from the other collections. */ | ||||
| BKE_collection_object_add(bmain, collection_dst, ob); | BKE_collection_object_add(bmain, collection_dst, ob); | ||||
| scene_collections_object_remove(bmain, scene, ob, false, collection_dst); | scene_collections_object_remove(bmain, scene, ob, false, collection_dst); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Move object within a collection after specified object. | |||||
| * | |||||
| * For outliner drag & drop. | |||||
| */ | |||||
| void BKE_collection_object_move_after(Main *bmain, | |||||
| Collection *collection, | |||||
| Object *ob_relative, | |||||
| Object *ob) | |||||
| { | |||||
| if (ELEM(NULL, collection, ob_relative, ob)) { | |||||
| return; | |||||
| } | |||||
| CollectionObject *relative = BLI_findptr( | |||||
| &collection->gobject, ob_relative, offsetof(CollectionObject, ob)); | |||||
| if (!relative) { | |||||
| return; | |||||
| } | |||||
| int index_to = BLI_findindex(&collection->gobject, relative); | |||||
| CollectionObject *object = BLI_findptr(&collection->gobject, ob, offsetof(CollectionObject, ob)); | |||||
| if (!object) { | |||||
| return; | |||||
| } | |||||
| int index_from = BLI_findindex(&collection->gobject, object); | |||||
| BLI_listbase_move_index(&collection->gobject, index_from, index_to); | |||||
| BKE_main_collection_sync(bmain); | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Collection Scene Membership | /** \name Collection Scene Membership | ||||
| * \{ */ | * \{ */ | ||||
| bool BKE_collection_is_in_scene(Collection *collection) | bool BKE_collection_is_in_scene(Collection *collection) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 683 Lines • Show Last 20 Lines | |||||