Commit: 1e7a51daa6b0295656b170265ffdf0223868956c
Author: YimingWu
Date: Thu Aug 13 23:10:56 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rB1e7a51daa6b0295656b170265ffdf0223868956c
LineArt: Linked files now support collection-in-collection type of linking.
===================================================================
M source/blender/blenkernel/BKE_collection.h
M source/blender/blenkernel/intern/collection.c
M source/blender/editors/lineart/lineart_cpu.c
M source/blender/makesdna/DNA_collection_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_collection.h
b/source/blender/blenkernel/BKE_collection.h
index f4393742dff..37585939a0d 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -78,6 +78,8 @@ struct Scene *BKE_collection_master_scene_search(const struct
Main *bmain,
bool BKE_collection_has_object(struct Collection *collection, const struct
Object *ob);
bool BKE_collection_has_object_recursive(struct Collection *collection, struct
Object *ob);
+bool BKE_collection_has_object_recursive_instanced(struct Collection
*collection,
+ struct Object *ob);
struct Collection *BKE_collection_object_find(struct Main *bmain,
struct Scene *scene,
struct Collection *collection,
@@ -119,6 +121,7 @@ bool BKE_collection_object_cyclic_check(struct Main *bmain,
/* Object list cache. */
struct ListBase BKE_collection_object_cache_get(struct Collection *collection);
+ListBase BKE_collection_object_cache_instanced_get(struct Collection
*collection);
void BKE_collection_object_cache_free(struct Collection *collection);
struct Base *BKE_collection_or_layer_objects(const struct ViewLayer
*view_layer,
diff --git a/source/blender/blenkernel/intern/collection.c
b/source/blender/blenkernel/intern/collection.c
index 0d65ee5faa3..694bb068717 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -550,7 +550,10 @@ const char *BKE_collection_ui_name_get(struct Collection
*collection)
/** \name Object List Cache
* \{ */
-static void collection_object_cache_fill(ListBase *lb, Collection *collection,
int parent_restrict)
+static void collection_object_cache_fill(ListBase *lb,
+ Collection *collection,
+ int parent_restrict,
+ bool with_instances)
{
int child_restrict = collection->flag | parent_restrict;
@@ -561,6 +564,10 @@ static void collection_object_cache_fill(ListBase *lb,
Collection *collection, i
base = MEM_callocN(sizeof(Base), "Object Base");
base->object = cob->ob;
BLI_addtail(lb, base);
+ if (with_instances && cob->ob->instance_collection) {
+ collection_object_cache_fill(
+ lb, cob->ob->instance_collection, child_restrict, with_instances);
+ }
}
/* Only collection flags are checked here currently, object restrict flag
is checked
@@ -575,7 +582,7 @@ static void collection_object_cache_fill(ListBase *lb,
Collection *collection, i
}
LISTBASE_FOREACH (CollectionChild *, child, &collection->children) {
- collection_object_cache_fill(lb, child->collection, child_restrict);
+ collection_object_cache_fill(lb, child->collection, child_restrict,
with_instances);
}
}
@@ -586,7 +593,7 @@ ListBase BKE_collection_object_cache_get(Collection
*collection)
BLI_mutex_lock(&cache_lock);
if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
- collection_object_cache_fill(&collection->object_cache, collection, 0);
+ collection_object_cache_fill(&collection->object_cache, collection, 0,
false);
collection->flag |= COLLECTION_HAS_OBJECT_CACHE;
}
BLI_mutex_unlock(&cache_lock);
@@ -595,11 +602,29 @@ ListBase BKE_collection_object_cache_get(Collection
*collection)
return collection->object_cache;
}
+ListBase BKE_collection_object_cache_instanced_get(Collection *collection)
+{
+ if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
+ static ThreadMutex cache_lock = BLI_MUTEX_INITIALIZER;
+
+ BLI_mutex_lock(&cache_lock);
+ if (!(collection->flag & COLLECTION_HAS_OBJECT_CACHE)) {
+ collection_object_cache_fill(&collection->object_cache_instanced,
collection, 0, true);
+ collection->flag |= COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
+ }
+ BLI_mutex_unlock(&cache_lock);
+ }
+
+ return collection->object_cache_instanced;
+}
+
static void collection_object_cache_free(Collection *collection)
{
/* Clear own cache an for all parents, since those are affected by changes
as well. */
collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ collection->flag &= ~COLLECTION_HAS_OBJECT_CACHE_INSTANCED;
BLI_freelistN(&collection->object_cache);
+ BLI_freelistN(&collection->object_cache_instanced);
LISTBASE_FOREACH (CollectionParent *, parent, &collection->parents) {
collection_object_cache_free(parent->collection);
@@ -717,6 +742,16 @@ bool BKE_collection_has_object_recursive(Collection
*collection, Object *ob)
return (BLI_findptr(&objects, ob, offsetof(Base, object)));
}
+bool BKE_collection_has_object_recursive_instanced(Collection *collection,
Object *ob)
+{
+ if (ELEM(NULL, collection, ob)) {
+ return false;
+ }
+
+ const ListBase objects =
BKE_collection_object_cache_instanced_get(collection);
+ return (BLI_findptr(&objects, ob, offsetof(Base, object)));
+}
+
static Collection *collection_next_find(Main *bmain, Scene *scene, Collection
*collection)
{
if (scene && collection == scene->master_collection) {
diff --git a/source/blender/editors/lineart/lineart_cpu.c
b/source/blender/editors/lineart/lineart_cpu.c
index d5dc7b215ee..2546b12854f 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -3668,7 +3668,7 @@ void ED_lineart_gpencil_generate_from_chain(Depsgraph
*UNUSED(depsgraph),
continue;
}
if (orig_col && rlc->object_ref) {
- if (!BKE_collection_has_object_recursive(orig_col, (Object
*)rlc->object_ref)) {
+ if (!BKE_collection_has_object_recursive_instanced(orig_col, (Object
*)rlc->object_ref)) {
continue;
}
}
diff --git a/source/blender/makesdna/DNA_collection_types.h
b/source/blender/makesdna/DNA_collection_types.h
index c7267688924..d32f3cb2fd1 100644
--- a/source/blender/makesdna/DNA_collection_types.h
+++ b/source/blender/makesdna/DNA_collection_types.h
@@ -77,6 +77,9 @@ typedef struct Collection {
* collections due to memory usage reasons. */
ListBase object_cache;
+ /* Need this for line art sub-collection selections. */
+ ListBase object_cache_instanced;
+
/* Runtime. List of collections that are a parent of this
* datablock. */
ListBase parents;
@@ -94,6 +97,7 @@ enum {
COLLECTION_RESTRICT_RENDER = (1 << 3), /* Disable in renders. */
COLLECTION_HAS_OBJECT_CACHE = (1 << 4), /* Runtime: object_cache is
populated. */
COLLECTION_IS_MASTER = (1 << 5), /* Is master collection embedded in the
scene. */
+ COLLECTION_HAS_OBJECT_CACHE_INSTANCED = (1 << 4), /* for
object_cache_instanced. */
};
/* Collection->tag */
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs