diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2012-01-17 20:31:13 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2012-01-17 20:31:13 +0400 |
commit | a8081c1d2bb9115833493b011bb93d6c08112b2d (patch) | |
tree | 4383d080b80786257b291068e48a06bdb0ef5bd6 /source/blender/editors/uvedit/uvedit_draw.c | |
parent | fcc54520d1f029b86cb8c6f43c239ef81090a99a (diff) |
Uv Tools branch GSOC 2011
=========================
Documentation: http://wiki.blender.org/index.php/User:Psy-Fi/UV_Tools
Major features include:
*16 bit image support in viewport
*Subsurf aware unwrapping
*Smart Stitch(snap/rotate islands, preview, middlepoint/endpoint stitching)
*Seams from islands tool (marks seams and sharp, depending on settings)
*Uv Sculpting(Grab/Pinch/Rotate)
All tools are complete apart from stitching that is considered stable but with an extra edge mode under development(will be in soc-2011-onion-uv-tools).
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_draw.c')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 110 |
1 files changed, 98 insertions, 12 deletions
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 0da3f66fc6f..6ced91f0d01 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -380,12 +380,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac } } -static void draw_uvs_other(Scene *scene, Object *obedit, MTFace *activetf) +static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage) { Base *base; - Image *curimage; - - curimage= (activetf)? activetf->tpage: NULL; glColor3ub(96, 96, 96); @@ -419,6 +416,34 @@ static void draw_uvs_other(Scene *scene, Object *obedit, MTFace *activetf) } } +static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob) +{ + Mesh *me= ob->data; + Image *curimage = ED_space_image(sima); + + if(sima->flag & SI_DRAW_OTHER) + draw_uvs_other(scene, ob, curimage); + + glColor3ub(112, 112, 112); + + if(me->mtface) { + MFace *mface= me->mface; + MTFace *tface= me->mtface; + int a; + + for(a=me->totface; a>0; a--, tface++, mface++) { + if(tface->tpage == curimage) { + glBegin(GL_LINE_LOOP); + glVertex2fv(tface->uv[0]); + glVertex2fv(tface->uv[1]); + glVertex2fv(tface->uv[2]); + if(mface->v4) glVertex2fv(tface->uv[3]); + glEnd(); + } + } + } +} + /* draws uv's in the image space */ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) { @@ -432,6 +457,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) float pointsize; int drawfaces, interpedges; Image *ima= sima->image; + StitchPreviewer *stitch_preview = uv_get_stitch_previewer(); em= BKE_mesh_get_editmesh(me); activetf= EM_get_active_mtface(em, &efa_act, NULL, 0); /* will be set to NULL if hidden */ @@ -445,8 +471,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) interpedges= (ts->uv_selectmode == UV_SELECT_VERTEX); /* draw other uvs */ - if(sima->flag & SI_DRAW_OTHER) - draw_uvs_other(scene, obedit, activetf); + if(sima->flag & SI_DRAW_OTHER) { + Image *curimage= (activetf)? activetf->tpage: NULL; + + draw_uvs_other(scene, obedit, curimage); + } /* 1. draw shadow mesh */ @@ -522,7 +551,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } - + /* 3. draw active face stippled */ if(activetf) { @@ -831,24 +860,81 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) bglEnd(); } + /* finally draw stitch preview */ + if(stitch_preview) { + glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); + glEnableClientState(GL_VERTEX_ARRAY); + + glEnable(GL_BLEND); + + UI_ThemeColor4(TH_STITCH_PREVIEW_ACTIVE); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->static_tris); + glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris*3); + + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->static_quads); + glDrawArrays(GL_QUADS, 0, stitch_preview->num_static_quads*4); + + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_tris); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + UI_ThemeColor4(TH_STITCH_PREVIEW_FACE); + glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_tris*3); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + UI_ThemeColor4(TH_STITCH_PREVIEW_EDGE); + glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_tris*3); + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + /*UI_ThemeColor4(TH_STITCH_PREVIEW_VERT); + glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_tris*3);*/ + + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_quads); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + UI_ThemeColor4(TH_STITCH_PREVIEW_FACE); + glDrawArrays(GL_QUADS, 0, stitch_preview->num_quads*4); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + UI_ThemeColor4(TH_STITCH_PREVIEW_EDGE); + glDrawArrays(GL_QUADS, 0, stitch_preview->num_quads*4); + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + /*UI_ThemeColor4(TH_STITCH_PREVIEW_VERT); + glDrawArrays(GL_QUADS, 0, stitch_preview->num_quads*4);*/ + + glDisable(GL_BLEND); + + /* draw vert preview */ + glPointSize(pointsize*2.0); + UI_ThemeColor4(TH_STITCH_PREVIEW_STITCHABLE); + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_stitchable); + glDrawArrays(GL_POINTS, 0, stitch_preview->num_stitchable); + + UI_ThemeColor4(TH_STITCH_PREVIEW_UNSTITCHABLE); + glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_unstitchable); + glDrawArrays(GL_POINTS, 0, stitch_preview->num_unstitchable); + + glPopClientAttrib(); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + } + glPointSize(1.0); BKE_mesh_end_editmesh(obedit->data, em); } -void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedit) +void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedit, Object *obact) { - int show_uvedit, show_uvshadow; + ToolSettings *toolsettings = scene->toolsettings; + int show_uvedit, show_uvshadow, show_texpaint_uvshadow; + show_texpaint_uvshadow = (obact && obact->type == OB_MESH && obact->mode == OB_MODE_TEXTURE_PAINT); show_uvedit= ED_space_image_show_uvedit(sima, obedit); show_uvshadow= ED_space_image_show_uvshadow(sima, obedit); - if(show_uvedit || show_uvshadow) { + if(show_uvedit || show_uvshadow || show_texpaint_uvshadow) { if(show_uvshadow) draw_uvs_shadow(obedit); - else + else if(show_uvedit) draw_uvs(sima, scene, obedit); + else + draw_uvs_texpaint(sima, scene, obact); - if(show_uvedit) + if(show_uvedit && !(toolsettings->use_uv_sculpt)) drawcursor_sima(sima, ar); } } |