Blender  V3.3
BKE_deform.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
4 #pragma once
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
15 struct BlendDataReader;
16 struct BlendWriter;
17 struct ID;
18 struct ListBase;
19 struct MDeformVert;
20 struct MEdge;
21 struct MLoop;
22 struct MPoly;
23 struct Object;
24 struct bDeformGroup;
25 
27 const struct ListBase *BKE_object_defgroup_list(const struct Object *ob);
29 
30 int BKE_object_defgroup_count(const struct Object *ob);
38 void BKE_object_defgroup_active_index_set(struct Object *ob, int new_index);
39 
40 const struct ListBase *BKE_id_defgroup_list_get(const struct ID *id);
41 struct ListBase *BKE_id_defgroup_list_get_mutable(struct ID *id);
42 int BKE_id_defgroup_name_index(const struct ID *id, const char *name);
43 bool BKE_id_defgroup_name_find(const struct ID *id,
44  const char *name,
45  int *r_index,
46  struct bDeformGroup **r_group);
47 
48 struct bDeformGroup *BKE_object_defgroup_new(struct Object *ob, const char *name);
49 void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase);
50 struct bDeformGroup *BKE_defgroup_duplicate(const struct bDeformGroup *ingroup);
51 struct bDeformGroup *BKE_object_defgroup_find_name(const struct Object *ob, const char *name);
55 int *BKE_object_defgroup_flip_map(const struct Object *ob, int *flip_map_len, bool use_default);
60  int *flip_map_len,
61  bool use_default,
62  int defgroup);
63 int BKE_object_defgroup_flip_index(const struct Object *ob, int index, bool use_default);
64 int BKE_object_defgroup_name_index(const struct Object *ob, const char *name);
65 void BKE_object_defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob);
66 
67 struct MDeformWeight *BKE_defvert_find_index(const struct MDeformVert *dv, int defgroup);
73 struct MDeformWeight *BKE_defvert_ensure_index(struct MDeformVert *dv, int defgroup);
79 void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, float weight);
85 void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw);
86 void BKE_defvert_clear(struct MDeformVert *dvert);
91 int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b);
95 bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, int defgroup_tot);
96 
97 void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert);
98 void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert);
99 void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert);
100 
101 float BKE_defvert_find_weight(const struct MDeformVert *dvert, int defgroup);
109 float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int defgroup);
110 
114 float BKE_defvert_total_selected_weight(const struct MDeformVert *dv,
115  int defbase_tot,
116  const bool *defbase_sel);
117 
127  int defbase_tot,
128  const bool *defbase_sel,
129  int defbase_tot_sel,
130  bool is_normalized);
131 
132 /* This much unlocked weight is considered equivalent to none. */
133 #define VERTEX_WEIGHT_LOCK_EPSILON 1e-6f
134 
141  float locked_weight,
142  float unlocked_weight);
149  const struct MDeformVert *dv,
150  int defbase_tot,
151  const bool *defbase_locked,
152  const bool *defbase_unlocked);
153 
154 void BKE_defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src);
160 void BKE_defvert_copy_subset(struct MDeformVert *dvert_dst,
161  const struct MDeformVert *dvert_src,
162  const bool *vgroup_subset,
163  int vgroup_tot);
169 void BKE_defvert_mirror_subset(struct MDeformVert *dvert_dst,
170  const struct MDeformVert *dvert_src,
171  const bool *vgroup_subset,
172  int vgroup_tot,
173  const int *flip_map,
174  int flip_map_len);
180 void BKE_defvert_copy_index(struct MDeformVert *dvert_dst,
181  int defgroup_dst,
182  const struct MDeformVert *dvert_src,
183  int defgroup_src);
188 void BKE_defvert_sync(struct MDeformVert *dvert_dst,
189  const struct MDeformVert *dvert_src,
190  bool use_ensure);
194 void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst,
195  const struct MDeformVert *dvert_src,
196  const int *flip_map,
197  int flip_map_len,
198  bool use_ensure);
202 void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, int map_len);
203 void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, int flip_map_len);
204 void BKE_defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, int flip_map_len);
205 void BKE_defvert_normalize(struct MDeformVert *dvert);
209 void BKE_defvert_normalize_subset(struct MDeformVert *dvert,
210  const bool *vgroup_subset,
211  int vgroup_tot);
216  const bool *vgroup_subset,
217  int vgroup_tot,
218  uint def_nr_lock);
223  const bool *vgroup_subset,
224  int vgroup_tot,
225  const bool *lock_flags,
226  int defbase_tot);
227 
228 /* Utilities to 'extract' a given vgroup into a simple float array,
229  * for verts, but also edges/polys/loops. */
230 
232  int defgroup,
233  int num_verts,
234  bool invert_vgroup,
235  float *r_weights);
241  int defgroup,
242  int num_verts,
243  struct MEdge *edges,
244  int num_edges,
245  bool invert_vgroup,
246  float *r_weights);
248  int defgroup,
249  int num_verts,
250  struct MLoop *loops,
251  int num_loops,
252  bool invert_vgroup,
253  float *r_weights);
255  int defgroup,
256  int num_verts,
257  struct MLoop *loops,
258  int num_loops,
259  struct MPoly *polys,
260  int num_polys,
261  bool invert_vgroup,
262  float *r_weights);
263 
264 void BKE_defvert_weight_to_rgb(float r_rgb[3], float weight);
265 
267  int count,
268  const struct MDeformVert *dvlist);
269 void BKE_defvert_blend_read(struct BlendDataReader *reader,
270  int count,
271  struct MDeformVert *mdverts);
272 void BKE_defbase_blend_write(struct BlendWriter *writer, const ListBase *defbase);
273 
274 #ifdef __cplusplus
275 }
276 #endif
bool BKE_object_supports_vertex_groups(const struct Object *ob)
bool BKE_defvert_is_weight_zero(const struct MDeformVert *dvert, int defgroup_tot)
Definition: deform.c:858
void BKE_defvert_normalize_lock_single(struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot, uint def_nr_lock)
Definition: deform.c:293
int BKE_object_defgroup_active_index_get(const struct Object *ob)
void BKE_defvert_extract_vgroup_to_polyweights(const struct MDeformVert *dvert, int defgroup, int num_verts, struct MLoop *loops, int num_loops, struct MPoly *polys, int num_polys, bool invert_vgroup, float *r_weights)
struct ListBase * BKE_object_defgroup_list_mutable(struct Object *ob)
Definition: deform.c:552
void BKE_defvert_normalize(struct MDeformVert *dvert)
Definition: deform.c:264
void BKE_defbase_blend_write(struct BlendWriter *writer, const ListBase *defbase)
Definition: deform.c:1557
void BKE_defvert_normalize_subset(struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot)
Definition: deform.c:227
struct MDeformWeight * BKE_defvert_find_index(const struct MDeformVert *dv, int defgroup)
void BKE_object_defgroup_active_index_set(struct Object *ob, int new_index)
Definition: deform.c:568
int * BKE_object_defgroup_flip_map(const struct Object *ob, int *flip_map_len, bool use_default)
void BKE_defvert_copy_index(struct MDeformVert *dvert_dst, int defgroup_dst, const struct MDeformVert *dvert_src, int defgroup_src)
int BKE_object_defgroup_name_index(const struct Object *ob, const char *name)
void BKE_defvert_remap(struct MDeformVert *dvert, const int *map, int map_len)
Definition: deform.c:215
void BKE_defvert_array_free(struct MDeformVert *dvert, int totvert)
Definition: deform.c:996
void BKE_defvert_copy_subset(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool *vgroup_subset, int vgroup_tot)
float BKE_defvert_total_selected_weight(const struct MDeformVert *dv, int defbase_tot, const bool *defbase_sel)
Definition: deform.c:872
const struct ListBase * BKE_id_defgroup_list_get(const struct ID *id)
void BKE_defvert_normalize_lock_map(struct MDeformVert *dvert, const bool *vgroup_subset, int vgroup_tot, const bool *lock_flags, int defbase_tot)
Definition: deform.c:347
const struct ListBase * BKE_object_defgroup_list(const struct Object *ob)
void BKE_defvert_flip(struct MDeformVert *dvert, const int *flip_map, int flip_map_len)
Definition: deform.c:402
void BKE_defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, int flip_map_len)
Definition: deform.c:416
void BKE_defgroup_copy_list(struct ListBase *outbase, const struct ListBase *inbase)
struct bDeformGroup * BKE_object_defgroup_new(struct Object *ob, const char *name)
Definition: deform.c:43
void BKE_defvert_blend_write(struct BlendWriter *writer, int count, const struct MDeformVert *dvlist)
struct MDeformWeight * BKE_defvert_ensure_index(struct MDeformVert *dv, int defgroup)
Definition: deform.c:748
float BKE_defvert_calc_lock_relative_weight(float weight, float locked_weight, float unlocked_weight)
Definition: deform.c:911
void BKE_defvert_array_copy(struct MDeformVert *dst, const struct MDeformVert *src, int totvert)
void BKE_defvert_sync_mapped(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const int *flip_map, int flip_map_len, bool use_ensure)
bool BKE_id_defgroup_name_find(const struct ID *id, const char *name, int *r_index, struct bDeformGroup **r_group)
Definition: deform.c:517
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:939
struct ListBase * BKE_id_defgroup_list_get_mutable(struct ID *id)
Definition: deform.c:493
float BKE_defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, int defgroup)
Definition: deform.c:710
int BKE_object_defgroup_flip_index(const struct Object *ob, int index, bool use_default)
void BKE_object_defgroup_unique_name(struct bDeformGroup *dg, struct Object *ob)
Definition: deform.c:692
void BKE_defvert_extract_vgroup_to_edgeweights(const struct MDeformVert *dvert, int defgroup, int num_verts, struct MEdge *edges, int num_edges, bool invert_vgroup, float *r_weights)
void BKE_defvert_blend_read(struct BlendDataReader *reader, int count, struct MDeformVert *mdverts)
Definition: deform.c:1581
void BKE_defvert_array_free_elems(struct MDeformVert *dvert, int totvert)
Definition: deform.c:978
void BKE_defvert_remove_group(struct MDeformVert *dvert, struct MDeformWeight *dw)
Definition: deform.c:804
void BKE_defvert_weight_to_rgb(float r_rgb[3], float weight)
Definition: deform.c:1518
void BKE_defvert_copy(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src)
float BKE_defvert_find_weight(const struct MDeformVert *dvert, int defgroup)
Definition: deform.c:704
int BKE_id_defgroup_name_index(const struct ID *id, const char *name)
void BKE_defvert_mirror_subset(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, const bool *vgroup_subset, int vgroup_tot, const int *flip_map, int flip_map_len)
void BKE_defvert_extract_vgroup_to_loopweights(const struct MDeformVert *dvert, int defgroup, int num_verts, struct MLoop *loops, int num_loops, bool invert_vgroup, float *r_weights)
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:894
void BKE_defvert_add_index_notest(struct MDeformVert *dv, int defgroup, float weight)
Definition: deform.c:779
struct bDeformGroup * BKE_object_defgroup_find_name(const struct Object *ob, const char *name)
int * BKE_object_defgroup_flip_map_single(const struct Object *ob, int *flip_map_len, bool use_default, int defgroup)
int BKE_object_defgroup_count(const struct Object *ob)
void BKE_defvert_clear(struct MDeformVert *dvert)
Definition: deform.c:835
void BKE_defvert_sync(struct MDeformVert *dvert_dst, const struct MDeformVert *dvert_src, bool use_ensure)
struct bDeformGroup * BKE_defgroup_duplicate(const struct bDeformGroup *ingroup)
int BKE_defvert_find_shared(const struct MDeformVert *dvert_a, const struct MDeformVert *dvert_b)
void BKE_defvert_extract_vgroup_to_vertweights(const struct MDeformVert *dvert, int defgroup, int num_verts, bool invert_vgroup, float *r_weights)
unsigned int uint
Definition: BLI_sys_types.h:67
SyclQueue void void * src
int count
SocketIndexByIdentifierMap * map
Definition: DNA_ID.h:368