[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47528] trunk/blender/source/blender: pass the object wire color along to drawing functions, too many places would use glGetFloatv(GL_CURRENT_COLOR, curcol), which also become confusing to debug if in some cases the color was set beforehand .
Campbell Barton
ideasman42 at gmail.com
Wed Jun 6 20:00:21 CEST 2012
Revision: 47528
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47528
Author: campbellbarton
Date: 2012-06-06 18:00:08 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
pass the object wire color along to drawing functions, too many places would use glGetFloatv(GL_CURRENT_COLOR, curcol), which also become confusing to debug if in some cases the color was set beforehand.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/math_color_inline.c
trunk/blender/source/blender/editors/space_view3d/drawarmature.c
trunk/blender/source/blender/editors/space_view3d/drawobject.c
trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
trunk/blender/source/blender/editors/space_view3d/view3d_intern.h
Modified: trunk/blender/source/blender/blenlib/intern/math_color_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_color_inline.c 2012-06-06 17:18:14 UTC (rev 47527)
+++ trunk/blender/source/blender/blenlib/intern/math_color_inline.c 2012-06-06 18:00:08 UTC (rev 47528)
@@ -215,4 +215,11 @@
}
}
+MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
+{
+ r_col[0] = ((pack) >> 0) & 0xFF;
+ r_col[1] = ((pack) >> 8) & 0xFF;
+ r_col[2] = ((pack) >> 16) & 0xFF;
+}
+
#endif /* __MATH_COLOR_INLINE_C__ */
Modified: trunk/blender/source/blender/editors/space_view3d/drawarmature.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawarmature.c 2012-06-06 17:18:14 UTC (rev 47527)
+++ trunk/blender/source/blender/editors/space_view3d/drawarmature.c 2012-06-06 18:00:08 UTC (rev 47528)
@@ -1656,7 +1656,8 @@
}
/* assumes object is Armature with pose */
-static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt,
+static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ int dt, const unsigned char ob_wire_col[4],
const short is_ghost, const short is_outline)
{
RegionView3D *rv3d = ar->regiondata;
@@ -1833,14 +1834,7 @@
else if (arm->flag & ARM_POSEMODE)
set_pchan_colorset(ob, pchan);
else {
- if ((scene->basact) == base) {
- if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_ACTIVE);
- else UI_ThemeColor(TH_WIRE);
- }
- else {
- if (base->flag & (SELECT + BA_WAS_SEL)) UI_ThemeColor(TH_SELECT);
- else UI_ThemeColor(TH_WIRE);
- }
+ glColor3ubv(ob_wire_col);
}
/* catch exception for bone with hidden parent */
@@ -2353,7 +2347,7 @@
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2432,7 +2426,7 @@
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
glDisable(GL_BLEND);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
@@ -2502,7 +2496,7 @@
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
}
@@ -2517,7 +2511,7 @@
if (CFRA != cfrao) {
BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL);
BKE_pose_where_is(scene, ob);
- draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE);
+ draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE);
}
}
}
@@ -2537,8 +2531,11 @@
/* ********************************** Armature Drawing - Main ************************* */
-/* called from drawobject.c, return 1 if nothing was drawn */
-int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline)
+/* called from drawobject.c, return 1 if nothing was drawn
+ * (ob_wire_col == NULL) when drawing ghost */
+int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base,
+ int dt, int flag, const unsigned char ob_wire_col[4],
+ const short is_outline)
{
Object *ob = base->object;
bArmature *arm = ob->data;
@@ -2605,7 +2602,7 @@
}
}
}
- draw_pose_bones(scene, v3d, ar, base, dt, FALSE, is_outline);
+ draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, FALSE, is_outline);
arm->flag &= ~ARM_POSEMODE;
if (ob->mode & OB_MODE_POSE)
Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c 2012-06-06 17:18:14 UTC (rev 47527)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c 2012-06-06 18:00:08 UTC (rev 47528)
@@ -1189,14 +1189,17 @@
glCullFace(GL_BACK);
}
-static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt, int flag)
+static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ int dt, int flag, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
const float pixsize = ED_view3d_pixel_size(rv3d, ob->obmat[3]);
Lamp *la = ob->data;
float vec[3], lvec[3], vvec[3], circrad, x, y, z;
float lampsize;
- float imat[4][4], curcol[4];
+ float imat[4][4];
+
+ unsigned char curcol[4];
unsigned char col[4];
/* cone can't be drawn for duplicated lamps, because duplilist would be freed to */
/* the moment of view3d_draw_transp() call */
@@ -1230,10 +1233,12 @@
copy_v3_v3(vec, ob->obmat[3]);
/* for AA effects */
- glGetFloatv(GL_CURRENT_COLOR, curcol);
- curcol[3] = 0.6;
- glColor4fv(curcol);
-
+ curcol[0] = ob_wire_col[0];
+ curcol[1] = ob_wire_col[1];
+ curcol[2] = ob_wire_col[2];
+ curcol[3] = 154;
+ glColor4ubv(curcol);
+
if (lampsize > 0.0f) {
if (ob->id.us > 1) {
@@ -1249,7 +1254,7 @@
/* restore */
if (ob->id.us > 1)
- glColor4fv(curcol);
+ glColor4ubv(curcol);
/* Outer circle */
circrad = 3.0f * lampsize;
@@ -1482,7 +1487,7 @@
glDisable(GL_BLEND);
/* restore for drawing extra stuff */
- glColor3fv(curcol);
+ glColor3ubv(ob_wire_col);
}
@@ -1516,7 +1521,7 @@
}
#ifdef VIEW3D_CAMERA_BORDER_HACK
-float view3d_camera_border_hack_col[4];
+unsigned char view3d_camera_border_hack_col[3];
short view3d_camera_border_hack_test = FALSE;
#endif
@@ -1701,11 +1706,11 @@
}
static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip,
- int flag, int draw_selected)
+ int flag, const unsigned char ob_wire_col[4],
+ int draw_selected)
{
MovieTracking *tracking = &clip->tracking;
MovieTrackingObject *tracking_object;
- float curcol[4];
int global_track_index = 1;
if ((v3d->flag2 & V3D_SHOW_RECONSTRUCTION) == 0)
@@ -1714,8 +1719,6 @@
if (v3d->flag2 & V3D_RENDER_OVERRIDE)
return;
- glGetFloatv(GL_CURRENT_COLOR, curcol);
-
glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
@@ -1734,14 +1737,15 @@
glDisable(GL_COLOR_MATERIAL);
glDisable(GL_LIGHTING);
- glColor4fv(curcol);
+ glColor3ubv(ob_wire_col);
if (flag & DRAW_PICKING)
glLoadName(base->selcol);
}
/* flag similar to draw_object() */
-static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int flag)
+static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ int flag, const unsigned char ob_wire_col[4])
{
/* a standing up pyramid with (0,0,0) as top */
Camera *cam;
@@ -1755,13 +1759,15 @@
/* draw data for movie clip set as active for scene */
if (clip) {
- draw_viewport_reconstruction(scene, base, v3d, clip, flag, FALSE);
- draw_viewport_reconstruction(scene, base, v3d, clip, flag, TRUE);
+ draw_viewport_reconstruction(scene, base, v3d, clip, flag, ob_wire_col, FALSE);
+ draw_viewport_reconstruction(scene, base, v3d, clip, flag, ob_wire_col, TRUE);
}
#ifdef VIEW3D_CAMERA_BORDER_HACK
if (is_view && !(G.f & G_PICKSEL)) {
- glGetFloatv(GL_CURRENT_COLOR, view3d_camera_border_hack_col);
+ view3d_camera_border_hack_col[0] = ob_wire_col[0];
+ view3d_camera_border_hack_col[1] = ob_wire_col[1];
+ view3d_camera_border_hack_col[2] = ob_wire_col[2];
view3d_camera_border_hack_test = TRUE;
return;
}
@@ -3778,17 +3784,15 @@
return 0;
}
-static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
+static void drawDispListsolid(ListBase *lb, Object *ob,
+ const unsigned char ob_wire_col[4], int use_glsl)
{
DispList *dl;
GPUVertexAttribs gattribs;
- float *data, curcol[4];
+ float *data;
float *ndata;
if (lb == NULL) return;
-
- /* for drawing wire */
- glGetFloatv(GL_CURRENT_COLOR, curcol);
glEnable(GL_LIGHTING);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -3811,7 +3815,7 @@
int nr;
glDisable(GL_LIGHTING);
- glColor3fv(curcol);
+ glColor3ubv(ob_wire_col);
// glVertexPointer(3, GL_FLOAT, 0, dl->verts);
// glDrawArrays(GL_LINE_STRIP, 0, dl->nr);
@@ -3845,7 +3849,7 @@
case DL_SURF:
if (dl->index) {
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
if (dl->rt & CU_SMOOTH) glShadeModel(GL_SMOOTH);
else glShadeModel(GL_FLAT);
@@ -3859,7 +3863,7 @@
break;
case DL_INDEX3:
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
@@ -3879,7 +3883,7 @@
break;
case DL_INDEX4:
- GPU_enable_material(dl->col + 1, (glsl) ? &gattribs : NULL);
+ GPU_enable_material(dl->col + 1, (use_glsl) ? &gattribs : NULL);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, dl->verts);
@@ -3937,7 +3941,8 @@
}
/* returns 1 when nothing was drawn */
-static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, int dt)
+static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+ int dt, const unsigned char ob_wire_col[4])
{
Object *ob = base->object;
ListBase *lb = NULL;
@@ -3985,12 +3990,12 @@
else {
if (draw_glsl_material(scene, ob, v3d, dt)) {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL);
- drawDispListsolid(lb, ob, 1);
+ drawDispListsolid(lb, ob, ob_wire_col, TRUE);
GPU_end_object_materials();
}
else {
GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list