Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/CMakeLists.txt1
-rw-r--r--source/blender/editors/util/SConscript2
-rw-r--r--source/blender/editors/util/crazyspace.c79
-rw-r--r--source/blender/editors/util/ed_util.c16
-rw-r--r--source/blender/editors/util/editmode_undo.c22
5 files changed, 88 insertions, 32 deletions
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index 0be6ccaee2c..511b1ab49e0 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -24,6 +24,7 @@ set(INC
../../blenkernel
../../blenloader
../../blenlib
+ ../../bmesh
../../makesdna
../../makesrna
../../windowmanager
diff --git a/source/blender/editors/util/SConscript b/source/blender/editors/util/SConscript
index a694b211ca4..2d5ee84333b 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'], priority=[130] )
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c
index 9560924941d..1dd24db36ec 100644
--- a/source/blender/editors/util/crazyspace.c
+++ b/source/blender/editors/util/crazyspace.c
@@ -43,6 +43,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"
@@ -108,18 +109,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");
@@ -138,10 +139,63 @@ 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;
+ BMEdge *e;
+ BMLoop *l;
+ float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4;
+ int *vert_table = MEM_callocN(sizeof(int)*em->bm->totvert, "vert_table");
+ int index = 0;
+
+ BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ BMINDEX_SET(v, index);
+ index++;
+ }
+
+ index = 0;
+ 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*BMINDEX_GET(l->v);
+ v2= mappedcos + 3*BMINDEX_GET(BM_OtherEdgeVert(l2->e, l->v));
+ v3= mappedcos + 3*BMINDEX_GET(BM_OtherEdgeVert(l->e, l->v));
+
+ co1= (origcos)? origcos + 3*BMINDEX_GET(l->v) : l->v->co;
+ co2= (origcos)? origcos + 3*BMINDEX_GET(BM_OtherEdgeVert(l2->e, l->v)) : BM_OtherEdgeVert(l2->e, l->v)->co;
+ co3= (origcos)? origcos + 3*BMINDEX_GET(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[BMINDEX_GET(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)
+ BMINDEX_SET(v, vert_table[index]-1);
+ else
+ BMINDEX_SET(v, -1);
+
+ index++;
+ }
+
+ 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;
@@ -206,7 +260,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)
@@ -269,7 +323,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;
@@ -288,13 +343,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++)
@@ -309,7 +364,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 705fb83264c..e83138acf46 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -107,16 +107,16 @@ void ED_editors_exit(bContext *C)
Object *ob= sce->obedit;
/* global in meshtools... */
- mesh_octree_table(NULL, NULL, NULL, 'e');
- mesh_mirrtopo_table(NULL, 'e');
+ //BMESH_TODO mesh_octree_table(NULL, NULL, NULL, 'e');
+ //BMESH_TODO mesh_mirrtopo_table(NULL, 'e');
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) {
@@ -136,8 +136,8 @@ void ED_editors_exit(bContext *C)
/* if weight-painting is on, free mesh octree data */
if(ob->mode & OB_MODE_WEIGHT_PAINT) {
- mesh_octree_table(NULL, NULL, NULL, 'e');
- mesh_mirrtopo_table(NULL, 'e');
+ //BMESH_TODO mesh_octree_table(NULL, NULL, NULL, 'e');
+ //BMESH_TODO mesh_mirrtopo_table(NULL, 'e');
}
}
}
diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c
index 732e5087af2..6f4bbff8a0b 100644
--- a/source/blender/editors/util/editmode_undo.c
+++ b/source/blender/editors/util/editmode_undo.c
@@ -98,8 +98,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;
@@ -109,10 +109,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);
}
}
@@ -120,8 +120,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;
@@ -170,7 +170,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;
@@ -250,7 +250,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) {
@@ -258,7 +258,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 {
@@ -266,7 +266,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);
}
@@ -274,7 +274,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(CTX_data_scene(C), obedit);
}
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);