Revision: 40143
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40143
Author:   campbellbarton
Date:     2011-09-12 01:43:20 +0000 (Mon, 12 Sep 2011)
Log Message:
-----------
cleanup for object color theme (no functional changes), could set the opengl 
color 2-3 times per object.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-09-12 00:55:27 UTC (rev 40142)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c      
2011-09-12 01:43:20 UTC (rev 40143)
@@ -5841,46 +5841,68 @@
 
        /* which wire color */
        if((flag & DRAW_CONSTCOLOR) == 0) {
+               /* confusing logic here, there are 2 methods of setting the 
color
+                * 'colortab[colindex]' and 'theme_id', colindex overrides 
theme_id.
+                *
+                * note: no theme yet for 'colindex' */
+               int theme_id= TH_WIRE;
+               int theme_shade= 0;
+
                project_short(ar, ob->obmat[3], &base->sx);
 
-               if( (!scene->obedit) && (G.moving & G_TRANSFORM_OBJ) && 
(base->flag & (SELECT+BA_WAS_SEL))) UI_ThemeColor(TH_TRANSFORM);
+               if(             (scene->obedit == NULL) &&
+                       (G.moving & G_TRANSFORM_OBJ) &&
+                       (base->flag & (SELECT+BA_WAS_SEL)))
+               {
+                       theme_id= TH_TRANSFORM;
+               }
                else {
-
-                       if(ob->type==OB_LAMP) UI_ThemeColor(TH_LAMP);
-                       else if(ob->type==OB_SPEAKER) UI_ThemeColor(TH_SPEAKER);
-                       else UI_ThemeColor(TH_WIRE);
-
-                       if((scene->basact)==base) {
-                               if(base->flag & (SELECT+BA_WAS_SEL)) 
UI_ThemeColor(TH_ACTIVE);
-                       }
-                       else {
-                               if(base->flag & (SELECT+BA_WAS_SEL)) 
UI_ThemeColor(TH_SELECT);
-                       }
-
-                       // no theme yet
+                       /* Sets the 'colindex' */
                        if(ob->id.lib) {
-                               if(base->flag & (SELECT+BA_WAS_SEL)) colindex = 
4;
-                               else colindex = 3;
+                               colindex= (base->flag & (SELECT+BA_WAS_SEL)) ? 
4 : 3;
                        }
                        else if(warning_recursive==1) {
                                if(base->flag & (SELECT+BA_WAS_SEL)) {
-                                       if(scene->basact==base) colindex = 8;
-                                       else colindex= 7;
+                                       colindex= (scene->basact==base) ? 8 : 7;
                                }
-                               else colindex = 6;
+                               else {
+                                       colindex = 6;
+                               }
                        }
-                       else if(ob->flag & OB_FROMGROUP) {
-                               if(base->flag & (SELECT+BA_WAS_SEL)) {
-                                       if(scene->basact==base) 
UI_ThemeColor(TH_GROUP_ACTIVE);
-                                       else 
UI_ThemeColorShade(TH_GROUP_ACTIVE, -16); 
+                       /* Sets the 'theme_id' or fallback to wire */
+                       else {
+                               if(ob->flag & OB_FROMGROUP) {
+                                       if(base->flag & (SELECT+BA_WAS_SEL)) {
+                                               /* uses darker active color for 
non-active + selected*/
+                                               theme_id= TH_GROUP_ACTIVE;
+
+                                               if(scene->basact != base) {
+                                                       theme_shade= -16;
+                                               }
+                                       }
+                                       else {
+                                               theme_id= TH_GROUP;
+                                       }
                                }
-                               else UI_ThemeColor(TH_GROUP);
-                               colindex= 0;
+                               else {
+                                       if(base->flag & (SELECT+BA_WAS_SEL)) {
+                                               theme_id= scene->basact == base 
? TH_ACTIVE : TH_SELECT;
+                                       }
+                                       else {
+                                               if(ob->type==OB_LAMP) theme_id= 
TH_LAMP;
+                                               else if(ob->type==OB_SPEAKER) 
theme_id= TH_SPEAKER;
+                                               /* fallback to TH_WIRE */
+                                       }
+                               }
                        }
+               }
 
-               }       
-
-               if(colindex) {
+               /* finally set the color */
+               if(colindex == 0) {
+                       if(theme_shade == 0) UI_ThemeColor(theme_id);
+                       else                 UI_ThemeColorShade(theme_id, 
theme_shade);
+               }
+               else {
                        col= colortab[colindex];
                        cpack(col);
                }
@@ -5965,7 +5987,6 @@
                                }
 
                                if (cu->linewidth != 0.0f) {
-                                       cpack(0xff44ff);
                                        UI_ThemeColor(TH_WIRE);
                                        copy_v3_v3(vec1, ob->orig);
                                        copy_v3_v3(vec2, ob->orig);
@@ -5984,10 +6005,7 @@
                                setlinestyle(3);
                                for (i=0; i<cu->totbox; i++) {
                                        if (cu->tb[i].w != 0.0f) {
-                                               if (i == (cu->actbox-1))
-                                                       
UI_ThemeColor(TH_ACTIVE);
-                                               else
-                                                       UI_ThemeColor(TH_WIRE);
+                                               UI_ThemeColor(i == 
(cu->actbox-1) ? TH_ACTIVE : TH_WIRE);
                                                vec1[0] = (cu->xof * cu->fsize) 
+ cu->tb[i].x;
                                                vec1[1] = (cu->yof * cu->fsize) 
+ cu->tb[i].y + cu->fsize;
                                                vec1[2] = 0.001;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to