Files
test/source/blender/editors/include/ED_object_vgroup.hh
YimingWu 6756982f07 Fix #139873: Grease Pencil: Auto normalization on assign/remove operator
Auto normalization used to not work on assign/remove vertex group
operator, this was due to `BKE_object_defgroup_validmap_get` and
`vgroup_parray_alloc` did not handle grease pencil type objects. Now
added grease pencil cases in them and auto normalization works as
expected.

Pull Request: https://projects.blender.org/blender/blender/pulls/139912
2025-06-15 12:50:13 +02:00

107 lines
3.6 KiB
C++

/* SPDX-FileCopyrightText: 2008 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup editors
*/
#pragma once
#include <optional>
struct EnumPropertyItem;
struct ID;
struct MDeformVert;
struct Object;
struct PointerRNA;
struct PropertyRNA;
struct SpaceNode;
struct bContext;
struct bDeformGroup;
#define WEIGHT_REPLACE 1
#define WEIGHT_ADD 2
#define WEIGHT_SUBTRACT 3
namespace blender::ed::object {
bool vgroup_sync_from_pose(Object *ob);
void vgroup_select_by_name(Object *ob, const char *name);
/**
* Removes out of range #MDeformWeights
*/
void vgroup_data_clamp_range(ID *id, int total);
/**
* Matching index only.
*/
bool vgroup_array_copy(Object *ob, Object *ob_from);
bool vgroup_parray_alloc(ID *id,
MDeformVert ***dvert_arr,
int *dvert_tot,
bool use_vert_sel,
std::optional<int> current_frame = {});
/**
* For use with tools that use vgroup_parray_alloc with \a use_vert_sel ==
* true. This finds the unselected mirror deform verts and copies the weights to them from the
* selected.
*
* \note \a dvert_array has mirrored weights filled in,
* in case cleanup operations are needed on both.
*/
void vgroup_parray_mirror_sync(Object *ob,
MDeformVert **dvert_array,
int dvert_tot,
const bool *vgroup_validmap,
int vgroup_tot);
/**
* Fill in the pointers for mirror verts (as if all mirror verts were selected too).
*
* similar to #vgroup_parray_mirror_sync but only fill in mirror points.
*/
void vgroup_parray_mirror_assign(Object *ob, MDeformVert **dvert_array, int dvert_tot);
void vgroup_parray_remove_zero(MDeformVert **dvert_array,
int dvert_tot,
const bool *vgroup_validmap,
int vgroup_tot,
float epsilon,
bool keep_single);
void vgroup_parray_to_weight_array(const MDeformVert **dvert_array,
int dvert_tot,
float *dvert_weights,
int def_nr);
void vgroup_parray_from_weight_array(MDeformVert **dvert_array,
int dvert_tot,
const float *dvert_weights,
int def_nr,
bool remove_zero);
void vgroup_mirror(Object *ob,
bool mirror_weights,
bool flip_vgroups,
bool all_vgroups,
bool use_topology,
int *r_totmirr,
int *r_totfail);
/**
* Called while not in editmode.
*/
void vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, int assignmode);
/**
* Mesh object mode, lattice can be in edit-mode.
*/
void vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum);
float vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum);
/**
* Use when adjusting the active vertex weight and apply to mirror vertices.
*/
void vgroup_vert_active_mirror(Object *ob, int def_nr);
const EnumPropertyItem *vgroup_selection_itemf_helper(const bContext *C,
PointerRNA *ptr,
PropertyRNA *prop,
bool *r_free,
unsigned int selection_mask);
} // namespace blender::ed::object