2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 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 modifiers
|
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
|
|
|
*/
|
|
|
|
|
|
2022-03-23 23:24:54 -05:00
|
|
|
#include <cstring>
|
2019-04-04 15:07:37 +02:00
|
|
|
|
2022-05-17 09:41:32 +02:00
|
|
|
#include "BLI_math_vector.hh"
|
2019-04-04 15:07:37 +02:00
|
|
|
#include "BLI_string.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2019-04-04 15:07:37 +02:00
|
|
|
|
2024-02-09 18:59:42 +01:00
|
|
|
#include "BLT_translation.hh"
|
2020-06-05 10:41:03 -04: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_cachefile_types.h"
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2017-08-08 18:21:08 +02:00
|
|
|
#include "DNA_mesh_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_modifier_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2024-08-06 06:09:57 +02:00
|
|
|
#include "DNA_pointcloud_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"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_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
|
|
|
|
2020-08-03 03:28:04 +02:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2024-02-09 19:29:34 +01:00
|
|
|
#include "BKE_cachefile.hh"
|
2024-02-28 03:02:38 +01:00
|
|
|
#include "BKE_geometry_set.hh"
|
2024-01-18 12:20:42 +01:00
|
|
|
#include "BKE_lib_query.hh"
|
2023-03-12 22:29:15 +01:00
|
|
|
#include "BKE_mesh.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_resources.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_access.hh"
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_prototypes.hh"
|
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-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph_build.hh"
|
|
|
|
|
#include "DEG_depsgraph_query.hh"
|
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
|
|
|
|
2022-05-17 09:41:32 +02:00
|
|
|
#include "GEO_mesh_primitive_cuboid.hh"
|
|
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
#include "MOD_modifiertypes.hh"
|
|
|
|
|
#include "MOD_ui_common.hh"
|
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-03 11:55:53 +02:00
|
|
|
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
|
2024-01-15 12:44:04 -05:00
|
|
|
# include "BKE_lib_id.hh"
|
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
|
|
|
|
|
|
2021-08-03 11:55:53 +02:00
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
|
# include "ABC_alembic.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef WITH_USD
|
2024-02-06 13:03:28 +01:00
|
|
|
# include "usd.hh"
|
2021-08-03 11:55:53 +02:00
|
|
|
#endif
|
|
|
|
|
|
2024-02-28 03:02:38 +01:00
|
|
|
using namespace blender;
|
Mesh: Remove redundant custom data pointers
For copy-on-write, we want to share attribute arrays between meshes
where possible. Mutable pointers like `Mesh.mvert` make that difficult
by making ownership vague. They also make code more complex by adding
redundancy.
The simplest solution is just removing them and retrieving layers from
`CustomData` as needed. Similar changes have already been applied to
curves and point clouds (e9f82d3dc7ee, 410a6efb747f). Removing use of
the pointers generally makes code more obvious and more reusable.
Mesh data is now accessed with a C++ API (`Mesh::edges()` or
`Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`).
The CoW changes this commit makes possible are described in T95845
and T95842, and started in D14139 and D14140. The change also simplifies
the ongoing mesh struct-of-array refactors from T95965.
**RNA/Python Access Performance**
Theoretically, accessing mesh elements with the RNA API may become
slower, since the layer needs to be found on every random access.
However, overhead is already high enough that this doesn't make a
noticible differenc, and performance is actually improved in some
cases. Random access can be up to 10% faster, but other situations
might be a bit slower. Generally using `foreach_get/set` are the best
way to improve performance. See the differential revision for more
discussion about Python performance.
Cycles has been updated to use raw pointers and the internal Blender
mesh types, mostly because there is no sense in having this overhead
when it's already compiled with Blender. In my tests this roughly
halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million
face grid).
Differential Revision: https://developer.blender.org/D15488
2022-09-05 11:56:34 -05:00
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void init_data(ModifierData *md)
|
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
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
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
|
|
|
|
2025-05-20 17:32:49 +02:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(mcmd, modifier));
|
|
|
|
|
|
|
|
|
|
mcmd->cache_file = nullptr;
|
|
|
|
|
mcmd->object_path[0] = '\0';
|
|
|
|
|
mcmd->read_flag = MOD_MESHSEQ_READ_ALL;
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(mcmd, DNA_struct_default_get(MeshSeqCacheModifierData), modifier);
|
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-27 12:04:18 +10:00
|
|
|
static void copy_data(const ModifierData *md, ModifierData *target, const int 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
|
|
|
{
|
|
|
|
|
#if 0
|
2018-05-08 15:04:10 +02:00
|
|
|
const MeshSeqCacheModifierData *mcmd = (const MeshSeqCacheModifierData *)md;
|
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
|
|
|
|
|
MeshSeqCacheModifierData *tmcmd = (MeshSeqCacheModifierData *)target;
|
|
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_copydata_generic(md, target, 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
|
|
|
|
2022-03-23 15:33:29 +01:00
|
|
|
tmcmd->reader = nullptr;
|
2019-04-04 15:07:37 +02:00
|
|
|
tmcmd->reader_object_path[0] = '\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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void free_data(ModifierData *md)
|
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
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
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-10-29 12:23:09 +02:00
|
|
|
if (mcmd->reader) {
|
2019-04-04 15:07:37 +02:00
|
|
|
mcmd->reader_object_path[0] = '\0';
|
|
|
|
|
BKE_cachefile_reader_free(mcmd->cache_file, &mcmd->reader);
|
2016-10-29 12:23:09 +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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*use_render_params*/)
|
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
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
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
|
|
|
|
|
|
|
|
/* leave it up to the modifier to check the file is valid on calculation */
|
2022-03-23 15:33:29 +01:00
|
|
|
return (mcmd->cache_file == nullptr) || (mcmd->object_path[0] == '\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
|
|
|
}
|
|
|
|
|
|
2022-12-09 13:51:52 -06:00
|
|
|
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
|
|
|
|
|
|
2022-12-09 04:25:29 +01:00
|
|
|
/* Return true if the modifier evaluation is for the ORCO mesh and the mesh hasn't changed
|
|
|
|
|
* topology.
|
|
|
|
|
*/
|
|
|
|
|
static bool can_use_mesh_for_orco_evaluation(MeshSeqCacheModifierData *mcmd,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
const Mesh *mesh,
|
|
|
|
|
const float time,
|
2024-08-23 13:09:20 +10:00
|
|
|
const char **r_err_str)
|
2022-12-09 04:25:29 +01:00
|
|
|
{
|
|
|
|
|
if ((ctx->flag & MOD_APPLY_ORCO) == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CacheFile *cache_file = mcmd->cache_file;
|
|
|
|
|
|
|
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC:
|
2022-12-09 13:51:52 -06:00
|
|
|
# ifdef WITH_ALEMBIC
|
2024-08-23 13:09:20 +10:00
|
|
|
if (!ABC_mesh_topology_changed(mcmd->reader, ctx->object, mesh, time, r_err_str)) {
|
2022-12-09 04:25:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2022-12-09 13:51:52 -06:00
|
|
|
# endif
|
2022-12-09 04:25:29 +01:00
|
|
|
break;
|
|
|
|
|
case CACHEFILE_TYPE_USD:
|
2022-12-09 13:51:52 -06:00
|
|
|
# ifdef WITH_USD
|
2024-02-06 13:03:28 +01:00
|
|
|
if (!blender::io::usd::USD_mesh_topology_changed(
|
2024-08-23 13:09:20 +10:00
|
|
|
mcmd->reader, ctx->object, mesh, time, r_err_str))
|
2024-02-06 13:03:28 +01:00
|
|
|
{
|
2022-12-09 04:25:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2022-12-09 13:51:52 -06:00
|
|
|
# endif
|
2022-12-09 04:25:29 +01:00
|
|
|
break;
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 06:09:57 +02:00
|
|
|
static Mesh *generate_bounding_box_mesh(const std::optional<Bounds<float3>> &bounds,
|
|
|
|
|
Material **mat,
|
|
|
|
|
short totcol)
|
2021-08-19 14:34:01 +02:00
|
|
|
{
|
2023-06-16 08:08:18 -04:00
|
|
|
if (!bounds) {
|
2022-05-17 09:41:32 +02:00
|
|
|
return nullptr;
|
2021-08-19 14:34:01 +02:00
|
|
|
}
|
|
|
|
|
|
2023-06-16 08:08:18 -04:00
|
|
|
Mesh *result = geometry::create_cuboid_mesh(bounds->max - bounds->min, 2, 2, 2);
|
2024-08-06 06:09:57 +02:00
|
|
|
if (mat) {
|
|
|
|
|
result->mat = static_cast<Material **>(MEM_dupallocN(mat));
|
|
|
|
|
result->totcol = totcol;
|
2023-03-15 19:01:53 +01:00
|
|
|
}
|
2024-08-06 06:09:57 +02:00
|
|
|
|
2025-03-28 11:36:39 -04:00
|
|
|
bke::mesh_translate(*result, math::midpoint(bounds->min, bounds->max), false);
|
2021-08-19 14:34:01 +02:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 13:51:52 -06:00
|
|
|
#endif
|
|
|
|
|
|
2024-02-28 03:02:38 +01:00
|
|
|
static void modify_geometry_set(ModifierData *md,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
bke::GeometrySet *geometry_set)
|
|
|
|
|
{
|
|
|
|
|
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
|
|
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
|
|
|
|
|
|
|
|
|
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
|
|
|
|
CacheFile *cache_file = mcmd->cache_file;
|
|
|
|
|
const float frame = DEG_get_ctime(ctx->depsgraph);
|
2024-04-18 20:55:13 +02:00
|
|
|
const double time = BKE_cachefile_time_offset(cache_file, frame, FPS);
|
2024-02-28 03:02:38 +01:00
|
|
|
const char *err_str = nullptr;
|
|
|
|
|
|
|
|
|
|
if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
|
|
|
|
|
STRNCPY(mcmd->reader_object_path, mcmd->object_path);
|
|
|
|
|
BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
|
|
|
|
|
if (!mcmd->reader) {
|
|
|
|
|
BKE_modifier_set_error(
|
|
|
|
|
ctx->object, md, "Could not create cache reader for file %s", cache_file->filepath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (geometry_set->has_mesh()) {
|
|
|
|
|
const Mesh *mesh = geometry_set->get_mesh();
|
|
|
|
|
if (can_use_mesh_for_orco_evaluation(mcmd, ctx, mesh, time, &err_str)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Do not process data if using a render procedural, return a box instead for displaying in the
|
|
|
|
|
* viewport. */
|
|
|
|
|
if (BKE_cache_file_uses_render_procedural(cache_file, scene)) {
|
2024-08-06 06:09:57 +02:00
|
|
|
Mesh *bbox = nullptr;
|
2024-02-28 03:02:38 +01:00
|
|
|
if (geometry_set->has_mesh()) {
|
2024-08-06 06:09:57 +02:00
|
|
|
const Mesh *mesh = geometry_set->get_mesh();
|
|
|
|
|
bbox = generate_bounding_box_mesh(mesh->bounds_min_max(), mesh->mat, mesh->totcol);
|
|
|
|
|
}
|
|
|
|
|
else if (geometry_set->has_pointcloud()) {
|
|
|
|
|
const PointCloud *pointcloud = geometry_set->get_pointcloud();
|
|
|
|
|
bbox = generate_bounding_box_mesh(
|
|
|
|
|
pointcloud->bounds_min_max(), pointcloud->mat, pointcloud->totcol);
|
2024-02-28 03:02:38 +01:00
|
|
|
}
|
|
|
|
|
|
2025-03-06 20:53:52 +01:00
|
|
|
*geometry_set = bke::GeometrySet::from_mesh(bbox);
|
2024-02-28 03:02:38 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Time (in frames or seconds) between two velocity samples. Automatically computed to
|
|
|
|
|
* scale the velocity vectors at render time for generating proper motion blur data. */
|
2025-01-13 09:40:30 +01:00
|
|
|
# ifdef WITH_ALEMBIC
|
2024-02-28 03:02:38 +01:00
|
|
|
float velocity_scale = mcmd->velocity_scale;
|
|
|
|
|
if (mcmd->cache_file->velocity_unit == CACHEFILE_VELOCITY_UNIT_FRAME) {
|
|
|
|
|
velocity_scale *= FPS;
|
|
|
|
|
}
|
2025-01-13 09:40:30 +01:00
|
|
|
# endif
|
2024-02-28 03:02:38 +01:00
|
|
|
|
|
|
|
|
switch (cache_file->type) {
|
|
|
|
|
case CACHEFILE_TYPE_ALEMBIC: {
|
|
|
|
|
# ifdef WITH_ALEMBIC
|
|
|
|
|
ABCReadParams params;
|
|
|
|
|
params.time = time;
|
|
|
|
|
params.read_flags = mcmd->read_flag;
|
|
|
|
|
params.velocity_name = mcmd->cache_file->velocity_name;
|
|
|
|
|
params.velocity_scale = velocity_scale;
|
|
|
|
|
ABC_read_geometry(mcmd->reader, ctx->object, *geometry_set, ¶ms, &err_str);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CACHEFILE_TYPE_USD: {
|
|
|
|
|
# ifdef WITH_USD
|
|
|
|
|
const blender::io::usd::USDMeshReadParams params = blender::io::usd::create_mesh_read_params(
|
|
|
|
|
time * FPS, mcmd->read_flag);
|
|
|
|
|
blender::io::usd::USD_read_geometry(
|
|
|
|
|
mcmd->reader, ctx->object, *geometry_set, params, &err_str);
|
|
|
|
|
# endif
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case CACHE_FILE_TYPE_INVALID:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err_str) {
|
|
|
|
|
BKE_modifier_set_error(ctx->object, md, "%s", err_str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
UNUSED_VARS(ctx, md, geometry_set);
|
|
|
|
|
return;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static Mesh *modify_mesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
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-03 11:55:53 +02:00
|
|
|
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-08-09 11:51:21 +02:00
|
|
|
/* Only used to check whether we are operating on org data or not... */
|
2023-12-08 16:40:06 -05:00
|
|
|
Mesh *object_mesh = (ctx->object->type == OB_MESH) ? static_cast<Mesh *>(ctx->object->data) :
|
|
|
|
|
nullptr;
|
2018-06-06 11:06:11 +02:00
|
|
|
Mesh *org_mesh = mesh;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-22 15:03:42 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
2019-04-04 15:07:37 +02:00
|
|
|
CacheFile *cache_file = mcmd->cache_file;
|
2018-06-06 11:06:11 +02:00
|
|
|
const float frame = DEG_get_ctime(ctx->depsgraph);
|
2022-09-25 18:33:28 +10:00
|
|
|
const double time = BKE_cachefile_time_offset(cache_file, double(frame), FPS);
|
2022-03-23 15:33:29 +01:00
|
|
|
const char *err_str = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-04 15:07:37 +02:00
|
|
|
if (!mcmd->reader || !STREQ(mcmd->reader_object_path, mcmd->object_path)) {
|
|
|
|
|
STRNCPY(mcmd->reader_object_path, mcmd->object_path);
|
|
|
|
|
BKE_cachefile_reader_open(cache_file, &mcmd->reader, ctx->object, mcmd->object_path);
|
2016-11-18 12:03:12 +01:00
|
|
|
if (!mcmd->reader) {
|
2020-05-08 19:02:03 +10:00
|
|
|
BKE_modifier_set_error(
|
2021-08-03 11:55:53 +02:00
|
|
|
ctx->object, md, "Could not create reader for file %s", cache_file->filepath);
|
2018-06-06 11:06:11 +02:00
|
|
|
return mesh;
|
2016-10-29 12:23:09 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-19 14:34:01 +02:00
|
|
|
/* Do not process data if using a render procedural, return a box instead for displaying in the
|
|
|
|
|
* viewport. */
|
2022-04-01 15:27:11 +02:00
|
|
|
if (BKE_cache_file_uses_render_procedural(cache_file, scene)) {
|
2024-08-06 06:09:57 +02:00
|
|
|
return generate_bounding_box_mesh(org_mesh->bounds_min_max(), org_mesh->mat, org_mesh->totcol);
|
2021-08-19 14:34:01 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-03 11:55:53 +02:00
|
|
|
/* If this invocation is for the ORCO mesh, and the mesh hasn't changed topology, we
|
2019-08-16 14:52:08 +02:00
|
|
|
* must return the mesh as-is instead of deforming it. */
|
2022-12-09 04:25:29 +01:00
|
|
|
if (can_use_mesh_for_orco_evaluation(mcmd, ctx, mesh, time, &err_str)) {
|
|
|
|
|
return mesh;
|
2019-08-16 14:52:08 +02:00
|
|
|
}
|
|
|
|
|
|
2023-12-08 16:40:06 -05:00
|
|
|
if (object_mesh != nullptr) {
|
Mesh: Move positions to a generic attribute
**Changes**
As described in T93602, this patch removes all use of the `MVert`
struct, replacing it with a generic named attribute with the name
`"position"`, consistent with other geometry types.
Variable names have been changed from `verts` to `positions`, to align
with the attribute name and the more generic design (positions are not
vertices, they are just an attribute stored on the point domain).
This change is made possible by previous commits that moved all other
data out of `MVert` to runtime data or other generic attributes. What
remains is mostly a simple type change. Though, the type still shows up
859 times, so the patch is quite large.
One compromise is that now `CD_MASK_BAREMESH` now contains
`CD_PROP_FLOAT3`. With the general move towards generic attributes
over custom data types, we are removing use of these type masks anyway.
**Benefits**
The most obvious benefit is reduced memory usage and the benefits
that brings in memory-bound situations. `float3` is only 3 bytes, in
comparison to `MVert` which was 4. When there are millions of vertices
this starts to matter more.
The other benefits come from using a more generic type. Instead of
writing algorithms specifically for `MVert`, code can just use arrays
of vectors. This will allow eliminating many temporary arrays or
wrappers used to extract positions.
Many possible improvements aren't implemented in this patch, though
I did switch simplify or remove the process of creating temporary
position arrays in a few places.
The design clarity that "positions are just another attribute" brings
allows removing explicit copying of vertices in some procedural
operations-- they are just processed like most other attributes.
**Performance**
This touches so many areas that it's hard to benchmark exhaustively,
but I observed some areas as examples.
* The mesh line node with 4 million count was 1.5x (8ms to 12ms) faster.
* The Spring splash screen went from ~4.3 to ~4.5 fps.
* The subdivision surface modifier/node was slightly faster
RNA access through Python may be slightly slower, since now we need
a name lookup instead of just a custom data type lookup for each index.
**Future Improvements**
* Remove uses of "vert_coords" functions:
* `BKE_mesh_vert_coords_alloc`
* `BKE_mesh_vert_coords_get`
* `BKE_mesh_vert_coords_apply{_with_mat4}`
* Remove more hidden copying of positions
* General simplification now possible in many areas
* Convert more code to C++ to use `float3` instead of `float[3]`
* Currently `reinterpret_cast` is used for those C-API functions
Differential Revision: https://developer.blender.org/D15982
2023-01-10 00:10:43 -05:00
|
|
|
const Span<float3> mesh_positions = mesh->vert_positions();
|
Mesh: Move edges to a generic attribute
Implements #95966, as the final step of #95965.
This commit changes the storage of mesh edge vertex indices from the
`MEdge` type to the generic `int2` attribute type. This follows the
general design for geometry and the attribute system, where the data
storage type and the usage semantics are separated.
The main benefit of the change is reduced memory usage-- the
requirements of storing mesh edges is reduced by 1/3. For example,
this saves 8MB on a 1 million vertex grid. This also gives performance
benefits to any memory-bound mesh processing algorithm that uses edges.
Another benefit is that all of the edge's vertex indices are
contiguous. In a few cases, it's helpful to process all of them as
`Span<int>` rather than `Span<int2>`. Similarly, the type is more
likely to match a generic format used by a library, or code that
shouldn't know about specific Blender `Mesh` types.
Various Notes:
- The `.edge_verts` name is used to reflect a mapping between domains,
similar to `.corner_verts`, etc. The period means that it the data
shouldn't change arbitrarily by the user or procedural operations.
- `edge[0]` is now used instead of `edge.v1`
- Signed integers are used instead of unsigned to reduce the mixing
of signed-ness, which can be error prone.
- All of the previously used core mesh data types (`MVert`, `MEdge`,
`MLoop`, `MPoly` are now deprecated. Only generic types are used).
- The `vec2i` DNA type is used in the few C files where necessary.
Pull Request: https://projects.blender.org/blender/blender/pulls/106638
2023-04-17 13:47:41 +02:00
|
|
|
const Span<blender::int2> mesh_edges = mesh->edges();
|
2023-07-24 22:06:55 +02:00
|
|
|
const blender::OffsetIndices mesh_faces = mesh->faces();
|
2023-12-08 16:40:06 -05:00
|
|
|
const Span<float3> me_positions = object_mesh->vert_positions();
|
|
|
|
|
const Span<blender::int2> me_edges = object_mesh->edges();
|
|
|
|
|
const blender::OffsetIndices me_faces = object_mesh->faces();
|
2019-08-16 14:52:08 +02:00
|
|
|
|
|
|
|
|
/* TODO(sybren+bastien): possibly check relevant custom data layers (UV/color depending on
|
Mesh: Remove redundant custom data pointers
For copy-on-write, we want to share attribute arrays between meshes
where possible. Mutable pointers like `Mesh.mvert` make that difficult
by making ownership vague. They also make code more complex by adding
redundancy.
The simplest solution is just removing them and retrieving layers from
`CustomData` as needed. Similar changes have already been applied to
curves and point clouds (e9f82d3dc7ee, 410a6efb747f). Removing use of
the pointers generally makes code more obvious and more reusable.
Mesh data is now accessed with a C++ API (`Mesh::edges()` or
`Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`).
The CoW changes this commit makes possible are described in T95845
and T95842, and started in D14139 and D14140. The change also simplifies
the ongoing mesh struct-of-array refactors from T95965.
**RNA/Python Access Performance**
Theoretically, accessing mesh elements with the RNA API may become
slower, since the layer needs to be found on every random access.
However, overhead is already high enough that this doesn't make a
noticible differenc, and performance is actually improved in some
cases. Random access can be up to 10% faster, but other situations
might be a bit slower. Generally using `foreach_get/set` are the best
way to improve performance. See the differential revision for more
discussion about Python performance.
Cycles has been updated to use raw pointers and the internal Blender
mesh types, mostly because there is no sense in having this overhead
when it's already compiled with Blender. In my tests this roughly
halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million
face grid).
Differential Revision: https://developer.blender.org/D15488
2022-09-05 11:56:34 -05:00
|
|
|
* flags) and duplicate those too.
|
2024-02-19 15:54:08 +01:00
|
|
|
* XXX(Hans): This probably isn't true anymore with various copy-on-eval improvements, etc. */
|
Mesh: Move positions to a generic attribute
**Changes**
As described in T93602, this patch removes all use of the `MVert`
struct, replacing it with a generic named attribute with the name
`"position"`, consistent with other geometry types.
Variable names have been changed from `verts` to `positions`, to align
with the attribute name and the more generic design (positions are not
vertices, they are just an attribute stored on the point domain).
This change is made possible by previous commits that moved all other
data out of `MVert` to runtime data or other generic attributes. What
remains is mostly a simple type change. Though, the type still shows up
859 times, so the patch is quite large.
One compromise is that now `CD_MASK_BAREMESH` now contains
`CD_PROP_FLOAT3`. With the general move towards generic attributes
over custom data types, we are removing use of these type masks anyway.
**Benefits**
The most obvious benefit is reduced memory usage and the benefits
that brings in memory-bound situations. `float3` is only 3 bytes, in
comparison to `MVert` which was 4. When there are millions of vertices
this starts to matter more.
The other benefits come from using a more generic type. Instead of
writing algorithms specifically for `MVert`, code can just use arrays
of vectors. This will allow eliminating many temporary arrays or
wrappers used to extract positions.
Many possible improvements aren't implemented in this patch, though
I did switch simplify or remove the process of creating temporary
position arrays in a few places.
The design clarity that "positions are just another attribute" brings
allows removing explicit copying of vertices in some procedural
operations-- they are just processed like most other attributes.
**Performance**
This touches so many areas that it's hard to benchmark exhaustively,
but I observed some areas as examples.
* The mesh line node with 4 million count was 1.5x (8ms to 12ms) faster.
* The Spring splash screen went from ~4.3 to ~4.5 fps.
* The subdivision surface modifier/node was slightly faster
RNA access through Python may be slightly slower, since now we need
a name lookup instead of just a custom data type lookup for each index.
**Future Improvements**
* Remove uses of "vert_coords" functions:
* `BKE_mesh_vert_coords_alloc`
* `BKE_mesh_vert_coords_get`
* `BKE_mesh_vert_coords_apply{_with_mat4}`
* Remove more hidden copying of positions
* General simplification now possible in many areas
* Convert more code to C++ to use `float3` instead of `float[3]`
* Currently `reinterpret_cast` is used for those C-API functions
Differential Revision: https://developer.blender.org/D15982
2023-01-10 00:10:43 -05:00
|
|
|
if ((me_positions.data() == mesh_positions.data()) || (me_edges.data() == mesh_edges.data()) ||
|
2023-07-24 22:06:55 +02:00
|
|
|
(me_faces.data() == mesh_faces.data()))
|
2022-09-08 11:22:30 +10:00
|
|
|
{
|
2023-02-12 14:37:16 +11:00
|
|
|
/* We need to duplicate data here, otherwise we'll modify org mesh, see #51701. */
|
2022-03-23 15:33:29 +01:00
|
|
|
mesh = reinterpret_cast<Mesh *>(
|
|
|
|
|
BKE_id_copy_ex(nullptr,
|
|
|
|
|
&mesh->id,
|
|
|
|
|
nullptr,
|
|
|
|
|
LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT |
|
|
|
|
|
LIB_ID_CREATE_NO_DEG_TAG | LIB_ID_COPY_NO_PREVIEW));
|
2017-08-08 18:21:08 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2024-02-28 03:02:38 +01:00
|
|
|
bke::GeometrySet geometry_set = bke::GeometrySet::from_mesh(
|
|
|
|
|
mesh, bke::GeometryOwnershipType::Editable);
|
|
|
|
|
modify_geometry_set(md, ctx, &geometry_set);
|
|
|
|
|
Mesh *result = geometry_set.get_component_for_write<bke::MeshComponent>().release();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-23 15:33:29 +01:00
|
|
|
if (!ELEM(result, nullptr, mesh) && (mesh != org_mesh)) {
|
|
|
|
|
BKE_id_free(nullptr, mesh);
|
2018-06-06 11:06:11 +02:00
|
|
|
mesh = org_mesh;
|
2017-08-08 18:21:08 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-06 11:06:11 +02:00
|
|
|
return result ? result : mesh;
|
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
|
|
|
#else
|
2022-12-09 13:51:52 -06:00
|
|
|
UNUSED_VARS(ctx, md);
|
2018-11-28 16:21:24 +11:00
|
|
|
return mesh;
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static bool depends_on_time(Scene *scene, ModifierData *md)
|
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-03 11:55:53 +02:00
|
|
|
#if defined(WITH_USD) || defined(WITH_ALEMBIC)
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
2021-08-19 14:34:01 +02:00
|
|
|
/* Do not evaluate animations if using the render engine procedural. */
|
2022-03-23 15:33:29 +01:00
|
|
|
return (mcmd->cache_file != nullptr) &&
|
2022-04-01 15:27:11 +02:00
|
|
|
!BKE_cache_file_uses_render_procedural(mcmd->cache_file, scene);
|
2018-09-19 11:08:27 +02:00
|
|
|
#else
|
2022-04-01 20:10:13 +02:00
|
|
|
UNUSED_VARS(scene, md);
|
2018-09-19 11:08:27 +02:00
|
|
|
return false;
|
|
|
|
|
#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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
|
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
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
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-27 12:04:18 +10:00
|
|
|
walk(user_data, ob, reinterpret_cast<ID **>(&mcmd->cache_file), IDWALK_CB_USER);
|
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-27 12:04:18 +10:00
|
|
|
static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
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
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *mcmd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
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
|
|
|
|
2022-03-23 15:33:29 +01:00
|
|
|
if (mcmd->cache_file != nullptr) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_cache_relation(
|
|
|
|
|
ctx->node, mcmd->cache_file, DEG_OB_COMP_CACHE, "Mesh 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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
static void panel_draw(const bContext *C, Panel *panel)
|
|
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA cache_file_ptr = RNA_pointer_get(ptr, "cache_file");
|
2020-06-05 10:41:03 -04:00
|
|
|
bool has_cache_file = !RNA_pointer_is_null(&cache_file_ptr);
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiTemplateCacheFile(layout, C, ptr, "cache_file");
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
if (has_cache_file) {
|
2022-03-23 15:33:29 +01:00
|
|
|
uiItemPointerR(
|
2024-12-06 14:08:10 +01:00
|
|
|
layout, ptr, "object_path", &cache_file_ptr, "object_paths", std::nullopt, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RNA_enum_get(&ob_ptr, "type") == OB_MESH) {
|
2025-05-08 20:45:37 +02:00
|
|
|
layout->prop(ptr, "read_data", UI_ITEM_R_EXPAND, std::nullopt, ICON_NONE);
|
|
|
|
|
layout->prop(ptr, "use_vertex_interpolation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
2025-04-09 06:50:25 +02:00
|
|
|
else if (RNA_enum_get(&ob_ptr, "type") == OB_CURVES) {
|
2025-05-08 20:45:37 +02:00
|
|
|
layout->prop(ptr, "use_vertex_interpolation", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
2025-04-09 06:50:25 +02:00
|
|
|
}
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2025-05-13 17:27:30 +02:00
|
|
|
modifier_error_message_draw(layout, ptr);
|
2021-12-23 18:05:00 +01:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void velocity_panel_draw(const bContext * /*C*/, Panel *panel)
|
2021-12-23 18:05:00 +01:00
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
|
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
|
|
|
|
|
|
|
|
|
PointerRNA fileptr;
|
|
|
|
|
if (!uiTemplateCacheFilePointer(ptr, "cache_file", &fileptr)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
uiTemplateCacheFileVelocity(layout, &fileptr);
|
2025-05-08 20:45:37 +02:00
|
|
|
layout->prop(ptr, "velocity_scale", UI_ITEM_NONE, std::nullopt, ICON_NONE);
|
2021-12-23 18:05:00 +01:00
|
|
|
}
|
2020-08-03 03:28:04 +02:00
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void time_panel_draw(const bContext * /*C*/, Panel *panel)
|
2021-12-23 18:05:00 +01:00
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
|
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
|
|
|
|
|
|
|
|
|
PointerRNA fileptr;
|
|
|
|
|
if (!uiTemplateCacheFilePointer(ptr, "cache_file", &fileptr)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
uiTemplateCacheFileTimeSettings(layout, &fileptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void render_procedural_panel_draw(const bContext *C, Panel *panel)
|
|
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
|
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
|
|
|
|
|
|
|
|
|
PointerRNA fileptr;
|
|
|
|
|
if (!uiTemplateCacheFilePointer(ptr, "cache_file", &fileptr)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
uiTemplateCacheFileProcedural(layout, C, &fileptr);
|
2020-06-05 10:41:03 -04: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
|
|
|
static void override_layers_panel_draw(const bContext *C, Panel *panel)
|
|
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
|
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
|
|
|
|
|
|
|
|
|
PointerRNA fileptr;
|
|
|
|
|
if (!uiTemplateCacheFilePointer(ptr, "cache_file", &fileptr)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
uiTemplateCacheFileLayers(layout, C, &fileptr);
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void panel_register(ARegionType *region_type)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
2021-12-23 18:05:00 +01:00
|
|
|
PanelType *panel_type = modifier_panel_register(
|
|
|
|
|
region_type, eModifierType_MeshSequenceCache, panel_draw);
|
2022-03-23 15:33:29 +01:00
|
|
|
modifier_subpanel_register(region_type, "time", "Time", nullptr, time_panel_draw, panel_type);
|
2021-12-23 18:05:00 +01:00
|
|
|
modifier_subpanel_register(region_type,
|
|
|
|
|
"render_procedural",
|
|
|
|
|
"Render Procedural",
|
2022-03-23 15:33:29 +01:00
|
|
|
nullptr,
|
2021-12-23 18:05:00 +01:00
|
|
|
render_procedural_panel_draw,
|
|
|
|
|
panel_type);
|
|
|
|
|
modifier_subpanel_register(
|
2022-03-23 15:33:29 +01:00
|
|
|
region_type, "velocity", "Velocity", nullptr, velocity_panel_draw, panel_type);
|
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
|
|
|
modifier_subpanel_register(region_type,
|
|
|
|
|
"override_layers",
|
|
|
|
|
"Override Layers",
|
2022-03-23 21:09:07 +01:00
|
|
|
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
|
|
|
override_layers_panel_draw,
|
|
|
|
|
panel_type);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void blend_read(BlendDataReader * /*reader*/, ModifierData *md)
|
2020-06-23 17:25:44 +02:00
|
|
|
{
|
2022-03-23 15:33:29 +01:00
|
|
|
MeshSeqCacheModifierData *msmcd = reinterpret_cast<MeshSeqCacheModifierData *>(md);
|
|
|
|
|
msmcd->reader = nullptr;
|
2020-06-23 17:25:44 +02:00
|
|
|
msmcd->reader_object_path[0] = '\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
|
|
|
ModifierTypeInfo modifierType_MeshSequenceCache = {
|
2023-07-26 17:08:14 +02:00
|
|
|
/*idname*/ "MeshSequenceCache",
|
2023-01-16 12:41:11 +11:00
|
|
|
/*name*/ N_("MeshSequenceCache"),
|
2023-07-27 12:04:18 +10:00
|
|
|
/*struct_name*/ "MeshSeqCacheModifierData",
|
|
|
|
|
/*struct_size*/ sizeof(MeshSeqCacheModifierData),
|
2023-01-16 12:41:11 +11:00
|
|
|
/*srna*/ &RNA_MeshSequenceCacheModifier,
|
2023-11-14 10:03:56 +01:00
|
|
|
/*type*/ ModifierTypeType::Constructive,
|
2023-01-16 12:41:11 +11:00
|
|
|
/*flags*/
|
2025-01-26 20:07:57 +01:00
|
|
|
(eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_AcceptsCVs),
|
2023-01-16 12:41:11 +11:00
|
|
|
/*icon*/ ICON_MOD_MESHDEFORM, /* TODO: Use correct icon. */
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
/*copy_data*/ copy_data,
|
|
|
|
|
|
|
|
|
|
/*deform_verts*/ nullptr,
|
|
|
|
|
/*deform_matrices*/ nullptr,
|
|
|
|
|
/*deform_verts_EM*/ nullptr,
|
|
|
|
|
/*deform_matrices_EM*/ nullptr,
|
|
|
|
|
/*modify_mesh*/ modify_mesh,
|
2024-02-28 03:02:38 +01:00
|
|
|
/*modify_geometry_set*/ modify_geometry_set,
|
2023-07-27 12:04:18 +10:00
|
|
|
|
|
|
|
|
/*init_data*/ init_data,
|
|
|
|
|
/*required_data_mask*/ nullptr,
|
|
|
|
|
/*free_data*/ free_data,
|
|
|
|
|
/*is_disabled*/ is_disabled,
|
|
|
|
|
/*update_depsgraph*/ update_depsgraph,
|
|
|
|
|
/*depends_on_time*/ depends_on_time,
|
|
|
|
|
/*depends_on_normals*/ nullptr,
|
|
|
|
|
/*foreach_ID_link*/ foreach_ID_link,
|
|
|
|
|
/*foreach_tex_link*/ nullptr,
|
|
|
|
|
/*free_runtime_data*/ nullptr,
|
|
|
|
|
/*panel_register*/ panel_register,
|
|
|
|
|
/*blend_write*/ nullptr,
|
|
|
|
|
/*blend_read*/ blend_read,
|
2024-01-18 22:51:30 +01:00
|
|
|
/*foreach_cache*/ nullptr,
|
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
|
|
|
};
|