Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/object/object_hook.c')
-rw-r--r--source/blender/editors/object/object_hook.c102
1 files changed, 54 insertions, 48 deletions
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index e8637b57724..b3f62f3fc0f 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -54,23 +54,26 @@
#include "object_intern.h"
-static int return_editmesh_indexar(BMEditMesh *em, int *r_tot, int **r_indexar, float r_cent[3])
+static int return_editmesh_indexar(BMEditMesh *em,
+ int *r_indexar_num,
+ int **r_indexar,
+ float r_cent[3])
{
BMVert *eve;
BMIter iter;
- int *index, nr, totvert = 0;
+ int *index, nr, indexar_num = 0;
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
- totvert++;
+ indexar_num++;
}
}
- if (totvert == 0) {
+ if (indexar_num == 0) {
return 0;
}
- *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
- *r_tot = totvert;
+ *r_indexar = index = MEM_mallocN(4 * indexar_num, "hook indexar");
+ *r_indexar_num = indexar_num;
nr = 0;
zero_v3(r_cent);
@@ -83,9 +86,9 @@ static int return_editmesh_indexar(BMEditMesh *em, int *r_tot, int **r_indexar,
nr++;
}
- mul_v3_fl(r_cent, 1.0f / (float)totvert);
+ mul_v3_fl(r_cent, 1.0f / (float)indexar_num);
- return totvert;
+ return indexar_num;
}
static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, float r_cent[3])
@@ -97,7 +100,7 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name,
if (cd_dvert_offset != -1) {
const int defgrp_index = active_index - 1;
- int totvert = 0;
+ int indexar_num = 0;
MDeformVert *dvert;
BMVert *eve;
@@ -109,14 +112,14 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name,
if (BKE_defvert_find_weight(dvert, defgrp_index) > 0.0f) {
add_v3_v3(r_cent, eve->co);
- totvert++;
+ indexar_num++;
}
}
- if (totvert) {
+ if (indexar_num) {
const ListBase *defbase = BKE_object_defgroup_list(obedit);
bDeformGroup *dg = BLI_findlink(defbase, defgrp_index);
BLI_strncpy(r_name, dg->name, sizeof(dg->name));
- mul_v3_fl(r_cent, 1.0f / (float)totvert);
+ mul_v3_fl(r_cent, 1.0f / (float)indexar_num);
return true;
}
}
@@ -139,7 +142,7 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (nr == hmd->indexar[index]) {
BM_vert_select_set(em->bm, eve, true);
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
@@ -151,12 +154,12 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd)
}
static int return_editlattice_indexar(Lattice *editlatt,
- int *r_tot,
int **r_indexar,
+ int *r_indexar_num,
float r_cent[3])
{
BPoint *bp;
- int *index, nr, totvert = 0, a;
+ int *index, nr, indexar_num = 0, a;
/* count */
a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw;
@@ -164,18 +167,18 @@ static int return_editlattice_indexar(Lattice *editlatt,
while (a--) {
if (bp->f1 & SELECT) {
if (bp->hide == 0) {
- totvert++;
+ indexar_num++;
}
}
bp++;
}
- if (totvert == 0) {
+ if (indexar_num == 0) {
return 0;
}
- *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar");
- *r_tot = totvert;
+ *r_indexar = index = MEM_mallocN(4 * indexar_num, "hook indexar");
+ *r_indexar_num = indexar_num;
nr = 0;
zero_v3(r_cent);
@@ -193,9 +196,9 @@ static int return_editlattice_indexar(Lattice *editlatt,
nr++;
}
- mul_v3_fl(r_cent, 1.0f / (float)totvert);
+ mul_v3_fl(r_cent, 1.0f / (float)indexar_num);
- return totvert;
+ return indexar_num;
}
static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
@@ -211,7 +214,7 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (hmd->indexar[index] == nr) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
@@ -220,12 +223,15 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd)
}
}
-static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar, float r_cent[3])
+static int return_editcurve_indexar(Object *obedit,
+ int **r_indexar,
+ int *r_indexar_num,
+ float r_cent[3])
{
ListBase *editnurb = object_editcurve_get(obedit);
BPoint *bp;
BezTriple *bezt;
- int *index, a, nr, totvert = 0;
+ int *index, a, nr, indexar_num = 0;
LISTBASE_FOREACH (Nurb *, nu, editnurb) {
if (nu->type == CU_BEZIER) {
@@ -233,13 +239,13 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
a = nu->pntsu;
while (a--) {
if (bezt->f1 & SELECT) {
- totvert++;
+ indexar_num++;
}
if (bezt->f2 & SELECT) {
- totvert++;
+ indexar_num++;
}
if (bezt->f3 & SELECT) {
- totvert++;
+ indexar_num++;
}
bezt++;
}
@@ -249,18 +255,18 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
a = nu->pntsu * nu->pntsv;
while (a--) {
if (bp->f1 & SELECT) {
- totvert++;
+ indexar_num++;
}
bp++;
}
}
}
- if (totvert == 0) {
+ if (indexar_num == 0) {
return 0;
}
- *r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar");
- *r_tot = totvert;
+ *r_indexar = index = MEM_mallocN(sizeof(*index) * indexar_num, "hook indexar");
+ *r_indexar_num = indexar_num;
nr = 0;
zero_v3(r_cent);
@@ -305,21 +311,21 @@ static int return_editcurve_indexar(Object *obedit, int *r_tot, int **r_indexar,
}
}
- mul_v3_fl(r_cent, 1.0f / (float)totvert);
+ mul_v3_fl(r_cent, 1.0f / (float)indexar_num);
- return totvert;
+ return indexar_num;
}
static bool object_hook_index_array(Main *bmain,
Scene *scene,
Object *obedit,
- int *r_tot,
int **r_indexar,
+ int *r_indexar_num,
char *r_name,
float r_cent[3])
{
*r_indexar = NULL;
- *r_tot = 0;
+ *r_indexar_num = 0;
r_name[0] = 0;
switch (obedit->type) {
@@ -338,7 +344,7 @@ static bool object_hook_index_array(Main *bmain,
BKE_editmesh_looptri_and_normals_calc(em);
/* check selected vertices first */
- if (return_editmesh_indexar(em, r_tot, r_indexar, r_cent) == 0) {
+ if (return_editmesh_indexar(em, r_indexar_num, r_indexar, r_cent) == 0) {
return return_editmesh_vgroup(obedit, em, r_name, r_cent);
}
return true;
@@ -347,10 +353,10 @@ static bool object_hook_index_array(Main *bmain,
case OB_SURF:
ED_curve_editnurb_load(bmain, obedit);
ED_curve_editnurb_make(obedit);
- return return_editcurve_indexar(obedit, r_tot, r_indexar, r_cent);
+ return return_editcurve_indexar(obedit, r_indexar, r_indexar_num, r_cent);
case OB_LATTICE: {
Lattice *lt = obedit->data;
- return return_editlattice_indexar(lt->editlatt->latt, r_tot, r_indexar, r_cent);
+ return return_editlattice_indexar(lt->editlatt->latt, r_indexar, r_indexar_num, r_cent);
}
default:
return false;
@@ -371,21 +377,21 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bezt->f1 |= SELECT;
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f2 |= SELECT;
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
nr++;
if (nr == hmd->indexar[index]) {
bezt->f3 |= SELECT;
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
@@ -400,7 +406,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd)
while (a--) {
if (nr == hmd->indexar[index]) {
bp->f1 |= SELECT;
- if (index < hmd->totindex - 1) {
+ if (index < hmd->indexar_num - 1) {
index++;
}
}
@@ -514,10 +520,10 @@ static int add_hook_object(const bContext *C,
HookModifierData *hmd = NULL;
float cent[3];
float pose_mat[4][4];
- int tot, ok, *indexar;
+ int indexar_num, ok, *indexar;
char name[MAX_NAME];
- ok = object_hook_index_array(bmain, scene, obedit, &tot, &indexar, name, cent);
+ ok = object_hook_index_array(bmain, scene, obedit, &indexar, &indexar_num, name, cent);
if (!ok) {
BKE_report(reports, RPT_ERROR, "Requires selected vertices or active vertex group");
@@ -545,7 +551,7 @@ static int add_hook_object(const bContext *C,
hmd->object = ob;
hmd->indexar = indexar;
copy_v3_v3(hmd->cent, cent);
- hmd->totindex = tot;
+ hmd->indexar_num = indexar_num;
BLI_strncpy(hmd->name, name, sizeof(hmd->name));
unit_m4(pose_mat);
@@ -873,7 +879,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
HookModifierData *hmd = NULL;
float cent[3];
char name[MAX_NAME];
- int *indexar, tot;
+ int *indexar, indexar_num;
object_hook_from_context(C, &ptr, num, &ob, &hmd);
if (hmd == NULL) {
@@ -883,7 +889,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
/* assign functionality */
- if (!object_hook_index_array(bmain, scene, ob, &tot, &indexar, name, cent)) {
+ if (!object_hook_index_array(bmain, scene, ob, &indexar, &indexar_num, name, cent)) {
BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group");
return OPERATOR_CANCELLED;
}
@@ -893,7 +899,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op)
copy_v3_v3(hmd->cent, cent);
hmd->indexar = indexar;
- hmd->totindex = tot;
+ hmd->indexar_num = indexar_num;
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob);