[Bf-blender-cvs] [11dead0] cycles-ptex-06: Add debug drawing code for showing poly vert order
Nicholas Bishop
noreply at git.blender.org
Thu Jan 15 20:12:57 CET 2015
Commit: 11dead00dda4a38cd45466fd0c3e6536e0556be4
Author: Nicholas Bishop
Date: Wed Jan 7 19:14:00 2015 +0100
Branches: cycles-ptex-06
https://developer.blender.org/rB11dead00dda4a38cd45466fd0c3e6536e0556be4
Add debug drawing code for showing poly vert order
===================================================================
M source/blender/editors/space_view3d/drawobject.c
===================================================================
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 55b621d..25b76ba 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -3672,6 +3672,66 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
}
}
+static void dm_draw_vert_order(DerivedMesh *dm)
+{
+ typedef struct {
+ float pos[3], col[3];
+ } VertCol;
+
+ const MVert *verts = dm->getVertArray(dm);
+ const MPoly *polys = dm->getPolyArray(dm);
+ const MLoop *loops = dm->getLoopArray(dm);
+ int a, b;
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+ glPushAttrib(GL_ENABLE_BIT);
+ glShadeModel(GL_SMOOTH);
+ /* TODO(bishop): should probably leave depth on and do an offset
+ * or something */
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_LIGHTING);
+
+ for (a = 0; a < dm->getNumPolys(dm); a++) {
+ const MPoly *p = &polys[a];
+ VertCol *points = MEM_callocN(sizeof(VertCol) * p->totloop, "points");
+
+ float avg[3] = {0, 0, 0};
+ for (b = 0; b < p->totloop; b++) {
+ const MLoop *l = &loops[p->loopstart + b];
+ const MVert *v = &verts[l->v];
+ copy_v3_v3(points[b].pos, v->co);
+ add_v3_v3(avg, v->co);
+
+ /* First line red, else green */
+ if (b <= 1) {
+ points[b].col[0] = 1;
+ points[b].col[1] = 0;
+ } else {
+ points[b].col[0] = 0;
+ points[b].col[1] = 1;
+ }
+ }
+
+ /* Move points in towards center a bit */
+ mul_v3_fl(avg, 1.0f / p->totloop);
+ for (b = 0; b < p->totloop; b++) {
+ interp_v3_v3v3(points[b].pos, points[b].pos, avg, 0.3);
+ }
+
+ glVertexPointer(3, GL_FLOAT, sizeof(VertCol), points);
+ glColorPointer(3, GL_FLOAT, sizeof(VertCol), &points[0].col);
+ glDrawArrays(GL_LINE_STRIP, 0, p->totloop);
+
+ MEM_freeN(points);
+ }
+
+ /* Reset all GL state */
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
+ glPopAttrib();
+}
+
static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base,
const char dt, const unsigned char ob_wire_col[4], const short dflag)
{
@@ -3922,6 +3982,8 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
ED_view3d_polygon_offset(rv3d, 0.0);
}
}
+
+ dm_draw_vert_order(dm);
if (is_obact && BKE_paint_select_vert_test(ob)) {
const int use_depth = (v3d->flag & V3D_ZBUF_SELECT);
More information about the Bf-blender-cvs
mailing list