[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11531] branches/soc-2007-maike/source/ blender: Altered mesh outline drawing

Miguel Torres Lima torreslima at gmail.com
Thu Aug 9 18:56:54 CEST 2007


Revision: 11531
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11531
Author:   maike
Date:     2007-08-09 18:56:54 +0200 (Thu, 09 Aug 2007)

Log Message:
-----------
Altered mesh outline drawing
Removed unnecessary set and get color functions
Corrected mesh outline draw bug

Modified Paths:
--------------
    branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h
    branches/soc-2007-maike/source/blender/src/glsl_drawobject.c

Modified: branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h
===================================================================
--- branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h	2007-08-09 16:43:15 UTC (rev 11530)
+++ branches/soc-2007-maike/source/blender/include/BIF_glsl_drawobject.h	2007-08-09 16:56:54 UTC (rev 11531)
@@ -6,6 +6,7 @@
 struct MFace;
 struct MVert;
 struct DispList;
+struct DerivedMesh;
 
 /* ----------------------------------------------------------------------------- */
 
@@ -45,10 +46,5 @@
 void glsl_draw_mball(struct Base *base);
 
 void glsl_draw_dispList(struct Object *ob, struct DispList *dl);
-void glsl_set_outline_colors(void);
-void glsl_draw_outline(struct Object *ob, int flag, struct MFace *face, int num, struct MVert *vert);
 
-float *glsl_get_active_color(void);
-float *glsl_get_selected_color(void);
-
-void glsl_draw_mesh_selected_outline(struct MFace *face, int num, struct MVert *vert);
+void glsl_draw_outline(struct Object *ob, struct DerivedMesh *dm);

Modified: branches/soc-2007-maike/source/blender/src/glsl_drawobject.c
===================================================================
--- branches/soc-2007-maike/source/blender/src/glsl_drawobject.c	2007-08-09 16:43:15 UTC (rev 11530)
+++ branches/soc-2007-maike/source/blender/src/glsl_drawobject.c	2007-08-09 16:56:54 UTC (rev 11531)
@@ -54,10 +54,7 @@
 extern struct Material defmaterial;
 extern GHash *matHash;
 
-static float active_color[4] = { -1, -1, -1 };
-static float selected_color[4] = { -1, -1, -1 };
 
-
 void glsl_runtime_lamp_uniforms(Lamp *lamp, Object *obj, Object *lamp_obj, int num, GLuint program)
 {
   char *loc = glsl_string(3, 0, "lights[", GINT, num, 0, "].loc");
@@ -352,12 +349,10 @@
   int i;
   Material *oldmat = NULL;
   GLSL_Program program = NULL;
+  
 
+  glsl_draw_outline(ob, dm);
 
-  if(ob == OBACT ||  (flag & (SELECT+BA_WAS_SEL)))
-    glsl_draw_outline(ob, base->flag, face, dm->numFaceData, vert);
-
-
   for(i = 0; i < dm->numFaceData; i++, face++, tface++){
     Material *mat = give_current_material(ob, (int) face->mat_nr + 1);
     MCol *tmpcol;
@@ -659,84 +654,28 @@
 }
 
 
-void glsl_set_outline_colors(void)
-{
-  bTheme *bt = U.themes.first;
-  ThemeSpace ts = bt->tv3d;
-  int i;
-  
-  for(i = 0; i < 4; i++){
-    active_color[i] = ts.active[i] / 255.0;
-    selected_color[i] = ts.select[i] / 255.0;
-  }
-}
 
-
-void glsl_draw_outline(Object *ob, int flag, MFace *face, int num, MVert *vert)
+void glsl_draw_outline(Object *ob, DerivedMesh *dm)
 {
-  if(active_color[0] == -1)
-    glsl_set_outline_colors();
-
-  glDepthMask(GL_FALSE);
-  if(ob == OBACT || (flag & (SELECT+BA_WAS_SEL))){
-    if(ob == OBACT)
-      glColor4fv(active_color);
-    else
-      glColor4fv(selected_color);
-
-    glLineWidth(2.0);    
-    glsl_draw_mesh_selected_outline(face, num, vert);
-    glLineWidth(1.0);
-  }
   glDepthMask(GL_TRUE);
-}
 
-
-float *glsl_get_active_color(void)
-{
-  if(active_color[0] == -1)
-    glsl_set_outline_colors();
-
-  return active_color;
-}
-
-
-float *glsl_get_selected_color(void)
-{
-  if(active_color[0] == -1)
-    glsl_set_outline_colors();
-
-  return selected_color;
-}
-
-
-void glsl_draw_mesh_selected_outline(MFace *face, int num, MVert *vert)
-{
-  int i;
-
-  glBegin(GL_LINES);
-
-  for(i = 0; i < num; i++, face++){
-
-    glVertex3fv(vert[face->v1].co);
-    glVertex3fv(vert[face->v2].co);
-
-    glVertex3fv(vert[face->v2].co);
-    glVertex3fv(vert[face->v3].co);
-
-    if(face->v4){   
-      glVertex3fv(vert[face->v3].co);
-      glVertex3fv(vert[face->v4].co);
-
-      glVertex3fv(vert[face->v4].co);
-      glVertex3fv(vert[face->v1].co);
+  if(G.vd->transp==0) {   // not when we draw the transparent pass
+    glLineWidth(2.0);
+    glDepthMask(0);
+    
+    /* if transparent, we cannot draw the edges for solid select... edges have no material info.
+       drawFacesSolid() doesn't draw the transparent faces */
+    if(ob->dtx & OB_DRAWTRANSP) {
+      glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+      dm->drawFacesSolid(dm, set_gl_material);
+      glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
     }
-    else{  
-      glVertex3fv(vert[face->v3].co);
-      glVertex3fv(vert[face->v1].co);
+    else {
+      dm->drawEdges(dm, 0);
     }
-  }
-
-  glEnd();
-  glLineWidth(1.0);
+    
+    glLineWidth(1.0);
+    glDepthMask(1);
+  } 
 }
+





More information about the Bf-blender-cvs mailing list