81 for (defgroup = inbase->
first; defgroup; defgroup = defgroup->
next) {
113 const bool *vgroup_subset,
114 const int vgroup_tot)
117 for (defgroup = 0; defgroup < vgroup_tot; defgroup++) {
118 if (vgroup_subset[defgroup]) {
131 const bool *vgroup_subset,
132 const int vgroup_tot,
134 const int flip_map_len)
137 for (defgroup = 0; defgroup < vgroup_tot && defgroup < flip_map_len; defgroup++) {
138 if (vgroup_subset[defgroup] && (dvert_dst != dvert_src || flip_map[defgroup] != defgroup)) {
173 const int defgroup_dst,
175 const int defgroup_src)
204 for (
int i = 0; i < dvert_src->
totweight; i++, dw_src++) {
226 const int flip_map_len,
227 const bool use_ensure)
231 for (
int i = 0; i < dvert_src->
totweight; i++, dw_src++) {
232 if (dw_src->
def_nr < flip_map_len) {
255 for (
int i = dvert->
totweight; i != 0; i--, dw++) {
256 if (dw->
def_nr < map_len) {
268 const bool *vgroup_subset,
269 const int vgroup_tot)
276 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
282 float tot_weight = 0.0f;
283 for (
int i = dvert->
totweight; i != 0; i--, dw++) {
284 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
289 if (tot_weight > 0.0f) {
290 float scalar = 1.0f / tot_weight;
292 for (
int i = dvert->
totweight; i != 0; i--, dw++) {
293 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
315 float tot_weight = 0.0f;
317 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
321 if (tot_weight > 0.0f) {
322 float scalar = 1.0f / tot_weight;
323 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
337 const bool *vgroup_subset,
338 const int vgroup_tot,
339 const uint def_nr_lock)
346 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
347 if (def_nr_lock != dw->
def_nr) {
356 float tot_weight = 0.0f;
357 float lock_iweight = 1.0f;
359 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
360 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
361 if (dw->
def_nr != def_nr_lock) {
366 lock_iweight = (1.0f - dw_lock->
weight);
367 CLAMP(lock_iweight, 0.0f, 1.0f);
372 if (tot_weight > 0.0f) {
375 float scalar = (1.0f / tot_weight) * lock_iweight;
376 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
377 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
394 const bool *vgroup_subset,
395 const int vgroup_tot,
396 const bool *lock_flags,
397 const int defbase_tot)
404 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
405 if ((dw->
def_nr < defbase_tot) && (lock_flags[dw->
def_nr] ==
false)) {
413 float tot_weight = 0.0f;
414 float lock_iweight = 0.0f;
416 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
417 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
418 if ((dw->
def_nr < defbase_tot) && (lock_flags[dw->
def_nr] ==
false)) {
423 lock_iweight += dw->
weight;
428 lock_iweight =
max_ff(0.0f, 1.0f - lock_iweight);
430 if (tot_weight > 0.0f) {
433 float scalar = (1.0f / tot_weight) * lock_iweight;
434 for (i = dvert->
totweight, dw = dvert->
dw; i != 0; i--, dw++) {
435 if ((dw->
def_nr < vgroup_tot) && vgroup_subset[dw->
def_nr]) {
436 if ((dw->
def_nr < defbase_tot) && (lock_flags[dw->
def_nr] ==
false)) {
453 for (dw = dvert->
dw, i = 0; i < dvert->totweight; dw++, i++) {
454 if (dw->
def_nr < flip_map_len) {
455 if (flip_map[dw->
def_nr] >= 0) {
469 for (dw = dvert->
dw, i = 0; i < totweight; dw++, i++) {
470 if (dw->
def_nr < flip_map_len) {
471 if (flip_map[dw->
def_nr] >= 0) {
489 return (name && name[0] !=
'\0') ?
496 return (name && name[0] !=
'\0') ?
508 if (defbase_tot == 0) {
513 char name_flip[
sizeof(dg->
name)];
514 int i, flip_num, *map =
MEM_mallocN(defbase_tot *
sizeof(
int), __func__);
516 for (i = 0; i < defbase_tot; i++) {
547 const bool use_default,
552 if (defbase_tot == 0) {
557 char name_flip[
sizeof(dg->
name)];
558 int i, flip_num, *map =
MEM_mallocN(defbase_tot *
sizeof(
int), __func__);
560 for (i = 0; i < defbase_tot; i++) {
561 map[i] = use_default ? i : -1;
570 if (flip_num != -1) {
571 map[defgroup] = flip_num;
572 map[flip_num] = defgroup;
585 char name_flip[
sizeof(dg->
name)];
593 return (flip_index == -1 && use_default) ? index : flip_index;
635 return dw ? dw->
weight : 0.0f;
654 if (defgroup == -1) {
666 if (dvert && defgroup >= 0) {
670 for (i = dvert->
totweight; i != 0; i--, dw++) {
671 if (dw->
def_nr == defgroup) {
693 if (!dvert || defgroup < 0) {
711 dw_new->
def_nr = defgroup;
731 if (!dvert || defgroup < 0) {
737 "defvert_add_to group, new deformWeight");
745 dw_new->
def_nr = defgroup;
757 int i = dw - dvert->
dw;
805 for (i = dvert_a->
totweight; i != 0; i--, dw++) {
821 for (
int i = dvert->
totweight; i != 0; i--, dw++) {
837 const bool *defbase_sel)
842 if (defbase_sel ==
NULL) {
846 for (
int i = dv->
totweight; i != 0; i--, dw++) {
847 if (dw->
def_nr < defbase_tot) {
848 if (defbase_sel[dw->
def_nr]) {
867 const bool *defbase_sel,
875 if (!is_normalized) {
876 total /= defbase_tot_sel;
889 float unlocked_weight)
892 if (unlocked_weight > 0.0f) {
893 return weight / unlocked_weight;
897 if (locked_weight <= 0.0f) {
903 if (weight != 0.0f) {
912 return weight / (1.0f - locked_weight);
923 const bool *defbase_locked,
924 const bool *defbase_unlocked)
928 if (unlocked > 0.0f) {
929 return weight / unlocked;
951 for (
int i = 0; i < totvert; i++) {
954 memcpy(dst[i].dw, src[i].dw,
sizeof(
MDeformWeight) * src[i].totweight);
970 for (
int i = 0; i < totvert; i++) {
996 const bool invert_vgroup)
998 if (dvert && defgroup != -1) {
1003 r_weights[i] = invert_vgroup ? (1.0f -
w) :
w;
1007 copy_vn_fl(r_weights, num_verts, invert_vgroup ? 1.0f : 0.0f);
1017 const int num_verts,
1019 const int num_edges,
1021 const bool invert_vgroup)
1023 if (dvert && defgroup != -1) {
1025 float *tmp_weights =
MEM_mallocN(
sizeof(*tmp_weights) * (
size_t)num_verts, __func__);
1028 dvert, defgroup, num_verts, tmp_weights, invert_vgroup);
1031 MEdge *me = &edges[i];
1033 r_weights[i] = (tmp_weights[me->
v1] + tmp_weights[me->
v2]) * 0.5f;
1045 const int num_verts,
1047 const int num_loops,
1049 const bool invert_vgroup)
1051 if (dvert && defgroup != -1) {
1053 float *tmp_weights =
MEM_mallocN(
sizeof(*tmp_weights) * (
size_t)num_verts, __func__);
1056 dvert, defgroup, num_verts, tmp_weights, invert_vgroup);
1059 MLoop *ml = &loops[i];
1061 r_weights[i] = tmp_weights[ml->
v];
1073 const int num_verts,
1075 const int UNUSED(num_loops),
1077 const int num_polys,
1079 const bool invert_vgroup)
1081 if (dvert && defgroup != -1) {
1083 float *tmp_weights =
MEM_mallocN(
sizeof(*tmp_weights) * (
size_t)num_verts, __func__);
1086 dvert, defgroup, num_verts, tmp_weights, invert_vgroup);
1089 MPoly *mp = &polys[i];
1095 w += tmp_weights[ml->
v];
1115 const void **sources,
1116 const float *weights,
1118 const float mix_factor)
1125 const int mix_mode = laymap->
mix_mode;
1131 float weight_src = 0.0f, weight_dst = 0.0f;
1134 for (i =
count; i--;) {
1135 for (j = data_src[i]->totweight; j--;) {
1136 if ((dw_src = &data_src[i]->dw[j])->def_nr == idx_src) {
1137 weight_src += dw_src->
weight * weights[i];
1145 weight_dst = dw_dst->
weight;
1153 CLAMP(weight_src, 0.0f, 1.0f);
1159 dw_dst->
weight = weight_src;
1165 const float mix_factor,
1166 const float *mix_weights,
1167 const int num_elem_dst,
1168 const bool use_create,
1169 const bool use_delete,
1176 const bool UNUSED(use_dupref_dst),
1178 const bool *use_layers_src,
1179 const int num_layers_src)
1192 idx_src = num_layers_src;
1193 while (idx_src-- && !use_layers_src[idx_src]) {
1198 if (idx_dst < idx_src) {
1201 for (; idx_dst < idx_src; idx_dst++) {
1210 else if (use_delete && idx_dst > idx_src) {
1211 while (idx_dst-- > idx_src) {
1223 if (!use_layers_src[idx_src]) {
1255 dg_dst = dg_dst_next;
1259 for (idx_src = 0, dg_src = ob_src->
defbase.
first; idx_src < num_layers_src;
1260 idx_src++, dg_src = dg_src->
next) {
1261 if (!use_layers_src[idx_src]) {
1268 idx_dst = ob_dst->
actdef - 1;
1310 const float mix_factor,
1311 const float *mix_weights,
1312 const int num_elem_dst,
1313 const bool use_create,
1314 const bool use_delete,
1319 const bool use_dupref_dst,
1320 const int fromlayers,
1323 int idx_src, idx_dst;
1345 if (data_dst && use_dupref_dst && r_map) {
1353 if (fromlayers >= 0) {
1354 idx_src = fromlayers;
1362 else if ((idx_src = ob_src->
actdef - 1) == -1) {
1366 if (tolayers >= 0) {
1372 if ((idx_dst = ob_dst->
actdef - 1) == -1) {
1379 idx_dst = ob_dst->
actdef - 1;
1385 if (num <= idx_dst) {
1390 for (; num <= idx_dst; num++) {
1402 idx_dst = ob_dst->
actdef - 1;
1434 int num_src, num_sel_unused;
1435 bool *use_layers_src =
NULL;
1438 switch (fromlayers) {
1453 if (use_layers_src) {
1488 const float blend = ((weight / 2.0f) + 0.5f);
1490 if (weight <= 0.25f) {
1492 r_rgb[1] =
blend * weight * 4.0f;
1495 else if (weight <= 0.50f) {
1498 r_rgb[2] =
blend * (1.0f - ((weight - 0.25f) * 4.0f));
1500 else if (weight <= 0.75f) {
1501 r_rgb[0] =
blend * ((weight - 0.50f) * 4.0f);
1505 else if (weight <= 1.0f) {
1507 r_rgb[1] =
blend * (1.0f - ((weight - 0.75f) * 4.0f));
1527 if (dvlist ==
NULL) {
1535 for (
int i = 0; i <
count; i++) {
1544 if (mdverts ==
NULL) {
1548 for (
int i =
count; i > 0; i--, mdverts++) {
1554 memcpy(dw_tmp, dw, dw_len);
1555 mdverts->
dw = dw_tmp;
typedef float(TangentPoint)[2]
CustomData interface, see also DNA_customdata_types.h.
@ CDT_MIX_REPLACE_ABOVE_THRESHOLD
void * CustomData_duplicate_referenced_layer(struct CustomData *data, const int type, const int totelem)
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
@ DT_LAYERS_VGROUP_SRC_BONE_SELECT
@ DT_LAYERS_VGROUP_SRC_BONE_DEFORM
General operations, lookup, etc. for blender objects.
void BKE_object_batch_cache_dirty_tag(struct Object *ob)
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_findstringindex(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
void copy_vn_fl(float *array_tar, const int size, const float val)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
void BLI_string_flip_side_name(char *r_name, const char *from_name, const bool strip_number, const size_t name_len)
bool BLI_uniquename_cb(UniquenameCheckCallback unique_check, void *arg, const char *defname, char delim, char *name, size_t name_len)
void * BLO_read_get_new_data_address(BlendDataReader *reader, const void *old_address)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
struct MDeformWeight MDeformWeight
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_VGROUP(_type)
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
Group RGB to Bright Vector Camera CLAMP
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void data_transfer_layersmapping_add_item(ListBase *r_map, const int cddata_type, const int mix_mode, const float mix_factor, const float *mix_weights, const void *data_src, void *data_dst, const int data_src_n, const int data_dst_n, const size_t elem_size, const size_t data_size, const size_t data_offset, const uint64_t data_flag, cd_datatransfer_interp interp, void *interp_data)
float data_transfer_interp_float_do(const int mix_mode, const float val_dst, const float val_src, const float mix_factor)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)