[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49949] trunk/blender/source/blender/ editors: code cleanup:
Campbell Barton
ideasman42 at gmail.com
Fri Aug 17 14:32:13 CEST 2012
Revision: 49949
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49949
Author: campbellbarton
Date: 2012-08-17 12:32:13 +0000 (Fri, 17 Aug 2012)
Log Message:
-----------
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()
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_image/image_ops.c
trunk/blender/source/blender/editors/space_node/node_view.c
trunk/blender/source/blender/editors/space_view3d/drawobject.c
Modified: trunk/blender/source/blender/editors/space_image/image_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_image/image_ops.c 2012-08-17 11:35:14 UTC (rev 49948)
+++ trunk/blender/source/blender/editors/space_image/image_ops.c 2012-08-17 12:32:13 UTC (rev 49949)
@@ -1985,9 +1985,7 @@
}
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;
}
}
Modified: trunk/blender/source/blender/editors/space_node/node_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_view.c 2012-08-17 11:35:14 UTC (rev 49948)
+++ trunk/blender/source/blender/editors/space_node/node_view.c 2012-08-17 12:32:13 UTC (rev 49949)
@@ -375,7 +375,7 @@
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 @@
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;
}
}
Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c 2012-08-17 11:35:14 UTC (rev 49948)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c 2012-08-17 12:32:13 UTC (rev 49949)
@@ -195,11 +195,10 @@
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);
glColor3fv(col);
@@ -1573,17 +1572,18 @@
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,14 +1626,14 @@
if (v3d->drawtype == OB_WIRE) {
glDisable(GL_LIGHTING);
- if (selected) {
- if (base == BASACT) UI_ThemeColor(TH_ACTIVE);
- else UI_ThemeColor(TH_SELECT);
+ if ((dflag & DRAW_CONSTCOLOR) == 0) {
+ if (selected && (track->flag & TRACK_CUSTOMCOLOR) == 0) {
+ glColor3ubv(ob_wire_col);
+ }
+ else {
+ glColor3fv(track->color);
+ }
}
- else {
- if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
- else UI_ThemeColor(TH_WIRE);
- }
drawaxes(0.05f, v3d->bundle_drawtype);
@@ -1643,8 +1643,9 @@
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,22 +1658,25 @@
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);
+ 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);
+ }
}
- else {
- if (track->flag & TRACK_CUSTOMCOLOR) glColor3fv(track->color);
- else UI_ThemeColor(TH_WIRE);
- }
drawaxes(0.05f, v3d->bundle_drawtype);
@@ -1684,13 +1688,9 @@
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 @@
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;
}
More information about the Bf-blender-cvs
mailing list