2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 #ifndef __BKE_DEFORM_H__
29 #define __BKE_DEFORM_H__
31 /** \file BKE_deform.h
34 * \author Reevan McKay et al
35 * \brief support for deformation groups and hooks.
46 struct bDeformGroup *BKE_defgroup_new(struct Object *ob, const char *name);
47 void defgroup_copy_list(struct ListBase *lb1, const struct ListBase *lb2);
48 struct bDeformGroup *defgroup_duplicate(const struct bDeformGroup *ingroup);
49 struct bDeformGroup *defgroup_find_name(struct Object *ob, const char *name);
50 int *defgroup_flip_map(struct Object *ob, int *flip_map_len, const bool use_default);
51 int *defgroup_flip_map_single(struct Object *ob, int *flip_map_len, const bool use_default, int defgroup);
52 int defgroup_flip_index(struct Object *ob, int index, const bool use_default);
53 int defgroup_name_index(struct Object *ob, const char *name);
54 void defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
56 struct MDeformWeight *defvert_find_index(const struct MDeformVert *dv, const int defgroup);
57 struct MDeformWeight *defvert_verify_index(struct MDeformVert *dv, const int defgroup);
58 void defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight);
59 void defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
60 void defvert_clear(struct MDeformVert *dvert);
61 int defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
62 bool defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot);
64 void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert);
65 void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert);
66 void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
68 float defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
69 float defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup);
71 float BKE_defvert_multipaint_collective_weight(
72 const struct MDeformVert *dv, int defbase_tot,
73 const bool *defbase_sel, int defbase_tot_sel, bool do_autonormalize);
75 void defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
76 void defvert_copy_subset(
77 struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
78 const bool *vgroup_subset, const int vgroup_tot);
79 void defvert_mirror_subset(
80 struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
81 const bool *vgroup_subset, const int vgroup_tot,
82 const int *flip_map, const int flip_map_len);
83 void defvert_copy_index(
84 struct MDeformVert *dvert_dst, const int defgroup_dst,
85 const struct MDeformVert *dvert_src, const int defgroup_src);
86 void defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool use_verify);
87 void defvert_sync_mapped(
88 struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src,
89 const int *flip_map, const int flip_map_len, const bool use_verify);
90 void defvert_remap(struct MDeformVert *dvert, int *map, const int map_len);
91 void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
92 void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
93 void defvert_normalize(struct MDeformVert *dvert);
94 void defvert_normalize_subset(
95 struct MDeformVert *dvert,
96 const bool *vgroup_subset, const int vgroup_tot);
97 void defvert_normalize_lock_single(
98 struct MDeformVert *dvert,
99 const bool *vgroup_subset, const int vgroup_tot,
100 const int def_nr_lock);
101 void defvert_normalize_lock_map(
102 struct MDeformVert *dvert,
103 const bool *vgroup_subset, const int vgroup_tot,
104 const bool *lock_flags, const int defbase_tot);
106 /* Utilities to 'extract' a given vgroup into a simple float array, for verts, but also edges/polys/loops. */
107 void BKE_defvert_extract_vgroup_to_vertweights(
108 struct MDeformVert *dvert, const int defgroup, const int num_verts, float *r_weights, const bool invert_vgroup);
109 void BKE_defvert_extract_vgroup_to_edgeweights(
110 struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MEdge *edges, const int num_edges,
111 float *r_weights, const bool invert_vgroup);
112 void BKE_defvert_extract_vgroup_to_loopweights(
113 struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops,
114 float *r_weights, const bool invert_vgroup);
115 void BKE_defvert_extract_vgroup_to_polyweights(
116 struct MDeformVert *dvert, const int defgroup, const int num_verts, struct MLoop *loops, const int num_loops,
117 struct MPoly *polys, const int num_polys, float *r_weights, const bool invert_vgroup);
119 void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
121 #endif /* __BKE_DEFORM_H__ */