2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2016 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
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-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
|
|
|
*/
|
|
|
|
|
|
2023-07-22 11:27:25 +10:00
|
|
|
#include <cstring>
|
2019-04-04 15:07:37 +02: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
|
|
|
#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"
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
#include "BKE_bpath.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"
|
|
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph_query.hh"
|
2019-04-04 15:07:37 +02:00
|
|
|
|
2021-08-19 14:34:01 +02:00
|
|
|
#include "RE_engine.h"
|
|
|
|
|
|
2023-08-28 15:01:05 +02:00
|
|
|
#include "BLO_read_write.hh"
|
2020-09-11 11:57:54 +02:00
|
|
|
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
#include "MEM_guardedalloc.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
|
|
|
|
|
|
2021-08-03 11:55:53 +02:00
|
|
|
#ifdef WITH_USD
|
|
|
|
|
# include "usd.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;
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(cache_file->velocity_name, ".velocities");
|
2020-03-09 12:21:45 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
static void cache_file_copy_data(Main * /*bmain*/,
|
2020-03-09 12:21:45 +01:00
|
|
|
ID *id_dst,
|
|
|
|
|
const ID *id_src,
|
2023-07-17 10:46:26 +02:00
|
|
|
const int /*flag*/)
|
2020-03-09 12:21:45 +01:00
|
|
|
{
|
|
|
|
|
CacheFile *cache_file_dst = (CacheFile *)id_dst;
|
|
|
|
|
const CacheFile *cache_file_src = (const CacheFile *)id_src;
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file_dst->handle = nullptr;
|
|
|
|
|
cache_file_dst->handle_readers = nullptr;
|
2020-03-09 12:21:45 +01:00
|
|
|
BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_src->object_paths);
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
BLI_duplicatelist(&cache_file_dst->layers, &cache_file_src->layers);
|
2020-03-09 12:21:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void cache_file_free_data(ID *id)
|
|
|
|
|
{
|
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
|
cachefile_handle_free(cache_file);
|
|
|
|
|
BLI_freelistN(&cache_file->object_paths);
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
BLI_freelistN(&cache_file->layers);
|
2020-03-09 12:21:45 +01:00
|
|
|
}
|
|
|
|
|
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
static void cache_file_foreach_path(ID *id, BPathForeachPathData *bpath_data)
|
|
|
|
|
{
|
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
2023-06-23 10:09:01 +10:00
|
|
|
BKE_bpath_foreach_path_fixed_process(
|
|
|
|
|
bpath_data, cache_file->filepath, sizeof(cache_file->filepath));
|
Refactor BKE_bpath module.
The main goal of this refactor is to make BPath module use `IDTypeInfo`,
and move each ID-specific part of the `foreach_path` looper into their
own IDTypeInfo struct, using a new `foreach_path` callback.
Additionally, following improvements/cleanups are included:
* Attempt to get better, more consistent namings.
** In particular, move from `path_visitor` to more standard `foreach_path`.
* Update and extend documentation.
** API doc was moved to header, according to recent discussions on this
topic.
* Remove `BKE_bpath_relocate_visitor` from API, this is specific
callback that belongs in `lib_id.c` user code.
NOTE: This commit is expected to be 100% non-behavioral-change. This
implies that several potential further changes were only noted as
comments (like using a more generic solution for
`lib_id_library_local_paths`, addressing inconsistencies like path of
packed libraries always being skipped, regardless of the
`BKE_BPATH_FOREACH_PATH_SKIP_PACKED` `eBPathForeachFlag` flag value,
etc.).
NOTE: basic unittests were added to master already in
rBdcc500e5a265093bc9cc.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D13381
2021-11-29 14:20:58 +01:00
|
|
|
}
|
|
|
|
|
|
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;
|
2021-08-19 11:13:55 +02:00
|
|
|
|
|
|
|
|
/* Clean up, important in undo case to reduce false detection of changed datablocks. */
|
|
|
|
|
BLI_listbase_clear(&cache_file->object_paths);
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file->handle = nullptr;
|
2021-08-19 11:13:55 +02:00
|
|
|
memset(cache_file->handle_filepath, 0, sizeof(cache_file->handle_filepath));
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file->handle_readers = nullptr;
|
2021-08-19 11:13:55 +02:00
|
|
|
|
|
|
|
|
BLO_write_id_struct(writer, CacheFile, id_address, &cache_file->id);
|
|
|
|
|
BKE_id_blend_write(writer, &cache_file->id);
|
|
|
|
|
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
/* write layers */
|
|
|
|
|
LISTBASE_FOREACH (CacheFileLayer *, layer, &cache_file->layers) {
|
|
|
|
|
BLO_write_struct(writer, CacheFileLayer, layer);
|
|
|
|
|
}
|
2020-09-11 11:57:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void cache_file_blend_read_data(BlendDataReader *reader, ID *id)
|
|
|
|
|
{
|
|
|
|
|
CacheFile *cache_file = (CacheFile *)id;
|
|
|
|
|
BLI_listbase_clear(&cache_file->object_paths);
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file->handle = nullptr;
|
2020-09-11 11:57:54 +02:00
|
|
|
cache_file->handle_filepath[0] = '\0';
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file->handle_readers = nullptr;
|
2020-09-11 11:57:54 +02:00
|
|
|
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
/* relink layers */
|
|
|
|
|
BLO_read_list(reader, &cache_file->layers);
|
2020-09-11 11:57:54 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-09 12:21:45 +01:00
|
|
|
IDTypeInfo IDType_ID_CF = {
|
2023-07-17 10:46:26 +02:00
|
|
|
/*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*/ IDTYPE_FLAGS_APPEND_IS_REUSABLE,
|
|
|
|
|
/*asset_type_info*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*init_data*/ cache_file_init_data,
|
|
|
|
|
/*copy_data*/ cache_file_copy_data,
|
|
|
|
|
/*free_data*/ cache_file_free_data,
|
|
|
|
|
/*make_local*/ nullptr,
|
|
|
|
|
/*foreach_id*/ nullptr,
|
|
|
|
|
/*foreach_cache*/ nullptr,
|
|
|
|
|
/*foreach_path*/ cache_file_foreach_path,
|
|
|
|
|
/*owner_pointer_get*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*blend_write*/ cache_file_blend_write,
|
|
|
|
|
/*blend_read_data*/ cache_file_blend_read_data,
|
2023-03-11 18:07:59 +01:00
|
|
|
/*blend_read_after_liblink*/ nullptr,
|
2023-07-17 10:46:26 +02:00
|
|
|
|
|
|
|
|
/*blend_read_undo_preserve*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*lib_override_apply_post*/ nullptr,
|
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;
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_cachefiles_init()
|
2016-08-26 14:25:03 +02:00
|
|
|
{
|
|
|
|
|
BLI_spin_init(&spin);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
void BKE_cachefiles_exit()
|
2016-09-19 09:02:31 +02:00
|
|
|
{
|
|
|
|
|
BLI_spin_end(&spin);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
void BKE_cachefile_reader_open(CacheFile *cache_file,
|
2023-07-20 11:30:25 +10:00
|
|
|
CacheReader **reader,
|
2019-04-04 15:07:37 +02:00
|
|
|
Object *object,
|
|
|
|
|
const char *object_path)
|
|
|
|
|
{
|
2021-08-03 11:55:53 +02:00
|
|
|
#if defined(WITH_ALEMBIC) || defined(WITH_USD)
|
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
if (cache_file->handle == nullptr) {
|
2019-04-04 15:07:37 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-03 11:55:53 +02:00
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC:
|
|
|
|
|
# ifdef WITH_ALEMBIC
|
|
|
|
|
/* Open Alembic cache reader. */
|
2023-06-15 03:37:29 +02:00
|
|
|
*reader = CacheReader_open_alembic_object(
|
|
|
|
|
cache_file->handle, *reader, object, object_path, cache_file->is_sequence);
|
2021-08-03 11:55:53 +02:00
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHEFILE_TYPE_USD:
|
|
|
|
|
# ifdef WITH_USD
|
|
|
|
|
/* Open USD cache reader. */
|
|
|
|
|
*reader = CacheReader_open_usd_object(cache_file->handle, *reader, object, object_path);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-04 15:07:37 +02:00
|
|
|
|
|
|
|
|
/* 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. */
|
2023-07-17 10:46:26 +02:00
|
|
|
if (cache_file->handle_readers == nullptr) {
|
2019-04-04 15:07:37 +02:00
|
|
|
cache_file->handle_readers = BLI_gset_ptr_new("CacheFile.handle_readers");
|
|
|
|
|
}
|
2023-07-17 10:46:26 +02:00
|
|
|
BLI_gset_reinsert(cache_file->handle_readers, reader, nullptr);
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
else if (cache_file->handle_readers) {
|
|
|
|
|
/* Remove in case CacheReader_open_alembic_object free the existing reader. */
|
2023-07-17 10:46:26 +02:00
|
|
|
BLI_gset_remove(cache_file->handle_readers, reader, nullptr);
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-20 11:30:25 +10:00
|
|
|
void BKE_cachefile_reader_free(CacheFile *cache_file, CacheReader **reader)
|
2019-04-04 15:07:37 +02:00
|
|
|
{
|
2021-08-03 11:55:53 +02:00
|
|
|
#if defined(WITH_ALEMBIC) || defined(WITH_USD)
|
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);
|
2023-07-17 10:46:26 +02:00
|
|
|
if (*reader != nullptr) {
|
2019-07-02 14:34:19 +02:00
|
|
|
if (cache_file) {
|
|
|
|
|
BLI_assert(cache_file->id.tag & LIB_TAG_COPIED_ON_WRITE);
|
2021-08-03 11:55:53 +02:00
|
|
|
|
|
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC:
|
|
|
|
|
# ifdef WITH_ALEMBIC
|
|
|
|
|
ABC_CacheReader_free(*reader);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHEFILE_TYPE_USD:
|
|
|
|
|
# ifdef WITH_USD
|
|
|
|
|
USD_CacheReader_free(*reader);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-07-02 14:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
*reader = nullptr;
|
2019-04-04 15:07:37 +02:00
|
|
|
|
2019-06-24 14:47:46 +02:00
|
|
|
if (cache_file && cache_file->handle_readers) {
|
2023-07-17 10:46:26 +02:00
|
|
|
BLI_gset_remove(cache_file->handle_readers, reader, nullptr);
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
2021-08-03 11:55:53 +02:00
|
|
|
#if defined(WITH_ALEMBIC) || defined(WITH_USD)
|
|
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
/* 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) {
|
2023-07-20 11:30:25 +10:00
|
|
|
CacheReader **reader = static_cast<CacheReader **>(BLI_gsetIterator_getKey(&gs_iter));
|
2023-07-17 10:46:26 +02:00
|
|
|
if (*reader != nullptr) {
|
2021-08-03 11:55:53 +02:00
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC:
|
|
|
|
|
# ifdef WITH_ALEMBIC
|
|
|
|
|
ABC_CacheReader_free(*reader);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHEFILE_TYPE_USD:
|
|
|
|
|
# ifdef WITH_USD
|
|
|
|
|
USD_CacheReader_free(*reader);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
*reader = nullptr;
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
BLI_gset_free(cache_file->handle_readers, nullptr);
|
|
|
|
|
cache_file->handle_readers = nullptr;
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
BLI_spin_unlock(&spin);
|
|
|
|
|
|
|
|
|
|
/* Free handle. */
|
|
|
|
|
if (cache_file->handle) {
|
2021-08-03 11:55:53 +02:00
|
|
|
|
|
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC:
|
|
|
|
|
# ifdef WITH_ALEMBIC
|
|
|
|
|
ABC_free_handle(cache_file->handle);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHEFILE_TYPE_USD:
|
|
|
|
|
# ifdef WITH_USD
|
|
|
|
|
USD_free_handle(cache_file->handle);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
cache_file->handle = nullptr;
|
2019-04-04 15:07:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
CacheFile *cache_file = static_cast<CacheFile *>(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
|
2021-08-03 11:55:53 +02:00
|
|
|
if (BLI_path_extension_check_glob(filepath, "*abc")) {
|
|
|
|
|
cache_file->type = CACHEFILE_TYPE_ALEMBIC;
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
cache_file->handle = ABC_create_handle(
|
2023-07-17 10:46:26 +02:00
|
|
|
bmain,
|
|
|
|
|
filepath,
|
|
|
|
|
static_cast<const CacheFileLayer *>(cache_file->layers.first),
|
|
|
|
|
&cache_file->object_paths);
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(cache_file->handle_filepath, filepath);
|
2021-08-03 11:55:53 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef WITH_USD
|
2023-01-26 18:08:45 -05:00
|
|
|
if (BLI_path_extension_check_glob(filepath, "*.usd;*.usda;*.usdc;*.usdz")) {
|
2021-08-03 11:55:53 +02:00
|
|
|
cache_file->type = CACHEFILE_TYPE_USD;
|
|
|
|
|
cache_file->handle = USD_create_handle(bmain, filepath, &cache_file->object_paths);
|
2023-07-25 13:31:18 +10:00
|
|
|
STRNCPY(cache_file->handle_filepath, filepath);
|
2021-08-03 11:55:53 +02: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
|
|
|
#endif
|
2019-04-04 15:07:37 +02:00
|
|
|
|
|
|
|
|
if (DEG_is_active(depsgraph)) {
|
2021-08-21 13:23:39 +10:00
|
|
|
/* Flush object paths back to original data-block for UI. */
|
2019-04-04 15:07:37 +02:00
|
|
|
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);
|
2021-07-12 16:15:03 +02:00
|
|
|
const float ctime = BKE_scene_ctime_get(scene);
|
2023-07-18 14:18:07 +10:00
|
|
|
const double fps = double(scene->r.frs_sec) / double(scene->r.frs_sec_base);
|
|
|
|
|
const int frame = int(BKE_cachefile_time_offset(cache_file, double(ctime), fps));
|
2019-04-04 15:07:37 +02: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
|
|
|
char ext[32];
|
2023-04-20 11:45:05 +10:00
|
|
|
BLI_path_frame_strip(r_filepath, ext, sizeof(ext));
|
2023-05-02 17:01:02 +10:00
|
|
|
BLI_path_frame(r_filepath, FILE_MAX, 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;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-08 17:57:35 +02:00
|
|
|
double BKE_cachefile_time_offset(const CacheFile *cache_file, const double time, const double 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
|
|
|
{
|
2023-07-18 14:18:07 +10:00
|
|
|
const double time_offset = double(cache_file->frame_offset) / fps;
|
|
|
|
|
const double frame = (cache_file->override_frame ? double(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
|
|
|
}
|
2021-08-19 14:34:01 +02:00
|
|
|
|
2022-04-01 15:27:11 +02:00
|
|
|
bool BKE_cache_file_uses_render_procedural(const CacheFile *cache_file, Scene *scene)
|
2021-08-19 14:34:01 +02:00
|
|
|
{
|
|
|
|
|
RenderEngineType *render_engine_type = RE_engines_find(scene->r.engine);
|
|
|
|
|
|
|
|
|
|
if (cache_file->type != CACHEFILE_TYPE_ALEMBIC ||
|
|
|
|
|
!RE_engine_supports_alembic_procedural(render_engine_type, scene))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-01 15:27:11 +02:00
|
|
|
return cache_file->use_render_procedural;
|
2021-08-19 14:34:01 +02:00
|
|
|
}
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
|
2022-08-27 14:51:21 +10:00
|
|
|
CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepath[1024])
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
{
|
2023-08-04 08:51:13 +10:00
|
|
|
LISTBASE_FOREACH (CacheFileLayer *, layer, &cache_file->layers) {
|
2022-08-27 14:51:21 +10:00
|
|
|
if (STREQ(layer->filepath, filepath)) {
|
2023-07-17 10:46:26 +02:00
|
|
|
return nullptr;
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int num_layers = BLI_listbase_count(&cache_file->layers);
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
CacheFileLayer *layer = static_cast<CacheFileLayer *>(
|
|
|
|
|
MEM_callocN(sizeof(CacheFileLayer), "CacheFileLayer"));
|
2023-05-09 12:50:37 +10:00
|
|
|
STRNCPY(layer->filepath, filepath);
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
|
|
|
|
|
BLI_addtail(&cache_file->layers, layer);
|
|
|
|
|
|
2023-07-18 14:18:07 +10:00
|
|
|
cache_file->active_layer = char(num_layers + 1);
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
|
|
|
|
|
return layer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CacheFileLayer *BKE_cachefile_get_active_layer(CacheFile *cache_file)
|
|
|
|
|
{
|
2023-07-17 10:46:26 +02:00
|
|
|
return static_cast<CacheFileLayer *>(
|
|
|
|
|
BLI_findlink(&cache_file->layers, cache_file->active_layer - 1));
|
Alembic: add support for reading override layers
Override layers are a standard feature of Alembic, where archives can override
data from other archives, provided that the hierarchies match.
This is useful for modifying a UV map, updating an animation, or even creating
some sort of LOD system where low resolution meshes are swapped by high resolution
versions.
It is possible to add UV maps and vertex colors using this system, however, they
will only appear in the spreadsheet editor when viewing evaluated data, as the UV
map and Vertex color UI only show data present on the original mesh.
Implementation wise, this adds a `CacheFileLayer` data structure to the `CacheFile`
DNA, as well as some operators and UI to present and manage the layers. For both
the Alembic importer and the Cycles procedural, the main change is creating an
archive from a list of filepaths, instead of a single one.
After importing the base file through the regular import operator, layers can be added
to or removed from the `CacheFile` via the UI list under the `Override Layers` panel
located in the Mesh Sequence Cache modifier. Layers can also be moved around or
hidden.
See differential page for tests files and demos.
Reviewed by: brecht, sybren
Differential Revision: https://developer.blender.org/D13603
2022-01-17 14:50:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_cachefile_remove_layer(CacheFile *cache_file, CacheFileLayer *layer)
|
|
|
|
|
{
|
|
|
|
|
cache_file->active_layer = 0;
|
|
|
|
|
BLI_remlink(&cache_file->layers, layer);
|
|
|
|
|
MEM_freeN(layer);
|
|
|
|
|
}
|