2022-02-10 23:07:11 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
* Copyright 2001-2002 NaN Holding BV. All rights reserved. */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2020-02-07 17:22:11 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
|
|
|
* \brief support for deformation groups and hooks.
|
2011-02-18 14:05:18 +01:00
|
|
|
*/
|
|
|
|
|
2020-09-30 03:51:13 +02:00
|
|
|
struct BlendDataReader;
|
|
|
|
struct BlendWriter;
|
2021-07-16 03:48:54 +02:00
|
|
|
struct ID;
|
2002-10-12 13:37:38 +02:00
|
|
|
struct ListBase;
|
2008-08-22 14:10:02 +02:00
|
|
|
struct MDeformVert;
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
struct MEdge;
|
|
|
|
struct MLoop;
|
|
|
|
struct MPoly;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct Object;
|
|
|
|
struct bDeformGroup;
|
2021-07-13 18:10:34 +02:00
|
|
|
|
|
|
|
bool BKE_object_supports_vertex_groups(const struct Object *ob);
|
|
|
|
const struct ListBase *BKE_object_defgroup_list(const struct Object *ob);
|
|
|
|
struct ListBase *BKE_object_defgroup_list_mutable(struct Object *ob);
|
|
|
|
|
|
|
|
int BKE_object_defgroup_count(const struct Object *ob);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \note For historical reasons, the index starts at 1 rather than 0.
|
|
|
|
*/
|
2021-07-13 18:10:34 +02:00
|
|
|
int BKE_object_defgroup_active_index_get(const struct Object *ob);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \note For historical reasons, the index starts at 1 rather than 0.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_object_defgroup_active_index_set(struct Object *ob, int new_index);
|
2021-07-13 18:10:34 +02:00
|
|
|
|
|
|
|
const struct ListBase *BKE_id_defgroup_list_get(const struct ID *id);
|
|
|
|
struct ListBase *BKE_id_defgroup_list_get_mutable(struct ID *id);
|
|
|
|
int BKE_id_defgroup_name_index(const struct ID *id, const char *name);
|
2021-11-23 14:35:49 +01:00
|
|
|
bool BKE_id_defgroup_name_find(const struct ID *id,
|
|
|
|
const char *name,
|
|
|
|
int *r_index,
|
|
|
|
struct bDeformGroup **r_group);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2020-03-06 02:50:56 +01:00
|
|
|
struct bDeformGroup *BKE_object_defgroup_new(struct Object *ob, const char *name);
|
2020-09-04 20:59:13 +02:00
|
|
|
void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase);
|
2020-03-06 02:50:56 +01:00
|
|
|
struct bDeformGroup *BKE_defgroup_duplicate(const struct bDeformGroup *ingroup);
|
2020-06-13 08:08:34 +02:00
|
|
|
struct bDeformGroup *BKE_object_defgroup_find_name(const struct Object *ob, const char *name);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
2022-09-13 05:24:45 +02:00
|
|
|
* Returns flip map for the vertex-groups of `ob`.
|
|
|
|
*
|
|
|
|
* \param use_default: How to handle cases where no symmetrical group is found.
|
|
|
|
* - false: sets these indices to -1, indicating the group should be ignored.
|
|
|
|
* - true: sets the index to its location in the array (making the group point to it's self).
|
|
|
|
* Enable this for symmetrical actions which apply weight operations on symmetrical vertices
|
|
|
|
* where the symmetrical group will be used (if found), otherwise the same group is used.
|
|
|
|
*
|
|
|
|
* \return An index array `r_flip_map_num` length,
|
|
|
|
* (aligned with the list result from `BKE_id_defgroup_list_get(ob)`).
|
|
|
|
* referencing the index of the symmetrical vertex-group of a fall-back value (see `use_default`).
|
|
|
|
* The caller is responsible for freeing the array.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2022-09-09 08:20:32 +02:00
|
|
|
int *BKE_object_defgroup_flip_map(const struct Object *ob, bool use_default, int *r_flip_map_num);
|
2022-09-09 07:55:51 +02:00
|
|
|
|
|
|
|
/**
|
2022-09-13 05:24:45 +02:00
|
|
|
* A version of #BKE_object_defgroup_flip_map that ignores locked groups.
|
2022-09-09 07:55:51 +02:00
|
|
|
*/
|
|
|
|
int *BKE_object_defgroup_flip_map_unlocked(const struct Object *ob,
|
2022-09-09 08:20:32 +02:00
|
|
|
bool use_default,
|
|
|
|
int *r_flip_map_num);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
2022-09-13 05:24:45 +02:00
|
|
|
* A version of #BKE_object_defgroup_flip_map that only takes a single group into account.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2020-06-13 08:08:34 +02:00
|
|
|
int *BKE_object_defgroup_flip_map_single(const struct Object *ob,
|
2022-01-07 01:38:08 +01:00
|
|
|
bool use_default,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defgroup,
|
|
|
|
int *r_flip_map_num);
|
2022-01-07 01:38:08 +01:00
|
|
|
int BKE_object_defgroup_flip_index(const struct Object *ob, int index, bool use_default);
|
2020-06-13 08:08:34 +02:00
|
|
|
int BKE_object_defgroup_name_index(const struct Object *ob, const char *name);
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_object_defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2022-01-07 01:38:08 +01:00
|
|
|
struct MDeformWeight *BKE_defvert_find_index(const struct MDeformVert *dv, int defgroup);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Ensures that `dv` has a deform weight entry for the specified defweight group.
|
|
|
|
*
|
|
|
|
* \note this function is mirrored in editmesh_tools.c, for use for edit-vertices.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
struct MDeformWeight *BKE_defvert_ensure_index(struct MDeformVert *dv, int defgroup);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Adds the given vertex to the specified vertex group, with given weight.
|
|
|
|
*
|
|
|
|
* \warning this does NOT check for existing, assume caller already knows its not there.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, float weight);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Removes the given vertex from the vertex group.
|
|
|
|
*
|
|
|
|
* \warning This function frees the given #MDeformWeight, do not use it afterward!
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
|
|
|
|
void BKE_defvert_clear(struct MDeformVert *dvert);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \return The first group index shared by both deform verts
|
|
|
|
* or -1 if none are found.
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \return true if has no weights.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, int defgroup_tot);
|
2010-01-26 18:07:47 +01:00
|
|
|
|
2013-02-11 05:43:49 +01:00
|
|
|
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert);
|
2012-12-28 10:06:48 +01:00
|
|
|
void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert);
|
|
|
|
void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
|
|
|
|
|
2022-01-07 01:38:08 +01:00
|
|
|
float BKE_defvert_find_weight(const struct MDeformVert *dvert, int defgroup);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Take care with this the rationale is:
|
|
|
|
* - if the object has no vertex group. act like vertex group isn't set and return 1.0.
|
|
|
|
* - if the vertex group exists but the 'defgroup' isn't found on this vertex, _still_ return 0.0.
|
|
|
|
*
|
|
|
|
* This is a bit confusing, just saves some checks from the caller.
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int defgroup);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \return The total weight in all groups marked in the selection mask.
|
|
|
|
*/
|
2018-10-07 17:25:51 +02:00
|
|
|
float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defbase_num,
|
2018-10-07 17:25:51 +02:00
|
|
|
const bool *defbase_sel);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \return The representative weight of a multi-paint group, used for
|
|
|
|
* viewport colors and actual painting.
|
|
|
|
*
|
|
|
|
* Result equal to sum of weights with auto normalize, and average otherwise.
|
|
|
|
* Value is not clamped, since painting relies on multiplication being always
|
|
|
|
* commutative with the collective weight function.
|
|
|
|
*/
|
2016-01-19 16:57:52 +01:00
|
|
|
float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defbase_num,
|
2016-01-19 16:57:52 +01:00
|
|
|
const bool *defbase_sel,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defbase_sel_num,
|
2018-10-07 17:25:51 +02:00
|
|
|
bool is_normalized);
|
|
|
|
|
2020-12-24 12:30:51 +01:00
|
|
|
/* This much unlocked weight is considered equivalent to none. */
|
|
|
|
#define VERTEX_WEIGHT_LOCK_EPSILON 1e-6f
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Computes the display weight for the lock relative weight paint mode.
|
|
|
|
*
|
|
|
|
* \return weight divided by 1-locked_weight with division by zero check
|
|
|
|
*/
|
2018-10-07 17:25:51 +02:00
|
|
|
float BKE_defvert_calc_lock_relative_weight(float weight,
|
|
|
|
float locked_weight,
|
|
|
|
float unlocked_weight);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Computes the display weight for the lock relative weight paint mode, using weight data.
|
|
|
|
*
|
|
|
|
* \return weight divided by unlocked, or 1-locked_weight with division by zero check.
|
|
|
|
*/
|
2018-10-07 17:25:51 +02:00
|
|
|
float BKE_defvert_lock_relative_weight(float weight,
|
|
|
|
const struct MDeformVert *dv,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defbase_num,
|
2018-10-07 17:25:51 +02:00
|
|
|
const bool *defbase_locked,
|
|
|
|
const bool *defbase_unlocked);
|
2016-01-19 16:57:52 +01:00
|
|
|
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Overwrite weights filtered by vgroup_subset.
|
|
|
|
* - do nothing if neither are set.
|
|
|
|
* - add destination weight if needed
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_copy_subset(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const bool *vgroup_subset,
|
2022-09-09 08:20:32 +02:00
|
|
|
int vgroup_num);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Overwrite weights filtered by vgroup_subset and with mirroring specified by the flip map
|
|
|
|
* - do nothing if neither are set.
|
|
|
|
* - add destination weight if needed
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_mirror_subset(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const bool *vgroup_subset,
|
2022-09-09 08:20:32 +02:00
|
|
|
int vgroup_num,
|
2020-03-06 02:50:56 +01:00
|
|
|
const int *flip_map,
|
2022-09-09 08:20:32 +02:00
|
|
|
int flip_map_num);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Copy an index from one #MDeformVert to another.
|
|
|
|
* - do nothing if neither are set.
|
|
|
|
* - add destination weight if needed.
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_copy_index(struct MDeformVert *dvert_dst,
|
2022-01-07 01:38:08 +01:00
|
|
|
int defgroup_dst,
|
2020-03-06 02:50:56 +01:00
|
|
|
const struct MDeformVert *dvert_src,
|
2022-01-07 01:38:08 +01:00
|
|
|
int defgroup_src);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Only sync over matching weights, don't add or remove groups
|
|
|
|
* warning, loop within loop.
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_sync(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
2022-01-07 01:38:08 +01:00
|
|
|
bool use_ensure);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* be sure all flip_map values are valid
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const int *flip_map,
|
2022-09-09 08:20:32 +02:00
|
|
|
int flip_map_num,
|
2022-01-07 01:38:08 +01:00
|
|
|
bool use_ensure);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* be sure all flip_map values are valid
|
|
|
|
*/
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, int map_len);
|
2022-09-09 08:20:32 +02:00
|
|
|
void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, int flip_map_num);
|
|
|
|
void BKE_defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, int flip_map_num);
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_normalize(struct MDeformVert *dvert);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Same as #BKE_defvert_normalize but takes a bool array.
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_normalize_subset(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
2022-09-09 08:20:32 +02:00
|
|
|
int vgroup_num);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Same as BKE_defvert_normalize() if the locked vgroup is not a member of the subset
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_normalize_lock_single(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
2022-09-09 08:20:32 +02:00
|
|
|
int vgroup_num,
|
2022-01-07 01:38:08 +01:00
|
|
|
uint def_nr_lock);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Same as BKE_defvert_normalize() if no locked vgroup is a member of the subset
|
|
|
|
*/
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_normalize_lock_map(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
2022-09-09 08:20:32 +02:00
|
|
|
int vgroup_num,
|
2020-03-06 02:50:56 +01:00
|
|
|
const bool *lock_flags,
|
2022-09-09 08:20:32 +02:00
|
|
|
int defbase_num);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2019-04-27 04:07:07 +02:00
|
|
|
/* Utilities to 'extract' a given vgroup into a simple float array,
|
|
|
|
* for verts, but also edges/polys/loops. */
|
2021-12-07 07:19:15 +01:00
|
|
|
|
2022-05-13 18:31:29 +02:00
|
|
|
void BKE_defvert_extract_vgroup_to_vertweights(const struct MDeformVert *dvert,
|
|
|
|
int defgroup,
|
2022-09-09 08:20:32 +02:00
|
|
|
int verts_num,
|
2022-05-13 18:31:29 +02:00
|
|
|
bool invert_vgroup,
|
|
|
|
float *r_weights);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* The following three make basic interpolation,
|
|
|
|
* using temp vert_weights array to avoid looking up same weight several times.
|
|
|
|
*/
|
2022-05-13 18:31:29 +02:00
|
|
|
void BKE_defvert_extract_vgroup_to_edgeweights(const struct MDeformVert *dvert,
|
2022-01-07 01:38:08 +01:00
|
|
|
int defgroup,
|
2022-09-09 08:20:32 +02:00
|
|
|
int verts_num,
|
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 18:56:34 +02:00
|
|
|
const struct MEdge *edges,
|
2022-09-09 08:20:32 +02:00
|
|
|
int edges_num,
|
2022-05-13 18:31:29 +02:00
|
|
|
bool invert_vgroup,
|
|
|
|
float *r_weights);
|
|
|
|
void BKE_defvert_extract_vgroup_to_loopweights(const struct MDeformVert *dvert,
|
2022-01-07 01:38:08 +01:00
|
|
|
int defgroup,
|
2022-09-09 08:20:32 +02:00
|
|
|
int verts_num,
|
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 18:56:34 +02:00
|
|
|
const struct MLoop *loops,
|
2022-09-09 08:20:32 +02:00
|
|
|
int loops_num,
|
2022-05-13 18:31:29 +02:00
|
|
|
bool invert_vgroup,
|
|
|
|
float *r_weights);
|
|
|
|
void BKE_defvert_extract_vgroup_to_polyweights(const struct MDeformVert *dvert,
|
2022-01-07 01:38:08 +01:00
|
|
|
int defgroup,
|
2022-09-09 08:20:32 +02:00
|
|
|
int verts_num,
|
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 18:56:34 +02:00
|
|
|
const struct MLoop *loops,
|
2022-09-09 08:20:32 +02:00
|
|
|
int loops_num,
|
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 18:56:34 +02:00
|
|
|
const struct MPoly *polys,
|
2022-09-09 08:20:32 +02:00
|
|
|
int polys_num,
|
2022-05-13 18:31:29 +02:00
|
|
|
bool invert_vgroup,
|
|
|
|
float *r_weights);
|
Transfer Data: add main core code and operators.
This add code needed to map a CD data layout from source mesh towards destination one,
and code needed to actually transfer data, using BKE's mesh remap generated data.
This allows to transfer most CD layers (vgroups, vcols, uvs...) as well as fake, boolean ones
(like smooth/sharp edges/faces, etc.). Some types are not yet transferable, mainly
shape keys, this is known TODO.
Data transfer can also use some advanced mixing in some cases (mostly, vgroups and vcols).
Notes:
* New transfer operators transfer data from active object towards selected ones.
* Modifier will be committed separately.
* Old weight transfer code (for vgroups) is kept for now, mostly because it is the only
usable one in weightpaint mode (it transfers from selected object to active one,
this is not sensible in Object mode, but needed in WeightPaint one). This will be addressed soon.
Again, heavily reviewed and enhanced by Campbell, thanks!
2015-01-09 19:11:40 +01:00
|
|
|
|
2022-01-07 01:38:08 +01:00
|
|
|
void BKE_defvert_weight_to_rgb(float r_rgb[3], float weight);
|
2018-06-29 14:56:38 +02:00
|
|
|
|
2022-05-22 20:06:24 +02:00
|
|
|
void BKE_defvert_blend_write(struct BlendWriter *writer,
|
|
|
|
int count,
|
|
|
|
const struct MDeformVert *dvlist);
|
2020-08-28 13:58:39 +02:00
|
|
|
void BKE_defvert_blend_read(struct BlendDataReader *reader,
|
|
|
|
int count,
|
|
|
|
struct MDeformVert *mdverts);
|
2021-07-13 18:10:34 +02:00
|
|
|
void BKE_defbase_blend_write(struct BlendWriter *writer, const ListBase *defbase);
|
2020-08-28 13:58:39 +02:00
|
|
|
|
2020-02-07 17:22:11 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|