diff options
author | Daniel Dunbar <daniel@zuster.org> | 2005-04-04 07:38:21 +0400 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2005-04-04 07:38:21 +0400 |
commit | 0b02d592b8d3c665aceba5c4665326c3fc80aa1c (patch) | |
tree | 2d98ee3560f7b9dd1c9fdf36a30acbeddaa692fd /source/blender/blenkernel | |
parent | 5c85bb9cd21975f01f1447070bea7138ced4d7dc (diff) |
- work-in-progress: subsurf level 0 now just acts like a regular mesh,
before it would follow subsurf code path by creating fake displistmesh,
etc... kinda fun for testing but just annoying now.
- change to creasing behavior, to make sure that with full creasing effect
is just simple subdivision.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_subsurf.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 20 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf.c | 31 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 8 |
6 files changed, 23 insertions, 53 deletions
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 1dddec2da1f..6e2cd74d455 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -39,9 +39,6 @@ struct EditMesh; struct DerivedMesh *subsurf_make_derived_from_editmesh(struct EditMesh *em, int subdivLevels, short type, struct DerivedMesh *oldDerived); struct DerivedMesh *subsurf_make_derived_from_mesh(struct Mesh *me, int subdivLevels); -struct DerivedMesh *subsurf_ccg_make_derived_from_editmesh(struct EditMesh *em, int useFlatSubdiv, int subdivLevels, struct DerivedMesh *oldDerived); -struct DerivedMesh *subsurf_ccg_make_derived_from_mesh(struct Mesh *me, int useFlatSubdiv, int subdivLevels); - void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]); #endif diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 2f6c95414e2..9dd5e7340c4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1131,7 +1131,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { CCGVert *v = effectedV[ptrIdx]; void *co = VERT_getCo(v, curLvl); void *nCo = VERT_getCo(v, nextLvl); - int sharpCount = 0; + int sharpCount = 0, allSharp = 1; float avgSharpness = 0.0; for (i=0; i<v->numEdges; i++) { @@ -1141,6 +1141,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { if (sharpness!=0.0f) { sharpCount++; avgSharpness += sharpness; + } else { + allSharp = 0; } } @@ -1206,7 +1208,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { ss->meshIFC.vertDataMulN(ss->meshData, q, (float) 1/sharpCount); - if (sharpCount!=2) { + if (sharpCount!=2 || allSharp) { // q = q + (co-q)*avgSharpness ss->meshIFC.vertDataCopy(ss->meshData, r, co); ss->meshIFC.vertDataSub(ss->meshData, r, q); @@ -1409,7 +1411,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { CCGVert *v = (CCGVert*) effectedV[ptrIdx]; void *co = VERT_getCo(v, curLvl); void *nCo = VERT_getCo(v, nextLvl); - int sharpCount = 0; + int sharpCount = 0, allSharp = 1; float avgSharpness = 0.0; for (i=0; i<v->numEdges; i++) { @@ -1419,6 +1421,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { if (sharpness!=0.0f) { sharpCount++; avgSharpness += sharpness; + } else { + allSharp = 0; } } @@ -1485,7 +1489,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { ss->meshIFC.vertDataMulN(ss->meshData, q, (float) 1/sharpCount); - if (sharpCount!=2) { + if (sharpCount!=2 || allSharp) { // q = q + (co-q)*avgSharpness ss->meshIFC.vertDataCopy(ss->meshData, r, co); ss->meshIFC.vertDataSub(ss->meshData, r, q); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a0752a241e7..566a6004a07 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -969,7 +969,7 @@ static void build_mesh_data(Object *ob, int inEditMode) if(eff->type==EFF_WAVE) makeDispList(ob); } } - if(mesh_uses_displist(me)) { + if(me->flag&ME_SUBSURF) { if(inEditMode && !G.editMesh->derived) { makeDispList(ob); } else if (!inEditMode && !me->derived) { @@ -986,8 +986,7 @@ DerivedMesh *mesh_get_derived(Object *ob) { Mesh *me= ob->data; - if (mesh_uses_displist(me)) { - + if ((me->flag&ME_SUBSURF) && me->subdiv) { if(G.obedit && me==G.obedit->data) { build_mesh_data(ob, 1); return G.editMesh->derived; @@ -1004,8 +1003,7 @@ DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree) { Mesh *me= ob->data; - if (mesh_uses_displist(me)) { - // XXX, assumes was created earlier... is this for sure? + if ((me->flag&ME_SUBSURF) && me->subdivr) { if (me->subdiv==me->subdivr) { *needsFree = 0; if(G.obedit && me==G.obedit->data) { @@ -1013,13 +1011,13 @@ DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree) } else { return me->derived; } + } + + *needsFree = 1; + if(G.obedit && me==G.obedit->data) { + return subsurf_make_derived_from_editmesh(G.editMesh, me->subdivr, me->subsurftype, NULL); } else { - *needsFree = 1; - if(G.obedit && me==G.obedit->data) { - return subsurf_make_derived_from_editmesh(G.editMesh, me->subdivr, me->subsurftype, NULL); - } else { - return subsurf_make_derived_from_mesh(me, me->subdivr); - } + return subsurf_make_derived_from_mesh(me, me->subdivr); } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a04c39f467d..c9a96f7e116 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1203,7 +1203,7 @@ void mcol_to_tface(Mesh *me, int freedata) } int mesh_uses_displist(Mesh *me) { - return (me->flag&ME_SUBSURF); + return (me->flag&ME_SUBSURF) && me->subdiv; } void mesh_calculate_vertex_normals(Mesh *me) diff --git a/source/blender/blenkernel/intern/subsurf.c b/source/blender/blenkernel/intern/subsurf.c index 60011c084b0..7359555da45 100644 --- a/source/blender/blenkernel/intern/subsurf.c +++ b/source/blender/blenkernel/intern/subsurf.c @@ -1082,37 +1082,6 @@ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short sub return dlm; } -DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, int subdivLevels, short type, DerivedMesh *oldDerived) { - if (subdivLevels<1) { - if (oldDerived) { - oldDerived->release(oldDerived); - } - return derivedmesh_from_displistmesh(em, displistmesh_from_editmesh(em)); - } else if (type==ME_CCG_SUBSURF || type==ME_SIMPLE_SUBSURF) { - return subsurf_ccg_make_derived_from_editmesh(em, type==ME_SIMPLE_SUBSURF, subdivLevels, oldDerived); - } else { - HyperMesh *hme= hypermesh_from_editmesh(em, subdivLevels); - - if (oldDerived) { - oldDerived->release(oldDerived); - } - - return derivedmesh_from_displistmesh(em, subsurf_subdivide_to_displistmesh(hme, subdivLevels, type)); - } -} - -DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels) { - if (subdivLevels<1) { - return derivedmesh_from_displistmesh(NULL, displistmesh_from_mesh(me, NULL)); - } else if (me->subsurftype==ME_CCG_SUBSURF || me->subsurftype==ME_SIMPLE_SUBSURF) { - return subsurf_ccg_make_derived_from_mesh(me, me->subsurftype==ME_SIMPLE_SUBSURF, subdivLevels); - } else { - HyperMesh *hme= hypermesh_from_mesh(me, subdivLevels); - - return derivedmesh_from_displistmesh(NULL, subsurf_subdivide_to_displistmesh(hme, subdivLevels, me->subsurftype)); - } -} - // editarmature.c void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) { diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index ad556082153..61ee4737576 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -988,7 +988,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(SubSurf *ss) { /***/ -DerivedMesh *subsurf_ccg_make_derived_from_editmesh(EditMesh *em, int useFlatSubdiv, int subdivLevels, DerivedMesh *oldDerived) { +DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, int subdivLevels, short type, DerivedMesh *oldDerived) { CCGDerivedMesh *ccgdm; if (oldDerived) { @@ -998,12 +998,13 @@ DerivedMesh *subsurf_ccg_make_derived_from_editmesh(EditMesh *em, int useFlatSub ccgdm = getCCGDerivedMesh(ss); } - subSurf_sync(ccgdm->ss, useFlatSubdiv); + subSurf_sync(ccgdm->ss, type==ME_SIMPLE_SUBSURF); return (DerivedMesh*) ccgdm; } -DerivedMesh *subsurf_ccg_make_derived_from_mesh(Mesh *me, int useFlatSubdiv, int subdivLevels) { +DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels) { + int useFlatSubdiv = me->subsurftype==ME_SIMPLE_SUBSURF; SubSurf *ss = subSurf_fromMesh(me, useFlatSubdiv, subdivLevels); DispListMesh *dlm; @@ -1015,3 +1016,4 @@ DerivedMesh *subsurf_ccg_make_derived_from_mesh(Mesh *me, int useFlatSubdiv, int return derivedmesh_from_displistmesh(NULL, dlm); } + |