Blender  V2.93
BKE_deform.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
31 struct BlendDataReader;
32 struct BlendWriter;
33 struct ListBase;
34 struct MDeformVert;
35 struct MEdge;
36 struct MLoop;
37 struct MPoly;
38 struct Object;
39 struct bDeformGroup;
40 
41 struct bDeformGroup *BKE_object_defgroup_new(struct Object *ob, const char *name);
42 void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase);
43 struct bDeformGroup *BKE_defgroup_duplicate(const struct bDeformGroup *ingroup);
44 struct bDeformGroup *BKE_object_defgroup_find_name(const struct Object *ob, const char *name);
45 int *BKE_object_defgroup_flip_map(const struct Object *ob,
46  int *flip_map_len,
47  const bool use_default);
49  int *flip_map_len,
50  const bool use_default,
51  int defgroup);
52 int BKE_object_defgroup_flip_index(const struct Object *ob, int index, const bool use_default);
53 int BKE_object_defgroup_name_index(const struct Object *ob, const char *name);
54 void BKE_object_defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
55 
56 struct MDeformWeight *BKE_defvert_find_index(const struct MDeformVert *dv, const int defgroup);
57 struct MDeformWeight *BKE_defvert_ensure_index(struct MDeformVert *dv, const int defgroup);
58 void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight);
59 void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
60 void BKE_defvert_clear(struct MDeformVert *dvert);
61 int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
62 bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot);
63 
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);
67 
68 float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup);
69 float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert,
70  const int index,
71  const int defgroup);
72 
73 float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
74  int defbase_tot,
75  const bool *defbase_sel);
76 
78  int defbase_tot,
79  const bool *defbase_sel,
80  int defbase_tot_sel,
81  bool is_normalized);
82 
83 /* This much unlocked weight is considered equivalent to none. */
84 #define VERTEX_WEIGHT_LOCK_EPSILON 1e-6f
85 
87  float locked_weight,
88  float unlocked_weight);
90  const struct MDeformVert *dv,
91  int defbase_tot,
92  const bool *defbase_locked,
93  const bool *defbase_unlocked);
94 
95 void BKE_defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
96 void BKE_defvert_copy_subset(struct MDeformVert *dvert_dst,
97  const struct MDeformVert *dvert_src,
98  const bool *vgroup_subset,
99  const int vgroup_tot);
100 void BKE_defvert_mirror_subset(struct MDeformVert *dvert_dst,
101  const struct MDeformVert *dvert_src,
102  const bool *vgroup_subset,
103  const int vgroup_tot,
104  const int *flip_map,
105  const int flip_map_len);
106 void BKE_defvert_copy_index(struct MDeformVert *dvert_dst,
107  const int defgroup_dst,
108  const struct MDeformVert *dvert_src,
109  const int defgroup_src);
110 void BKE_defvert_sync(struct MDeformVert *dvert_dst,
111  const struct MDeformVert *dvert_src,
112  const bool use_ensure);
113 void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst,
114  const struct MDeformVert *dvert_src,
115  const int *flip_map,
116  const int flip_map_len,
117  const bool use_ensure);
118 void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, const int map_len);
119 void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len);
120 void BKE_defvert_flip_merged(struct MDeformVert *dvert,
121  const int *flip_map,
122  const int flip_map_len);
123 void BKE_defvert_normalize(struct MDeformVert *dvert);
124 void BKE_defvert_normalize_subset(struct MDeformVert *dvert,
125  const bool *vgroup_subset,
126  const int vgroup_tot);
128  const bool *vgroup_subset,
129  const int vgroup_tot,
130  const uint def_nr_lock);
132  const bool *vgroup_subset,
133  const int vgroup_tot,
134  const bool *lock_flags,
135  const int defbase_tot);
136 
137 /* Utilities to 'extract' a given vgroup into a simple float array,
138  * for verts, but also edges/polys/loops. */
140  const int defgroup,
141  const int num_verts,
142  float *r_weights,
143  const bool invert_vgroup);
145  const int defgroup,
146  const int num_verts,
147  struct MEdge *edges,
148  const int num_edges,
149  float *r_weights,
150  const bool invert_vgroup);
152  const int defgroup,
153  const int num_verts,
154  struct MLoop *loops,
155  const int num_loops,
156  float *r_weights,
157  const bool invert_vgroup);
159  const int defgroup,
160  const int num_verts,
161  struct MLoop *loops,
162  const int num_loops,
163  struct MPoly *polys,
164  const int num_polys,
165  float *r_weights,
166  const bool invert_vgroup);
167 
168 void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight);
169 
170 void BKE_defvert_blend_write(struct BlendWriter *writer, int count, struct MDeformVert *dvlist);
171 void BKE_defvert_blend_read(struct BlendDataReader *reader,
172  int count,
173  struct MDeformVert *mdverts);
174 
175 #ifdef __cplusplus
176 }
177 #endif
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)
Definition: deform.c:1043
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)
void BKE_defvert_blend_write(struct BlendWriter *writer, int count, struct MDeformVert *dvlist)
Definition: deform.c:1525
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)
Definition: deform.c:393
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)
Definition: deform.c:1015
void BKE_defvert_normalize(struct MDeformVert *dvert)
Definition: deform.c:304
void BKE_defvert_extract_vgroup_to_vertweights(struct MDeformVert *dvert, const int defgroup, const int num_verts, float *r_weights, const bool invert_vgroup)
Definition: deform.c:992
void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int *flip_map, const int flip_map_len, const bool use_ensure)
int BKE_object_defgroup_name_index(const struct Object *ob, const char *name)
void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert)
Definition: deform.c:977
float BKE_defvert_total_selected_weight(const struct MDeformVert *dv, int defbase_tot, const bool *defbase_sel)
Definition: deform.c:835
void BKE_defvert_weight_to_rgb(float r_rgb[3], const float weight)
Definition: deform.c:1486
void BKE_defvert_normalize_subset(struct MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot)
Definition: deform.c:267
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_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len)
Definition: deform.c:462
struct MDeformWeight * BKE_defvert_ensure_index(struct MDeformVert *dv, const int defgroup)
Definition: deform.c:688
void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase)
int BKE_object_defgroup_flip_index(const struct Object *ob, int index, const bool use_default)
struct bDeformGroup * BKE_object_defgroup_new(struct Object *ob, const char *name)
Definition: deform.c:57
struct MDeformWeight * BKE_defvert_find_index(const struct MDeformVert *dv, const int defgroup)
float BKE_defvert_calc_lock_relative_weight(float weight, float locked_weight, float unlocked_weight)
Definition: deform.c:887
float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert, const int index, const int defgroup)
Definition: deform.c:645
float BKE_defvert_find_weight(const struct MDeformVert *dvert, const int defgroup)
Definition: deform.c:632
bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, const int defgroup_tot)
Definition: deform.c:818
void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert)
void BKE_defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool use_ensure)
void BKE_defvert_copy_index(struct MDeformVert *dvert_dst, const int defgroup_dst, const struct MDeformVert *dvert_src, const int defgroup_src)
float BKE_defvert_lock_relative_weight(float weight, const struct MDeformVert *dv, int defbase_tot, const bool *defbase_locked, const bool *defbase_unlocked)
Definition: deform.c:920
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_object_defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob)
Definition: deform.c:620
int * BKE_object_defgroup_flip_map(const struct Object *ob, int *flip_map_len, const bool use_default)
void BKE_defvert_blend_read(struct BlendDataReader *reader, int count, struct MDeformVert *mdverts)
Definition: deform.c:1542
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert)
Definition: deform.c:959
void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw)
Definition: deform.c:754
void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, const int map_len)
Definition: deform.c:252
void BKE_defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src)
void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len)
Definition: deform.c:448
int * BKE_object_defgroup_flip_map_single(const struct Object *ob, int *flip_map_len, const bool use_default, int defgroup)
float BKE_defvert_multipaint_collective_weight(const struct MDeformVert *dv, int defbase_tot, const bool *defbase_sel, int defbase_tot_sel, bool is_normalized)
Definition: deform.c:865
struct bDeformGroup * BKE_object_defgroup_find_name(const struct Object *ob, const char *name)
void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, const float weight)
Definition: deform.c:726
void BKE_defvert_clear(struct MDeformVert *dvert)
Definition: deform.c:785
void BKE_defvert_normalize_lock_single(struct MDeformVert *dvert, const bool *vgroup_subset, const int vgroup_tot, const uint def_nr_lock)
Definition: deform.c:336
struct bDeformGroup * BKE_defgroup_duplicate(const struct bDeformGroup *ingroup)
int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b)
unsigned int uint
Definition: BLI_sys_types.h:83
int count