Fix (unreported) missing rna path for some background image properties.

RNA camera code did not handle path for its image/movieclip users
sub-data, and moviclip RNA struct definition did not have a rna path
function at all.
This commit is contained in:
Bastien Montagne 2022-06-08 17:49:40 +02:00
parent d62e6f1225
commit 8843705f65
4 changed files with 43 additions and 6 deletions

View File

@ -125,6 +125,24 @@ static char *rna_Camera_background_image_path(const PointerRNA *ptr)
return NULL;
}
char *rna_CameraBackgroundImage_image_or_movieclip_user_path(const PointerRNA *ptr)
{
const char *user = ptr->data;
Camera *camera = (Camera *)ptr->owner_id;
int bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, iuser));
if (bgpic_index >= 0) {
return BLI_sprintfN("background_images[%d].image_user", bgpic_index);
}
bgpic_index = BLI_findindex(&camera->bg_images, user - offsetof(CameraBGImage, cuser));
if (bgpic_index >= 0) {
return BLI_sprintfN("background_images[%d].clip_user", bgpic_index);
}
return NULL;
}
static bool rna_Camera_background_images_override_apply(Main *bmain,
PointerRNA *ptr_dst,
PointerRNA *ptr_src,
@ -272,6 +290,7 @@ static void rna_def_camera_background_image(BlenderRNA *brna)
prop = RNA_def_property(srna, "image_user", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);
RNA_def_property_struct_type(prop, "ImageUser");
RNA_def_property_pointer_sdna(prop, NULL, "iuser");
RNA_def_property_ui_text(
prop,

View File

@ -182,12 +182,12 @@ static char *rna_ImageUser_path(const PointerRNA *ptr)
switch (GS(ptr->owner_id->name)) {
case ID_OB:
case ID_TE: {
case ID_TE:
return BLI_strdup("image_user");
}
case ID_NT: {
case ID_NT:
return rna_Node_ImageUser_path(ptr);
}
case ID_CA:
return rna_CameraBackgroundImage_image_or_movieclip_user_path(ptr);
default:
break;
}

View File

@ -404,6 +404,7 @@ bool rna_GPencil_datablocks_obdata_poll(struct PointerRNA *ptr, const struct Poi
char *rna_TextureSlot_path(const struct PointerRNA *ptr);
char *rna_Node_ImageUser_path(const struct PointerRNA *ptr);
char *rna_CameraBackgroundImage_image_or_movieclip_user_path(const struct PointerRNA *ptr);
/* Set U.is_dirty and redraw. */

View File

@ -118,6 +118,22 @@ static PointerRNA rna_MovieClip_metadata_get(MovieClip *clip)
return ptr;
}
static char *rna_MovieClipUser_path(const PointerRNA *ptr)
{
if (ptr->owner_id) {
/* MovieClipUser *mc_user = ptr->data; */
switch (GS(ptr->owner_id->name)) {
case ID_CA:
return rna_CameraBackgroundImage_image_or_movieclip_user_path(ptr);
default:
break;
}
}
return BLI_strdup("");
}
#else
static void rna_def_movieclip_proxy(BlenderRNA *brna)
@ -244,7 +260,7 @@ static void rna_def_movieclip_proxy(BlenderRNA *brna)
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
}
static void rna_def_moviecliUser(BlenderRNA *brna)
static void rna_def_movieclipUser(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
@ -263,6 +279,7 @@ static void rna_def_moviecliUser(BlenderRNA *brna)
srna,
"Movie Clip User",
"Parameters defining how a MovieClip data-block is used by another data-block");
RNA_def_struct_path_func(srna, "rna_MovieClipUser_path");
prop = RNA_def_property(srna, "frame_current", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "framenr");
@ -435,7 +452,7 @@ void RNA_def_movieclip(BlenderRNA *brna)
{
rna_def_movieclip(brna);
rna_def_movieclip_proxy(brna);
rna_def_moviecliUser(brna);
rna_def_movieclipUser(brna);
rna_def_movieClipScopes(brna);
}