2011-02-18 14:05:18 +01:00
|
|
|
/*
|
2002-10-12 13:37:38 +02:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-17 00:40:48 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 14:34:04 +01:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 13:37:38 +02:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
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;
|
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;
|
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);
|
|
|
|
int *BKE_object_defgroup_flip_map(const struct Object *ob,
|
|
|
|
int *flip_map_len,
|
|
|
|
const bool use_default);
|
|
|
|
int *BKE_object_defgroup_flip_map_single(const struct Object *ob,
|
2020-03-06 02:50:56 +01:00
|
|
|
int *flip_map_len,
|
|
|
|
const bool use_default,
|
|
|
|
int defgroup);
|
2020-06-13 08:08:34 +02:00
|
|
|
int BKE_object_defgroup_flip_index(const struct Object *ob, int index, const bool use_default);
|
|
|
|
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
|
|
|
|
2020-03-06 02:50:56 +01:00
|
|
|
struct MDeformWeight *BKE_defvert_find_index(const struct MDeformVert *dv, const int defgroup);
|
|
|
|
struct MDeformWeight *BKE_defvert_ensure_index(struct MDeformVert *dv, const int defgroup);
|
|
|
|
void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight);
|
|
|
|
void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
|
|
|
|
void BKE_defvert_clear(struct MDeformVert *dvert);
|
|
|
|
int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
|
|
|
|
bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, const 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);
|
|
|
|
|
2020-03-06 02:50:56 +01:00
|
|
|
float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
|
|
|
|
float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert,
|
|
|
|
const int index,
|
|
|
|
const int defgroup);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2018-10-07 17:25:51 +02:00
|
|
|
float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
|
|
|
|
int defbase_tot,
|
|
|
|
const bool *defbase_sel);
|
|
|
|
|
2016-01-19 16:57:52 +01:00
|
|
|
float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv,
|
|
|
|
int defbase_tot,
|
|
|
|
const bool *defbase_sel,
|
|
|
|
int defbase_tot_sel,
|
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
|
|
|
|
|
2018-10-07 17:25:51 +02:00
|
|
|
float BKE_defvert_calc_lock_relative_weight(float weight,
|
|
|
|
float locked_weight,
|
|
|
|
float unlocked_weight);
|
|
|
|
float BKE_defvert_lock_relative_weight(float weight,
|
|
|
|
const struct MDeformVert *dv,
|
|
|
|
int defbase_tot,
|
|
|
|
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);
|
|
|
|
void BKE_defvert_copy_subset(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const bool *vgroup_subset,
|
|
|
|
const int vgroup_tot);
|
|
|
|
void BKE_defvert_mirror_subset(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const bool *vgroup_subset,
|
|
|
|
const int vgroup_tot,
|
|
|
|
const int *flip_map,
|
|
|
|
const int flip_map_len);
|
|
|
|
void BKE_defvert_copy_index(struct MDeformVert *dvert_dst,
|
|
|
|
const int defgroup_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
|
|
|
const int defgroup_src);
|
|
|
|
void BKE_defvert_sync(struct MDeformVert *dvert_dst,
|
|
|
|
const struct MDeformVert *dvert_src,
|
2020-03-06 03:00:01 +01:00
|
|
|
const bool use_ensure);
|
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,
|
|
|
|
const int flip_map_len,
|
2020-03-06 03:00:01 +01:00
|
|
|
const bool use_ensure);
|
2020-07-13 11:27:09 +02:00
|
|
|
void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, const int map_len);
|
2020-03-06 02:50:56 +01:00
|
|
|
void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
|
|
|
|
void BKE_defvert_flip_merged(struct MDeformVert *dvert,
|
|
|
|
const int *flip_map,
|
|
|
|
const int flip_map_len);
|
|
|
|
void BKE_defvert_normalize(struct MDeformVert *dvert);
|
|
|
|
void BKE_defvert_normalize_subset(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
|
|
|
const int vgroup_tot);
|
|
|
|
void BKE_defvert_normalize_lock_single(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
|
|
|
const int vgroup_tot,
|
|
|
|
const uint def_nr_lock);
|
|
|
|
void BKE_defvert_normalize_lock_map(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset,
|
|
|
|
const int vgroup_tot,
|
|
|
|
const bool *lock_flags,
|
|
|
|
const int defbase_tot);
|
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. */
|
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
|
|
|
void BKE_defvert_extract_vgroup_to_vertweights(struct MDeformVert *dvert,
|
|
|
|
const int defgroup,
|
|
|
|
const int num_verts,
|
|
|
|
float *r_weights,
|
|
|
|
const bool invert_vgroup);
|
|
|
|
void BKE_defvert_extract_vgroup_to_edgeweights(struct MDeformVert *dvert,
|
|
|
|
const int defgroup,
|
|
|
|
const int num_verts,
|
|
|
|
struct MEdge *edges,
|
|
|
|
const int num_edges,
|
|
|
|
float *r_weights,
|
|
|
|
const bool invert_vgroup);
|
|
|
|
void BKE_defvert_extract_vgroup_to_loopweights(struct MDeformVert *dvert,
|
|
|
|
const int defgroup,
|
|
|
|
const int num_verts,
|
|
|
|
struct MLoop *loops,
|
|
|
|
const int num_loops,
|
|
|
|
float *r_weights,
|
|
|
|
const bool invert_vgroup);
|
|
|
|
void BKE_defvert_extract_vgroup_to_polyweights(struct MDeformVert *dvert,
|
|
|
|
const int defgroup,
|
|
|
|
const int num_verts,
|
|
|
|
struct MLoop *loops,
|
|
|
|
const int num_loops,
|
|
|
|
struct MPoly *polys,
|
|
|
|
const int num_polys,
|
|
|
|
float *r_weights,
|
|
|
|
const bool invert_vgroup);
|
|
|
|
|
2018-06-29 14:56:38 +02:00
|
|
|
void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
|
|
|
|
|
2020-08-28 13:58:39 +02:00
|
|
|
void BKE_defvert_blend_write(struct BlendWriter *writer, int count, struct MDeformVert *dvlist);
|
|
|
|
void BKE_defvert_blend_read(struct BlendDataReader *reader,
|
|
|
|
int count,
|
|
|
|
struct MDeformVert *mdverts);
|
|
|
|
|
2020-02-07 17:22:11 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|