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
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* Contributor(s): Kevin Dietrich.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file blender/blenkernel/intern/cachefile.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#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"
|
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_utildefines.h"
|
|
|
|
|
|
|
|
#include "BKE_animsys.h"
|
|
|
|
#include "BKE_cachefile.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#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"
|
|
|
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
# include "ABC_alembic.h"
|
|
|
|
#endif
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0);
|
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
|
|
|
|
|
|
|
BKE_cachefile_init(cache_file);
|
|
|
|
|
|
|
|
return cache_file;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_cachefile_init(CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
cache_file->handle = NULL;
|
|
|
|
cache_file->filepath[0] = '\0';
|
|
|
|
cache_file->override_frame = false;
|
|
|
|
cache_file->frame = 0.0f;
|
|
|
|
cache_file->is_sequence = false;
|
|
|
|
cache_file->scale = 1.0f;
|
2016-08-26 14:25:03 +02:00
|
|
|
cache_file->handle_mutex = BLI_mutex_alloc();
|
2017-04-21 12:47:14 +02:00
|
|
|
BLI_listbase_clear(&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
|
|
|
}
|
|
|
|
|
|
|
|
/** Free (or release) any data used by this cachefile (does not free the cachefile itself). */
|
|
|
|
void BKE_cachefile_free(CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
BKE_animdata_free((ID *)cache_file, false);
|
|
|
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
ABC_free_handle(cache_file->handle);
|
|
|
|
#endif
|
|
|
|
|
2016-11-04 08:11:40 +01:00
|
|
|
if (cache_file->handle_mutex) {
|
|
|
|
BLI_mutex_free(cache_file->handle_mutex);
|
|
|
|
}
|
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_freelistN(&cache_file->object_paths);
|
|
|
|
}
|
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/**
|
|
|
|
* Only copy internal data of CacheFile ID from source to already allocated/initialized destination.
|
|
|
|
* You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
|
|
|
|
*
|
|
|
|
* WARNING! This function will not handle ID user count!
|
|
|
|
*
|
|
|
|
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
|
|
|
|
*/
|
|
|
|
void BKE_cachefile_copy_data(
|
|
|
|
Main *UNUSED(bmain), CacheFile *cache_file_dst, const CacheFile *UNUSED(cache_file_src), const int UNUSED(flag))
|
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
|
|
|
{
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
cache_file_dst->handle = NULL;
|
|
|
|
BLI_listbase_clear(&cache_file_dst->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
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file_copy;
|
|
|
|
BKE_id_copy_ex(bmain, &cache_file->id, (ID **)&cache_file_copy, 0, false);
|
|
|
|
return cache_file_copy;
|
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_make_local(Main *bmain, CacheFile *cache_file, const bool lib_local)
|
|
|
|
{
|
|
|
|
BKE_id_make_local_generic(bmain, &cache_file->id, true, lib_local);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_cachefile_reload(const Main *bmain, CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
char filepath[FILE_MAX];
|
|
|
|
|
|
|
|
BLI_strncpy(filepath, cache_file->filepath, sizeof(filepath));
|
|
|
|
BLI_path_abs(filepath, ID_BLEND_PATH(bmain, &cache_file->id));
|
|
|
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
if (cache_file->handle) {
|
|
|
|
ABC_free_handle(cache_file->handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
cache_file->handle = ABC_create_handle(filepath, &cache_file->object_paths);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_cachefile_ensure_handle(const Main *bmain, CacheFile *cache_file)
|
|
|
|
{
|
2016-08-26 14:25:03 +02:00
|
|
|
BLI_spin_lock(&spin);
|
|
|
|
if (cache_file->handle_mutex == NULL) {
|
|
|
|
cache_file->handle_mutex = BLI_mutex_alloc();
|
|
|
|
}
|
|
|
|
BLI_spin_unlock(&spin);
|
|
|
|
|
|
|
|
BLI_mutex_lock(cache_file->handle_mutex);
|
|
|
|
|
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
|
|
|
if (cache_file->handle == NULL) {
|
|
|
|
BKE_cachefile_reload(bmain, cache_file);
|
|
|
|
}
|
2016-08-26 14:25:03 +02:00
|
|
|
|
|
|
|
BLI_mutex_unlock(cache_file->handle_mutex);
|
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_update_frame(Main *bmain, Scene *scene, const float ctime, const float fps)
|
|
|
|
{
|
|
|
|
CacheFile *cache_file;
|
|
|
|
char filename[FILE_MAX];
|
|
|
|
|
|
|
|
for (cache_file = bmain->cachefiles.first; cache_file; cache_file = cache_file->id.next) {
|
|
|
|
/* Execute drivers only, as animation has already been done. */
|
|
|
|
BKE_animsys_evaluate_animdata(scene, &cache_file->id, cache_file->adt, ctime, ADT_RECALC_DRIVERS);
|
|
|
|
|
|
|
|
if (!cache_file->is_sequence) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const float time = BKE_cachefile_time_offset(cache_file, ctime, fps);
|
|
|
|
|
|
|
|
if (BKE_cachefile_filepath_get(bmain, cache_file, time, filename)) {
|
2017-07-03 13:49:16 +02:00
|
|
|
BKE_cachefile_clean(scene, 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
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
ABC_free_handle(cache_file->handle);
|
|
|
|
cache_file->handle = ABC_create_handle(filename, NULL);
|
|
|
|
#endif
|
2017-07-03 13:49:16 +02:00
|
|
|
break;
|
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, const CacheFile *cache_file, float frame,
|
|
|
|
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)) {
|
|
|
|
char ext[32];
|
|
|
|
BLI_path_frame_strip(r_filepath, true, ext);
|
|
|
|
BLI_path_frame(r_filepath, frame, frame_len);
|
|
|
|
BLI_ensure_extension(r_filepath, FILE_MAX, ext);
|
|
|
|
|
|
|
|
/* TODO(kevin): store sequence range? */
|
|
|
|
return BLI_exists(r_filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
float BKE_cachefile_time_offset(CacheFile *cache_file, const float time, const float fps)
|
|
|
|
{
|
|
|
|
const float frame = (cache_file->override_frame ? cache_file->frame : time);
|
|
|
|
return cache_file->is_sequence ? frame : frame / fps;
|
|
|
|
}
|
2016-10-29 12:23:09 +02:00
|
|
|
|
|
|
|
/* TODO(kevin): replace this with some depsgraph mechanism, or something similar. */
|
|
|
|
void BKE_cachefile_clean(Scene *scene, CacheFile *cache_file)
|
|
|
|
{
|
|
|
|
for (Base *base = scene->base.first; base; base = base->next) {
|
|
|
|
Object *ob = base->object;
|
|
|
|
|
|
|
|
ModifierData *md = modifiers_findByType(ob, eModifierType_MeshSequenceCache);
|
|
|
|
|
|
|
|
if (md) {
|
|
|
|
MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)md;
|
|
|
|
|
|
|
|
if (cache_file == mcmd->cache_file) {
|
2016-10-30 03:42:46 +01:00
|
|
|
#ifdef WITH_ALEMBIC
|
2017-01-30 10:46:24 +01:00
|
|
|
if (mcmd->reader != NULL) {
|
|
|
|
CacheReader_free(mcmd->reader);
|
|
|
|
}
|
2016-10-30 03:42:46 +01:00
|
|
|
#endif
|
2016-10-29 12:23:09 +02:00
|
|
|
mcmd->reader = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (bConstraint *con = ob->constraints.first; con; con = con->next) {
|
|
|
|
if (con->type != CONSTRAINT_TYPE_TRANSFORM_CACHE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
bTransformCacheConstraint *data = con->data;
|
|
|
|
|
|
|
|
if (cache_file == data->cache_file) {
|
2016-10-30 03:42:46 +01:00
|
|
|
#ifdef WITH_ALEMBIC
|
2017-01-30 10:46:24 +01:00
|
|
|
if (data->reader != NULL) {
|
|
|
|
CacheReader_free(data->reader);
|
|
|
|
}
|
2016-10-30 03:42:46 +01:00
|
|
|
#endif
|
2016-10-29 12:23:09 +02:00
|
|
|
data->reader = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|