[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55194] trunk/blender/source/blender: code cleanup:
Campbell Barton
ideasman42 at gmail.com
Mon Mar 11 17:23:33 CET 2013
Revision: 55194
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55194
Author: campbellbarton
Date: 2013-03-11 16:23:33 +0000 (Mon, 11 Mar 2013)
Log Message:
-----------
code cleanup:
- move recursive bone/parent check into ED_armature.h
- remove unused vars
- use const for paint vector args.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/object.c
trunk/blender/source/blender/editors/armature/armature_utils.c
trunk/blender/source/blender/editors/include/ED_armature.h
trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
trunk/blender/source/blender/editors/space_outliner/outliner_select.c
trunk/blender/source/blender/editors/space_outliner/outliner_tools.c
Modified: trunk/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/object.c 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/blenkernel/intern/object.c 2013-03-11 16:23:33 UTC (rev 55194)
@@ -3128,9 +3128,8 @@
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;
}
}
Modified: trunk/blender/source/blender/editors/armature/armature_utils.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_utils.c 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/armature/armature_utils.c 2013-03-11 16:23:33 UTC (rev 55194)
@@ -147,6 +147,15 @@
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 */
Modified: trunk/blender/source/blender/editors/include/ED_armature.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_armature.h 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/include/ED_armature.h 2013-03-11 16:23:33 UTC (rev 55194)
@@ -135,6 +135,7 @@
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);
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_2d.c 2013-03-11 16:23:33 UTC (rev 55194)
@@ -720,7 +720,8 @@
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
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c 2013-03-11 16:23:33 UTC (rev 55194)
@@ -450,7 +450,7 @@
/* 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 @@
}
/* 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 @@
/* 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 @@
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 @@
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 @@
* 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 @@
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 @@
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(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 @@
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);
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h 2013-03-11 16:23:33 UTC (rev 55194)
@@ -131,7 +131,7 @@
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);
Modified: trunk/blender/source/blender/editors/space_outliner/outliner_select.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner_select.c 2013-03-11 16:02:16 UTC (rev 55193)
+++ trunk/blender/source/blender/editors/space_outliner/outliner_select.c 2013-03-11 16:23:33 UTC (rev 55194)
@@ -160,32 +160,24 @@
}
}
-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
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list