2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2007-12-20 10:27:13 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2007-12-20 10:27:13 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-12-20 10:27:13 +00:00
|
|
|
*
|
2011-10-27 03:40:12 +00:00
|
|
|
* Contributor(s): Campbell barton, Alex Fraser
|
2007-12-20 10:27:13 +00:00
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2007-12-20 10:27:13 +00:00
|
|
|
*/
|
|
|
|
|
2012-12-20 13:29:58 +00:00
|
|
|
/** \file blender/blenkernel/intern/bpath.c
|
2011-02-27 20:37:56 +00:00
|
|
|
* \ingroup bli
|
|
|
|
*/
|
|
|
|
|
2011-10-27 03:40:12 +00:00
|
|
|
/* TODO,
|
2012-03-18 07:38:51 +00:00
|
|
|
* currently there are some cases we don't support.
|
2011-10-27 03:40:12 +00:00
|
|
|
* - passing output paths to the visitor?, like render out.
|
|
|
|
* - passing sequence strips with many images.
|
2012-03-18 07:38:51 +00:00
|
|
|
* - passing directory paths - visitors don't know which path is a dir or a file.
|
2011-10-27 03:40:12 +00:00
|
|
|
* */
|
2011-02-27 20:37:56 +00:00
|
|
|
|
2009-09-06 13:20:05 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
2010-12-05 23:14:48 +00:00
|
|
|
#include <assert.h>
|
2009-09-06 13:20:05 +00:00
|
|
|
|
2012-03-12 23:56:11 +00:00
|
|
|
/* path/file handling stuff */
|
2009-09-06 13:20:05 +00:00
|
|
|
#ifndef WIN32
|
2012-03-11 23:47:41 +00:00
|
|
|
# include <dirent.h>
|
|
|
|
# include <unistd.h>
|
2009-09-06 13:20:05 +00:00
|
|
|
#else
|
2012-03-11 23:47:41 +00:00
|
|
|
# include <io.h>
|
|
|
|
# include "BLI_winstuff.h"
|
2009-09-06 13:20:05 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_brush_types.h"
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
#include "DNA_cachefile_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_image_types.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_modifier_types.h"
|
2011-12-04 17:16:22 +00:00
|
|
|
#include "DNA_movieclip_types.h"
|
2018-02-07 11:14:08 +11:00
|
|
|
#include "DNA_object_fluidsim_types.h"
|
|
|
|
#include "DNA_object_force_types.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_particle_types.h"
|
2008-04-25 16:09:16 +00:00
|
|
|
#include "DNA_sequence_types.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_sound_types.h"
|
|
|
|
#include "DNA_text_types.h"
|
2012-11-27 16:19:52 +00:00
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_node_types.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_texture_types.h"
|
2010-01-28 18:20:28 +00:00
|
|
|
#include "DNA_vfont_types.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_smoke_types.h"
|
2013-03-23 03:00:37 +00:00
|
|
|
#include "DNA_freestyle_types.h"
|
2007-12-20 10:27:13 +00:00
|
|
|
|
2008-12-15 05:21:44 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2007-12-20 10:27:13 +00:00
|
|
|
|
2012-08-03 22:12:57 +00:00
|
|
|
#include "BKE_font.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "BKE_library.h"
|
2010-12-06 00:52:30 +00:00
|
|
|
#include "BKE_main.h"
|
2012-11-27 16:19:52 +00:00
|
|
|
#include "BKE_node.h"
|
2010-01-11 10:48:41 +00:00
|
|
|
#include "BKE_report.h"
|
2011-10-27 03:40:12 +00:00
|
|
|
#include "BKE_sequencer.h"
|
2013-09-02 14:23:42 +00:00
|
|
|
#include "BKE_image.h"
|
2008-04-25 16:09:16 +00:00
|
|
|
|
2012-12-15 15:59:25 +00:00
|
|
|
#include "BKE_bpath.h" /* own include */
|
|
|
|
|
2015-04-11 00:42:35 +10:00
|
|
|
#ifndef _MSC_VER
|
|
|
|
# include "BLI_strict_flags.h"
|
|
|
|
#endif
|
2015-04-10 22:01:10 +10:00
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), const char *path_src)
|
2011-05-19 13:50:53 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
ReportList *reports = (ReportList *)userdata;
|
2010-12-05 23:14:48 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (!BLI_exists(path_src)) {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src);
|
2008-04-25 16:09:16 +00:00
|
|
|
}
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
/* high level function */
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_missing_files_check(Main *bmain, ReportList *reports)
|
2011-01-18 00:10:11 +00:00
|
|
|
{
|
2014-06-29 09:41:02 +02:00
|
|
|
BKE_bpath_traverse_main(bmain, checkMissingFiles_visit_cb,
|
|
|
|
BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_SKIP_PACKED, reports);
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
typedef struct BPathRemap_Data {
|
2011-10-27 01:25:07 +00:00
|
|
|
const char *basedir;
|
|
|
|
ReportList *reports;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
int count_tot;
|
|
|
|
int count_changed;
|
|
|
|
int count_failed;
|
|
|
|
} BPathRemap_Data;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2014-08-06 02:48:37 +10:00
|
|
|
static bool bpath_relative_convert_visit_cb(void *userdata, char *path_dst, const char *path_src)
|
2009-01-28 22:36:34 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
BPathRemap_Data *data = (BPathRemap_Data *)userdata;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_tot++;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2012-08-29 10:32:38 +00:00
|
|
|
if (BLI_path_is_rel(path_src)) {
|
2013-06-24 03:06:32 +00:00
|
|
|
return false; /* already relative */
|
2010-12-05 23:14:48 +00:00
|
|
|
}
|
2011-10-27 01:25:07 +00:00
|
|
|
else {
|
|
|
|
strcpy(path_dst, path_src);
|
|
|
|
BLI_path_rel(path_dst, data->basedir);
|
2012-08-29 10:32:38 +00:00
|
|
|
if (BLI_path_is_rel(path_dst)) {
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_changed++;
|
2010-12-05 23:14:48 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src);
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_failed++;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *reports)
|
2007-12-20 10:27:13 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
BPathRemap_Data data = {NULL};
|
2014-08-06 02:48:37 +10:00
|
|
|
const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
if (basedir[0] == '\0') {
|
2011-10-27 01:25:07 +00:00
|
|
|
printf("%s: basedir='', this is a bug\n", __func__);
|
2010-01-08 17:50:55 +00:00
|
|
|
return;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
data.basedir = basedir;
|
|
|
|
data.reports = reports;
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2014-08-06 02:48:37 +10:00
|
|
|
BKE_bpath_traverse_main(bmain, bpath_relative_convert_visit_cb, flag, (void *)&data);
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
|
2012-10-21 14:02:30 +00:00
|
|
|
"Total files %d | Changed %d | Failed %d",
|
2011-10-27 01:25:07 +00:00
|
|
|
data.count_tot, data.count_changed, data.count_failed);
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 02:48:37 +10:00
|
|
|
static bool bpath_absolute_convert_visit_cb(void *userdata, char *path_dst, const char *path_src)
|
2011-09-28 05:53:40 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
BPathRemap_Data *data = (BPathRemap_Data *)userdata;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_tot++;
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
if (BLI_path_is_rel(path_src) == false) {
|
|
|
|
return false; /* already absolute */
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2011-10-27 01:25:07 +00:00
|
|
|
else {
|
|
|
|
strcpy(path_dst, path_src);
|
|
|
|
BLI_path_abs(path_dst, data->basedir);
|
2013-06-24 03:06:32 +00:00
|
|
|
if (BLI_path_is_rel(path_dst) == false) {
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_changed++;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2011-10-27 01:25:07 +00:00
|
|
|
else {
|
2012-10-21 14:02:30 +00:00
|
|
|
BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src);
|
2011-10-27 01:25:07 +00:00
|
|
|
data->count_failed++;
|
|
|
|
}
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2007-12-24 17:07:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
/* similar to BKE_bpath_relative_convert - keep in sync! */
|
|
|
|
void BKE_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *reports)
|
2010-01-08 17:50:55 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
BPathRemap_Data data = {NULL};
|
2014-08-06 02:48:37 +10:00
|
|
|
const int flag = BKE_BPATH_TRAVERSE_SKIP_LIBRARY;
|
2011-05-18 05:21:44 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
if (basedir[0] == '\0') {
|
2011-10-27 01:25:07 +00:00
|
|
|
printf("%s: basedir='', this is a bug\n", __func__);
|
2011-05-18 06:48:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-05-18 05:21:44 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
data.basedir = basedir;
|
|
|
|
data.reports = reports;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2014-08-06 02:48:37 +10:00
|
|
|
BKE_bpath_traverse_main(bmain, bpath_absolute_convert_visit_cb, flag, (void *)&data);
|
2010-01-08 17:50:55 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO,
|
2012-10-21 14:02:30 +00:00
|
|
|
"Total files %d | Changed %d | Failed %d",
|
2011-10-27 01:25:07 +00:00
|
|
|
data.count_tot, data.count_changed, data.count_failed);
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
|
2012-07-30 16:42:26 +00:00
|
|
|
/**
|
|
|
|
* find this file recursively, use the biggest file so thumbnails don't get used by mistake
|
2012-10-20 20:36:51 +00:00
|
|
|
* \param filename_new: the path will be copied here, caller must initialize as empty string.
|
2012-07-30 16:42:26 +00:00
|
|
|
* \param dirname: subdir to search
|
|
|
|
* \param filename: set this filename
|
|
|
|
* \param filesize: filesize for the file
|
2012-01-31 18:00:41 +00:00
|
|
|
*
|
2012-07-30 16:42:26 +00:00
|
|
|
* \returns found: 1/0.
|
2012-01-31 18:00:41 +00:00
|
|
|
*/
|
2007-12-20 10:27:13 +00:00
|
|
|
#define MAX_RECUR 16
|
2015-04-10 22:01:10 +10:00
|
|
|
static bool missing_files_find__recursive(
|
|
|
|
char *filename_new,
|
|
|
|
const char *dirname,
|
|
|
|
const char *filename,
|
|
|
|
off_t *r_filesize,
|
|
|
|
int *r_recur_depth)
|
2007-12-20 10:27:13 +00:00
|
|
|
{
|
|
|
|
/* file searching stuff */
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *de;
|
2014-05-28 22:50:40 +06:00
|
|
|
BLI_stat_t status;
|
2007-12-20 10:27:13 +00:00
|
|
|
char path[FILE_MAX];
|
2015-04-10 22:01:10 +10:00
|
|
|
off_t size;
|
2013-06-24 03:06:32 +00:00
|
|
|
bool found = false;
|
2012-01-31 18:00:41 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
dir = opendir(dirname);
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
if (dir == NULL)
|
2012-01-31 18:00:41 +00:00
|
|
|
return found;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-04-10 22:01:10 +10:00
|
|
|
if (*r_filesize == -1)
|
|
|
|
*r_filesize = 0; /* dir opened fine */
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
while ((de = readdir(dir)) != NULL) {
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-01-26 16:58:02 +01:00
|
|
|
if (FILENAME_IS_CURRPAR(de->d_name))
|
2007-12-20 10:27:13 +00:00
|
|
|
continue;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-02-13 03:21:27 +00:00
|
|
|
BLI_join_dirfile(path, sizeof(path), dirname, de->d_name);
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-02-18 07:26:10 +11:00
|
|
|
if (BLI_stat(path, &status) == -1)
|
2012-05-12 15:02:10 +00:00
|
|
|
continue; /* cant stat, don't bother with this file, could print debug info here */
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2007-12-20 10:27:13 +00:00
|
|
|
if (S_ISREG(status.st_mode)) { /* is file */
|
2017-05-08 09:42:36 +10:00
|
|
|
if (BLI_path_ncmp(filename, de->d_name, FILE_MAX) == 0) { /* name matches */
|
2007-12-20 10:27:13 +00:00
|
|
|
/* open the file to read its size */
|
2012-03-11 23:47:41 +00:00
|
|
|
size = status.st_size;
|
2015-04-10 22:01:10 +10:00
|
|
|
if ((size > 0) && (size > *r_filesize)) { /* find the biggest file */
|
|
|
|
*r_filesize = size;
|
2008-01-21 22:10:20 +00:00
|
|
|
BLI_strncpy(filename_new, path, FILE_MAX);
|
2013-06-24 03:06:32 +00:00
|
|
|
found = true;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-19 13:50:53 +00:00
|
|
|
}
|
|
|
|
else if (S_ISDIR(status.st_mode)) { /* is subdir */
|
2015-04-10 22:01:10 +10:00
|
|
|
if (*r_recur_depth <= MAX_RECUR) {
|
|
|
|
(*r_recur_depth)++;
|
|
|
|
found |= missing_files_find__recursive(filename_new, path, filename, r_filesize, r_recur_depth);
|
|
|
|
(*r_recur_depth)--;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dir);
|
2012-01-31 18:00:41 +00:00
|
|
|
return found;
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 23:47:41 +00:00
|
|
|
typedef struct BPathFind_Data {
|
2011-10-27 01:25:07 +00:00
|
|
|
const char *basedir;
|
2013-06-24 02:57:06 +00:00
|
|
|
const char *searchdir;
|
2011-10-27 01:25:07 +00:00
|
|
|
ReportList *reports;
|
2013-06-24 02:57:06 +00:00
|
|
|
bool find_all;
|
2011-10-27 01:25:07 +00:00
|
|
|
} BPathFind_Data;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-04-10 22:01:10 +10:00
|
|
|
static bool missing_files_find__visit_cb(void *userdata, char *path_dst, const char *path_src)
|
2011-10-27 01:25:07 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
BPathFind_Data *data = (BPathFind_Data *)userdata;
|
2011-10-27 01:25:07 +00:00
|
|
|
char filename_new[FILE_MAX];
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-04-10 22:01:10 +10:00
|
|
|
off_t filesize = -1;
|
2012-03-11 23:47:41 +00:00
|
|
|
int recur_depth = 0;
|
2015-04-10 22:01:10 +10:00
|
|
|
bool found;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2013-06-24 02:57:06 +00:00
|
|
|
if (data->find_all == false) {
|
|
|
|
if (BLI_exists(path_src)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-30 16:42:26 +00:00
|
|
|
filename_new[0] = '\0';
|
|
|
|
|
2015-04-10 22:01:10 +10:00
|
|
|
found = missing_files_find__recursive(
|
|
|
|
filename_new,
|
|
|
|
data->searchdir, BLI_path_basename(path_src),
|
|
|
|
&filesize, &recur_depth);
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (filesize == -1) { /* could not open dir */
|
2012-01-31 18:00:41 +00:00
|
|
|
BKE_reportf(data->reports, RPT_WARNING,
|
2012-10-21 14:02:30 +00:00
|
|
|
"Could not open directory '%s'",
|
2012-01-31 18:00:41 +00:00
|
|
|
BLI_path_basename(data->searchdir));
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2012-01-31 18:00:41 +00:00
|
|
|
}
|
2013-06-24 03:06:32 +00:00
|
|
|
else if (found == false) {
|
2011-10-27 01:25:07 +00:00
|
|
|
BKE_reportf(data->reports, RPT_WARNING,
|
2012-10-21 14:02:30 +00:00
|
|
|
"Could not find '%s' in '%s'",
|
2015-02-08 14:33:06 +11:00
|
|
|
BLI_path_basename(path_src), data->searchdir);
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-09-05 00:37:06 +00:00
|
|
|
bool was_relative = BLI_path_is_rel(path_dst);
|
|
|
|
|
2012-01-31 18:00:41 +00:00
|
|
|
BLI_strncpy(path_dst, filename_new, FILE_MAX);
|
2013-09-05 00:37:06 +00:00
|
|
|
|
|
|
|
/* keep path relative if the previous one was relative */
|
|
|
|
if (was_relative)
|
|
|
|
BLI_path_rel(path_dst, data->basedir);
|
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2013-06-24 02:57:06 +00:00
|
|
|
void BKE_bpath_missing_files_find(Main *bmain, const char *searchpath, ReportList *reports,
|
|
|
|
const bool find_all)
|
2011-10-27 01:25:07 +00:00
|
|
|
{
|
2012-03-11 23:47:41 +00:00
|
|
|
struct BPathFind_Data data = {NULL};
|
2015-05-18 13:42:47 +10:00
|
|
|
const int flag = BKE_BPATH_TRAVERSE_ABS | BKE_BPATH_TRAVERSE_RELOAD_EDITED;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2013-09-05 00:37:06 +00:00
|
|
|
data.basedir = bmain->name;
|
2012-03-11 23:47:41 +00:00
|
|
|
data.reports = reports;
|
2013-06-24 02:57:06 +00:00
|
|
|
data.searchdir = searchpath;
|
|
|
|
data.find_all = find_all;
|
2011-05-19 13:50:53 +00:00
|
|
|
|
2015-05-18 13:42:47 +10:00
|
|
|
BKE_bpath_traverse_main(bmain, missing_files_find__visit_cb, flag, (void *)&data);
|
2007-12-20 10:27:13 +00:00
|
|
|
}
|
2011-10-23 17:52:20 +00:00
|
|
|
|
|
|
|
/* Run a visitor on a string, replacing the contents of the string as needed. */
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool rewrite_path_fixed(char *path, BPathVisitor visit_cb, const char *absbase, void *userdata)
|
2011-10-26 21:22:35 +00:00
|
|
|
{
|
2011-10-27 01:25:07 +00:00
|
|
|
char path_src_buf[FILE_MAX];
|
|
|
|
const char *path_src;
|
2011-10-26 22:46:06 +00:00
|
|
|
char path_dst[FILE_MAX];
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (absbase) {
|
|
|
|
BLI_strncpy(path_src_buf, path, sizeof(path_src_buf));
|
|
|
|
BLI_path_abs(path_src_buf, absbase);
|
2012-03-11 23:47:41 +00:00
|
|
|
path_src = path_src_buf;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-11 23:47:41 +00:00
|
|
|
path_src = path;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
|
2013-09-05 00:37:06 +00:00
|
|
|
/* so functions can check old value */
|
|
|
|
BLI_strncpy(path_dst, path, FILE_MAX);
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (visit_cb(userdata, path_dst, path_src)) {
|
2011-10-26 22:46:06 +00:00
|
|
|
BLI_strncpy(path, path_dst, FILE_MAX);
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool rewrite_path_fixed_dirfile(char path_dir[FILE_MAXDIR],
|
|
|
|
char path_file[FILE_MAXFILE],
|
|
|
|
BPathVisitor visit_cb,
|
|
|
|
const char *absbase,
|
|
|
|
void *userdata)
|
2011-10-26 22:46:06 +00:00
|
|
|
{
|
|
|
|
char path_src[FILE_MAX];
|
|
|
|
char path_dst[FILE_MAX];
|
|
|
|
|
|
|
|
BLI_join_dirfile(path_src, sizeof(path_src), path_dir, path_file);
|
|
|
|
|
2015-05-06 02:22:00 +10:00
|
|
|
/* so functions can check old value */
|
|
|
|
BLI_strncpy(path_dst, path_src, FILE_MAX);
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (absbase) {
|
|
|
|
BLI_path_abs(path_src, absbase);
|
|
|
|
}
|
|
|
|
|
2011-10-26 22:46:06 +00:00
|
|
|
if (visit_cb(userdata, path_dst, (const char *)path_src)) {
|
2011-10-29 08:18:42 +00:00
|
|
|
BLI_split_dirfile(path_dst, path_dir, path_file, FILE_MAXDIR, FILE_MAXFILE);
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool rewrite_path_alloc(char **path, BPathVisitor visit_cb, const char *absbase, void *userdata)
|
2011-10-26 22:46:06 +00:00
|
|
|
{
|
2011-10-27 01:25:07 +00:00
|
|
|
char path_src_buf[FILE_MAX];
|
|
|
|
const char *path_src;
|
2011-10-26 22:46:06 +00:00
|
|
|
char path_dst[FILE_MAX];
|
|
|
|
|
2011-10-27 01:25:07 +00:00
|
|
|
if (absbase) {
|
|
|
|
BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf));
|
|
|
|
BLI_path_abs(path_src_buf, absbase);
|
2012-03-11 23:47:41 +00:00
|
|
|
path_src = path_src_buf;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-03-11 23:47:41 +00:00
|
|
|
path_src = *path;
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (visit_cb(userdata, path_dst, path_src)) {
|
2015-03-23 22:51:12 +11:00
|
|
|
MEM_freeN(*path);
|
2012-03-11 23:47:41 +00:00
|
|
|
(*path) = BLI_strdup(path_dst);
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-02 14:23:42 +00:00
|
|
|
/* fix the image user "ok" tag after updating paths, so ImBufs get loaded */
|
|
|
|
static void bpath_traverse_image_user_cb(Image *ima, ImageUser *iuser, void *customdata)
|
|
|
|
{
|
|
|
|
if (ima == customdata)
|
|
|
|
iuser->ok = 1;
|
|
|
|
}
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
/* Run visitor function 'visit' on all paths contained in 'id'. */
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
|
2011-10-26 21:22:35 +00:00
|
|
|
{
|
2012-12-15 15:31:50 +00:00
|
|
|
const char *absbase = (flag & BKE_BPATH_TRAVERSE_ABS) ? ID_BLEND_PATH(bmain, id) : NULL;
|
2011-10-27 01:25:07 +00:00
|
|
|
|
2017-11-06 17:17:10 +01:00
|
|
|
if ((flag & BKE_BPATH_TRAVERSE_SKIP_LIBRARY) && ID_IS_LINKED(id)) {
|
2011-10-27 03:40:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-10-23 17:52:20 +00:00
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (GS(id->name)) {
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_IM:
|
2012-11-27 16:19:52 +00:00
|
|
|
{
|
|
|
|
Image *ima;
|
2012-05-12 15:02:10 +00:00
|
|
|
ima = (Image *)id;
|
2015-04-06 10:40:12 -03:00
|
|
|
if (BKE_image_has_packedfile(ima) == false || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(ima->source, IMA_SRC_FILE, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) {
|
2013-09-18 19:35:13 +00:00
|
|
|
if (rewrite_path_fixed(ima->name, visit_cb, absbase, bpath_user_data)) {
|
2015-05-18 13:42:47 +10:00
|
|
|
if (flag & BKE_BPATH_TRAVERSE_RELOAD_EDITED) {
|
|
|
|
if (!BKE_image_has_packedfile(ima) &&
|
|
|
|
/* image may have been painted onto (and not saved, T44543) */
|
|
|
|
!BKE_image_is_dirty(ima))
|
|
|
|
{
|
|
|
|
BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD);
|
|
|
|
BKE_image_walk_all_users(bmain, ima, bpath_traverse_image_user_cb);
|
|
|
|
}
|
2013-09-18 19:35:13 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
}
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
break;
|
2012-11-27 16:19:52 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_BR:
|
2011-10-27 03:40:12 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
Brush *brush = (Brush *)id;
|
2011-10-27 03:40:12 +00:00
|
|
|
if (brush->icon_filepath[0]) {
|
2011-10-27 05:34:39 +00:00
|
|
|
rewrite_path_fixed(brush->icon_filepath, visit_cb, absbase, bpath_user_data);
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_OB:
|
2012-11-27 16:19:52 +00:00
|
|
|
{
|
|
|
|
Object *ob = (Object *)id;
|
|
|
|
ModifierData *md;
|
|
|
|
ParticleSystem *psys;
|
2011-10-27 03:40:12 +00:00
|
|
|
|
|
|
|
#define BPATH_TRAVERSE_POINTCACHE(ptcaches) \
|
|
|
|
{ \
|
|
|
|
PointCache *cache; \
|
2012-05-12 15:02:10 +00:00
|
|
|
for (cache = (ptcaches).first; cache; cache = cache->next) { \
|
|
|
|
if (cache->flag & PTCACHE_DISK_CACHE) { \
|
2011-10-27 05:34:39 +00:00
|
|
|
rewrite_path_fixed(cache->path, \
|
|
|
|
visit_cb, \
|
|
|
|
absbase, \
|
|
|
|
bpath_user_data); \
|
2011-10-27 03:40:12 +00:00
|
|
|
} \
|
|
|
|
} \
|
2012-05-27 20:13:59 +00:00
|
|
|
} (void)0
|
2011-10-27 03:40:12 +00:00
|
|
|
|
2012-11-27 16:19:52 +00:00
|
|
|
/* do via modifiers instead */
|
2011-10-27 03:40:12 +00:00
|
|
|
#if 0
|
2012-11-27 16:19:52 +00:00
|
|
|
if (ob->fluidsimSettings) {
|
|
|
|
rewrite_path_fixed(ob->fluidsimSettings->surfdataPath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
2011-10-27 03:40:12 +00:00
|
|
|
#endif
|
|
|
|
|
2012-11-27 16:19:52 +00:00
|
|
|
for (md = ob->modifiers.first; md; md = md->next) {
|
|
|
|
if (md->type == eModifierType_Fluidsim) {
|
|
|
|
FluidsimModifierData *fluidmd = (FluidsimModifierData *)md;
|
|
|
|
if (fluidmd->fss) {
|
|
|
|
rewrite_path_fixed(fluidmd->fss->surfdataPath, visit_cb, absbase, bpath_user_data);
|
2012-05-12 15:02:10 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
}
|
|
|
|
else if (md->type == eModifierType_Smoke) {
|
|
|
|
SmokeModifierData *smd = (SmokeModifierData *)md;
|
|
|
|
if (smd->type & MOD_SMOKE_TYPE_DOMAIN) {
|
|
|
|
BPATH_TRAVERSE_POINTCACHE(smd->domain->ptcaches[0]);
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
else if (md->type == eModifierType_Cloth) {
|
|
|
|
ClothModifierData *clmd = (ClothModifierData *) md;
|
|
|
|
BPATH_TRAVERSE_POINTCACHE(clmd->ptcaches);
|
2012-05-12 15:02:10 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
else if (md->type == eModifierType_Ocean) {
|
|
|
|
OceanModifierData *omd = (OceanModifierData *) md;
|
|
|
|
rewrite_path_fixed(omd->cachepath, visit_cb, absbase, bpath_user_data);
|
2012-05-12 15:02:10 +00:00
|
|
|
}
|
2013-01-21 15:41:00 +00:00
|
|
|
else if (md->type == eModifierType_MeshCache) {
|
|
|
|
MeshCacheModifierData *mcmd = (MeshCacheModifierData *) md;
|
|
|
|
rewrite_path_fixed(mcmd->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 16:19:52 +00:00
|
|
|
if (ob->soft) {
|
|
|
|
BPATH_TRAVERSE_POINTCACHE(ob->soft->ptcaches);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
|
|
|
|
BPATH_TRAVERSE_POINTCACHE(psys->ptcaches);
|
|
|
|
}
|
|
|
|
|
2011-10-27 03:40:12 +00:00
|
|
|
#undef BPATH_TRAVERSE_POINTCACHE
|
|
|
|
|
2012-05-12 15:02:10 +00:00
|
|
|
break;
|
2012-11-27 16:19:52 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_SO:
|
2011-10-27 03:40:12 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
bSound *sound = (bSound *)id;
|
2012-12-15 15:31:50 +00:00
|
|
|
if (sound->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
|
2011-10-27 05:34:39 +00:00
|
|
|
rewrite_path_fixed(sound->name, visit_cb, absbase, bpath_user_data);
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_TXT:
|
|
|
|
if (((Text *)id)->name) {
|
|
|
|
rewrite_path_alloc(&((Text *)id)->name, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ID_VF:
|
2011-10-27 03:40:12 +00:00
|
|
|
{
|
2012-08-03 22:12:57 +00:00
|
|
|
VFont *vfont = (VFont *)id;
|
2012-12-15 15:31:50 +00:00
|
|
|
if (vfont->packedfile == NULL || (flag & BKE_BPATH_TRAVERSE_SKIP_PACKED) == 0) {
|
2013-06-24 03:06:32 +00:00
|
|
|
if (BKE_vfont_is_builtin(vfont) == false) {
|
2011-10-27 05:34:39 +00:00
|
|
|
rewrite_path_fixed(((VFont *)id)->name, visit_cb, absbase, bpath_user_data);
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_MA:
|
|
|
|
{
|
|
|
|
Material *ma = (Material *)id;
|
|
|
|
bNodeTree *ntree = ma->nodetree;
|
|
|
|
|
2012-12-01 07:58:27 +00:00
|
|
|
if (ntree) {
|
2012-11-27 17:21:58 +00:00
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == SH_NODE_SCRIPT) {
|
|
|
|
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
|
|
|
|
rewrite_path_fixed(nss->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
Cycles: Add Support for IES files as textures for light strength
This patch adds support for IES files, a file format that is commonly used to store the directional intensity distribution of light sources.
The new IES node is supposed to be plugged into the Strength input of the Emission node of the lamp.
Since people generating IES files do not really seem to care about the standard, the parser is flexible enough to accept all test files I have tried.
Some common weirdnesses are distributing values over multiple lines that should go into one line, using commas instead of spaces as delimiters and adding various useless stuff at the end of the file.
The user interface of the node is similar to the script node, the user can either select an internal Text or load a file.
Internally, IES files are handled similar to Image textures: They are stored in slots by the LightManager and each unique IES is assigned to one slot.
The local coordinate system of the lamp is used, so that the direction of the light can be changed. For UI reasons, it's usually best to add an area light,
rotate it and then change its type, since especially the point light does not immediately show its local coordinate system in the viewport.
Reviewers: #cycles, dingto, sergey, brecht
Reviewed By: #cycles, dingto, brecht
Subscribers: OgDEV, crazyrobinhood, secundar, cardboard, pisuke, intrah, swerner, micah_denn, harvester, gottfried, disnel, campbellbarton, duarteframos, Lapineige, brecht, juicyfruit, dingto, marek, rickyblender, bliblubli, lockal, sergey
Differential Revision: https://developer.blender.org/D1543
2018-05-27 00:46:37 +02:00
|
|
|
else if (node->type == SH_NODE_TEX_IES) {
|
|
|
|
NodeShaderTexIES *ies = (NodeShaderTexIES *)node->storage;
|
|
|
|
rewrite_path_fixed(ies->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ID_NT:
|
|
|
|
{
|
|
|
|
bNodeTree *ntree = (bNodeTree *)id;
|
|
|
|
bNode *node;
|
|
|
|
|
|
|
|
if (ntree->type == NTREE_SHADER) {
|
|
|
|
/* same as lines above */
|
|
|
|
for (node = ntree->nodes.first; node; node = node->next) {
|
|
|
|
if (node->type == SH_NODE_SCRIPT) {
|
|
|
|
NodeShaderScript *nss = (NodeShaderScript *)node->storage;
|
|
|
|
rewrite_path_fixed(nss->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
Cycles: Add Support for IES files as textures for light strength
This patch adds support for IES files, a file format that is commonly used to store the directional intensity distribution of light sources.
The new IES node is supposed to be plugged into the Strength input of the Emission node of the lamp.
Since people generating IES files do not really seem to care about the standard, the parser is flexible enough to accept all test files I have tried.
Some common weirdnesses are distributing values over multiple lines that should go into one line, using commas instead of spaces as delimiters and adding various useless stuff at the end of the file.
The user interface of the node is similar to the script node, the user can either select an internal Text or load a file.
Internally, IES files are handled similar to Image textures: They are stored in slots by the LightManager and each unique IES is assigned to one slot.
The local coordinate system of the lamp is used, so that the direction of the light can be changed. For UI reasons, it's usually best to add an area light,
rotate it and then change its type, since especially the point light does not immediately show its local coordinate system in the viewport.
Reviewers: #cycles, dingto, sergey, brecht
Reviewed By: #cycles, dingto, brecht
Subscribers: OgDEV, crazyrobinhood, secundar, cardboard, pisuke, intrah, swerner, micah_denn, harvester, gottfried, disnel, campbellbarton, duarteframos, Lapineige, brecht, juicyfruit, dingto, marek, rickyblender, bliblubli, lockal, sergey
Differential Revision: https://developer.blender.org/D1543
2018-05-27 00:46:37 +02:00
|
|
|
else if (node->type == SH_NODE_TEX_IES) {
|
|
|
|
NodeShaderTexIES *ies = (NodeShaderTexIES *)node->storage;
|
|
|
|
rewrite_path_fixed(ies->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_SCE:
|
2011-10-26 22:46:06 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
Scene *scene = (Scene *)id;
|
2011-10-26 22:46:06 +00:00
|
|
|
if (scene->ed) {
|
|
|
|
Sequence *seq;
|
|
|
|
|
2012-05-12 15:02:10 +00:00
|
|
|
SEQ_BEGIN(scene->ed, seq)
|
2012-04-30 16:22:40 +00:00
|
|
|
{
|
2011-10-26 22:46:06 +00:00
|
|
|
if (SEQ_HAS_PATH(seq)) {
|
2014-02-20 12:32:47 +11:00
|
|
|
StripElem *se = seq->strip->stripdata;
|
|
|
|
|
|
|
|
if (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_SOUND_RAM) && se) {
|
|
|
|
rewrite_path_fixed_dirfile(seq->strip->dir, se->name,
|
2011-12-18 12:54:50 +00:00
|
|
|
visit_cb, absbase, bpath_user_data);
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2014-02-20 12:32:47 +11:00
|
|
|
else if ((seq->type == SEQ_TYPE_IMAGE) && se) {
|
2011-10-27 03:40:12 +00:00
|
|
|
/* might want an option not to loop over all strips */
|
2015-04-14 10:30:14 +10:00
|
|
|
unsigned int len = (unsigned int)MEM_allocN_len(se) / (unsigned int)sizeof(*se);
|
2015-04-10 22:01:10 +10:00
|
|
|
unsigned int i;
|
2011-10-27 03:40:12 +00:00
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
if (flag & BKE_BPATH_TRAVERSE_SKIP_MULTIFILE) {
|
2011-11-01 06:26:55 +00:00
|
|
|
/* only operate on one path */
|
2015-04-10 22:01:10 +10:00
|
|
|
len = MIN2(1u, len);
|
2011-11-01 06:26:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-12 15:02:10 +00:00
|
|
|
for (i = 0; i < len; i++, se++) {
|
2011-12-18 12:54:50 +00:00
|
|
|
rewrite_path_fixed_dirfile(seq->strip->dir, se->name,
|
|
|
|
visit_cb, absbase, bpath_user_data);
|
2011-10-27 03:40:12 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-26 22:46:06 +00:00
|
|
|
else {
|
|
|
|
/* simple case */
|
2011-10-27 05:34:39 +00:00
|
|
|
rewrite_path_fixed(seq->strip->dir, visit_cb, absbase, bpath_user_data);
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
SEQ_END
|
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_ME:
|
2011-10-26 22:46:06 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
Mesh *me = (Mesh *)id;
|
2012-10-02 00:28:01 +00:00
|
|
|
if (me->ldata.external) {
|
|
|
|
rewrite_path_fixed(me->ldata.external->filename, visit_cb, absbase, bpath_user_data);
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_LI:
|
2011-10-26 22:46:06 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
Library *lib = (Library *)id;
|
2012-12-27 15:07:19 +00:00
|
|
|
/* keep packedfile paths always relative to the blend */
|
|
|
|
if (lib->packedfile == NULL) {
|
|
|
|
if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
|
|
|
|
BKE_library_filepath_set(lib, lib->name);
|
|
|
|
}
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-10-26 22:46:06 +00:00
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
case ID_MC:
|
2011-12-04 17:16:22 +00:00
|
|
|
{
|
2012-05-12 15:02:10 +00:00
|
|
|
MovieClip *clip = (MovieClip *)id;
|
2011-12-04 17:16:22 +00:00
|
|
|
rewrite_path_fixed(clip->name, visit_cb, absbase, bpath_user_data);
|
2012-11-27 16:19:52 +00:00
|
|
|
break;
|
2011-12-04 17:16:22 +00:00
|
|
|
}
|
Basic Alembic support
All in all, this patch adds an Alembic importer, an Alembic exporter,
and a new CacheFile data block which, for now, wraps around an Alembic
archive. This data block is made available through a new modifier ("Mesh
Sequence Cache") as well as a new constraint ("Transform Cache") to
somewhat properly support respectively geometric and transformation data
streaming from alembic caches.
A more in-depth documentation is to be found on the wiki, as well as a
guide to compile alembic: https://wiki.blender.org/index.php/
User:Kevindietrich/AlembicBasicIo.
Many thanks to everyone involved in this little project, and huge shout
out to "cgstrive" for the thorough testings with Maya, 3ds Max, Houdini
and Realflow as well as @fjuhec, @jensverwiebe and @jasperge for the
custom builds and compile fixes.
Reviewers: sergey, campbellbarton, mont29
Reviewed By: sergey, campbellbarton, mont29
Differential Revision: https://developer.blender.org/D2060
2016-08-06 06:20:37 +02:00
|
|
|
case ID_CF:
|
|
|
|
{
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
rewrite_path_fixed(cache_file->filepath, visit_cb, absbase, bpath_user_data);
|
|
|
|
break;
|
|
|
|
}
|
2012-05-12 15:02:10 +00:00
|
|
|
default:
|
|
|
|
/* Nothing to do for other IDs that don't contain file paths. */
|
|
|
|
break;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_traverse_id_list(Main *bmain, ListBase *lb, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
|
2011-10-27 01:25:07 +00:00
|
|
|
{
|
|
|
|
ID *id;
|
2012-03-11 23:47:41 +00:00
|
|
|
for (id = lb->first; id; id = id->next) {
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_traverse_id(bmain, id, visit_cb, flag, bpath_user_data);
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_traverse_main(Main *bmain, BPathVisitor visit_cb, const int flag, void *bpath_user_data)
|
2011-10-27 01:25:07 +00:00
|
|
|
{
|
|
|
|
ListBase *lbarray[MAX_LIBARRAY];
|
2012-03-11 23:47:41 +00:00
|
|
|
int a = set_listbasepointers(bmain, lbarray);
|
|
|
|
while (a--) {
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_traverse_id_list(bmain, lbarray[a], visit_cb, flag, bpath_user_data);
|
2012-03-11 23:47:41 +00:00
|
|
|
}
|
2011-10-27 01:25:07 +00:00
|
|
|
}
|
|
|
|
|
2011-10-23 17:52:20 +00:00
|
|
|
/* Rewrites a relative path to be relative to the main file - unless the path is
|
2012-03-03 20:19:11 +00:00
|
|
|
* absolute, in which case it is not altered. */
|
2013-06-24 03:06:32 +00:00
|
|
|
bool BKE_bpath_relocate_visitor(void *pathbase_v, char *path_dst, const char *path_src)
|
2011-10-26 21:22:35 +00:00
|
|
|
{
|
2011-10-23 17:52:20 +00:00
|
|
|
/* be sure there is low chance of the path being too short */
|
|
|
|
char filepath[(FILE_MAXDIR * 2) + FILE_MAXFILE];
|
2012-03-11 23:47:41 +00:00
|
|
|
const char *base_new = ((char **)pathbase_v)[0];
|
|
|
|
const char *base_old = ((char **)pathbase_v)[1];
|
2011-10-23 17:52:20 +00:00
|
|
|
|
2012-08-29 10:32:38 +00:00
|
|
|
if (BLI_path_is_rel(base_old)) {
|
2011-10-26 21:22:35 +00:00
|
|
|
printf("%s: error, old base path '%s' is not absolute.\n",
|
|
|
|
__func__, base_old);
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make referenced file absolute. This would be a side-effect of
|
2012-03-08 04:12:11 +00:00
|
|
|
* BLI_cleanup_file, but we do it explicitly so we know if it changed. */
|
2011-10-26 21:22:35 +00:00
|
|
|
BLI_strncpy(filepath, path_src, FILE_MAX);
|
|
|
|
if (BLI_path_abs(filepath, base_old)) {
|
2011-10-23 17:52:20 +00:00
|
|
|
/* Path was relative and is now absolute. Remap.
|
|
|
|
* Important BLI_cleanup_dir runs before the path is made relative
|
|
|
|
* because it wont work for paths that start with "//../" */
|
2011-10-26 21:22:35 +00:00
|
|
|
BLI_cleanup_file(base_new, filepath);
|
|
|
|
BLI_path_rel(filepath, base_new);
|
|
|
|
BLI_strncpy(path_dst, filepath, FILE_MAX);
|
2013-06-24 03:06:32 +00:00
|
|
|
return true;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Path was not relative to begin with. */
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2011-10-23 17:52:20 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-07 04:13:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
/**
|
|
|
|
* Backup/Restore/Free functions,
|
2014-06-09 11:01:51 +10:00
|
|
|
* \note These functions assume the data won't change order.
|
2012-11-07 04:13:03 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct PathStore {
|
|
|
|
struct PathStore *next, *prev;
|
2013-03-24 12:13:13 +00:00
|
|
|
};
|
2012-11-07 04:13:03 +00:00
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool bpath_list_append(void *userdata, char *UNUSED(path_dst), const char *path_src)
|
2012-11-07 04:13:03 +00:00
|
|
|
{
|
|
|
|
/* store the path and string in a single alloc */
|
|
|
|
ListBase *ls = userdata;
|
|
|
|
size_t path_size = strlen(path_src) + 1;
|
2013-03-24 12:13:13 +00:00
|
|
|
struct PathStore *path_store = MEM_mallocN(sizeof(struct PathStore) + path_size, __func__);
|
2012-11-07 04:13:03 +00:00
|
|
|
char *filepath = (char *)(path_store + 1);
|
|
|
|
|
|
|
|
memcpy(filepath, path_src, path_size);
|
|
|
|
BLI_addtail(ls, path_store);
|
2013-06-24 03:06:32 +00:00
|
|
|
return false;
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
static bool bpath_list_restore(void *userdata, char *path_dst, const char *path_src)
|
2012-11-07 04:13:03 +00:00
|
|
|
{
|
|
|
|
/* assume ls->first wont be NULL because the number of paths can't change!
|
|
|
|
* (if they do caller is wrong) */
|
|
|
|
ListBase *ls = userdata;
|
|
|
|
struct PathStore *path_store = ls->first;
|
|
|
|
const char *filepath = (char *)(path_store + 1);
|
2013-06-24 03:06:32 +00:00
|
|
|
bool ret;
|
2012-11-07 04:13:03 +00:00
|
|
|
|
2013-06-24 03:06:32 +00:00
|
|
|
if (STREQ(path_src, filepath)) {
|
|
|
|
ret = false;
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BLI_strncpy(path_dst, filepath, FILE_MAX);
|
2013-06-24 03:06:32 +00:00
|
|
|
ret = true;
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BLI_freelinkN(ls, path_store);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return ls_handle */
|
2012-12-15 15:31:50 +00:00
|
|
|
void *BKE_bpath_list_backup(Main *bmain, const int flag)
|
2012-11-07 04:13:03 +00:00
|
|
|
{
|
|
|
|
ListBase *ls = MEM_callocN(sizeof(ListBase), __func__);
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_traverse_main(bmain, bpath_list_append, flag, ls);
|
2012-11-07 04:13:03 +00:00
|
|
|
|
|
|
|
return ls;
|
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_list_restore(Main *bmain, const int flag, void *ls_handle)
|
2012-11-07 04:13:03 +00:00
|
|
|
{
|
|
|
|
ListBase *ls = ls_handle;
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
BKE_bpath_traverse_main(bmain, bpath_list_restore, flag, ls);
|
2012-11-07 04:13:03 +00:00
|
|
|
}
|
|
|
|
|
2012-12-15 15:31:50 +00:00
|
|
|
void BKE_bpath_list_free(void *ls_handle)
|
2012-11-07 04:13:03 +00:00
|
|
|
{
|
|
|
|
ListBase *ls = ls_handle;
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_assert(BLI_listbase_is_empty(ls)); /* assumes we were used */
|
2012-11-07 04:13:03 +00:00
|
|
|
BLI_freelistN(ls);
|
|
|
|
MEM_freeN(ls);
|
|
|
|
}
|