From 9d4300b0c60047b56f84f28650eb39cd35cf386b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 5 Apr 2020 21:25:33 +0200 Subject: Volumes: add volume.grids.frame_filepath to get the current frame filepath This can be used by external renderers that can load OpenVDB files. --- source/blender/blenkernel/BKE_volume.h | 1 + source/blender/blenkernel/intern/volume.cc | 10 ++++++++++ source/blender/makesrna/intern/rna_volume.c | 25 ++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/BKE_volume.h b/source/blender/blenkernel/BKE_volume.h index 3125ad0326e..224f3ede45d 100644 --- a/source/blender/blenkernel/BKE_volume.h +++ b/source/blender/blenkernel/BKE_volume.h @@ -85,6 +85,7 @@ bool BKE_volume_is_loaded(const struct Volume *volume); int BKE_volume_num_grids(const struct Volume *volume); const char *BKE_volume_grids_error_msg(const struct Volume *volume); +const char *BKE_volume_grids_frame_filepath(const struct Volume *volume); VolumeGrid *BKE_volume_grid_get(const struct Volume *volume, int grid_index); VolumeGrid *BKE_volume_grid_active_get(const struct Volume *volume); VolumeGrid *BKE_volume_grid_find(const struct Volume *volume, const char *name); diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 2af40c8e8fb..9d9e8423bcf 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -901,6 +901,16 @@ const char *BKE_volume_grids_error_msg(const Volume *volume) #endif } +const char *BKE_volume_grids_frame_filepath(const Volume *volume) +{ +#ifdef WITH_OPENVDB + return volume->runtime.grids->filepath; +#else + UNUSED_VARS(volume); + return ""; +#endif +} + VolumeGrid *BKE_volume_grid_get(const Volume *volume, int grid_index) { #ifdef WITH_OPENVDB diff --git a/source/blender/makesrna/intern/rna_volume.c b/source/blender/makesrna/intern/rna_volume.c index 0ee1dbc791b..25b5395b35c 100644 --- a/source/blender/makesrna/intern/rna_volume.c +++ b/source/blender/makesrna/intern/rna_volume.c @@ -194,6 +194,19 @@ static int rna_VolumeGrids_error_message_length(PointerRNA *ptr) return strlen(BKE_volume_grids_error_msg(volume)); } +/* Frame Filepath */ +static void rna_VolumeGrids_frame_filepath_get(PointerRNA *ptr, char *value) +{ + Volume *volume = (Volume *)ptr->data; + strcpy(value, BKE_volume_grids_frame_filepath(volume)); +} + +static int rna_VolumeGrids_frame_filepath_length(PointerRNA *ptr) +{ + Volume *volume = (Volume *)ptr->data; + return strlen(BKE_volume_grids_frame_filepath(volume)); +} + #else static void rna_def_volume_grid(BlenderRNA *brna) @@ -308,6 +321,16 @@ static void rna_def_volume_grids(BlenderRNA *brna, PropertyRNA *cprop) "Frame number that volume grids will be loaded at, based on scene time " "and volume parameters"); + prop = RNA_def_property(srna, "frame_filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs( + prop, "rna_VolumeGrids_frame_filepath_get", "rna_VolumeGrids_frame_filepath_length", NULL); + + RNA_def_property_ui_text(prop, + "Frame File Path", + "Volume file used for loading the volume at the current frame. Empty " + "if the volume has not be loaded or the frame only exists in memory"); + /* API */ FunctionRNA *func; PropertyRNA *parm; @@ -446,7 +469,7 @@ static void rna_def_volume(BlenderRNA *brna) /* File */ prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_ui_text(prop, "File Path", "Volume sample file used by this Volume data-block"); + RNA_def_property_ui_text(prop, "File Path", "Volume file used by this Volume data-block"); RNA_def_property_update(prop, 0, "rna_Volume_update_filepath"); prop = RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE); -- cgit v1.2.3