Cleanup: wrap function args
This commit is contained in:
parent
b2dc0e6970
commit
88e69806b9
|
@ -253,9 +253,10 @@ bool ED_vgroup_parray_alloc(ID *id, MDeformVert ***dvert_arr, int *dvert_tot, co
|
|||
*
|
||||
* \note \a dvert_array has mirrored weights filled in, incase cleanup operations are needed on both.
|
||||
*/
|
||||
void ED_vgroup_parray_mirror_sync(Object *ob,
|
||||
MDeformVert **dvert_array, const int dvert_tot,
|
||||
const bool *vgroup_validmap, const int vgroup_tot)
|
||||
void ED_vgroup_parray_mirror_sync(
|
||||
Object *ob,
|
||||
MDeformVert **dvert_array, const int dvert_tot,
|
||||
const bool *vgroup_validmap, const int vgroup_tot)
|
||||
{
|
||||
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
||||
MDeformVert **dvert_array_all = NULL;
|
||||
|
@ -298,8 +299,9 @@ void ED_vgroup_parray_mirror_sync(Object *ob,
|
|||
*
|
||||
* similar to #ED_vgroup_parray_mirror_sync but only fill in mirror points.
|
||||
*/
|
||||
void ED_vgroup_parray_mirror_assign(Object *ob,
|
||||
MDeformVert **dvert_array, const int dvert_tot)
|
||||
void ED_vgroup_parray_mirror_assign(
|
||||
Object *ob,
|
||||
MDeformVert **dvert_array, const int dvert_tot)
|
||||
{
|
||||
BMEditMesh *em = BKE_editmesh_from_object(ob);
|
||||
MDeformVert **dvert_array_all = NULL;
|
||||
|
@ -330,9 +332,10 @@ void ED_vgroup_parray_mirror_assign(Object *ob,
|
|||
MEM_freeN(dvert_array_all);
|
||||
}
|
||||
|
||||
void ED_vgroup_parray_remove_zero(MDeformVert **dvert_array, const int dvert_tot,
|
||||
const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const float epsilon, const bool keep_single)
|
||||
void ED_vgroup_parray_remove_zero(
|
||||
MDeformVert **dvert_array, const int dvert_tot,
|
||||
const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const float epsilon, const bool keep_single)
|
||||
{
|
||||
MDeformVert *dv;
|
||||
int i;
|
||||
|
@ -482,9 +485,10 @@ void ED_vgroup_parray_from_weight_array(
|
|||
|
||||
|
||||
/* TODO, cache flip data to speedup calls within a loop. */
|
||||
static void mesh_defvert_mirror_update_internal(Object *ob,
|
||||
MDeformVert *dvert_dst, MDeformVert *dvert_src,
|
||||
const int def_nr)
|
||||
static void mesh_defvert_mirror_update_internal(
|
||||
Object *ob,
|
||||
MDeformVert *dvert_dst, MDeformVert *dvert_src,
|
||||
const int def_nr)
|
||||
{
|
||||
if (def_nr == -1) {
|
||||
/* all vgroups, add groups where neded */
|
||||
|
@ -502,8 +506,9 @@ static void mesh_defvert_mirror_update_internal(Object *ob,
|
|||
}
|
||||
}
|
||||
|
||||
static void ED_mesh_defvert_mirror_update_em(Object *ob, BMVert *eve, int def_nr, int vidx,
|
||||
const int cd_dvert_offset)
|
||||
static void ED_mesh_defvert_mirror_update_em(
|
||||
Object *ob, BMVert *eve, int def_nr, int vidx,
|
||||
const int cd_dvert_offset)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
BMEditMesh *em = me->edit_btmesh;
|
||||
|
@ -711,26 +716,30 @@ const EnumPropertyItem *ED_object_vgroup_selection_itemf_helper(
|
|||
return item;
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *rna_vertex_group_with_single_itemf(bContext *C, PointerRNA *ptr,
|
||||
PropertyRNA *prop, bool *r_free)
|
||||
static const EnumPropertyItem *rna_vertex_group_with_single_itemf(
|
||||
bContext *C, PointerRNA *ptr,
|
||||
PropertyRNA *prop, bool *r_free)
|
||||
{
|
||||
return ED_object_vgroup_selection_itemf_helper(C, ptr, prop, r_free, WT_VGROUP_MASK_ALL);
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *rna_vertex_group_select_itemf(bContext *C, PointerRNA *ptr,
|
||||
PropertyRNA *prop, bool *r_free)
|
||||
static const EnumPropertyItem *rna_vertex_group_select_itemf(
|
||||
bContext *C, PointerRNA *ptr,
|
||||
PropertyRNA *prop, bool *r_free)
|
||||
{
|
||||
return ED_object_vgroup_selection_itemf_helper(C, ptr, prop, r_free, WT_VGROUP_MASK_ALL & ~(1 << WT_VGROUP_ACTIVE));
|
||||
return ED_object_vgroup_selection_itemf_helper(
|
||||
C, ptr, prop, r_free, WT_VGROUP_MASK_ALL & ~(1 << WT_VGROUP_ACTIVE));
|
||||
}
|
||||
|
||||
static void vgroup_operator_subset_select_props(wmOperatorType *ot, bool use_active)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
prop = RNA_def_enum(ot->srna,
|
||||
"group_select_mode", DummyRNA_NULL_items,
|
||||
use_active ? WT_VGROUP_ACTIVE : WT_VGROUP_ALL, "Subset",
|
||||
"Define which subset of Groups shall be used");
|
||||
prop = RNA_def_enum(
|
||||
ot->srna,
|
||||
"group_select_mode", DummyRNA_NULL_items,
|
||||
use_active ? WT_VGROUP_ACTIVE : WT_VGROUP_ALL, "Subset",
|
||||
"Define which subset of Groups shall be used");
|
||||
|
||||
if (use_active) {
|
||||
RNA_def_enum_funcs(prop, rna_vertex_group_with_single_itemf);
|
||||
|
@ -747,9 +756,10 @@ static void vgroup_operator_subset_select_props(wmOperatorType *ot, bool use_act
|
|||
|
||||
/* for Mesh in Object mode */
|
||||
/* allows editmode for Lattice */
|
||||
static void ED_vgroup_nr_vert_add(Object *ob,
|
||||
const int def_nr, const int vertnum,
|
||||
const float weight, const int assignmode)
|
||||
static void ED_vgroup_nr_vert_add(
|
||||
Object *ob,
|
||||
const int def_nr, const int vertnum,
|
||||
const float weight, const int assignmode)
|
||||
{
|
||||
/* add the vert to the deform group with the
|
||||
* specified number
|
||||
|
@ -1220,9 +1230,10 @@ static void getSingleCoordinate(MVert *points, int count, float coord[3])
|
|||
* compute the amount of vertical distance relative to the plane and store it in dists,
|
||||
* then get the horizontal and vertical change and store them in changes
|
||||
*/
|
||||
static void getVerticalAndHorizontalChange(const float norm[3], float d, const float coord[3],
|
||||
const float start[3], float distToStart,
|
||||
float *end, float (*changes)[2], float *dists, int index)
|
||||
static void getVerticalAndHorizontalChange(
|
||||
const float norm[3], float d, const float coord[3],
|
||||
const float start[3], float distToStart,
|
||||
float *end, float (*changes)[2], float *dists, int index)
|
||||
{
|
||||
/* A = Q - ((Q - P).N)N
|
||||
* D = (a * x0 + b * y0 +c * z0 + d) */
|
||||
|
@ -1273,8 +1284,9 @@ static DerivedMesh *dm_deform_recalc(Scene *scene, Object *ob)
|
|||
* norm and d are the plane's properties for the equation: ax + by + cz + d = 0
|
||||
* coord is a point on the plane
|
||||
*/
|
||||
static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
|
||||
float coord[3], float d, float distToBe, float strength, float cp)
|
||||
static void moveCloserToDistanceFromPlane(
|
||||
Scene *scene, Object *ob, Mesh *me, int index, float norm[3],
|
||||
float coord[3], float d, float distToBe, float strength, float cp)
|
||||
{
|
||||
DerivedMesh *dm;
|
||||
MDeformWeight *dw;
|
||||
|
@ -1494,9 +1506,10 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength,
|
|||
}
|
||||
}
|
||||
|
||||
static void vgroup_levels_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const int UNUSED(subset_count),
|
||||
const float offset, const float gain)
|
||||
static void vgroup_levels_subset(
|
||||
Object *ob, const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const int UNUSED(subset_count),
|
||||
const float offset, const float gain)
|
||||
{
|
||||
MDeformWeight *dw;
|
||||
MDeformVert *dv, **dvert_array = NULL;
|
||||
|
@ -1531,8 +1544,9 @@ static void vgroup_levels_subset(Object *ob, const bool *vgroup_validmap, const
|
|||
}
|
||||
|
||||
if (use_mirror && use_vert_sel) {
|
||||
ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
ED_vgroup_parray_mirror_sync(
|
||||
ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
}
|
||||
|
||||
MEM_freeN(dvert_array);
|
||||
|
@ -1589,12 +1603,14 @@ static bool vgroup_normalize_all(
|
|||
/* in case its not selected */
|
||||
if ((dv = dvert_array[i])) {
|
||||
if (lock_flags) {
|
||||
defvert_normalize_lock_map(dv, vgroup_validmap, vgroup_tot,
|
||||
lock_flags, defbase_tot);
|
||||
defvert_normalize_lock_map(
|
||||
dv, vgroup_validmap, vgroup_tot,
|
||||
lock_flags, defbase_tot);
|
||||
}
|
||||
else if (lock_active) {
|
||||
defvert_normalize_lock_single(dv, vgroup_validmap, vgroup_tot,
|
||||
def_nr);
|
||||
defvert_normalize_lock_single(
|
||||
dv, vgroup_validmap, vgroup_tot,
|
||||
def_nr);
|
||||
}
|
||||
else {
|
||||
defvert_normalize_subset(dv, vgroup_validmap, vgroup_tot);
|
||||
|
@ -1661,9 +1677,10 @@ static void vgroup_lock_all(Object *ob, int action)
|
|||
}
|
||||
}
|
||||
|
||||
static void vgroup_invert_subset(Object *ob,
|
||||
const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const int UNUSED(subset_count), const bool auto_assign, const bool auto_remove)
|
||||
static void vgroup_invert_subset(
|
||||
Object *ob,
|
||||
const bool *vgroup_validmap, const int vgroup_tot,
|
||||
const int UNUSED(subset_count), const bool auto_assign, const bool auto_remove)
|
||||
{
|
||||
MDeformWeight *dw;
|
||||
MDeformVert *dv, **dvert_array = NULL;
|
||||
|
@ -1702,14 +1719,16 @@ static void vgroup_invert_subset(Object *ob,
|
|||
}
|
||||
|
||||
if (use_mirror && use_vert_sel) {
|
||||
ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
ED_vgroup_parray_mirror_sync(
|
||||
ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
}
|
||||
|
||||
if (auto_remove) {
|
||||
ED_vgroup_parray_remove_zero(dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot,
|
||||
0.0f, false);
|
||||
ED_vgroup_parray_remove_zero(
|
||||
dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot,
|
||||
0.0f, false);
|
||||
}
|
||||
|
||||
MEM_freeN(dvert_array);
|
||||
|
@ -1929,8 +1948,9 @@ static void vgroup_smooth_subset(
|
|||
/* not so efficient to get 'dvert_array' again just so unselected verts are NULL'd */
|
||||
if (use_mirror) {
|
||||
ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, true);
|
||||
ED_vgroup_parray_mirror_sync(ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
ED_vgroup_parray_mirror_sync(
|
||||
ob, dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot);
|
||||
if (dvert_array)
|
||||
MEM_freeN(dvert_array);
|
||||
}
|
||||
|
@ -1954,11 +1974,12 @@ static int inv_cmp_mdef_vert_weights(const void *a1, const void *a2)
|
|||
/* Used for limiting the number of influencing bones per vertex when exporting
|
||||
* skinned meshes. if all_deform_weights is True, limit all deform modifiers
|
||||
* to max_weights regardless of type, otherwise, only limit the number of influencing bones per vertex*/
|
||||
static int vgroup_limit_total_subset(Object *ob,
|
||||
const bool *vgroup_validmap,
|
||||
const int vgroup_tot,
|
||||
const int subset_count,
|
||||
const int max_weights)
|
||||
static int vgroup_limit_total_subset(
|
||||
Object *ob,
|
||||
const bool *vgroup_validmap,
|
||||
const int vgroup_tot,
|
||||
const int subset_count,
|
||||
const int max_weights)
|
||||
{
|
||||
MDeformVert *dv, **dvert_array = NULL;
|
||||
int i, dvert_tot = 0;
|
||||
|
@ -2025,8 +2046,9 @@ static int vgroup_limit_total_subset(Object *ob,
|
|||
}
|
||||
|
||||
|
||||
static void vgroup_clean_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
|
||||
const float epsilon, const bool keep_single)
|
||||
static void vgroup_clean_subset(
|
||||
Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
|
||||
const float epsilon, const bool keep_single)
|
||||
{
|
||||
MDeformVert **dvert_array = NULL;
|
||||
int dvert_tot = 0;
|
||||
|
@ -2043,16 +2065,18 @@ static void vgroup_clean_subset(Object *ob, const bool *vgroup_validmap, const i
|
|||
ED_vgroup_parray_mirror_assign(ob, dvert_array, dvert_tot);
|
||||
}
|
||||
|
||||
ED_vgroup_parray_remove_zero(dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot,
|
||||
epsilon, keep_single);
|
||||
ED_vgroup_parray_remove_zero(
|
||||
dvert_array, dvert_tot,
|
||||
vgroup_validmap, vgroup_tot,
|
||||
epsilon, keep_single);
|
||||
|
||||
MEM_freeN(dvert_array);
|
||||
}
|
||||
}
|
||||
|
||||
static void vgroup_quantize_subset(Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
|
||||
const int steps)
|
||||
static void vgroup_quantize_subset(
|
||||
Object *ob, const bool *vgroup_validmap, const int vgroup_tot, const int UNUSED(subset_count),
|
||||
const int steps)
|
||||
{
|
||||
MDeformVert **dvert_array = NULL;
|
||||
int dvert_tot = 0;
|
||||
|
@ -2090,11 +2114,12 @@ static void vgroup_quantize_subset(Object *ob, const bool *vgroup_validmap, cons
|
|||
}
|
||||
}
|
||||
|
||||
static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
|
||||
const char sel, const char sel_mirr,
|
||||
const int *flip_map, const int flip_map_len,
|
||||
const bool mirror_weights, const bool flip_vgroups, const bool all_vgroups,
|
||||
const int act_vgroup)
|
||||
static void dvert_mirror_op(
|
||||
MDeformVert *dvert, MDeformVert *dvert_mirr,
|
||||
const char sel, const char sel_mirr,
|
||||
const int *flip_map, const int flip_map_len,
|
||||
const bool mirror_weights, const bool flip_vgroups, const bool all_vgroups,
|
||||
const int act_vgroup)
|
||||
{
|
||||
BLI_assert(sel || sel_mirr);
|
||||
|
||||
|
@ -2153,10 +2178,11 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr,
|
|||
|
||||
/* TODO, vgroup locking */
|
||||
/* TODO, face masking */
|
||||
void ED_vgroup_mirror(Object *ob,
|
||||
const bool mirror_weights, const bool flip_vgroups,
|
||||
const bool all_vgroups, const bool use_topology,
|
||||
int *r_totmirr, int *r_totfail)
|
||||
void ED_vgroup_mirror(
|
||||
Object *ob,
|
||||
const bool mirror_weights, const bool flip_vgroups,
|
||||
const bool all_vgroups, const bool use_topology,
|
||||
int *r_totmirr, int *r_totfail)
|
||||
{
|
||||
|
||||
#define VGROUP_MIRR_OP \
|
||||
|
@ -3277,12 +3303,13 @@ static int vertex_group_mirror_exec(bContext *C, wmOperator *op)
|
|||
Object *ob = ED_object_context(C);
|
||||
int totmirr = 0, totfail = 0;
|
||||
|
||||
ED_vgroup_mirror(ob,
|
||||
RNA_boolean_get(op->ptr, "mirror_weights"),
|
||||
RNA_boolean_get(op->ptr, "flip_group_names"),
|
||||
RNA_boolean_get(op->ptr, "all_groups"),
|
||||
RNA_boolean_get(op->ptr, "use_topology"),
|
||||
&totmirr, &totfail);
|
||||
ED_vgroup_mirror(
|
||||
ob,
|
||||
RNA_boolean_get(op->ptr, "mirror_weights"),
|
||||
RNA_boolean_get(op->ptr, "flip_group_names"),
|
||||
RNA_boolean_get(op->ptr, "all_groups"),
|
||||
RNA_boolean_get(op->ptr, "use_topology"),
|
||||
&totmirr, &totfail);
|
||||
|
||||
ED_mesh_report_mirror(op, totmirr, totfail);
|
||||
|
||||
|
|
|
@ -76,8 +76,9 @@ struct VertProjUpdate {
|
|||
/* -------------------------------------------------------------------- */
|
||||
/* Internal Init */
|
||||
|
||||
static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, const float co[3],
|
||||
const float no_f[3], const short no_s[3])
|
||||
static void vpaint_proj_dm_map_cosnos_init__map_cb(
|
||||
void *userData, int index, const float co[3],
|
||||
const float no_f[3], const short no_s[3])
|
||||
{
|
||||
struct VertProjHandle *vp_handle = userData;
|
||||
DMCoNo *co_no = &vp_handle->vcosnos[index];
|
||||
|
@ -98,8 +99,9 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, co
|
|||
}
|
||||
}
|
||||
|
||||
static void vpaint_proj_dm_map_cosnos_init(Scene *scene, Object *ob,
|
||||
struct VertProjHandle *vp_handle)
|
||||
static void vpaint_proj_dm_map_cosnos_init(
|
||||
Scene *scene, Object *ob,
|
||||
struct VertProjHandle *vp_handle)
|
||||
{
|
||||
Mesh *me = ob->data;
|
||||
DerivedMesh *dm;
|
||||
|
@ -128,8 +130,9 @@ static void vpaint_proj_dm_map_cosnos_init(Scene *scene, Object *ob,
|
|||
|
||||
/* Same as init but take mouse location into account */
|
||||
|
||||
static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index, const float co[3],
|
||||
const float no_f[3], const short no_s[3])
|
||||
static void vpaint_proj_dm_map_cosnos_update__map_cb(
|
||||
void *userData, int index, const float co[3],
|
||||
const float no_f[3], const short no_s[3])
|
||||
{
|
||||
struct VertProjUpdate *vp_update = userData;
|
||||
struct VertProjHandle *vp_handle = vp_update->vp_handle;
|
||||
|
@ -141,9 +144,10 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index,
|
|||
/* first find distance to this vertex */
|
||||
float co_ss[2]; /* screenspace */
|
||||
|
||||
if (ED_view3d_project_float_object(vp_update->ar,
|
||||
co, co_ss,
|
||||
V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
|
||||
if (ED_view3d_project_float_object(
|
||||
vp_update->ar,
|
||||
co, co_ss,
|
||||
V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR) == V3D_PROJ_RET_OK)
|
||||
{
|
||||
const float dist_sq = len_squared_v2v2(vp_update->mval_fl, co_ss);
|
||||
if (dist_sq > vp_handle->dists_sq[index]) {
|
||||
|
@ -169,8 +173,9 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index,
|
|||
}
|
||||
}
|
||||
|
||||
static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
|
||||
ARegion *ar, const float mval_fl[2])
|
||||
static void vpaint_proj_dm_map_cosnos_update(
|
||||
struct VertProjHandle *vp_handle,
|
||||
ARegion *ar, const float mval_fl[2])
|
||||
{
|
||||
struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl};
|
||||
|
||||
|
@ -198,8 +203,9 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
|
|||
/* -------------------------------------------------------------------- */
|
||||
/* Public Functions */
|
||||
|
||||
struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
|
||||
DMCoNo **r_vcosnos)
|
||||
struct VertProjHandle *ED_vpaint_proj_handle_create(
|
||||
Scene *scene, Object *ob,
|
||||
DMCoNo **r_vcosnos)
|
||||
{
|
||||
struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__);
|
||||
Mesh *me = ob->data;
|
||||
|
@ -228,8 +234,9 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob,
|
|||
return vp_handle;
|
||||
}
|
||||
|
||||
void ED_vpaint_proj_handle_update(struct VertProjHandle *vp_handle,
|
||||
ARegion *ar, const float mval_fl[2])
|
||||
void ED_vpaint_proj_handle_update(
|
||||
struct VertProjHandle *vp_handle,
|
||||
ARegion *ar, const float mval_fl[2])
|
||||
{
|
||||
if (vp_handle->use_update) {
|
||||
vpaint_proj_dm_map_cosnos_update(vp_handle, ar, mval_fl);
|
||||
|
|
Loading…
Reference in New Issue