diff options
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/editors/util/SConscript | 2 | ||||
-rw-r--r-- | source/blender/editors/util/crazyspace.c | 75 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util.c | 8 | ||||
-rw-r--r-- | source/blender/editors/util/editmode_undo.c | 22 |
5 files changed, 81 insertions, 28 deletions
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index 7a6ccdff08f..e56d5802e1f 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -23,6 +23,7 @@ set(INC ../../blenkernel ../../blenlib ../../blenloader + ../../bmesh ../../makesdna ../../makesrna ../../windowmanager @@ -75,6 +76,7 @@ set(SRC ../include/ED_sound.h ../include/ED_space_api.h ../include/ED_text.h + ../include/ED_toolmode.h ../include/ED_transform.h ../include/ED_types.h ../include/ED_util.h diff --git a/source/blender/editors/util/SConscript b/source/blender/editors/util/SConscript index cfbc735eb5c..16501c59551 100644 --- a/source/blender/editors/util/SConscript +++ b/source/blender/editors/util/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' -incs += ' ../../makesrna' +incs += ' ../../makesrna ../../bmesh' incs += ' ../../blenloader' env.BlenderLib ( 'bf_editors_util', sources, Split(incs), [], libtype=['core','player'], priority=[330,210] ) diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 9ee4a875e24..26db6ff32ac 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -41,6 +41,7 @@ #include "BKE_modifier.h" #include "BKE_multires.h" #include "BKE_mesh.h" +#include "BKE_tessmesh.h" #include "BLI_utildefines.h" #include "BLI_math.h" @@ -106,18 +107,18 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) Mesh *me= obedit->data; DerivedMesh *dm; float *vertexcos; - int nverts= me->edit_mesh->totvert; + int nverts= me->edit_btmesh->bm->totvert; short *flags; MappedUserData userData; /* disable subsurf temporal, get mapped cos, and enable it */ if(modifiers_disable_subsurf_temporary(obedit)) { /* need to make new derivemesh */ - makeDerivedMesh(scene, obedit, me->edit_mesh, CD_MASK_BAREMESH); + makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, 0); } /* now get the cage */ - dm= editmesh_get_derived_cage(scene, obedit, me->edit_mesh, CD_MASK_BAREMESH); + dm= editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH); vertexcos= MEM_callocN(3*sizeof(float)*nverts, "vertexcos map"); flags= MEM_callocN(sizeof(short)*nverts, "vertexcos flags"); @@ -136,10 +137,59 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) return vertexcos; } -void crazyspace_set_quats_editmesh(EditMesh *em, float *origcos, float *mappedcos, float *quats) +void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mappedcos, float *quats) { - EditVert *eve, *prev; - EditFace *efa; + BMVert *v; + BMIter iter, liter; + BMLoop *l; + float *v1, *v2, *v3, *co1, *co2, *co3; + int *vert_table = MEM_callocN(sizeof(int)*em->bm->totvert, "vert_table"); + int index = 0; + + BM_ElemIndex_Ensure(em->bm, BM_VERT); + + BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { + if (!BM_TestHFlag(v, BM_SELECT) || BM_TestHFlag(v, BM_HIDDEN)) + continue; + + BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_VERT, v) { + BMLoop *l2 = BM_OtherFaceLoop(l->e, l->f, v); + + /* retrieve mapped coordinates */ + v1= mappedcos + 3*BM_GetIndex(l->v); + v2= mappedcos + 3*BM_GetIndex(BM_OtherEdgeVert(l2->e, l->v)); + v3= mappedcos + 3*BM_GetIndex(BM_OtherEdgeVert(l->e, l->v)); + + co1= (origcos)? origcos + 3*BM_GetIndex(l->v) : l->v->co; + co2= (origcos)? origcos + 3*BM_GetIndex(BM_OtherEdgeVert(l2->e, l->v)) : BM_OtherEdgeVert(l2->e, l->v)->co; + co3= (origcos)? origcos + 3*BM_GetIndex(BM_OtherEdgeVert(l->e, l->v)) : BM_OtherEdgeVert(l->e, l->v)->co; + + set_crazy_vertex_quat(quats, v1, v2, v3, co1, co2, co3); + quats+= 4; + + vert_table[BM_GetIndex(l->v)] = index+1; + + index++; + break; /*just do one corner*/ + } + } + + index = 0; + BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { + if (vert_table[index] != 0) + BM_SetIndex(v, vert_table[index]-1); /* set_dirty! */ + else + BM_SetIndex(v, -1); /* set_dirty! */ + + index++; + } + em->bm->elem_index_dirty |= BM_VERT; + + MEM_freeN(vert_table); +#if 0 + BMEditVert *eve, *prev; + BMEditFace *efa; + BMIter iter; float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4; intptr_t index= 0; @@ -204,7 +254,7 @@ void crazyspace_set_quats_editmesh(EditMesh *em, float *origcos, float *mappedco /* restore abused prev pointer */ for(prev= NULL, eve= em->verts.first; eve; prev= eve, eve= eve->next) eve->prev= prev; - +#endif } void crazyspace_set_quats_mesh(Mesh *me, float *origcos, float *mappedcos, float *quats) @@ -267,7 +317,8 @@ void crazyspace_set_quats_mesh(Mesh *me, float *origcos, float *mappedcos, float } } -int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) +int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em, + float (**deformmats)[3][3], float (**deformcos)[3]) { ModifierData *md; DerivedMesh *dm; @@ -286,13 +337,13 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f for(i = 0; md && i <= cageIndex; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!editmesh_modifier_is_enabled(scene, md, dm)) + if(!editbmesh_modifier_is_enabled(scene, md, dm)) continue; if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { if(!defmats) { - dm= editmesh_get_derived(em, NULL); - deformedVerts= editmesh_get_vertex_cos(em, &numVerts); + dm= getEditDerivedBMesh(em, ob, NULL); + deformedVerts= editbmesh_get_vertex_cos(em, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); for(a=0; a<numVerts; a++) @@ -307,7 +358,7 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f } for(; md && i <= cageIndex; md = md->next, i++) - if(editmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) + if(editbmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) numleft++; if(dm) diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 1a1022a5c7f..169135478f6 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -107,10 +107,10 @@ void ED_editors_exit(bContext *C) if(ob) { if(ob->type==OB_MESH) { Mesh *me= ob->data; - if(me->edit_mesh) { - free_editMesh(me->edit_mesh); - MEM_freeN(me->edit_mesh); - me->edit_mesh= NULL; + if(me->edit_btmesh) { + EDBM_FreeEditBMesh(me->edit_btmesh); + MEM_freeN(me->edit_btmesh); + me->edit_btmesh= NULL; } } else if(ob->type==OB_ARMATURE) { diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 34dffc11d94..4776cf0af53 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -96,8 +96,8 @@ typedef struct UndoElem { char name[MAXUNDONAME]; void * (*getdata)(bContext *C); void (*freedata)(void *); - void (*to_editmode)(void *, void *); - void * (*from_editmode)(void *); + void (*to_editmode)(void *, void *, void *); + void * (*from_editmode)(void *, void *); int (*validate_undo)(void *, void *); } UndoElem; @@ -107,10 +107,10 @@ static UndoElem *curundo= NULL; /* ********************* xtern api calls ************* */ -static void undo_restore(UndoElem *undo, void *editdata) +static void undo_restore(UndoElem *undo, void *editdata, void *obdata) { if(undo) { - undo->to_editmode(undo->undodata, editdata); + undo->to_editmode(undo->undodata, editdata, obdata); } } @@ -118,8 +118,8 @@ static void undo_restore(UndoElem *undo, void *editdata) void undo_editmode_push(bContext *C, const char *name, void * (*getdata)(bContext *C), void (*freedata)(void *), - void (*to_editmode)(void *, void *), - void *(*from_editmode)(void *), + void (*to_editmode)(void *, void *, void *), + void *(*from_editmode)(void *, void *), int (*validate_undo)(void *, void *)) { UndoElem *uel; @@ -168,7 +168,7 @@ void undo_editmode_push(bContext *C, const char *name, /* copy */ memused= MEM_get_memory_in_use(); editdata= getdata(C); - curundo->undodata= curundo->from_editmode(editdata); + curundo->undodata= curundo->from_editmode(editdata, obedit->data); curundo->undosize= MEM_get_memory_in_use() - memused; curundo->ob= obedit; curundo->id= obedit->id; @@ -248,7 +248,7 @@ void undo_editmode_step(bContext *C, int step) undo_clean_stack(C); if(step==0) { - undo_restore(curundo, curundo->getdata(C)); + undo_restore(curundo, curundo->getdata(C), obedit->data); } else if(step==1) { @@ -256,7 +256,7 @@ void undo_editmode_step(bContext *C, int step) else { if(G.f & G_DEBUG) printf("undo %s\n", curundo->name); curundo= curundo->prev; - undo_restore(curundo, curundo->getdata(C)); + undo_restore(curundo, curundo->getdata(C), obedit->data); } } else { @@ -264,7 +264,7 @@ void undo_editmode_step(bContext *C, int step) if(curundo==NULL || curundo->next==NULL) error("No more steps to redo"); else { - undo_restore(curundo->next, curundo->getdata(C)); + undo_restore(curundo->next, curundo->getdata(C), obedit->data); curundo= curundo->next; if(G.f & G_DEBUG) printf("redo %s\n", curundo->name); } @@ -272,7 +272,7 @@ void undo_editmode_step(bContext *C, int step) /* special case for editmesh, mode must be copied back to the scene */ if(obedit->type == OB_MESH) { - EM_selectmode_to_scene(CTX_data_scene(C), obedit); + EDBM_selectmode_to_scene(C); } DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); |