92 outgroup->
next = outgroup->
prev =
nullptr;
99 const bool *vgroup_subset,
100 const int vgroup_num)
103 for (defgroup = 0; defgroup < vgroup_num; defgroup++) {
104 if (vgroup_subset[defgroup]) {
112 const bool *vgroup_subset,
113 const int vgroup_num,
115 const int flip_map_num)
118 for (defgroup = 0; defgroup < vgroup_num && defgroup < flip_map_num; defgroup++) {
119 if (vgroup_subset[defgroup] && (dvert_dst != dvert_src || flip_map[defgroup] != defgroup)) {
141 dvert_dst->
dw =
nullptr;
149 const int defgroup_dst,
151 const int defgroup_src)
176 for (
int i = 0;
i < dvert_src->
totweight;
i++, dw_src++) {
195 const int flip_map_num,
196 const bool use_ensure)
200 for (
int i = 0;
i < dvert_src->
totweight;
i++, dw_src++) {
201 if (dw_src->
def_nr < flip_map_num) {
222 if (dw->
def_nr < map_len) {
231 const bool *vgroup_subset,
232 const int vgroup_num)
239 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
245 float tot_weight = 0.0f;
247 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
252 if (tot_weight > 0.0f) {
253 float scalar = 1.0f / tot_weight;
256 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
278 float tot_weight = 0.0f;
284 if (tot_weight > 0.0f) {
285 float scalar = 1.0f / tot_weight;
297 const bool *vgroup_subset,
298 const int vgroup_num,
299 const uint def_nr_lock)
306 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
307 if (def_nr_lock != dw->
def_nr) {
316 float tot_weight = 0.0f;
317 float lock_iweight = 1.0f;
320 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
321 if (dw->
def_nr != def_nr_lock) {
326 lock_iweight = (1.0f - dw_lock->
weight);
327 CLAMP(lock_iweight, 0.0f, 1.0f);
332 if (tot_weight > 0.0f) {
335 float scalar = (1.0f / tot_weight) * lock_iweight;
337 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
351 const bool *vgroup_subset,
352 const int vgroup_num,
353 const bool *lock_flags,
354 const int defbase_num)
361 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
362 if ((dw->
def_nr < defbase_num) && (lock_flags[dw->
def_nr] ==
false)) {
370 float tot_weight = 0.0f;
371 float lock_iweight = 0.0f;
374 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
375 if ((dw->
def_nr < defbase_num) && (lock_flags[dw->
def_nr] ==
false)) {
380 lock_iweight += dw->
weight;
385 lock_iweight =
max_ff(0.0f, 1.0f - lock_iweight);
387 if (tot_weight > 0.0f) {
390 float scalar = (1.0f / tot_weight) * lock_iweight;
392 if ((dw->
def_nr < vgroup_num) && vgroup_subset[dw->
def_nr]) {
393 if ((dw->
def_nr < defbase_num) && (lock_flags[dw->
def_nr] ==
false)) {
411 if (dw->
def_nr < flip_map_num) {
412 if (flip_map[dw->
def_nr] >= 0) {
426 for (dw = dvert->
dw,
i = 0;
i < totweight; dw++,
i++) {
427 if (dw->
def_nr < flip_map_num) {
428 if (flip_map[dw->
def_nr] >= 0) {
454 const ID *
id =
static_cast<const ID *
>(ob->
data);
463 const Mesh *mesh = (
const Mesh *)
id;
522 if (name == group->name) {
553 if (name == group->name) {
554 if (r_index !=
nullptr) {
557 if (r_group !=
nullptr) {
609 const bool use_default,
610 const bool use_only_unlocked,
615 *r_flip_map_num = defbase_num;
617 if (defbase_num == 0) {
622 char name_flip[
sizeof(dg->
name)];
626 for (
i = 0;
i < defbase_num;
i++) {
646 if (flip_num != -1) {
662 const bool use_default,
669 const bool use_default,
675 *r_flip_map_num = defbase_num;
677 if (defbase_num == 0) {
684 for (
i = 0;
i < defbase_num;
i++) {
685 map[
i] = use_default ?
i : -1;
694 if (flip_num != -1) {
695 map[defgroup] = flip_num;
696 map[flip_num] = defgroup;
710 char name_flip[
sizeof(dg->
name)];
718 return (flip_index == -1 && use_default) ? index : flip_index;
732 if (curdef->name == name) {
753 std::string old_name = dg->
name;
766 return dw ? dw->
weight : 0.0f;
779 if (defgroup == -1) {
782 if (dvert ==
nullptr) {
783 return invert ? 1.0 : 0.0f;
789 weight = 1.0f - weight;
797 if (dvert && defgroup >= 0) {
802 if (dw->
def_nr == defgroup) {
819 if (!dvert || defgroup < 0) {
837 dw_new->
def_nr = defgroup;
852 if (!dvert || defgroup < 0) {
865 dw_new->
def_nr = defgroup;
881 const int i = dw - dvert->
dw;
941 const bool *defbase_sel)
946 if (defbase_sel ==
nullptr) {
951 if (dw->
def_nr < defbase_num) {
952 if (defbase_sel[dw->
def_nr]) {
962 const int defbase_num,
963 const bool *defbase_sel,
964 const int defbase_sel_num,
965 const bool is_normalized)
971 if (!is_normalized) {
972 total /= defbase_sel_num;
980 float unlocked_weight)
983 if (unlocked_weight > 0.0f) {
984 return weight / unlocked_weight;
988 if (locked_weight <= 0.0f) {
994 if (weight != 0.0f) {
1003 return weight / (1.0f - locked_weight);
1008 const int defbase_num,
1009 const bool *defbase_locked,
1010 const bool *defbase_unlocked)
1014 if (unlocked > 0.0f) {
1015 return weight / unlocked;
1037 for (
int i = 0;
i < totvert;
i++) {
1056 for (
int i = 0;
i < totvert;
i++) {
1080 const int verts_num,
1081 const bool invert_vgroup,
1084 if (dvert && defgroup != -1) {
1089 r_weights[
i] = invert_vgroup ? (1.0f -
w) :
w;
1093 copy_vn_fl(r_weights, verts_num, invert_vgroup ? 1.0f : 0.0f);
1099 const int verts_num,
1101 const int edges_num,
1102 const bool invert_vgroup,
1105 if (
UNLIKELY(!dvert || defgroup == -1)) {
1114 dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
1119 r_weights[
i] = (tmp_weights[edge[0]] + tmp_weights[edge[1]]) * 0.5f;
1127 const int verts_num,
1128 const int *corner_verts,
1129 const int loops_num,
1130 const bool invert_vgroup,
1133 if (
UNLIKELY(!dvert || defgroup == -1)) {
1142 dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
1145 r_weights[
i] = tmp_weights[corner_verts[
i]];
1153 const int verts_num,
1154 const int *corner_verts,
1157 const bool invert_vgroup,
1160 if (
UNLIKELY(!dvert || defgroup == -1)) {
1169 dvert, defgroup, verts_num, invert_vgroup, tmp_weights);
1173 const int *corner_vert = &corner_verts[face.
start()];
1174 int j = face.
size();
1177 for (; j--; corner_vert++) {
1178 w += tmp_weights[*corner_vert];
1180 r_weights[
i] =
w / float(face.
size());
1194 const void **sources,
1195 const float *weights,
1197 const float mix_factor)
1204 const int mix_mode = laymap->
mix_mode;
1209 float weight_src = 0.0f, weight_dst = 0.0f;
1211 bool has_dw_sources =
false;
1214 for (j = data_src[
i]->totweight; j--;) {
1216 if (dw_src->
def_nr == idx_src) {
1217 weight_src += dw_src->
weight * weights[
i];
1218 has_dw_sources =
true;
1226 weight_dst = dw_dst->
weight;
1234 CLAMP(weight_src, 0.0f, 1.0f);
1237 if (!has_dw_sources) {
1240 dw_dst->
weight = weight_src;
1247 dw_dst->
weight = weight_src;
1253 const float mix_factor,
1254 const float *mix_weights,
1255 const int num_elem_dst,
1256 const bool use_create,
1257 const bool use_delete,
1266 const bool *use_layers_src,
1267 const int num_layers_src)
1283 idx_src = num_layers_src;
1284 while (idx_src-- && !use_layers_src[idx_src]) {
1289 if (idx_dst < idx_src) {
1292 for (; idx_dst < idx_src; idx_dst++) {
1301 else if (use_delete && idx_dst > idx_src) {
1302 while (idx_dst-- > idx_src) {
1315 if (!use_layers_src[idx_src]) {
1347 dg_dst = dg_dst_next;
1352 idx_src < num_layers_src;
1353 idx_src++, dg_src = dg_src->
next)
1355 if (!use_layers_src[idx_src]) {
1360 if (idx_dst == -1) {
1406 const float mix_factor,
1407 const float *mix_weights,
1408 const int num_elem_dst,
1409 const bool use_create,
1410 const bool use_delete,
1415 const bool use_dupref_dst,
1416 const int fromlayers,
1419 int idx_src, idx_dst;
1446 if (data_dst && use_dupref_dst && r_map) {
1455 if (fromlayers >= 0) {
1456 idx_src = fromlayers;
1468 if (tolayers >= 0) {
1477 if (idx_dst == -1) {
1490 if (
num <= idx_dst) {
1495 for (;
num <= idx_dst;
num++) {
1503 if (idx_dst == -1) {
1541 int num_src, num_sel_unused;
1542 bool *use_layers_src =
nullptr;
1545 switch (fromlayers) {
1560 if (use_layers_src) {
1595 const float blend = ((weight / 2.0f) + 0.5f);
1597 if (weight <= 0.25f) {
1599 r_rgb[1] =
blend * weight * 4.0f;
1602 else if (weight <= 0.50f) {
1605 r_rgb[2] =
blend * (1.0f - ((weight - 0.25f) * 4.0f));
1607 else if (weight <= 0.75f) {
1608 r_rgb[0] =
blend * ((weight - 0.50f) * 4.0f);
1612 else if (weight <= 1.0f) {
1614 r_rgb[1] =
blend * (1.0f - ((weight - 0.75f) * 4.0f));
1641 if (dvlist ==
nullptr) {
1658 if (mdverts ==
nullptr) {
1662 for (
int i =
count;
i > 0;
i--, mdverts++) {
1669 memcpy(dw_tmp, dw, dw_len);
1674 mdverts->
dw =
nullptr;
1691 const int dvert_index_;
1702 dvert_index_(dvert_index)
1708 if (dverts_ ==
nullptr) {
1711 if (
const MDeformWeight *weight = this->find_weight_at_index(index)) {
1712 return weight->weight;
1720 if (value == 0.0f) {
1721 if (
MDeformWeight *weight = this->find_weight_at_index(index)) {
1722 weight->weight = 0.0f;
1734 for (const int64_t i : range) {
1735 this->set(i, src[i]);
1742 if (dverts_ ==
nullptr) {
1743 mask.foreach_index([&](
const int i) { dst[
i] = 0.0f; });
1746 mask.slice(range).foreach_index_optimized<int64_t>([&](const int64_t index) {
1747 if (const MDeformWeight *weight = this->find_weight_at_index(index)) {
1748 dst[index] = weight->weight;
1766 if (weight.def_nr == dvert_index_) {
1774 for (
const MDeformWeight &weight :
Span(dverts_[index].dw, dverts_[index].totweight)) {
1775 if (weight.def_nr == dvert_index_) {
1788 const int defgroup_index)
1796 for (MDeformVert &dvert : dverts.slice(range)) {
1797 MDeformWeight *weight = BKE_defvert_find_index(&dvert, defgroup_index);
1798 BKE_defvert_remove_group(&dvert, weight);
1799 for (MDeformWeight &weight : MutableSpan(dvert.dw, dvert.totweight)) {
1800 if (weight.def_nr > defgroup_index) {
1813 for (const int dst_i : range) {
1814 const int src_i = indices[dst_i];
1815 dst[dst_i].dw = static_cast<MDeformWeight *>(MEM_dupallocN(src[src_i].dw));
1816 dst[dst_i].totweight = src[src_i].totweight;
1817 dst[dst_i].flag = src[src_i].flag;
1827 dst[dst_i].totweight = src[src_i].totweight;
1828 dst[dst_i].flag = src[src_i].flag;
CustomData interface, see also DNA_customdata_types.h.
const void * CustomData_get_layer(const CustomData *data, eCustomDataType type)
void * CustomData_get_layer_for_write(CustomData *data, eCustomDataType type, int totelem)
void * CustomData_add_layer(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem)
Low-level operations for grease pencil.
void BKE_grease_pencil_vgroup_name_update(Object *ob, const char *old_name, const char *new_name)
Utility functions for vertex groups in grease pencil objects.
General operations, lookup, etc. for blender objects.
void BKE_object_batch_cache_dirty_tag(Object *ob)
#define BLI_assert_unreachable()
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE float max_ff(float a, float b)
void copy_vn_fl(float *array_tar, int size, float val)
ATTR_WARN_UNUSED_RESULT const size_t num
#define STRNCPY_UTF8(dst, src)
size_t BLI_string_flip_side_name(char *name_dst, const char *name_src, bool strip_number, size_t name_dst_maxncpy) ATTR_NONNULL(1
size_t void BLI_uniquename_cb(blender::FunctionRef< bool(blender::StringRefNull)> unique_check, const char *defname, char delim, char *name, size_t name_maxncpy) ATTR_NONNULL(2
#define UNUSED_VARS_NDEBUG(...)
#define BLO_write_struct(writer, struct_name, data_ptr)
#define BLO_write_struct_array(writer, struct_name, array_size, data_ptr)
#define BLO_read_struct_array(reader, struct_name, array_size, ptr_p)
@ DT_LAYERS_VGROUP_SRC_BONE_SELECT
@ DT_LAYERS_VGROUP_SRC_BONE_DEFORM
@ CDT_MIX_REPLACE_ABOVE_THRESHOLD
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_VGROUP(_type)
Read Guarded memory(de)allocation.
BMesh const char void * data
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static VArray For(Args &&...args)
constexpr int64_t size() const
constexpr int64_t start() const
constexpr IndexRange index_range() const
constexpr IndexRange index_range() const
constexpr bool is_empty() const
void copy_utf8_truncated(char *dst, int64_t dst_size) const
static VMutableArray For(Args &&...args)
void set_all(Span< float > src) override
void materialize(const IndexMask &mask, float *dst) const override
float get(const int64_t index) const override
void set(const int64_t index, const float value) override
void materialize_to_uninitialized(const IndexMask &mask, float *dst) const override
VArrayImpl_For_VertexWeights(MutableSpan< MDeformVert > dverts, const int dvert_index)
VArrayImpl_For_VertexWeights(Span< MDeformVert > dverts, const int dvert_index)
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)
#define MEM_reallocN(vmemh, len)
CCL_NAMESPACE_BEGIN ccl_device float invert(const float color, const float factor)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_dupallocN(const void *vmemh)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
void validate_drawing_vertex_groups(GreasePencil &grease_pencil)
void remove_defgroup_index(MutableSpan< MDeformVert > dverts, int defgroup_index)
void gather_deform_verts(Span< MDeformVert > src, Span< int > indices, MutableSpan< MDeformVert > dst)
VMutableArray< float > varray_for_mutable_deform_verts(MutableSpan< MDeformVert > dverts, int defgroup_index)
VArray< float > varray_for_deform_verts(Span< MDeformVert > dverts, int defgroup_index)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< int32_t, 2 > int2
int vertex_group_active_index
ListBase vertex_group_names
ListBase vertex_group_names
int vertex_group_active_index
ListBase vertex_group_names
int vertex_group_active_index
ListBase vertex_group_names
int vertex_group_active_index
static int blend(const Tex *tex, const float texvec[3], TexResult *texres)