code cleanup:

- move recursive bone/parent check into ED_armature.h
- remove unused vars
- use const for paint vector args.
This commit is contained in:
Campbell Barton
2013-03-11 16:23:33 +00:00
parent 1672ac25ca
commit e6dcf9504e
8 changed files with 43 additions and 33 deletions

View File

@@ -3128,9 +3128,8 @@ KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name
bool BKE_object_is_child_recursive(Object *ob_parent, Object *ob_child)
{
Object *ob_test;
for (ob_test = ob_child->parent; ob_test; ob_test = ob_test->parent) {
if (ob_test == ob_parent) {
for (ob_child = ob_child->parent; ob_child; ob_child = ob_child->parent) {
if (ob_child == ob_parent) {
return true;
}
}

View File

@@ -147,6 +147,15 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
bone_free(arm, exBone);
}
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child)
{
for (ebone_child = ebone_child->parent; ebone_child; ebone_child = ebone_child->parent) {
if (ebone_child == ebone_parent)
return true;
}
return false;
}
/* *************************************************************** */
/* Mirroring */

View File

@@ -135,6 +135,7 @@ void ED_armature_validate_active(struct bArmature *arm);
void add_primitive_bone(struct Scene *scene, struct View3D *v3d, struct RegionView3D *rv3d);
struct EditBone *ED_armature_edit_bone_add(struct bArmature *arm, const char *name);
void ED_armature_edit_bone_remove(struct bArmature *arm, EditBone *exBone);
bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebone_child);
void transform_armature_mirror_update(struct Object *obedit);
void ED_armature_origin_set(struct Scene *scene, struct Object *ob, float cursor[3], int centermode, int around);

View File

@@ -720,7 +720,8 @@ int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int era
painter->firsttouch = 0;
copy_v2_v2(painter->lastpaintpos, newuv);
} else {
}
else {
copy_v2_v2(painter->lastpaintpos, olduv);
}
/* OCIO_TODO: float buffers are now always linear, so always use color correction

View File

@@ -450,7 +450,7 @@ static float VecZDepthPersp(const float pt[2],
/* Return the top-most face index that the screen space coord 'pt' touches (or -1) */
static int project_paint_PickFace(const ProjPaintState *ps, float pt[2], float w[3], int *side)
static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], float w[3], int *side)
{
LinkNode *node;
float w_tmp[3];
@@ -526,7 +526,8 @@ static void uvco_to_wrapped_pxco(float uv[2], int ibuf_x, int ibuf_y, float *x,
}
/* Set the top-most face color that the screen space coord 'pt' touches (or return 0 if none touch) */
static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float *rgba_fp, unsigned char *rgba, const int interp)
static int project_paint_PickColor(const ProjPaintState *ps, const float pt[2],
float *rgba_fp, unsigned char *rgba, const int interp)
{
float w[3], uv[2];
int side;
@@ -951,7 +952,8 @@ static int check_seam(const ProjPaintState *ps, const int orig_face, const int o
/* Calculate outset UV's, this is not the same as simply scaling the UVs,
* since the outset coords are a margin that keep an even distance from the original UV's,
* note that the image aspect is taken into account */
static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const float scaler, const int ibuf_x, const int ibuf_y, const int is_quad)
static void uv_image_outset(float (*orig_uv)[2], float (*outset_uv)[2], const float scaler,
const int ibuf_x, const int ibuf_y, const int is_quad)
{
float a1, a2, a3, a4 = 0.0f;
float puv[4][2]; /* pixelspace uv's */
@@ -1132,7 +1134,8 @@ static void screen_px_from_persp(
interp_v3_v3v3v3(pixelScreenCo, v1co, v2co, v3co, w);
}
static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3], int side, unsigned char rgba_ub[4], float rgba_f[4])
static void project_face_pixel(const MTFace *tf_other, ImBuf *ibuf_other, const float w[3],
int side, unsigned char rgba_ub[4], float rgba_f[4])
{
float *uvCo1, *uvCo2, *uvCo3;
float uv_other[2], x, y;
@@ -3231,7 +3234,7 @@ static void project_paint_begin(ProjPaintState *ps)
BLI_linklist_free(image_LinkList, NULL);
}
static void paint_proj_begin_clone(ProjPaintState *ps, int mouse[2])
static void paint_proj_begin_clone(ProjPaintState *ps, const int mouse[2])
{
/* setup clone offset */
if (ps->tool == PAINT_TOOL_CLONE) {
@@ -3612,7 +3615,8 @@ static void do_projectpaint_clone_f(ProjPaintState *ps, ProjPixel *projPixel, fl
* accumulation of color greater then 'projPixel->mask' however in the case of smear its not
* really that important to be correct as it is with clone and painting
*/
static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *smearArena, LinkNode **smearPixels, float co[2])
static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask,
MemArena *smearArena, LinkNode **smearPixels, const float co[2])
{
unsigned char rgba_ub[4];
@@ -3623,7 +3627,8 @@ static void do_projectpaint_smear(ProjPaintState *ps, ProjPixel *projPixel, floa
BLI_linklist_prepend_arena(smearPixels, (void *)projPixel, smearArena);
}
static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *smearArena, LinkNode **smearPixels_f, float co[2])
static void do_projectpaint_smear_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask,
MemArena *smearArena, LinkNode **smearPixels_f, const float co[2])
{
float rgba[4];
@@ -3644,7 +3649,8 @@ static float inv_pow2(float f)
return 1.0f - f;
}
static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask,
MemArena *softenArena, LinkNode **softenPixels)
{
unsigned int accum_tot = 0;
unsigned int i;
@@ -3676,7 +3682,8 @@ static void do_projectpaint_soften_f(ProjPaintState *ps, ProjPixel *projPixel, f
}
}
static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask, MemArena *softenArena, LinkNode **softenPixels)
static void do_projectpaint_soften(ProjPaintState *ps, ProjPixel *projPixel, float alpha, float mask,
MemArena *softenArena, LinkNode **softenPixels)
{
unsigned int accum_tot = 0;
unsigned int i;
@@ -4209,7 +4216,8 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps)
return;
}
void *paint_proj_new_stroke(bContext *C, Object *ob, int mouse[2]) {
void *paint_proj_new_stroke(bContext *C, Object *ob, const int mouse[2])
{
ProjPaintState *ps = MEM_callocN(sizeof(ProjPaintState), "ProjectionPaintState");
project_state_init(C, ob, ps);

View File

@@ -131,7 +131,7 @@ void *paint_2d_new_stroke(struct bContext *, struct wmOperator *);
void paint_2d_redraw(const bContext *C, void *ps, int final);
void paint_2d_stroke_done(void *ps);
int paint_2d_stroke(void *ps, const int prev_mval[2], const int mval[2], int eraser);
void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, int mouse[2]);
void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const int mouse[2]);
int paint_proj_stroke(void *ps, const int prevmval_i[2], const int mval_i[2]);
void paint_proj_stroke_done(void *ps);
void paint_brush_init_tex(struct Brush *brush);

View File

@@ -160,32 +160,24 @@ static void do_outliner_object_select_recursive(Scene *scene, Object *ob_parent,
}
}
static void do_outliner_bone_select_recursive(Scene *scene, bArmature *arm, Bone *bone_parent, bool select)
static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, bool select)
{
Bone *bone;
for (bone = bone_parent->childbase.first; bone; bone = bone->next) {
if(select && PBONE_VISIBLE(arm, bone))
if (select && PBONE_VISIBLE(arm, bone))
bone->flag |= BONE_SELECTED;
else
bone->flag &= ~BONE_SELECTED;
do_outliner_bone_select_recursive(scene, arm, bone, select);
do_outliner_bone_select_recursive(arm, bone, select);
}
}
static bool is_child_of(EditBone *ebone, EditBone *ebone_parent) {
for (ebone = ebone->parent; ebone; ebone=ebone->parent) {
if (ebone == ebone_parent)
return true;
}
return false;
}
static void do_outliner_ebone_select_recursive(Scene *scene, bArmature *arm, EditBone *ebone_parent, bool select)
static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_parent, bool select)
{
EditBone *ebone;
for (ebone = ebone_parent->next; ebone; ebone=ebone->next) {
if (is_child_of(ebone, ebone_parent)) {
if(select && EBONE_VISIBLE(arm, ebone))
for (ebone = ebone_parent->next; ebone; ebone = ebone->next) {
if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) {
if (select && EBONE_VISIBLE(arm, ebone))
ebone->flag |= BONE_SELECTED;
else
ebone->flag &= ~BONE_SELECTED;
@@ -514,7 +506,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
if (recursive) {
/* Recursive select/deselect */
do_outliner_bone_select_recursive(scene, arm, bone, (bone->flag & BONE_SELECTED) != 0);
do_outliner_bone_select_recursive(arm, bone, (bone->flag & BONE_SELECTED) != 0);
}
@@ -578,7 +570,7 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te,
if (recursive) {
/* Recursive select/deselect */
do_outliner_ebone_select_recursive(scene, arm, ebone, (ebone->flag & BONE_SELECTED) != 0);
do_outliner_ebone_select_recursive(arm, ebone, (ebone->flag & BONE_SELECTED) != 0);
}
}
else if (ebone->flag & BONE_SELECTED) {

View File

@@ -584,7 +584,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li
/* **************************************** */
enum {
OL_OP_ENDMARKER =0,
OL_OP_ENDMARKER = 0,
OL_OP_SELECT,
OL_OP_DESELECT,
OL_OP_SELECT_HIERARCHY,