[Bf-blender-cvs] [4c41f8e9ad3] greasepencil-object: Partial fix to T58917 - No valid cage

Dalai Felinto noreply at git.blender.org
Fri Dec 7 17:15:54 CET 2018


Commit: 4c41f8e9ad30828110751b36301fdd2b4c45b3e6
Author: Dalai Felinto
Date:   Fri Dec 7 10:41:57 2018 -0200
Branches: greasepencil-object
https://developer.blender.org/rB4c41f8e9ad30828110751b36301fdd2b4c45b3e6

Partial fix to T58917 - No valid cage

The fix itself simply is to store the cage object as a pointer instead
of a string/name.

That said baking with or without cage is yielding very different results
than in 2.7.

===================================================================

M	intern/cycles/blender/addon/ui.py
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index b276d0bee10..19d3a0fcf54 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1815,7 +1815,7 @@ class CYCLES_RENDER_PT_bake(CyclesButtonsPanel, Panel):
             sub.prop(cbk, "use_cage", text="Cage")
             if cbk.use_cage:
                 sub.prop(cbk, "cage_extrusion", text="Extrusion")
-                sub.prop_search(cbk, "cage_object", scene, "objects", text="Cage Object")
+                sub.prop(cbk, "cage_object", text="Cage Object")
             else:
                 sub.prop(cbk, "cage_extrusion", text="Ray Distance")
 
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index 6a9c1c82ab1..a06be37f41d 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -407,6 +407,7 @@ void BKE_library_foreach_ID_link(Main *bmain, ID *id, LibraryIDLinkCallback call
 				CALLBACK_INVOKE(scene->world, IDWALK_CB_USER);
 				CALLBACK_INVOKE(scene->set, IDWALK_CB_NOP);
 				CALLBACK_INVOKE(scene->clip, IDWALK_CB_USER);
+				CALLBACK_INVOKE(scene->r.bake.cage_object, IDWALK_CB_NOP);
 				if (scene->nodetree) {
 					/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
 					library_foreach_ID_as_subdata_link((ID **)&scene->nodetree, callback, user_data, flag, &data);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3f541a3e7d7..c5b418e8294 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6174,6 +6174,10 @@ static void lib_link_scene(FileData *fd, Main *main)
 				lib_link_view_layer(fd, sce->id.lib, view_layer);
 			}
 
+			if (sce->r.bake.cage_object) {
+				sce->r.bake.cage_object = newlibadr(fd, sce->id.lib, sce->r.bake.cage_object);
+			}
+
 #ifdef USE_SETSCENE_CHECK
 			if (sce->set != NULL) {
 				/* link flag for scenes with set would be reset later,
@@ -10026,6 +10030,10 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
 	if (sce->master_collection) {
 		expand_collection(fd, mainvar, sce->master_collection);
 	}
+
+	if (sce->r.bake.cage_object) {
+		expand_doit(fd, mainvar, sce->r.bake.cage_object);
+	}
 }
 
 static void expand_camera(FileData *fd, Main *mainvar, Camera *ca)
diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c
index 2f879937f7a..b9cc13cda34 100644
--- a/source/blender/editors/object/object_bake_api.c
+++ b/source/blender/editors/object/object_bake_api.c
@@ -1358,7 +1358,9 @@ static void bake_set_props(wmOperator *op, Scene *scene)
 
 	prop = RNA_struct_find_property(op->ptr, "cage_object");
 	if (!RNA_property_is_set(op->ptr, prop)) {
-		RNA_property_string_set(op->ptr, prop, bake->cage);
+		if (bake->cage_object) {
+			RNA_property_string_set(op->ptr, prop, bake->cage_object->id.name + 2);
+		}
 	}
 
 	prop = RNA_struct_find_property(op->ptr, "normal_space");
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 880180802d8..b70446543ce 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -521,7 +521,7 @@ typedef struct BakeData {
 	char save_mode;
 	char pad[3];
 
-	char cage[64];  /* MAX_NAME */
+	struct Object *cage_object;
 } BakeData;
 
 /* BakeData.normal_swizzle (char) */
@@ -1588,6 +1588,7 @@ typedef struct Scene {
 	/* Physics simulation settings */
 	struct PhysicsSettings physics_settings;
 
+	void *pad8;
 	uint64_t customdata_mask;	/* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */
 	uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */
 
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index b44bdfc2201..fe4d69b910f 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -3753,10 +3753,10 @@ static void rna_def_bake_data(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Bake Data", "Bake data for a Scene data-block");
 	RNA_def_struct_path_func(srna, "rna_BakeSettings_path");
 
-	prop = RNA_def_property(srna, "cage_object", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_sdna(prop, NULL, "cage");
+	prop = RNA_def_property(srna, "cage_object", PROP_POINTER, PROP_NONE);
 	RNA_def_property_ui_text(prop, "Cage Object", "Object to use as cage "
 	                         "instead of calculating the cage from the active object with cage extrusion");
+	RNA_def_property_flag(prop, PROP_EDITABLE);
 	RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL);
 
 	prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);



More information about the Bf-blender-cvs mailing list