patch [#29673] Visualize Indices (developer aid)
authorCampbell Barton <ideasman42@gmail.com>
Thu, 22 Dec 2011 05:39:23 +0000 (05:39 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 22 Dec 2011 05:39:23 +0000 (05:39 +0000)
by Howard Trickey (howardt)

release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_mesh_types.h
source/blender/makesrna/intern/rna_mesh.c

index 57bde4eb0ddc3011de7d37b648deb3b92eae71e5..46a569c71d40bef67d77c31181d20bd7e91f56a1 100644 (file)
@@ -2247,6 +2247,8 @@ class VIEW3D_PT_view3d_meshdisplay(Panel):
         col.prop(mesh, "show_extra_edge_length")
         col.prop(mesh, "show_extra_face_angle")
         col.prop(mesh, "show_extra_face_area")
+        if bpy.app.debug:
+          col.prop(mesh, "show_extra_indices")
 
 
 class VIEW3D_PT_view3d_curvedisplay(Panel):
index 3199c00a32aff6f8f711b7218393df64775daf8b..eb6f50b932fa689021ace19456654f5f05cdc316 100644 (file)
@@ -2793,6 +2793,44 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d,
        }
 }
 
+static void draw_em_indices(EditMesh *em)
+{
+       EditEdge *e;
+       EditFace *f;
+       EditVert *v;
+       int i;
+       char val[32];
+       float pos[3];
+       unsigned char col[4];
+
+       /* For now, reuse appropriate theme colors from stats text colors */
+
+       UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
+       for (v = em->verts.first, i = 0; v; v = v->next, i++) {
+               if (v->f & SELECT) {
+                       sprintf(val, "%d", i);
+                       view3d_cached_text_draw_add(v->co, val, 0, V3D_CACHE_TEXT_ASCII, col);
+               }
+       }
+
+       UI_GetThemeColor3ubv(TH_DRAWEXTRA_EDGELEN, col);
+       for (e = em->edges.first, i = 0; e; e = e->next, i++) {
+               if (e->f & SELECT) {
+                       sprintf(val, "%d", i);
+                       mid_v3_v3v3(pos, e->v1->co, e->v2->co);
+                       view3d_cached_text_draw_add(pos, val, 0, V3D_CACHE_TEXT_ASCII, col);
+               }
+       }
+
+       UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col);
+       for (f = em->faces.first, i = 0; f; f = f->next, i++) {
+               if (f->f & SELECT) {
+                       sprintf(val, "%d", i);
+                       view3d_cached_text_draw_add(f->cent, val, 0, V3D_CACHE_TEXT_ASCII, col);
+               }
+       }
+}
+
 static int draw_em_fancy__setFaceOpts(void *UNUSED(userData), int index, int *UNUSED(drawSmooth_r))
 {
        EditFace *efa = EM_get_face_for_index(index);
@@ -2968,6 +3006,11 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
                {
                        draw_em_measure_stats(v3d, rv3d, ob, em, &scene->unit);
                }
+
+               if ((G.f & G_DEBUG) && (me->drawflag & ME_DRAWEXTRA_INDICES) &&
+                   !(v3d->flag2 & V3D_RENDER_OVERRIDE)) {
+                       draw_em_indices(em);
+               }
        }
 
        if(dt>OB_WIRE) {
index 7d57e2c295ce9571dcd2783a931cfb2603b8ec48..f8062aeccc7ffe8a8ab7e7e5a32dda703b584d11 100644 (file)
@@ -162,6 +162,9 @@ typedef struct TFace {
 #define ME_DRAWEXTRA_FACEAREA (1 << 11)
 #define ME_DRAWEXTRA_FACEANG  (1 << 12)
 
+/* debug only option */
+#define ME_DRAWEXTRA_INDICES (1 << 13)
+
 /* old global flags:
 #define G_DRAWEDGES            (1 << 18)
 #define G_DRAWFACES            (1 <<  7)
index 02be3183f2c8d8a484742bd4a37c28f922da74bc..f6e958ab1f5b81df037d58490dc114528788f694 100644 (file)
@@ -2132,6 +2132,11 @@ static void rna_def_mesh(BlenderRNA *brna)
                                 "Display the area of selected faces, using global values when set in the transform panel");
        RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
 
+       prop= RNA_def_property(srna, "show_extra_indices", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_INDICES);
+       RNA_def_property_ui_text(prop, "Indices", "Displays the index numbers of selected vertices, edges, and faces");
+       RNA_def_property_update(prop, 0, "rna_Mesh_update_draw");
+
        /* editflag */
        prop= RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "editflag", ME_EDIT_MIRROR_X);