diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-12 10:53:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-12 10:53:47 +0400 |
commit | aedd4af57e5777dd32585560980f4661ec4d491d (patch) | |
tree | 81d7514200d498b01ef621c83052cf5f42aac84f /source/blender/editors | |
parent | 0873cbaed5aea31f3fc8b16dacecb2d332c9b6f5 (diff) |
code cleanup/bugfix uninitialized values
- edgebisect bmesh operator used uninialized beauty field.
- BLI_join_dirfile could read from before the string bounds when passed an empty dir string.
- pransform could use an uninitialized projected coordinate (unlikely but possible)
- RNA_property_path_from_ID_check would compare against an uninitialized pointer when the path wasn't found.
also have bmesh walker use BM_edge_other_vert() utility function.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform.c | 63 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 6 |
2 files changed, 37 insertions, 32 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 7b98a2f0083..4334d323737 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -136,28 +136,28 @@ static void convertViewVec2D(View2D *v2d, float vec[3], int dx, int dy) vec[2]= 0.0f; } -void convertViewVec(TransInfo *t, float vec[3], int dx, int dy) +void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) { if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) { float mval_f[2]; mval_f[0] = dx; mval_f[1] = dy; - ED_view3d_win_to_delta(t->ar, mval_f, vec); + ED_view3d_win_to_delta(t->ar, mval_f, r_vec); } else if(t->spacetype==SPACE_IMAGE) { float aspx, aspy; - convertViewVec2D(t->view, vec, dx, dy); + convertViewVec2D(t->view, r_vec, dx, dy); ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); - vec[0]*= aspx; - vec[1]*= aspy; + r_vec[0] *= aspx; + r_vec[1] *= aspy; } else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { - convertViewVec2D(t->view, vec, dx, dy); + convertViewVec2D(t->view, r_vec, dx, dy); } else if(ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) { - convertViewVec2D(&t->ar->v2d, vec, dx, dy); + convertViewVec2D(&t->ar->v2d, r_vec, dx, dy); } else if(t->spacetype==SPACE_CLIP) { View2D *v2d = t->view; @@ -166,17 +166,17 @@ void convertViewVec(TransInfo *t, float vec[3], int dx, int dy) divx= v2d->mask.xmax-v2d->mask.xmin; divy= v2d->mask.ymax-v2d->mask.ymin; - vec[0]= (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx; - vec[1]= (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy; - vec[2]= 0.0f; + r_vec[0] = (v2d->cur.xmax-v2d->cur.xmin)*(dx)/divx; + r_vec[1] = (v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy; + r_vec[2] = 0.0f; } else { printf("%s: called in an invalid context\n", __func__); - zero_v3(vec); + zero_v3(r_vec); } } -void projectIntView(TransInfo *t, float *vec, int *adr) +void projectIntView(TransInfo *t, const float vec[3], int adr[2]) { if (t->spacetype==SPACE_VIEW3D) { if(t->ar->regiontype == RGN_TYPE_WINDOW) @@ -229,26 +229,31 @@ void projectIntView(TransInfo *t, float *vec, int *adr) } } -void projectFloatView(TransInfo *t, float *vec, float *adr) +void projectFloatView(TransInfo *t, const float vec[3], float adr[2]) { - if (t->spacetype==SPACE_VIEW3D) { - if(t->ar->regiontype == RGN_TYPE_WINDOW) - project_float_noclip(t->ar, vec, adr); - } - else if(ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { - int a[2]; - - projectIntView(t, vec, a); - adr[0]= a[0]; - adr[1]= a[1]; + switch (t->spacetype) { + case SPACE_VIEW3D: + { + if (t->ar->regiontype == RGN_TYPE_WINDOW) { + project_float_noclip(t->ar, vec, adr); + return; + } + break; + } + case SPACE_IMAGE: + case SPACE_CLIP: + case SPACE_IPO: + case SPACE_NLA: + { + int a[2]; + projectIntView(t, vec, a); + adr[0] = a[0]; + adr[1] = a[1]; + return; + } } - else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { - int a[2]; - projectIntView(t, vec, a); - adr[0]= a[0]; - adr[1]= a[1]; - } + zero_v2(adr); } void applyAspectRatio(TransInfo *t, float *vec) diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 48c05f00ea8..0bef33149d7 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -444,9 +444,9 @@ void transformApply(struct bContext *C, TransInfo *t); int transformEnd(struct bContext *C, TransInfo *t); void setTransformViewMatrices(TransInfo *t); -void convertViewVec(TransInfo *t, float *vec, int dx, int dy); -void projectIntView(TransInfo *t, float *vec, int *adr); -void projectFloatView(TransInfo *t, float *vec, float *adr); +void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy); +void projectIntView(TransInfo *t, const float vec[3], int adr[2]); +void projectFloatView(TransInfo *t, const float vec[3], float adr[2]); void applyAspectRatio(TransInfo *t, float *vec); void removeAspectRatio(TransInfo *t, float *vec); |