[Bf-blender-cvs] [1e801df3ef1] temp-lanpr-review: LANPR: Use pointer to save collection LANPR config.
YimingWu
noreply at git.blender.org
Wed Nov 27 14:11:20 CET 2019
Commit: 1e801df3ef1f4663bef1833ba1809f2f182e7be5
Author: YimingWu
Date: Wed Nov 27 21:10:38 2019 +0800
Branches: temp-lanpr-review
https://developer.blender.org/rB1e801df3ef1f4663bef1833ba1809f2f182e7be5
LANPR: Use pointer to save collection LANPR config.
===================================================================
M release/scripts/startup/bl_ui/properties_collection.py
M source/blender/blenkernel/intern/collection.c
M source/blender/blenkernel/intern/library_query.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/lanpr/lanpr_cpu.c
M source/blender/makesdna/DNA_collection_types.h
M source/blender/makesrna/intern/rna_collection.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index 8b99af8a33e..d3f68e1a712 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -69,11 +69,19 @@ class COLLECTION_PT_lanpr_collection(CollectionButtonsPanel, Panel):
def poll(cls, context):
return context.scene.render.engine == 'BLENDER_LANPR' or context.scene.lanpr.enabled
+ def draw_header(self, context):
+ layout = self.layout
+ collection = context.collection
+ layout.prop(collection, "configure_lanpr", text="")
+
def draw(self,context):
layout = self.layout
layout.use_property_split = True
layout.use_property_decorate = False
collection = context.collection
+ if not collection.configure_lanpr:
+ return
+
lanpr = collection.lanpr
row = layout.row()
row.prop(lanpr,"usage")
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 68a38c94ff7..398894d24b1 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -125,6 +125,12 @@ void BKE_collection_free(Collection *collection)
BLI_freelistN(&collection->parents);
BKE_collection_object_cache_free(collection);
+
+ /* Remove LANPR configurations */
+ if(collection->lanpr){
+ MEM_freeN(collection->lanpr);
+ collection->lanpr = NULL;
+ }
}
/**
@@ -227,6 +233,13 @@ void BKE_collection_copy_data(Main *bmain,
for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) {
collection_object_add(bmain, collection_dst, cob->ob, flag, false);
}
+
+ /* Copy LANPR configurations */
+ if((collection_src->lanpr != NULL) && (collection_dst->lanpr == NULL)){
+ CollectionLANPR* lanpr = MEM_callocN(sizeof(CollectionLANPR), "Duplicated CollectionLANPR");
+ collection_dst->lanpr = lanpr;
+ }
+ memcpy(collection_dst->lanpr, collection_src->lanpr, sizeof(CollectionLANPR));
}
static Collection *collection_duplicate_recursive(Main *bmain,
@@ -366,6 +379,13 @@ Collection *BKE_collection_duplicate(Main *bmain,
BKE_main_collection_sync(bmain);
+ /* Copy LANPR configurations */
+ if((collection->lanpr != NULL) && (collection_new->lanpr == NULL)){
+ CollectionLANPR* lanpr = MEM_callocN(sizeof(CollectionLANPR), "Duplicated CollectionLANPR");
+ collection_new->lanpr = lanpr;
+ }
+ memcpy(collection_new->lanpr, collection->lanpr, sizeof(CollectionLANPR));
+
return collection_new;
}
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index c36d5b27b54..c0bd6e05c44 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -493,7 +493,9 @@ static void library_foreach_ID_link(Main *bmain,
CALLBACK_INVOKE(child->collection, IDWALK_CB_USER);
}
- CALLBACK_INVOKE(scene->master_collection->lanpr.target, IDWALK_CB_USER);
+ if(scene->master_collection->lanpr){
+ CALLBACK_INVOKE(scene->master_collection->lanpr->target, IDWALK_CB_USER);
+ }
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 265e8851347..e6675dd7f60 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6277,7 +6277,10 @@ static void lib_link_collection_data(FileData *fd, Library *lib, Collection *col
child->collection = newlibadr_us(fd, lib, child->collection);
}
- collection->lanpr.target = newlibadr_us(fd, lib, collection->lanpr.target);
+ collection->lanpr = newdataadr(fd,collection->lanpr);
+ if(collection->lanpr){
+ collection->lanpr->target = newlibadr_us(fd, lib, collection->lanpr->target);
+ }
BKE_collection_parent_relations_rebuild(collection);
}
@@ -10447,7 +10450,7 @@ static void expand_collection(FileData *fd, Main *mainvar, Collection *collectio
expand_doit(fd, mainvar, child->collection);
}
- expand_doit(fd, mainvar, collection->lanpr.target);
+ expand_doit(fd, mainvar, collection->lanpr->target);
#ifdef USE_COLLECTION_COMPAT_28
if (collection->collection != NULL) {
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 11e7e227d7c..191fc81b190 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3979,13 +3979,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
if (!DNA_struct_find(fd->filesdna, "SceneLANPR")) {
- for (Collection *co = bmain->collections.first; co; co = co->id.next) {
- co->lanpr.contour.use = 1;
- co->lanpr.crease.use = 1;
- co->lanpr.material.use = 1;
- co->lanpr.edge_mark.use = 1;
- co->lanpr.intersection.use = 1;
- }
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
scene->lanpr.crease_threshold = 0.7;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8a8bd8836ad..84c2220958d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2383,6 +2383,10 @@ static void write_collection_nolib(WriteData *wd, Collection *collection)
for (CollectionChild *child = collection->children.first; child; child = child->next) {
writestruct(wd, DATA, CollectionChild, 1, child);
}
+
+ if(collection->flag & COLLECTION_CONFIGURED_FOR_LANPR){
+ writestruct(wd, DATA, CollectionLANPR, 1, collection->lanpr);
+ }
}
static void write_collection(WriteData *wd, Collection *collection)
diff --git a/source/blender/editors/lanpr/lanpr_cpu.c b/source/blender/editors/lanpr/lanpr_cpu.c
index 659f283b950..6beccb11594 100644
--- a/source/blender/editors/lanpr/lanpr_cpu.c
+++ b/source/blender/editors/lanpr/lanpr_cpu.c
@@ -1765,13 +1765,14 @@ int ED_lanpr_object_collection_usage_check(Collection *c, Object *o)
int object_is_used = (o->lanpr.usage == OBJECT_FEATURE_LINE_INCLUDE ||
o->lanpr.usage == OBJECT_FEATURE_LINE_INHERENT);
- if (object_is_used && (c->lanpr.flags & LANPR_LINE_LAYER_COLLECTION_FORCE) &&
- c->lanpr.usage != COLLECTION_FEATURE_LINE_INCLUDE) {
+ if (object_is_used && (c->flag & COLLECTION_CONFIGURED_FOR_LANPR) &&
+ (c->lanpr->flags & LANPR_LINE_LAYER_COLLECTION_FORCE) &&
+ (c->lanpr->usage != COLLECTION_FEATURE_LINE_INCLUDE)) {
if (BKE_collection_has_object_recursive(c, o)) {
- if (c->lanpr.usage == COLLECTION_FEATURE_LINE_EXCLUDE) {
+ if (c->lanpr->usage == COLLECTION_FEATURE_LINE_EXCLUDE) {
return OBJECT_FEATURE_LINE_EXCLUDE;
}
- else if (c->lanpr.usage == COLLECTION_FEATURE_LINE_OCCLUSION_ONLY) {
+ else if (c->lanpr->usage == COLLECTION_FEATURE_LINE_OCCLUSION_ONLY) {
return OBJECT_FEATURE_LINE_OCCLUSION_ONLY;
}
}
@@ -1780,10 +1781,10 @@ int ED_lanpr_object_collection_usage_check(Collection *c, Object *o)
if (c->children.first == NULL) {
if (BKE_collection_has_object(c, o)) {
if (o->lanpr.usage == OBJECT_FEATURE_LINE_INHERENT) {
- if (c->lanpr.usage == COLLECTION_FEATURE_LINE_OCCLUSION_ONLY) {
+ if ((c->flag & COLLECTION_CONFIGURED_FOR_LANPR) && (c->lanpr->usage == COLLECTION_FEATURE_LINE_OCCLUSION_ONLY)) {
return OBJECT_FEATURE_LINE_OCCLUSION_ONLY;
}
- else if (c->lanpr.usage == COLLECTION_FEATURE_LINE_EXCLUDE) {
+ else if ((c->flag & COLLECTION_CONFIGURED_FOR_LANPR) &&(c->lanpr->usage == COLLECTION_FEATURE_LINE_EXCLUDE)) {
return OBJECT_FEATURE_LINE_EXCLUDE;
}
else {
@@ -2684,11 +2685,15 @@ static int lanpr_max_occlusion_in_collections(Collection *c)
CollectionChild *cc;
int max_occ = 0;
int max;
- if (c->lanpr.flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) {
- max = MAX2(c->lanpr.level_start, c->lanpr.level_end);
+ if(!(c->flag & COLLECTION_CONFIGURED_FOR_LANPR)){
+ return 0;
+ }
+
+ if (c->lanpr->flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) {
+ max = MAX2(c->lanpr->level_start, c->lanpr->level_end);
}
else {
- max = c->lanpr.level_start;
+ max = c->lanpr->level_start;
}
max_occ = MAX2(max, max_occ);
@@ -4232,98 +4237,97 @@ static void lanpr_update_gp_strokes_collection(
}
}
- if (col->lanpr.usage != COLLECTION_FEATURE_LINE_INCLUDE || !col->lanpr.target) {
- return;
- }
-
- gpobj = col->lanpr.target;
-
- if (target_only && target_only != gpobj) {
- return;
- }
-
- CollectionLANPR *cl = &col->lanpr;
- int level_start = cl->level_start;
- int level_end = (cl->flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) ? cl->level_end :
- cl->level_start;
+ if(col->flag & COLLECTION_CONFIGURED_FOR_LANPR){
+ if (col->lanpr->usage != COLLECTION_FEATURE_LINE_INCLUDE || !col->lanpr->target) {
+ return;
+ }
+ gpobj = col->lanpr->target;
+ if (target_only && target_only != gpobj) {
+ return;
+ }
+ CollectionLANPR *cl = &col->lanpr;
+ int level_start = cl->level_start;
+ int level_end = (cl->flags & LANPR_LINE_LAYER_USE_MULTIPLE_LEVELS) ? cl->level_end :
+ cl->level_start;
- if (cl->flags & LANPR_LINE_LAYER_USE_SAME_STYLE) {
- lanpr_update_gp_strokes_single(dg,
- gpobj,
- NULL,
- frame,
- level_start,
- level_end,
- cl->target_layer,
- cl->target_material,
- col,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list