diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-17 16:32:13 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-17 16:32:13 +0400 |
commit | 1465b06fad0f6240c73f8bc9f2295912ff8e8d8f (patch) | |
tree | aedb7f002920b7ec62a8b1de9660c8e35d97ae52 /source/blender/editors | |
parent | dac761057d16e264a74162ba625bdb3c6cf07fb4 (diff) |
code cleanup:
- pass wire color to camera draw_viewport_object_reconstruction() rather then getting the theme color directly.
this makes a change where selection color wont be used for unselected cameras (which IMHO is better, drawing selected wire color on nonselected cameras was confusing).
- use rgb_uchar_to_float()
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_view.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 64 |
3 files changed, 36 insertions, 40 deletions
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 30480bd095f..9e16f984e09 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1985,9 +1985,7 @@ int ED_space_image_color_sample(SpaceImage *sima, ARegion *ar, int mval[2], floa } else if (ibuf->rect) { cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); - r_col[0] = cp[0] / 255.0f; - r_col[1] = cp[1] / 255.0f; - r_col[2] = cp[2] / 255.0f; + rgb_uchar_to_float(r_col, cp); ret = TRUE; } } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index e0cbbd697d7..79ca10fd7b4 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -375,7 +375,7 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { float *fp; - char *cp; + unsigned char *cp; int x = (int)(fx * ibuf->x), y = (int)(fy * ibuf->y); CLAMP(x, 0, ibuf->x - 1); @@ -393,10 +393,8 @@ int ED_space_node_color_sample(SpaceNode *snode, ARegion *ar, int mval[2], float ret = TRUE; } else if (ibuf->rect) { - cp = (char *)(ibuf->rect + y * ibuf->x + x); - r_col[0] = cp[0] / 255.0f; - r_col[1] = cp[1] / 255.0f; - r_col[2] = cp[2] / 255.0f; + cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); + rgb_uchar_to_float(r_col, cp); ret = TRUE; } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index d9a57cadb2c..a1a7bda4800 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -195,10 +195,9 @@ static void draw_empty_cone(float size); static void ob_wire_color_blend_theme_id(const unsigned char ob_wire_col[4], const int theme_id, float fac) { - float col_bg[3], col[3]; - float col_wire[3] = {ob_wire_col[0] / 255.0f, - ob_wire_col[1] / 255.0f, - ob_wire_col[2] / 255.0f}; + float col_wire[3], col_bg[3], col[3]; + + rgb_uchar_to_float(col_wire, ob_wire_col); UI_GetThemeColor3fv(theme_id, col_bg); interp_v3_v3v3(col, col_bg, col_wire, fac); @@ -1573,17 +1572,18 @@ static void draw_bundle_sphere(void) static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, MovieTrackingObject *tracking_object, - const short dflag, int *global_track_index, int draw_selected) + const short dflag, const unsigned char ob_wire_col[4], + int *global_track_index, int draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; float mat[4][4], imat[4][4]; - unsigned char col[4], scol[4]; + unsigned char col_unsel[4], col_sel[4]; int tracknr = *global_track_index; ListBase *tracksbase = BKE_tracking_object_get_tracks(tracking, tracking_object); - UI_GetThemeColor4ubv(TH_TEXT, col); - UI_GetThemeColor4ubv(TH_SELECT, scol); + UI_GetThemeColor4ubv(TH_TEXT, col_unsel); + UI_GetThemeColor4ubv(TH_SELECT, col_sel); BKE_tracking_get_camera_object_matrix(scene, base->object, mat); @@ -1626,13 +1626,13 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->drawtype == OB_WIRE) { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } + else { + glColor3fv(track->color); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1643,8 +1643,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if (v3d->bundle_drawtype == OB_EMPTY_SPHERE) { /* selection outline */ if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + glColor3ubv(ob_wire_col); + } glLineWidth(2.f); glDisable(GL_LIGHTING); @@ -1657,21 +1658,24 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D glLineWidth(1.f); } - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_BUNDLE_SOLID); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_BUNDLE_SOLID); + } draw_bundle_sphere(); } else { glDisable(GL_LIGHTING); - if (selected) { - if (base == BASACT) UI_ThemeColor(TH_ACTIVE); - else UI_ThemeColor(TH_SELECT); - } - else { - if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); - else UI_ThemeColor(TH_WIRE); + if ((dflag & DRAW_CONSTCOLOR) == 0) { + if (selected) { + glColor3ubv(ob_wire_col); + } + else { + if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color); + else UI_ThemeColor(TH_WIRE); + } } drawaxes(0.05f, v3d->bundle_drawtype); @@ -1684,13 +1688,9 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D if ((dflag & DRAW_PICKING) == 0 && (v3d->flag2 & V3D_SHOW_BUNDLENAME)) { float pos[3]; - unsigned char tcol[4]; - - if (selected) memcpy(tcol, scol, sizeof(tcol)); - else memcpy(tcol, col, sizeof(tcol)); mul_v3_m4v3(pos, mat, track->bundle_pos); - view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, tcol); + view3d_cached_text_draw_add(pos, track->name, 10, V3D_CACHE_TEXT_GLOBALSPACE, selected ? col_sel : col_unsel); } tracknr++; @@ -1748,7 +1748,7 @@ static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, tracking_object = tracking->objects.first; while (tracking_object) { draw_viewport_object_reconstruction(scene, base, v3d, clip, tracking_object, - dflag, &global_track_index, draw_selected); + dflag, ob_wire_col, &global_track_index, draw_selected); tracking_object = tracking_object->next; } |