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:
authorGeoffrey Bantle <hairbat@yahoo.com>2006-04-03 23:02:22 +0400
committerGeoffrey Bantle <hairbat@yahoo.com>2006-04-03 23:02:22 +0400
commitcc8051eeadc09228fd5176dc145b0bc0caa2f89b (patch)
tree374ee3290094f75651749dc0b274722ec3daa34c
parente9a9caee4c05dd1421cdc59a1ed3b85dfd457a9d (diff)
-> Stored Selections in Mesh DNA
Stored selections now get saved to mesh library blocks as direct data. The idea that stored selections are 'erased' when leaving editmode and switching objects is pretty mysterious for the user. Note that currently the mselect array in a mesh is not written to file. Not sure whether to change this or not.
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/makesdna/DNA_mesh_types.h5
-rw-r--r--source/blender/makesdna/DNA_meshdata_types.h8
-rw-r--r--source/blender/src/editmesh.c60
-rw-r--r--source/blender/src/editmesh_lib.c7
5 files changed, 68 insertions, 13 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2c7386ac45d..aff8c07c990 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2209,6 +2209,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh)
mesh->bb= NULL;
mesh->oc= 0;
mesh->dface= NULL;
+ mesh->mselect= NULL;
if (mesh->tface) {
TFace *tfaces= mesh->tface;
diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h
index e5496c895bc..6f477e963c6 100644
--- a/source/blender/makesdna/DNA_mesh_types.h
+++ b/source/blender/makesdna/DNA_mesh_types.h
@@ -79,11 +79,12 @@ typedef struct Mesh {
struct MCol *mcol;
struct MSticky *msticky;
struct Mesh *texcomesh;
-
+ struct MSelect *mselect;
+
struct OcInfo *oc; /* not written in file */
void *sumohandle;
- int totvert, totedge, totface;
+ int totvert, totedge, totface, totselect, pad2;
int texflag;
float loc[3];
diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h
index 834c206d8e0..691696f1c80 100644
--- a/source/blender/makesdna/DNA_meshdata_types.h
+++ b/source/blender/makesdna/DNA_meshdata_types.h
@@ -71,6 +71,10 @@ typedef struct MSticky {
float co[2];
} MSticky;
+typedef struct MSelect {
+ int index;
+ int type;
+} MSelect;
/* mvert->flag (1=SELECT) */
#define ME_SPHERETEST 2
#define ME_SPHERETEMP 4
@@ -111,3 +115,7 @@ typedef struct MSticky {
#define ME_FACE_STEPINDEX (1<<7)
#endif
+/* mselect->type */
+#define ME_VSEl 0
+#define ME_ESEl 1
+#define ME_FSEL 2
diff --git a/source/blender/src/editmesh.c b/source/blender/src/editmesh.c
index b3c89690bb1..f2766b9574d 100644
--- a/source/blender/src/editmesh.c
+++ b/source/blender/src/editmesh.c
@@ -719,16 +719,20 @@ void make_editMesh()
MFace *mface;
TFace *tface;
MVert *mvert;
+ MSelect *mselect;
KeyBlock *actkey;
EditVert *eve, **evlist, *eve1, *eve2, *eve3, *eve4;
EditFace *efa;
EditEdge *eed;
+ EditSelection *ese;
int tot, a;
/* because of reload */
free_editMesh(G.editMesh);
G.totvert= tot= me->totvert;
+ G.totedge= me->totedge;
+ G.totface= me->totface;
if(tot==0) {
countall();
@@ -848,6 +852,20 @@ void make_editMesh()
end_editmesh_fastmalloc(); // resets global function pointers
+ if(me->mselect){
+ //restore editselections
+ EM_init_index_arrays(1,1,1);
+ mselect = me->mselect;
+ for(a=0; a<me->totselect; a++, mselect++){
+ ese = MEM_callocN(sizeof(EditSelection), "Edit Selection");
+ ese->type = mselect->type;
+ if(ese->type == EDITVERT) ese->data = EM_get_vert_for_index(mselect->index); else
+ if(ese->type == EDITEDGE) ese->data = EM_get_edge_for_index(mselect->index); else
+ if(ese->type == EDITFACE) ese->data = EM_get_face_for_index(mselect->index);
+ BLI_addtail(&(G.editMesh->selected),ese);
+ }
+ EM_free_index_arrays();
+ }
/* this creates coherent selections. also needed for older files */
EM_selectmode_set();
/* paranoia check to enforce hide rules */
@@ -869,9 +887,11 @@ void load_editMesh(void)
MEdge *medge;
MFace *mface;
MSticky *ms;
+ MSelect *mselect;
EditVert *eve;
EditFace *efa;
EditEdge *eed;
+ EditSelection *ese;
float *fp, *newkey, *oldkey, nor[3];
int i, a, ototvert, totedge=0;
MDeformVert *dvert;
@@ -966,6 +986,7 @@ void load_editMesh(void)
}
/* the edges */
+ a= 0;
eed= em->edges.first;
while(eed) {
medge->v1= (unsigned int) eed->v1->tmp.l;
@@ -979,12 +1000,15 @@ void load_editMesh(void)
if(eed->h & 1) medge->flag |= ME_HIDE;
medge->crease= (char)(255.0*eed->crease);
-
+
+ eed->tmp.l = a++;
+
medge++;
eed= eed->next;
}
/* the faces */
+ a = 0;
efa= em->faces.first;
i = 0;
while(efa) {
@@ -1035,7 +1059,8 @@ void load_editMesh(void)
/* no index '0' at location 3 or 4 */
test_index_face(mface, NULL, &efa->tf, efa->v4?4:3);
-
+
+ efa->tmp.l = a++;
i++;
efa= efa->next;
}
@@ -1184,6 +1209,23 @@ void load_editMesh(void)
if(oldverts) MEM_freeN(oldverts);
+ i = 0;
+ for(ese=em->selected.first; ese; ese=ese->next) i++;
+ me->totselect = i;
+ if(i==0) mselect= NULL;
+ else mselect= MEM_callocN(i*sizeof(MSelect), "loadeditMesh selections");
+
+ if(me->mselect) MEM_freeN(me->mselect);
+ me->mselect= mselect;
+
+ for(ese=em->selected.first; ese; ese=ese->next){
+ mselect->type = ese->type;
+ if(ese->type == EDITVERT) mselect->index = ((EditVert*)ese->data)->tmp.l;
+ else if(ese->type == EDITEDGE) mselect->index = ((EditEdge*)ese->data)->tmp.l;
+ else if(ese->type == EDITFACE) mselect->index = ((EditFace*)ese->data)->tmp.l;
+ mselect++;
+ }
+
/* to be sure: clear ->tmp.l pointers */
eve= em->verts.first;
while(eve) {
@@ -1191,6 +1233,18 @@ void load_editMesh(void)
eve= eve->next;
}
+ eed= em->edges.first;
+ while(eed) {
+ eed->tmp.l = 0;
+ eed= eed->next;
+ }
+
+ efa= em->faces.first;
+ while(efa) {
+ efa->tmp.l = 0;
+ efa= efa->next;
+ }
+
/* remake softbody of all users */
if(me->id.us>1) {
Base *base;
@@ -1214,8 +1268,6 @@ void load_editMesh(void)
}
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
-
- BLI_freelistN(&(em->selected)); /*come up with better solution so leaving editmode and not switching meshes will not nuke this...*/
waitcursor(0);
}
diff --git a/source/blender/src/editmesh_lib.c b/source/blender/src/editmesh_lib.c
index 88852052eaa..a717e0ed9b9 100644
--- a/source/blender/src/editmesh_lib.c
+++ b/source/blender/src/editmesh_lib.c
@@ -66,13 +66,6 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data
#include "editmesh.h"
-
-//TODO
-//fix undo code. Biggest one.
-//fix issues with EM_selectmode_set()
-//get rid of 'lastvert' and 'firstvert' hacks in EditMesh struct and clean from undo code and 'load_editmesh' code and elsewhere
-//find out if storing EditSelection(s) in Mesh DNA is 'ok', even if only for runtime(?)
-
/* ********* Selection ************ */
static int EM_check_selection(void *data)
{