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
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2016 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
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
|
|
|
*/
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
#include <string.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_anim_types.h"
|
|
|
|
#include "DNA_cachefile_types.h"
|
2016-10-29 12:23:09 +02:00
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
#include "DNA_object_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_scene_types.h"
|
|
|
|
|
|
|
|
#include "BLI_fileops.h"
|
2019-04-04 15:07:37 +02:00
|
|
|
#include "BLI_ghash.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 "BLI_listbase.h"
|
|
|
|
#include "BLI_path_util.h"
|
|
|
|
#include "BLI_string.h"
|
2016-08-26 14:25:03 +02:00
|
|
|
#include "BLI_threads.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.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
|
|
|
|
2020-03-09 12:21:45 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
2020-09-11 11:57:54 +02:00
|
|
|
#include "BKE_anim_data.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 "BKE_cachefile.h"
|
2020-03-09 12:21:45 +01:00
|
|
|
#include "BKE_idtype.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.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 "BKE_main.h"
|
2016-10-29 12:23:09 +02:00
|
|
|
#include "BKE_modifier.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 "BKE_scene.h"
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
|
|
|
|
2020-09-11 11:57:54 +02:00
|
|
|
#include "BLO_read_write.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
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
# include "ABC_alembic.h"
|
|
|
|
#endif
|
|
|
|
|
2020-03-09 12:21:45 +01:00
|
|
|
static void cachefile_handle_free(CacheFile *cache_file);
|
|
|
|
|
|
|
|
static void cache_file_init_data(ID *id)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
|
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cache_file, id));
|
|
|
|
|
|
|
|
cache_file->scale = 1.0f;
|
2020-08-03 03:28:04 +02:00
|
|
|
cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND;
|
|
|
|
BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name));
|
2020-03-09 12:21:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cache_file_copy_data(Main *UNUSED(bmain),
|
|
|
|
ID *id_dst,
|
|
|
|
const ID *id_src,
|
|
|
|
const int UNUSED(flag))
|
|
|
|
{
|
|
|
|
CacheFile *cache_file_dst = (CacheFile *)id_dst;
|
|
|
|
const CacheFile *cache_file_src = (const CacheFile *)id_src;
|
|
|
|
|
|
|
|
cache_file_dst->handle = NULL;
|
|
|
|
cache_file_dst->handle_readers = NULL;
|
|
|
|
BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_src->object_paths);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cache_file_free_data(ID *id)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
cachefile_handle_free(cache_file);
|
|
|
|
BLI_freelistN(&cache_file->object_paths);
|
|
|
|
}
|
|
|
|
|
2020-09-11 11:57:54 +02:00
|
|
|
static void cache_file_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
if (cache_file->id.us > 0 || BLO_write_is_undo(writer)) {
|
|
|
|
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
|
|
|
|
BLI_listbase_clear(&cache_file->object_paths);
|
|
|
|
cache_file->handle = NULL;
|
|
|
|
memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
|
|
|
|
cache_file->handle_readers = NULL;
|
|
|
|
|
|
|
|
BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
|
2021-03-25 11:21:15 +01:00
|
|
|
BKE_id_blend_write(writer, &cache_file->id);
|
2020-09-11 11:57:54 +02:00
|
|
|
|
|
|
|
if (cache_file->adt) {
|
|
|
|
BKE_animdata_blend_write(writer, cache_file->adt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cache_file_blend_read_data(BlendDataReader *reader, ID *id)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
BLI_listbase_clear(&cache_file->object_paths);
|
|
|
|
cache_file->handle = NULL;
|
|
|
|
cache_file->handle_filepath[0] = '\0';
|
|
|
|
cache_file->handle_readers = NULL;
|
|
|
|
|
|
|
|
/* relink animdata */
|
|
|
|
BLO_read_data_address(reader, &cache_file->adt);
|
|
|
|
BKE_animdata_blend_read_data(reader, cache_file->adt);
|
|
|
|
}
|
|
|
|
|
2020-03-09 12:21:45 +01:00
|
|
|
IDTypeInfo IDType_ID_CF = {
|
|
|
|
.id_code = ID_CF,
|
|
|
|
.id_filter = FILTER_ID_CF,
|
|
|
|
.main_listbase_index = INDEX_ID_CF,
|
|
|
|
.struct_size = sizeof(CacheFile),
|
|
|
|
.name = "CacheFile",
|
|
|
|
.name_plural = "cache_files",
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_CACHEFILE,
|
|
|
|
.flags = 0,
|
|
|
|
|
|
|
|
.init_data = cache_file_init_data,
|
|
|
|
.copy_data = cache_file_copy_data,
|
|
|
|
.free_data = cache_file_free_data,
|
|
|
|
.make_local = NULL,
|
2020-05-21 18:35:11 +02:00
|
|
|
.foreach_id = NULL,
|
2020-08-28 13:05:48 +02:00
|
|
|
.foreach_cache = NULL,
|
2021-02-25 10:17:31 +01:00
|
|
|
.owner_get = NULL,
|
2020-08-28 13:05:48 +02:00
|
|
|
|
2020-09-11 11:57:54 +02:00
|
|
|
.blend_write = cache_file_blend_write,
|
|
|
|
.blend_read_data = cache_file_blend_read_data,
|
2020-08-28 13:05:48 +02:00
|
|
|
.blend_read_lib = NULL,
|
|
|
|
.blend_read_expand = NULL,
|
2020-11-03 11:39:36 +01:00
|
|
|
|
|
|
|
.blend_read_undo_preserve = NULL,
|
2021-01-22 14:52:50 +01:00
|
|
|
|
|
|
|
.lib_override_apply_post = NULL,
|
2020-03-09 12:21:45 +01:00
|
|
|
};
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
/* TODO: make this per cache file to avoid global locks. */
|
2016-08-26 14:25:03 +02:00
|
|
|
static SpinLock spin;
|
|
|
|
|
|
|
|
void BKE_cachefiles_init(void)
|
|
|
|
{
|
|
|
|
BLI_spin_init(&spin);
|
|
|
|
}
|
|
|
|
|
2016-09-19 09:02:31 +02:00
|
|
|
void BKE_cachefiles_exit(void)
|
|
|
|
{
|
|
|
|
BLI_spin_end(&spin);
|
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
void BKE_cachefile_reader_open(CacheFile *cache_file,
|
|
|
|
struct CacheReader **reader,
|
|
|
|
Object *object,
|
|
|
|
const char *object_path)
|
|
|
|
{
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
|
|
|
|
|
|
|
|
if (cache_file->handle == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open Alembic cache reader. */
|
|
|
|
*reader = CacheReader_open_alembic_object(cache_file->handle, *reader, object, object_path);
|
|
|
|
|
|
|
|
/* Multiple modifiers and constraints can call this function concurrently. */
|
|
|
|
BLI_spin_lock(&spin);
|
|
|
|
if (*reader) {
|
|
|
|
/* Register in set so we can free it when the cache file changes. */
|
|
|
|
if (cache_file->handle_readers == NULL) {
|
|
|
|
cache_file->handle_readers = BLI_gset_ptr_new("CacheFile.handle_readers");
|
|
|
|
}
|
|
|
|
BLI_gset_reinsert(cache_file->handle_readers, reader, NULL);
|
|
|
|
}
|
|
|
|
else if (cache_file->handle_readers) {
|
|
|
|
/* Remove in case CacheReader_open_alembic_object free the existing reader. */
|
|
|
|
BLI_gset_remove(cache_file->handle_readers, reader, NULL);
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&spin);
|
|
|
|
#else
|
2019-05-02 10:37:42 +10:00
|
|
|
UNUSED_VARS(cache_file, reader, object, object_path);
|
2019-04-04 15:07:37 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_cachefile_reader_free(CacheFile *cache_file, struct CacheReader **reader)
|
|
|
|
{
|
|
|
|
#ifdef WITH_ALEMBIC
|
2021-06-18 13:52:09 +02:00
|
|
|
/* Multiple modifiers and constraints can call this function concurrently, and
|
|
|
|
* cachefile_handle_free() can also be called at the same time. */
|
|
|
|
BLI_spin_lock(&spin);
|
2019-04-04 15:07:37 +02:00
|
|
|
if (*reader != NULL) {
|
2019-07-02 14:34:19 +02:00
|
|
|
if (cache_file) {
|
|
|
|
BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
|
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
CacheReader_free(*reader);
|
|
|
|
*reader = NULL;
|
|
|
|
|
2019-06-24 14:47:46 +02:00
|
|
|
if (cache_file && cache_file->handle_readers) {
|
2019-04-04 15:07:37 +02:00
|
|
|
BLI_gset_remove(cache_file->handle_readers, reader, NULL);
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 13:52:09 +02:00
|
|
|
BLI_spin_unlock(&spin);
|
2019-04-04 15:07:37 +02:00
|
|
|
#else
|
|
|
|
UNUSED_VARS(cache_file, reader);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cachefile_handle_free(CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
/* Free readers in all modifiers and constraints that use the handle, before
|
|
|
|
* we free the handle itself. */
|
|
|
|
BLI_spin_lock(&spin);
|
|
|
|
if (cache_file->handle_readers) {
|
|
|
|
GSetIterator gs_iter;
|
|
|
|
GSET_ITER (gs_iter, cache_file->handle_readers) {
|
|
|
|
struct CacheReader **reader = BLI_gsetIterator_getKey(&gs_iter);
|
|
|
|
if (*reader != NULL) {
|
|
|
|
CacheReader_free(*reader);
|
|
|
|
*reader = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_gset_free(cache_file->handle_readers, NULL);
|
|
|
|
cache_file->handle_readers = NULL;
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&spin);
|
|
|
|
|
|
|
|
/* Free handle. */
|
|
|
|
if (cache_file->handle) {
|
|
|
|
ABC_free_handle(cache_file->handle);
|
|
|
|
cache_file->handle = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_file->handle_filepath[0] = '\0';
|
|
|
|
#else
|
|
|
|
UNUSED_VARS(cache_file);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
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
|
|
|
void *BKE_cachefile_add(Main *bmain, const char *name)
|
|
|
|
{
|
2020-10-08 12:50:04 +02:00
|
|
|
CacheFile *cache_file = BKE_id_new(bmain, ID_CF, name);
|
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
|
|
|
|
|
|
|
return cache_file;
|
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file)
|
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
|
|
|
{
|
2019-04-04 15:07:37 +02:00
|
|
|
/* To force reload, free the handle and tag depsgraph to load it again. */
|
|
|
|
CacheFile *cache_file_eval = (CacheFile *)DEG_get_evaluated_id(depsgraph, &cache_file->id);
|
|
|
|
if (cache_file_eval) {
|
|
|
|
cachefile_handle_free(cache_file_eval);
|
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
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE);
|
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
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file)
|
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
|
|
|
{
|
2019-04-04 15:07:37 +02:00
|
|
|
BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
|
2016-08-26 14:25:03 +02:00
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
/* Compute filepath. */
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
if (!BKE_cachefile_filepath_get(bmain, depsgraph, cache_file, filepath)) {
|
|
|
|
return;
|
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
|
|
|
}
|
2016-08-26 14:25:03 +02:00
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
/* Test if filepath change or if we can keep the existing handle. */
|
|
|
|
if (STREQ(cache_file->handle_filepath, filepath)) {
|
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
cachefile_handle_free(cache_file);
|
|
|
|
BLI_freelistN(&cache_file->object_paths);
|
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
|
|
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
2019-09-19 15:55:03 +02:00
|
|
|
cache_file->handle = ABC_create_handle(bmain, filepath, &cache_file->object_paths);
|
2019-04-04 15:07:37 +02:00
|
|
|
BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX);
|
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
|
|
|
#endif
|
2019-04-04 15:07:37 +02:00
|
|
|
|
|
|
|
if (DEG_is_active(depsgraph)) {
|
|
|
|
/* Flush object paths back to original datablock for UI. */
|
|
|
|
CacheFile *cache_file_orig = (CacheFile *)DEG_get_original_id(&cache_file->id);
|
|
|
|
BLI_freelistN(&cache_file_orig->object_paths);
|
|
|
|
BLI_duplicatelist(&cache_file_orig->object_paths, &cache_file->object_paths);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_cachefile_filepath_get(const Main *bmain,
|
2019-04-04 15:07:37 +02:00
|
|
|
const Depsgraph *depsgraph,
|
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
|
|
|
const CacheFile *cache_file,
|
|
|
|
char r_filepath[FILE_MAX])
|
|
|
|
{
|
|
|
|
BLI_strncpy(r_filepath, cache_file->filepath, FILE_MAX);
|
|
|
|
BLI_path_abs(r_filepath, ID_BLEND_PATH(bmain, &cache_file->id));
|
|
|
|
|
|
|
|
int fframe;
|
|
|
|
int frame_len;
|
|
|
|
|
|
|
|
if (cache_file->is_sequence && BLI_path_frame_get(r_filepath, &fframe, &frame_len)) {
|
2019-04-04 15:07:37 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
|
|
|
const float ctime = BKE_scene_frame_get(scene);
|
|
|
|
const float fps = (((double)scene->r.frs_sec) / (double)scene->r.frs_sec_base);
|
|
|
|
const float frame = BKE_cachefile_time_offset(cache_file, ctime, fps);
|
|
|
|
|
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
|
|
|
char ext[32];
|
Fix BLI_path_frame_strip
The `BLI_path_frame_strip` function was completely broken, unless the
number of digits in the sequence number was the same as the length of
the extension. In other words, it would work fine for `file.0001.abc` (4
digit `0001` and 4 char `.abc`), but other combinations would truncate
to the shortest (`file.001.abc` would become `file.###.ab` and
`file.00001.a` would become `file.##.a`). The dependency between the
sequence number and the file extension is now removed.
The behaviour has changed a little bit in the case where there are no
numbers in the filename. Previously, `path="filename.abc"` would result
in `path="filename.abc"` and `ext=""`, but now it results in
`path="filename"` and `ext=".abc"`. This way `ext` always contains the
extension, and the behaviour is consistent regardless of whether there
were any numbers found.
Furthermore, I've removed the `bool set_frame_char` parameter, because
it was unclear, probably also buggy, and most importantly, never used.
I've also added a unit test for the `BLI_path_frame_strip` function.
2019-03-20 12:59:11 +01:00
|
|
|
BLI_path_frame_strip(r_filepath, ext);
|
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
|
|
|
BLI_path_frame(r_filepath, frame, frame_len);
|
2018-06-17 16:13:24 +02:00
|
|
|
BLI_path_extension_ensure(r_filepath, FILE_MAX, ext);
|
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
|
|
|
|
|
|
|
/* TODO(kevin): store sequence range? */
|
|
|
|
return BLI_exists(r_filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
float BKE_cachefile_time_offset(const CacheFile *cache_file, const float time, const float fps)
|
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
|
|
|
{
|
2017-10-29 17:23:50 +01:00
|
|
|
const float time_offset = cache_file->frame_offset / fps;
|
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
|
|
|
const float frame = (cache_file->override_frame ? cache_file->frame : time);
|
2017-10-29 17:23:50 +01:00
|
|
|
return cache_file->is_sequence ? frame : frame / fps - time_offset;
|
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
|
|
|
}
|