2011-02-18 14:05:18 +01:00
|
|
|
/*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-17 00:40:48 +02:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 13:37:38 +02:00
|
|
|
*/
|
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#ifndef __BKE_DEFORM_H__
|
|
|
|
#define __BKE_DEFORM_H__
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2011-02-18 14:05:18 +01:00
|
|
|
/** \file BKE_deform.h
|
|
|
|
* \ingroup bke
|
|
|
|
* \since June 2001
|
|
|
|
* \author Reevan McKay et al
|
|
|
|
* \brief support for deformation groups and hooks.
|
|
|
|
*/
|
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
struct Object;
|
|
|
|
struct ListBase;
|
|
|
|
struct bDeformGroup;
|
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;
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2013-07-04 05:56:18 +02:00
|
|
|
struct bDeformGroup *BKE_defgroup_new(struct Object *ob, const char *name);
|
2012-05-12 22:39:39 +02:00
|
|
|
void defgroup_copy_list(struct ListBase *lb1, struct ListBase *lb2);
|
2010-01-26 14:50:17 +01:00
|
|
|
struct bDeformGroup *defgroup_duplicate(struct bDeformGroup *ingroup);
|
2010-08-22 16:15:28 +02:00
|
|
|
struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
|
2013-03-21 00:14:18 +01:00
|
|
|
int *defgroup_flip_map(struct Object *ob, int *flip_map_len, const bool use_default);
|
|
|
|
int *defgroup_flip_map_single(struct Object *ob, int *flip_map_len, const bool use_default, int defgroup);
|
|
|
|
int defgroup_flip_index(struct Object *ob, int index, const bool use_default);
|
2012-05-12 22:39:39 +02:00
|
|
|
int defgroup_name_index(struct Object *ob, const char *name);
|
|
|
|
void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
struct MDeformWeight *defvert_find_index(const struct MDeformVert *dv, const int defgroup);
|
|
|
|
struct MDeformWeight *defvert_verify_index(struct MDeformVert *dv, const int defgroup);
|
2011-12-08 04:47:45 +01:00
|
|
|
void defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight);
|
|
|
|
void defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
|
2012-03-29 15:09:07 +02:00
|
|
|
void defvert_clear(struct MDeformVert *dvert);
|
2012-10-30 12:40:36 +01:00
|
|
|
int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
|
2013-02-22 05:09:04 +01:00
|
|
|
bool 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);
|
|
|
|
|
2011-11-30 08:39:54 +01:00
|
|
|
float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
|
|
|
|
float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup);
|
2010-01-26 14:50:17 +01:00
|
|
|
|
2011-11-30 08:39:54 +01:00
|
|
|
void defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
|
2013-06-23 17:37:08 +02:00
|
|
|
void defvert_copy_subset(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
|
|
|
|
const bool *vgroup_subset, const int vgroup_tot);
|
2011-11-30 08:39:54 +01:00
|
|
|
void defvert_copy_index(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int defgroup);
|
2013-03-21 00:14:18 +01:00
|
|
|
void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool use_verify);
|
2011-11-30 08:39:54 +01:00
|
|
|
void defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
|
2013-03-21 00:14:18 +01:00
|
|
|
const int *flip_map, const int flip_map_len, const bool use_verify);
|
2012-05-12 22:39:39 +02:00
|
|
|
void defvert_remap(struct MDeformVert *dvert, int *map, const int map_len);
|
2011-10-27 09:54:32 +02:00
|
|
|
void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
|
2012-03-19 22:09:16 +01:00
|
|
|
void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
|
2010-01-26 14:50:17 +01:00
|
|
|
void defvert_normalize(struct MDeformVert *dvert);
|
2013-06-23 17:37:08 +02:00
|
|
|
void defvert_normalize_subset(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset, const int vgroup_tot);
|
2013-10-10 08:33:23 +02:00
|
|
|
void defvert_normalize_lock_single(struct MDeformVert *dvert,
|
|
|
|
const bool *vgroup_subset, const int vgroup_tot,
|
|
|
|
const int def_nr_lock);
|
|
|
|
void 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
|
|
|
|
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
|
|
|
/* Utilities to 'extract' a given vgroup into a simple float array, for verts, but also edges/polys/loops. */
|
|
|
|
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);
|
|
|
|
|
2012-04-30 16:24:11 +02:00
|
|
|
/* utility function, note that MAX_VGROUP_NAME chars is the maximum string length since its only
|
2010-01-26 14:50:17 +01:00
|
|
|
* used with defgroups currently */
|
2012-04-30 10:24:44 +02:00
|
|
|
|
|
|
|
void BKE_deform_split_suffix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
|
|
|
|
void BKE_deform_split_prefix(const char string[MAX_VGROUP_NAME], char base[MAX_VGROUP_NAME], char ext[MAX_VGROUP_NAME]);
|
|
|
|
|
2013-11-16 18:20:31 +01:00
|
|
|
void BKE_deform_flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME],
|
|
|
|
const bool strip_number);
|
2010-01-15 18:28:00 +01:00
|
|
|
|
2013-03-21 00:14:18 +01:00
|
|
|
#endif /* __BKE_DEFORM_H__ */
|