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.
This commit is contained in:
Dalai Felinto 2018-12-07 10:41:57 -02:00
parent ad47b0236e
commit cc61b21dff
6 changed files with 17 additions and 5 deletions

View File

@ -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")

View File

@ -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);

View File

@ -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,
@ -10021,6 +10025,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)

View File

@ -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");

View File

@ -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) */
@ -1585,6 +1585,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) */

View File

@ -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);