From 6a9d29d1dbaf8d35243c4aeac4340d9f08c5ec5d Mon Sep 17 00:00:00 2001 From: Robert Wenzlaff Date: Sat, 10 Jan 2004 01:22:07 +0000 Subject: [PATCH] -Changed "Simple" button to pulldown menu or subsurf type. Paves way for additional subsurf types, and avoids confusion where Simple is on, but Subsurf is off. --- source/blender/blenkernel/BKE_subsurf.h | 6 ++++-- source/blender/blenkernel/intern/displist.c | 6 ++++-- source/blender/blenkernel/intern/subsurf.c | 13 ++++++++----- source/blender/makesdna/DNA_mesh_types.h | 8 ++++++-- source/blender/src/buttons_editing.c | 6 ++++-- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 1d65015448a..837ccf01f22 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -37,8 +37,10 @@ struct Displist; struct DispListMesh; struct ListBase; -struct DispListMesh *subsurf_make_dispListMesh_from_editmesh(struct ListBase *verts, struct ListBase *edges, struct ListBase *faces, int subdivLevels, int flags); -struct DispListMesh *subsurf_make_dispListMesh_from_mesh(struct Mesh *me, float *extverts, int subdivLevels, int flags); +struct DispListMesh *subsurf_make_dispListMesh_from_editmesh(struct ListBase *verts, struct ListBase *edges, + struct ListBase *faces, int subdivLevels, int flags, short type); +struct DispListMesh *subsurf_make_dispListMesh_from_mesh(struct Mesh *me, + float *extverts, int subdivLevels, int flags); void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]); diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 51c24d5d469..89183656bcc 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1650,10 +1650,12 @@ void makeDispList(Object *ob) DispListMesh *dlm; if (ob==G.obedit) { - dlm= subsurf_make_dispListMesh_from_editmesh(&G.edve, &G.eded, &G.edvl, me->subdiv, me->flag); + dlm= subsurf_make_dispListMesh_from_editmesh(&G.edve, &G.eded, &G.edvl, + me->subdiv, me->flag, me->subsurftype); } else { DispList *dlVerts= find_displist(&ob->disp, DL_VERTS); - dlm= subsurf_make_dispListMesh_from_mesh(me, dlVerts?dlVerts->verts:NULL, me->subdiv, me->flag); + dlm= subsurf_make_dispListMesh_from_mesh(me, dlVerts?dlVerts->verts:NULL, + me->subdiv, me->flag); } dl= MEM_callocN(sizeof(*dl), "dl"); diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c index 4aab0fb6d8f..96e3c090b69 100644 --- a/source/blender/blenkernel/intern/subsurf.c +++ b/source/blender/blenkernel/intern/subsurf.c @@ -919,7 +919,8 @@ static DispListMesh *hypermesh_to_displistmesh(HyperMesh *hme, short flag) { } /* flag is me->flag, for handles and 'optim' */ -static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short subdiv, short flag) { +static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short subdiv, + short flag, short type) { DispListMesh *dlm; int i; @@ -929,7 +930,7 @@ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short sub tmp->hasuvco= hme->hasuvco; tmp->orig_me= hme->orig_me; - if (flag & ME_SIMPLE_DIV) hypermesh_simple_subdivide(hme, tmp); + if (type & ME_SIMPLE_SUBSURF) hypermesh_simple_subdivide(hme, tmp); else hypermesh_subdivide(hme, tmp); /* default to CC subdiv. */ hypermesh_free(hme); @@ -942,22 +943,24 @@ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short sub return dlm; } -DispListMesh *subsurf_make_dispListMesh_from_editmesh(ListBase *verts, ListBase *edges, ListBase *faces, int subdivLevels, int flags) { +DispListMesh *subsurf_make_dispListMesh_from_editmesh(ListBase *verts, ListBase *edges, + ListBase *faces, int subdivLevels, int flags, short type) { if (subdivLevels<1) { return displistmesh_from_editmesh(verts, edges, faces); } else { HyperMesh *hme= hypermesh_from_editmesh(verts->first, edges->first, faces->first); - return subsurf_subdivide_to_displistmesh(hme, subdivLevels, flags); + return subsurf_subdivide_to_displistmesh(hme, subdivLevels, flags, type); } } + DispListMesh *subsurf_make_dispListMesh_from_mesh(Mesh *me, float *extverts, int subdivLevels, int flags) { if (subdivLevels<1) { return displistmesh_from_mesh(me, extverts); } else { HyperMesh *hme= hypermesh_from_mesh(me, extverts); - return subsurf_subdivide_to_displistmesh(hme, subdivLevels, flags); + return subsurf_subdivide_to_displistmesh(hme, subdivLevels, flags, me->subsurftype); } } diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 71c65d450bf..6a4f5260b58 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -142,7 +142,8 @@ typedef struct Mesh { short smoothresh, flag; short subdiv, subdivr, subdivdone; short totcol; - short reserved1, reserved2; /* Padding */ + short subsurftype; + short reserved1; /* Padding */ float cubemapsize, rtf; @@ -165,7 +166,10 @@ typedef struct Mesh { #define ME_SMESH 64 #define ME_SUBSURF 128 #define ME_OPT_EDGES 256 -#define ME_SIMPLE_DIV 512 + +/* Subsurf Type */ +#define ME_CC_SUBSURF 0 +#define ME_SIMPLE_SUBSURF 1 /* puno = vertexnormal (mface) */ #define ME_FLIPV1 1 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index ee7679a478b..d85fd384165 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -369,6 +369,8 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) { uiBlock *block; float val; + /* Hope to support more than two subsurf algorithms */ + char subsurfmenu[]="Subsurf Type%t|Catmul Clark%x0|Simple Subdiv.%x1"; block= uiNewBlock(&curarea->uiblocks, "editing_panel_mesh_type", UI_EMBOSS, UI_HELV, curarea->win); if( uiNewPanel(curarea, block, "Mesh", "Editing", 320, 0, 318, 204)==0) return; @@ -379,8 +381,8 @@ static void editing_panel_mesh_type(Object *ob, Mesh *me) uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); - uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf", 10,124,90,19, &me->flag, 0, 0, 0, 0, "Treats the active object as a Catmull-Clark Subdivision Surface"); - uiDefButS(block, TOG|BIT|9, B_MAKEDISP, "Simple", 100,124,64,19, &me->flag, 0, 0, 0, 0, "Treats the active object as a Simple Subdivision Surface for Radio/Displacement"); + uiDefButS(block, TOG|BIT|7, B_MAKEDISP, "SubSurf", 10,124,70,19, &me->flag, 0, 0, 0, 0, "Treats the active object as a Subdivision Surface"); + uiDefButS(block, MENU, B_MAKEDISP, subsurfmenu, 80,124,84,19, &(me->subsurftype), 0, 0, 0, 0, "Selects type of Subsurf algorithm."); uiBlockSetCol(block, TH_AUTO); uiDefButS(block, NUM, B_MAKEDISP, "Subdiv:", 10,104,110,19, &me->subdiv, 0, 6, 0, 0, "Defines the level of subdivision to display in real time interactively"); uiDefButS(block, NUM, B_MAKEDISP, "", 120, 104, 44, 19, &me->subdivr, 0, 6, 0, 0, "Defines the level of subdivision to apply during rendering");