Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-17 16:41:48 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-03-18 13:23:05 +0300
commitb0a1cf2c9ae696b07f7a236bc855a5ab4a493dcb (patch)
tree92295af11db5e984da42bfac7ca60190b8549a3f /source/blender/blenkernel/intern/packedFile.c
parent8dcfd392e4e62f193b666304425bc5ae635ecffe (diff)
Objects: add Volume object type, and prototypes for Hair and PointCloud
Only the volume object is exposed in the user interface. It is based on OpenVDB internally. Drawing and rendering code will follow in another commit. https://wiki.blender.org/wiki/Source/Objects/Volume https://wiki.blender.org/wiki/Reference/Release_Notes/2.83/Volumes Hair and PointCloud object types are hidden behind a WITH_NEW_OBJECT_TYPES build option. These are unfinished, and included only to make it easier to cooperate on development in the future and avoid tricky merges. https://wiki.blender.org/wiki/Source/Objects/New_Object_Types Ref T73201, T68981 Differential Revision: https://developer.blender.org/D6945
Diffstat (limited to 'source/blender/blenkernel/intern/packedFile.c')
-rw-r--r--source/blender/blenkernel/intern/packedFile.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c
index d69527e8626..34e86b29540 100644
--- a/source/blender/blenkernel/intern/packedFile.c
+++ b/source/blender/blenkernel/intern/packedFile.c
@@ -37,6 +37,7 @@
#include "DNA_ID.h"
#include "DNA_packedFile_types.h"
#include "DNA_sound_types.h"
+#include "DNA_volume_types.h"
#include "DNA_vfont_types.h"
#include "BLI_blenlib.h"
@@ -48,6 +49,7 @@
#include "BKE_packedFile.h"
#include "BKE_report.h"
#include "BKE_sound.h"
+#include "BKE_volume.h"
int BKE_packedfile_seek(PackedFile *pf, int offset, int whence)
{
@@ -114,6 +116,7 @@ int BKE_packedfile_count_all(Main *bmain)
Image *ima;
VFont *vf;
bSound *sound;
+ Volume *volume;
int count = 0;
/* let's check if there are packed files... */
@@ -135,6 +138,12 @@ int BKE_packedfile_count_all(Main *bmain)
}
}
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile) {
+ count++;
+ }
+ }
+
return count;
}
@@ -234,6 +243,7 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
Image *ima;
VFont *vfont;
bSound *sound;
+ Volume *volume;
int tot = 0;
for (ima = bmain->images.first; ima; ima = ima->id.next) {
@@ -266,6 +276,14 @@ void BKE_packedfile_pack_all(Main *bmain, ReportList *reports, bool verbose)
}
}
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile == NULL && !ID_IS_LINKED(volume)) {
+ volume->packedfile = BKE_packedfile_new(
+ reports, volume->filepath, BKE_main_blendfile_path(bmain));
+ tot++;
+ }
+ }
+
if (tot > 0) {
BKE_reportf(reports, RPT_INFO, "Packed %d file(s)", tot);
}
@@ -524,6 +542,9 @@ static void unpack_generate_paths(const char *name,
case ID_IM:
BLI_snprintf(r_relpath, relpathlen, "//textures/%s", tempname);
break;
+ case ID_VO:
+ BLI_snprintf(r_relpath, relpathlen, "//volumes/%s", tempname);
+ break;
default:
break;
}
@@ -643,6 +664,36 @@ int BKE_packedfile_unpack_image(Main *bmain,
return (ret_value);
}
+int BKE_packedfile_unpack_volume(Main *bmain,
+ ReportList *reports,
+ Volume *volume,
+ enum ePF_FileStatus how)
+{
+ char localname[FILE_MAX], absname[FILE_MAX];
+ char *newfilepath;
+ int ret_value = RET_ERROR;
+
+ if (volume != NULL) {
+ unpack_generate_paths(
+ volume->filepath, (ID *)volume, absname, localname, sizeof(absname), sizeof(localname));
+ newfilepath = BKE_packedfile_unpack_to_file(
+ reports, BKE_main_blendfile_path(bmain), absname, localname, volume->packedfile, how);
+ if (newfilepath != NULL) {
+ BLI_strncpy(volume->filepath, newfilepath, sizeof(volume->filepath));
+ MEM_freeN(newfilepath);
+
+ BKE_packedfile_free(volume->packedfile);
+ volume->packedfile = NULL;
+
+ BKE_volume_unload(volume);
+
+ ret_value = RET_OK;
+ }
+ }
+
+ return (ret_value);
+}
+
int BKE_packedfile_unpack_all_libraries(Main *bmain, ReportList *reports)
{
Library *lib;
@@ -702,6 +753,7 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt
Image *ima;
VFont *vf;
bSound *sound;
+ Volume *volume;
for (ima = bmain->images.first; ima; ima = ima->id.next) {
if (BKE_image_has_packedfile(ima)) {
@@ -720,6 +772,12 @@ void BKE_packedfile_unpack_all(Main *bmain, ReportList *reports, enum ePF_FileSt
BKE_packedfile_unpack_sound(bmain, reports, sound, how);
}
}
+
+ for (volume = bmain->volumes.first; volume; volume = volume->id.next) {
+ if (volume->packedfile) {
+ BKE_packedfile_unpack_volume(bmain, reports, volume, how);
+ }
+ }
}
/* ID should be not NULL, return 1 if there's a packed file */
@@ -738,6 +796,10 @@ bool BKE_packedfile_id_check(ID *id)
bSound *snd = (bSound *)id;
return snd->packedfile != NULL;
}
+ case ID_VO: {
+ Volume *volume = (Volume *)id;
+ return volume->packedfile != NULL;
+ }
case ID_LI: {
Library *li = (Library *)id;
return li->packedfile != NULL;
@@ -773,6 +835,13 @@ void BKE_packedfile_id_unpack(Main *bmain, ID *id, ReportList *reports, enum ePF
}
break;
}
+ case ID_VO: {
+ Volume *volume = (Volume *)id;
+ if (volume->packedfile) {
+ BKE_packedfile_unpack_volume(bmain, reports, volume, how);
+ }
+ break;
+ }
case ID_LI: {
Library *li = (Library *)id;
BKE_reportf(reports, RPT_ERROR, "Cannot unpack individual Library file, '%s'", li->name);