diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-15 18:01:39 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-15 18:01:39 +0300 |
commit | 237cd7a7a747334109a742c89dd0a78d4bb35d47 (patch) | |
tree | 2a0eb0772be8900d679f31969566478d7a75d791 | |
parent | c54cad0a32e044205891ee08a0bac44c655f6020 (diff) |
2.5
- Depricated another bunch of globals; all the totobj,
totmesh, totvert, and so on.
- All code that needs such totals now count it themselves,
these stats were not supposed to be reliable
- Editmesh now stores and manages own totals.
- Todo: make a scene->stats that tracks notifiers.
Bugfix: selecting failed in editmesh, backbuffer stuff was
too late, already using index ranges before it was set.
20 files changed, 377 insertions, 394 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index c0604a2b213..4bd9435708d 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -52,7 +52,6 @@ typedef struct Global { /* active pointers */ struct Main *main; - char editModeTitleExtra[64]; /* fonts, allocated global data */ struct BMF_Font *font, *fonts, *fontss; @@ -65,12 +64,7 @@ typedef struct Global { /* strings of recent opend files */ struct ListBase recent_files; - - /* totals */ - int totobj, totlamp, totobjsel, totcurve, totmesh; - int totbone, totbonesel; - int totvert, totedge, totface, totvertsel, totedgesel, totfacesel; - + short afbreek, moving; short background; short winpos, displaymode; /* used to be in Render */ @@ -108,10 +102,6 @@ typedef struct Global { /* Janco's playing ground */ struct bSoundListener* listener; - /* Test thingy for Nzc */ - int compat; /* toggle compatibility mode for edge rendering */ - int notonlysolid;/* T-> also edge-render transparent faces */ - /* ndof device found ? */ int ndofdevice; diff --git a/source/blender/blenkernel/intern/booleanops.c b/source/blender/blenkernel/intern/booleanops.c index 51c47746b99..e57dfea8eaf 100644 --- a/source/blender/blenkernel/intern/booleanops.c +++ b/source/blender/blenkernel/intern/booleanops.c @@ -268,7 +268,6 @@ static Object *AddNewBlenderMesh(Scene *scene, Base *base) // Initialize the mesh data associated with this object. ob_new->data= add_mesh("Mesh"); - G.totmesh++; // Finally assign the object type. ob_new->type= OB_MESH; diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 43056d7f98b..f2bcfdb5065 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -2430,7 +2430,7 @@ static void write_videoscape_mesh(Scene *scene, Object *ob, char *str) if(em) { - fprintf(fp, "%d\n", G.totvert); + fprintf(fp, "%d\n", em->totvert); tot= 0; eve= em->verts.first; @@ -3457,7 +3457,7 @@ static void dxf_get_mesh(Scene *scene, Mesh** m, Object** o, int noob) } else { *o = NULL; - *m = add_mesh("Mesh"); G.totmesh++; + *m = add_mesh("Mesh"); me = *m; ob = *o; @@ -4650,8 +4650,6 @@ static void dxf_read(Scene *scene, char *filename) ob->dupsta= 1; ob->dupend= 100; ob->recalc= OB_RECALC; /* needed because of weird way of adding libdata directly */ - G.totobj++; - ob->data= obdata; ((ID*)ob->data)->us++; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 02abfb73b96..ae73de892be 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -886,13 +886,13 @@ void *add_wave() static void *add_obdata_from_type(int type) { switch (type) { - case OB_MESH: G.totmesh++; return add_mesh("Mesh"); - case OB_CURVE: G.totcurve++; return add_curve("Curve", OB_CURVE); - case OB_SURF: G.totcurve++; return add_curve("Surf", OB_SURF); + case OB_MESH: return add_mesh("Mesh"); + case OB_CURVE: return add_curve("Curve", OB_CURVE); + case OB_SURF: return add_curve("Surf", OB_SURF); case OB_FONT: return add_curve("Text", OB_FONT); case OB_MBALL: return add_mball("Meta"); case OB_CAMERA: return add_camera("Camera"); - case OB_LAMP: G.totlamp++; return add_lamp("Lamp"); + case OB_LAMP: return add_lamp("Lamp"); case OB_LATTICE: return add_lattice("Lattice"); case OB_WAVE: return add_wave(); case OB_ARMATURE: return add_armature("Armature"); @@ -929,7 +929,6 @@ Object *add_only_object(int type, char *name) Object *ob; ob= alloc_libblock(&G.main->object, ID_OB, name); - G.totobj++; /* default object vars */ ob->type= type; diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index f0f54bae8ea..758e3d136aa 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -170,6 +170,8 @@ typedef struct EditMesh short selectmode; /* copy from object actcol */ short mat_nr; + /* stats */ + int totvert, totedge, totface, totvertsel, totedgesel, totfacesel; struct DerivedMesh *derivedCage, *derivedFinal; /* the custom data layer mask that was last used to calculate diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index af69fcbb8c7..4f67a31b8a3 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -344,7 +344,7 @@ void make_editNurb(Object *obedit) actkey = ob_get_keyblock(obedit); if(actkey) { - strcpy(G.editModeTitleExtra, "(Key) "); + // XXX strcpy(G.editModeTitleExtra, "(Key) "); key_to_curve(actkey, cu, editnurb); } } diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 00fb017d752..e7d9de758a9 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -86,14 +86,17 @@ void view3d_align_axis_to_vector(struct Scene *scene, struct View3D *v3d, int ax void drawcircball(int mode, float *cent, float rad, float tmat[][4]); /* backbuffer select and draw support */ +void view3d_validate_backbuf(struct ViewContext *vc); struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); -unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, unsigned int (*indextest)(unsigned int index)); +unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, + void *handle, unsigned int (*indextest)(void *handle, unsigned int index)); unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* select */ #define MAXPICKBUF 10000 short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigned int bufsize, rcti *input); void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); + /* XXX should move to arithb.c */ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2); diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index c791d4e604f..bc5b8a5853d 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -125,6 +125,7 @@ EditVert *addvertlist(EditMesh *em, float *vec, EditVert *example) eve= callocvert(em, sizeof(EditVert), 1); BLI_addtail(&em->verts, eve); + em->totvert++; if(vec) VECCOPY(eve->co, vec); @@ -154,6 +155,8 @@ void free_editvert (EditMesh *em, EditVert *eve) CustomData_em_free_block(&em->vdata, &eve->data); if(eve->fast==0) free(eve); + + em->totvert--; } @@ -259,6 +262,7 @@ EditEdge *addedgelist(EditMesh *em, EditVert *v1, EditVert *v2, EditEdge *exampl BLI_addtail(&em->edges, eed); eed->dir= swap; insert_hashedge(em, eed); + em->totedge++; /* copy edge data: rule is to do this with addedgelist call, before addfacelist */ @@ -276,9 +280,10 @@ EditEdge *addedgelist(EditMesh *em, EditVert *v1, EditVert *v2, EditEdge *exampl void remedge(EditMesh *em, EditEdge *eed) { - BLI_remlink(&em->edges, eed); remove_hashedge(em, eed); + + em->totedge--; } void free_editedge(EditMesh *em, EditEdge *eed) @@ -291,7 +296,6 @@ void free_editedge(EditMesh *em, EditEdge *eed) void free_editface(EditMesh *em, EditFace *efa) { - EM_remove_selection(em, efa, EDITFACE); if (em->act_face==efa) { @@ -301,6 +305,8 @@ void free_editface(EditMesh *em, EditFace *efa) CustomData_em_free_block(&em->fdata, &efa->data); if(efa->fast==0) free(efa); + + em->totface--; } void free_vertlist(EditMesh *em, ListBase *edve) @@ -316,6 +322,7 @@ void free_vertlist(EditMesh *em, ListBase *edve) eve= next; } edve->first= edve->last= NULL; + em->totvert= em->totvertsel= 0; } void free_edgelist(EditMesh *em, ListBase *lb) @@ -329,6 +336,7 @@ void free_edgelist(EditMesh *em, ListBase *lb) eed= next; } lb->first= lb->last= NULL; + em->totedge= em->totedgesel= 0; } void free_facelist(EditMesh *em, ListBase *lb) @@ -342,6 +350,7 @@ void free_facelist(EditMesh *em, ListBase *lb) efa= next; } lb->first= lb->last= NULL; + em->totface= em->totfacesel= 0; } EditFace *addfacelist(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4, EditFace *example, EditFace *exampleEdges) @@ -394,7 +403,8 @@ EditFace *addfacelist(EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, Ed } BLI_addtail(&em->faces, efa); - + em->totface++; + if(efa->v4) { CalcNormFloat4(efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co, efa->n); CalcCent4f(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co); @@ -562,7 +572,7 @@ void free_editMesh(EditMesh *em) mesh_octree_table(NULL, NULL, NULL, 'e'); - G.totvert= G.totface= 0; + em->totvert= em->totedge= em->totface= 0; // XXX if(em->retopo_paint_data) retopo_free_paint_data(em->retopo_paint_data); em->retopo_paint_data= NULL; @@ -828,9 +838,9 @@ void make_editMesh(Scene *scene, Object *ob) em->selectmode= scene->selectmode; // warning needs to be synced em->act_face = NULL; - G.totvert= tot= me->totvert; - G.totedge= me->totedge; - G.totface= me->totface; + em->totvert= tot= me->totvert; + em->totedge= me->totedge; + em->totface= me->totface; if(tot==0) { return; @@ -1031,21 +1041,19 @@ void load_editMesh(Scene *scene, Object *ob) /* eve->f2 : being used in vertexnormals */ edge_drawflags(em); - G.totvert= BLI_countlist(&em->verts); - G.totedge= BLI_countlist(&em->edges); - G.totface= BLI_countlist(&em->faces); + EM_stats_update(em); /* new Vertex block */ - if(G.totvert==0) mvert= NULL; - else mvert= MEM_callocN(G.totvert*sizeof(MVert), "loadeditMesh vert"); + if(em->totvert==0) mvert= NULL; + else mvert= MEM_callocN(em->totvert*sizeof(MVert), "loadeditMesh vert"); /* new Edge block */ - if(G.totedge==0) medge= NULL; - else medge= MEM_callocN(G.totedge*sizeof(MEdge), "loadeditMesh edge"); + if(em->totedge==0) medge= NULL; + else medge= MEM_callocN(em->totedge*sizeof(MEdge), "loadeditMesh edge"); /* new Face block */ - if(G.totface==0) mface= NULL; - else mface= MEM_callocN(G.totface*sizeof(MFace), "loadeditMesh face"); + if(em->totface==0) mface= NULL; + else mface= MEM_callocN(em->totface*sizeof(MFace), "loadeditMesh face"); /* lets save the old verts just in case we are actually working on * a key ... we now do processing of the keys at the end */ @@ -1061,9 +1069,9 @@ void load_editMesh(Scene *scene, Object *ob) CustomData_free(&me->fdata, me->totface); /* add new custom data */ - me->totvert= G.totvert; - me->totedge= G.totedge; - me->totface= G.totface; + me->totvert= em->totvert; + me->totedge= em->totedge; + me->totface= em->totface; CustomData_copy(&em->vdata, &me->vdata, CD_MASK_MESH, CD_CALLOC, me->totvert); CustomData_copy(&em->edata, &me->edata, CD_MASK_MESH, CD_CALLOC, me->totedge); @@ -1079,7 +1087,7 @@ void load_editMesh(Scene *scene, Object *ob) a= 0; /* check for point cache editing */ - cacheedit= editmesh_pointcache_edit(scene, ob, G.totvert, &pid, cachemat, 1); + cacheedit= editmesh_pointcache_edit(scene, ob, em->totvert, &pid, cachemat, 1); while(eve) { if(cacheedit) { @@ -1322,7 +1330,7 @@ void load_editMesh(Scene *scene, Object *ob) currkey = me->key->block.first; while(currkey) { - fp= newkey= MEM_callocN(me->key->elemsize*G.totvert, "currkey->data"); + fp= newkey= MEM_callocN(me->key->elemsize*em->totvert, "currkey->data"); oldkey = currkey->data; eve= em->verts.first; @@ -1356,7 +1364,7 @@ void load_editMesh(Scene *scene, Object *ob) ++mvert; eve= eve->next; } - currkey->totelem= G.totvert; + currkey->totelem= em->totvert; if(currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; @@ -1673,7 +1681,7 @@ void separate_mesh_loose(Scene *scene, Object *obedit) /* If the amount of vertices that is about to be split == the total amount of verts in the mesh, it means that there is only 1 unconnected object, so we don't have to separate */ - if(G.totvert==vertsep) done=1; + if(em->totvert==vertsep) done=1; else{ /* No splitting: select connected goes fine */ @@ -2034,9 +2042,9 @@ static void undoMesh_to_editMesh(void *umv, void *emv) end_editmesh_fastmalloc(); if(evar) MEM_freeN(evar); - G.totvert = um->totvert; - G.totedge = um->totedge; - G.totface = um->totface; + em->totvert = um->totvert; + em->totedge = um->totedge; + em->totface = um->totface; /*restore stored editselections*/ if(um->totsel){ EM_init_index_arrays(em, 1,1,1); @@ -2094,24 +2102,24 @@ void EM_init_index_arrays(EditMesh *em, int forVert, int forEdge, int forFace) int i; if (forVert) { - int tot= BLI_countlist(&em->verts); - g_em_vert_array = MEM_mallocN(sizeof(*g_em_vert_array)*tot, "em_v_arr"); + em->totvert= BLI_countlist(&em->verts); + g_em_vert_array = MEM_mallocN(sizeof(*g_em_vert_array)*em->totvert, "em_v_arr"); for (i=0,eve=em->verts.first; eve; i++,eve=eve->next) g_em_vert_array[i] = eve; } if (forEdge) { - int tot= BLI_countlist(&em->edges); - g_em_edge_array = MEM_mallocN(sizeof(*g_em_edge_array)*tot, "em_e_arr"); + em->totedge= BLI_countlist(&em->edges); + g_em_edge_array = MEM_mallocN(sizeof(*g_em_edge_array)*em->totedge, "em_e_arr"); for (i=0,eed=em->edges.first; eed; i++,eed=eed->next) g_em_edge_array[i] = eed; } if (forFace) { - int tot= BLI_countlist(&em->faces); - g_em_face_array = MEM_mallocN(sizeof(*g_em_face_array)*tot, "em_f_arr"); + em->totface= BLI_countlist(&em->faces); + g_em_face_array = MEM_mallocN(sizeof(*g_em_face_array)*em->totface, "em_f_arr"); for (i=0,efa=em->faces.first; efa; i++,efa=efa->next) g_em_face_array[i] = efa; diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index b4459201f5a..62dfcc1674c 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -1203,6 +1203,8 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se addfacelist(em, vtop, v1, v3, 0, NULL, NULL); } } + + EM_stats_update(em); /* simple selection flush OK, based on fact it's a single model */ EM_select_flush(em); /* flushes vertex -> edge -> face selection */ @@ -1662,7 +1664,6 @@ void MESH_OT_add_primitive_grid(wmOperatorType *ot) ot->poll= ED_operator_editmesh; } -// XXX No monkey ?! static int add_primitive_monkey_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); @@ -1682,7 +1683,7 @@ void MESH_OT_add_primitive_monkey(wmOperatorType *ot) { /* identifiers */ ot->name= "Add Monkey"; - ot->idname= "MESH_OT_add_monkey"; + ot->idname= "MESH_OT_add_primitive_monkey"; /* api callbacks */ ot->exec= add_primitive_monkey_exec; diff --git a/source/blender/editors/mesh/editmesh_lib.c b/source/blender/editors/mesh/editmesh_lib.c index 0bd3295d1d7..a3b33e71cf4 100644 --- a/source/blender/editors/mesh/editmesh_lib.c +++ b/source/blender/editors/mesh/editmesh_lib.c @@ -59,6 +59,64 @@ editmesh_lib: generic (no UI, no menus) operations/evaluators for editmesh data #include "mesh_intern.h" +/* ****************** stats *************** */ + +int EM_nfaces_selected(EditMesh *em) +{ + EditFace *efa; + int count= 0; + + for (efa= em->faces.first; efa; efa= efa->next) + if (efa->f & SELECT) + count++; + + em->totfacesel= count; + + return count; +} + +int EM_nedges_selected(EditMesh *em) +{ + EditEdge *eed; + int count= 0; + + for (eed= em->edges.first; eed; eed= eed->next) + if(eed->f & SELECT) + count++; + + em->totedgesel= count; + + return count; +} + +int EM_nvertices_selected(EditMesh *em) +{ + EditVert *eve; + int count= 0; + + for (eve= em->verts.first; eve; eve= eve->next) + if (eve->f & SELECT) + count++; + + em->totvertsel= count; + + return count; +} + +void EM_stats_update(EditMesh *em) +{ + + em->totvert= BLI_countlist(&em->verts); + em->totedge= BLI_countlist(&em->edges); + em->totface= BLI_countlist(&em->faces); + + EM_nvertices_selected(em); + EM_nedges_selected(em); + EM_nfaces_selected(em); +} + +/* ************************************** */ + /* this replaces the active flag used in uv/face mode */ void EM_set_actFace(EditMesh *em, EditFace *efa) { @@ -404,41 +462,6 @@ int faceselectedAND(EditFace *efa, int flag) } } -int EM_nfaces_selected(EditMesh *em) -{ - EditFace *efa; - int count= 0; - - for (efa= em->faces.first; efa; efa= efa->next) - if (efa->f & SELECT) - count++; - - return count; -} - -#if 0 -static int EM_nedges(EditMesh *em) -{ - EditEdge *eed; - int count= 0; - - for (eed= em->edges.first; eed; eed= eed->next) count++; - return count; -} -#endif - -int EM_nvertices_selected(EditMesh *em) -{ - EditVert *eve; - int count= 0; - - for (eve= em->verts.first; eve; eve= eve->next) - if (eve->f & SELECT) - count++; - - return count; -} - void EM_clear_flag_all(EditMesh *em, int flag) { EditVert *eve; @@ -449,7 +472,10 @@ void EM_clear_flag_all(EditMesh *em, int flag) for (eed= em->edges.first; eed; eed= eed->next) eed->f &= ~flag; for (efa= em->faces.first; efa; efa= efa->next) efa->f &= ~flag; - if(flag & SELECT) BLI_freelistN(&(em->selected)); + if(flag & SELECT) { + BLI_freelistN(&(em->selected)); + em->totvertsel= em->totedgesel= em->totfacesel= 0; + } } void EM_set_flag_all(EditMesh *em, int flag) @@ -462,6 +488,11 @@ void EM_set_flag_all(EditMesh *em, int flag) for (eed= em->edges.first; eed; eed= eed->next) if(eed->h==0) eed->f |= flag; for (efa= em->faces.first; efa; efa= efa->next) if(efa->h==0) efa->f |= flag; + if(flag & SELECT) { + em->totvertsel= em->totvert; + em->totedgesel= em->totedge; + em->totfacesel= em->totface; + } } /* flush for changes in vertices only */ @@ -484,6 +515,8 @@ void EM_deselect_flush(EditMesh *em) else efa->f &= ~SELECT; } } + EM_nedges_selected(em); + EM_nfaces_selected(em); } @@ -510,6 +543,8 @@ void EM_select_flush(EditMesh *em) if(efa->v1->f & efa->v2->f & efa->v3->f & SELECT ) efa->f |= SELECT; } } + EM_nedges_selected(em); + EM_nfaces_selected(em); } /* when vertices or edges can be selected, also make fgon consistant */ @@ -634,6 +669,9 @@ void EM_selectmode_flush(EditMesh *em) if(!(em->selectmode & SCE_SELECT_FACE)) check_fgons_selection(em); + EM_nvertices_selected(em); + EM_nedges_selected(em); + EM_nfaces_selected(em); } void EM_convertsel(EditMesh *em, short oldmode, short selectmode) @@ -694,6 +732,10 @@ void EM_convertsel(EditMesh *em, short oldmode, short selectmode) } check_fgons_selection(em); + + EM_nvertices_selected(em); + EM_nedges_selected(em); + EM_nfaces_selected(em); } /* when switching select mode, makes sure selection is consistant for editing */ @@ -728,6 +770,10 @@ void EM_selectmode_set(EditMesh *em) for(efa= em->faces.first; efa; efa= efa->next) if(efa->f & SELECT) EM_select_face(efa, 1); } + + EM_nvertices_selected(em); + EM_nedges_selected(em); + EM_nfaces_selected(em); } /* paranoia check, actually only for entering editmode. rule: diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index f9e0cd78044..fe96cf21f18 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -124,7 +124,7 @@ void EM_automerge(int update) // ) { // len = removedoublesflag(1, 1, scene->toolsettings->doublimit); // if (len) { -// G.totvert -= len; /* saves doing a countall */ +// em->totvert -= len; /* saves doing a countall */ // if (update) { // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); // } @@ -365,9 +365,9 @@ static void findnearestvert__doClosest(void *userData, EditVert *eve, int x, int -static unsigned int findnearestvert__backbufIndextest(unsigned int index) +static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int index) { - EditMesh *em= NULL; // XXX + EditMesh *em= (EditMesh *)handle; EditVert *eve = BLI_findlink(&em->verts, index-1); if(eve && (eve->f & SELECT)) return 0; @@ -389,8 +389,8 @@ EditVert *findnearestvert(ViewContext *vc, int *dist, short sel, short strict) unsigned int index; EditVert *eve; - if(strict) index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, strict, findnearestvert__backbufIndextest); - else index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, 0, NULL); + if(strict) index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, strict, vc->em, findnearestvert__backbufIndextest); + else index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_wireoffs, 0xFFFFFF, &distance, 0, NULL, NULL); eve = BLI_findlink(&vc->em->verts, index-1); @@ -492,7 +492,7 @@ EditEdge *findnearestedge(ViewContext *vc, int *dist) if(vc->v3d->drawtype>OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { int distance; - unsigned int index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_solidoffs, em_wireoffs, &distance,0, NULL); + unsigned int index = view3d_sample_backbuf_rect(vc, vc->mval, 50, em_solidoffs, em_wireoffs, &distance,0, NULL, NULL); EditEdge *eed = BLI_findlink(&vc->em->edges, index-1); if (eed && distance<*dist) { @@ -623,6 +623,9 @@ static int unified_findnearest(ViewContext *vc, EditVert **eve, EditEdge **eed, *eed= NULL; *efa= NULL; + /* no afterqueue (yet), so we check it now, otherwise the em_xxxofs indices are bad */ + view3d_validate_backbuf(vc); + if(em->selectmode & SCE_SELECT_VERTEX) *eve= findnearestvert(vc, &dist, SELECT, 0); if(em->selectmode & SCE_SELECT_FACE) @@ -1191,7 +1194,7 @@ void select_mesh_group_menu(EditMesh *em) selcount= vertgroup_select(em, ret); if (selcount) { /* update if data was selected */ EM_select_flush(em); /* so that selected verts, go onto select faces */ - G.totvertsel += selcount; + em->totvertsel += selcount; // if (EM_texFaceCheck()) BIF_undo_push("Select Similar Vertices"); } @@ -1203,7 +1206,7 @@ void select_mesh_group_menu(EditMesh *em) if (selcount) { /* update if data was selected */ /*EM_select_flush(em);*/ /* dont use because it can end up selecting more edges and is not usefull*/ - G.totedgesel+=selcount; + em->totedgesel+=selcount; // if (EM_texFaceCheck()) BIF_undo_push("Select Similar Edges"); } @@ -1213,7 +1216,7 @@ void select_mesh_group_menu(EditMesh *em) if (ret<1000) { selcount= facegroup_select(em, ret/100); if (selcount) { /* update if data was selected */ - G.totfacesel+=selcount; + em->totfacesel+=selcount; // if (EM_texFaceCheck()) BIF_undo_push("Select Similar Faces"); } @@ -1892,10 +1895,12 @@ void loop_multiselect(EditMesh *em, int looptype) EditEdge **edarray; int edindex, edfirstcount; - /*edarray = MEM_mallocN(sizeof(*edarray)*G.totedgesel,"edge array");*/ - edarray = MEM_mallocN(sizeof(EditEdge*)*G.totedgesel,"edge array"); + /* sets em->totedgesel */ + EM_nedges_selected(em); + + edarray = MEM_mallocN(sizeof(EditEdge*)*em->totedgesel,"edge array"); edindex = 0; - edfirstcount = G.totedgesel; + edfirstcount = em->totedgesel; for(eed=em->edges.first; eed; eed=eed->next){ if(eed->f&SELECT){ @@ -2465,7 +2470,7 @@ void hide_mesh(EditMesh *em, int swap) } } - G.totedgesel= G.totfacesel= G.totvertsel= 0; + em->totedgesel= em->totfacesel= em->totvertsel= 0; // if(EM_texFaceCheck()) // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4257480d96d..396e9ac8437 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -592,28 +592,28 @@ void extrude_mesh(Object *obedit, EditMesh *em) short nr, transmode= 0; if(em->selectmode & SCE_SELECT_VERTEX) { - if(G.totvertsel==0) nr= 0; - else if(G.totvertsel==1) nr= 4; - else if(G.totedgesel==0) nr= 4; - else if(G.totfacesel==0) + if(em->totvertsel==0) nr= 0; + else if(em->totvertsel==1) nr= 4; + else if(em->totedgesel==0) nr= 4; + else if(em->totfacesel==0) nr= pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4"); - else if(G.totfacesel==1) + else if(em->totfacesel==1) nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4"); else nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4"); } else if(em->selectmode & SCE_SELECT_EDGE) { - if (G.totedgesel==0) nr = 0; - else if (G.totedgesel==1) nr = 3; - else if(G.totfacesel==0) nr = 3; - else if(G.totfacesel==1) + if (em->totedgesel==0) nr = 0; + else if (em->totedgesel==1) nr = 3; + else if(em->totfacesel==0) nr = 3; + else if(em->totfacesel==1) nr= pupmenu("Extrude %t|Region %x1|Only Edges%x3"); else nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3"); } else { - if (G.totfacesel == 0) nr = 0; - else if (G.totfacesel == 1) nr = 1; + if (em->totfacesel == 0) nr = 0; + else if (em->totfacesel == 1) nr = 1; else nr= pupmenu("Extrude %t|Region %x1||Individual Faces %x2"); } @@ -5839,7 +5839,7 @@ void region_to_loop(EditMesh *em) EditEdge *eed; EditFace *efa; - if(G.totfacesel){ + if(em->totfacesel){ for(eed=em->edges.first; eed; eed=eed->next) eed->f1 = 0; for(efa=em->faces.first; efa; efa=efa->next){ diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 95a6bdbfe29..d8759e1f27b 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -105,6 +105,8 @@ void MESH_OT_add_primitive_monkey(struct wmOperatorType *ot); /* ******************* editmesh_lib.c */ +void EM_stats_update(EditMesh *em); + extern void EM_fgon_flags(EditMesh *em); extern void EM_hide_reset(EditMesh *em); @@ -119,7 +121,9 @@ void EM_data_interp_from_verts(EditMesh *em, EditVert *v1, EditVert *v2, EditVer void EM_data_interp_from_faces(EditMesh *em, EditFace *efa1, EditFace *efa2, EditFace *efan, int i1, int i2, int i3, int i4); int EM_nvertices_selected(EditMesh *em); +int EM_nedges_selected(EditMesh *em); int EM_nfaces_selected(EditMesh *em); + float EM_face_perimeter(EditFace *efa); void EM_store_selection(EditMesh *em, void *data, int type); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 1542fc298d0..b139ff622ed 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -390,6 +390,124 @@ void delete_obj(Scene *scene, View3D *v3d, int ok) BIF_undo_push("Delete object(s)"); } +static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin) +{ + ID_NEW(*obpoin); +} + +static void copy_object__forwardModifierLinks(void *userData, Object *ob, + ID **idpoin) +{ + /* this is copied from ID_NEW; it might be better to have a macro */ + if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; +} + + +/* after copying objects, copied data should get new pointers */ +static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) +{ + Base *base; + Object *ob; + Material *ma, *mao; + ID *id; + Ipo *ipo; + bActionStrip *strip; + int a; + + /* check object pointers */ + for(base= FIRSTBASE; base; base= base->next) { + if(TESTBASELIB(v3d, base)) { + ob= base->object; + relink_constraints(&ob->constraints); + if (ob->pose){ + bPoseChannel *chan; + for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ + relink_constraints(&chan->constraints); + } + } + modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); + ID_NEW(ob->parent); + ID_NEW(ob->track); + ID_NEW(ob->proxy); + ID_NEW(ob->proxy_group); + + for(strip= ob->nlastrips.first; strip; strip= strip->next) { + bActionModifier *amod; + for(amod= strip->modifiers.first; amod; amod= amod->next) + ID_NEW(amod->ob); + } + } + } + + /* materials */ + if( dupflag & USER_DUP_MAT) { + mao= G.main->mat.first; + while(mao) { + if(mao->id.newid) { + + ma= (Material *)mao->id.newid; + + if(dupflag & USER_DUP_TEX) { + for(a=0; a<MAX_MTEX; a++) { + if(ma->mtex[a]) { + id= (ID *)ma->mtex[a]->tex; + if(id) { + ID_NEW_US(ma->mtex[a]->tex) + else ma->mtex[a]->tex= copy_texture(ma->mtex[a]->tex); + id->us--; + } + } + } + } + id= (ID *)ma->ipo; + if(id) { + ID_NEW_US(ma->ipo) + else ma->ipo= copy_ipo(ma->ipo); + id->us--; + } + } + mao= mao->id.next; + } + } + + /* lamps */ + if( dupflag & USER_DUP_IPO) { + Lamp *la= G.main->lamp.first; + while(la) { + if(la->id.newid) { + Lamp *lan= (Lamp *)la->id.newid; + id= (ID *)lan->ipo; + if(id) { + ID_NEW_US(lan->ipo) + else lan->ipo= copy_ipo(lan->ipo); + id->us--; + } + } + la= la->id.next; + } + } + + /* ipos */ + ipo= G.main->ipo.first; + while(ipo) { + if(ipo->id.lib==NULL && ipo->id.newid) { + Ipo *ipon= (Ipo *)ipo->id.newid; + IpoCurve *icu; + for(icu= ipon->curve.first; icu; icu= icu->next) { + if(icu->driver) { + ID_NEW(icu->driver->ob); + } + } + } + ipo= ipo->id.next; + } + + set_sca_new_poins(); + + clear_id_newpoins(); + +} + static int return_editmesh_indexar(EditMesh *em, int *tot, int **indexar, float *cent) { EditVert *eve; @@ -2295,6 +2413,48 @@ void OBJECT_OT_make_track(wmOperatorType *ot) } /* ************* Make Dupli Real ********* */ +static void make_object_duplilist_real(Scene *scene, View3D *v3d, Base *base) +{ + Base *basen; + Object *ob; + ListBase *lb; + DupliObject *dob; + + if(!base && !(base = BASACT)) + return; + + if(!(base->object->transflag & OB_DUPLI)) + return; + + lb= object_duplilist(scene, base->object); + + for(dob= lb->first; dob; dob= dob->next) { + ob= copy_object(dob->ob); + /* font duplis can have a totcol without material, we get them from parent + * should be implemented better... + */ + if(ob->mat==NULL) ob->totcol= 0; + + basen= MEM_dupallocN(base); + basen->flag &= ~OB_FROMDUPLI; + BLI_addhead(&scene->base, basen); /* addhead: othwise eternal loop */ + basen->object= ob; + ob->ipo= NULL; /* make sure apply works */ + ob->parent= ob->track= NULL; + ob->disp.first= ob->disp.last= NULL; + ob->transflag &= ~OB_DUPLI; + + Mat4CpyMat4(ob->obmat, dob->mat); + ED_object_apply_obmat(ob); + } + + copy_object_set_idnew(scene, v3d, 0); + + free_object_duplilist(lb); + + base->object->transflag &= ~OB_DUPLI; +} + static int object_make_dupli_real_exec(bContext *C, wmOperator *op) { @@ -2707,7 +2867,7 @@ void ED_object_exit_editmode(bContext *C, int flag) // if(retopo_mesh_paint_check()) // retopo_end_okee(); - if(G.totvert>MESH_MAX_VERTS) { + if(me->edit_mesh->totvert>MESH_MAX_VERTS) { error("Too many vertices"); return; } @@ -3570,7 +3730,6 @@ void convertmenu(Scene *scene, View3D *v3d) /* make a new copy of the mesh */ ob1->data= copy_mesh(me); - G.totmesh++; /* make new mesh data from the original copy */ dm= mesh_get_derived_final(scene, ob1, CD_MASK_MESH); @@ -3661,7 +3820,6 @@ void convertmenu(Scene *scene, View3D *v3d) mb->id.us--; ob1->data= add_mesh("Mesh"); - G.totmesh++; ob1->type= OB_MESH; me= ob1->data; @@ -4837,248 +4995,6 @@ void apply_objects_visual_tx( Scene *scene, View3D *v3d ) } } -static void single_object_users__forwardModifierLinks(void *userData, Object *ob, Object **obpoin) -{ - ID_NEW(*obpoin); -} - -static void copy_object__forwardModifierLinks(void *userData, Object *ob, - ID **idpoin) -{ - /* this is copied from ID_NEW; it might be better to have a macro */ - if(*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; -} - - -/* after copying objects, copied data should get new pointers */ -static void copy_object_set_idnew(Scene *scene, View3D *v3d, int dupflag) -{ - Base *base; - Object *ob; - Material *ma, *mao; - ID *id; - Ipo *ipo; - bActionStrip *strip; - int a; - - /* check object pointers */ - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { - ob= base->object; - relink_constraints(&ob->constraints); - if (ob->pose){ - bPoseChannel *chan; - for (chan = ob->pose->chanbase.first; chan; chan=chan->next){ - relink_constraints(&chan->constraints); - } - } - modifiers_foreachIDLink(ob, copy_object__forwardModifierLinks, NULL); - ID_NEW(ob->parent); - ID_NEW(ob->track); - ID_NEW(ob->proxy); - ID_NEW(ob->proxy_group); - - for(strip= ob->nlastrips.first; strip; strip= strip->next) { - bActionModifier *amod; - for(amod= strip->modifiers.first; amod; amod= amod->next) - ID_NEW(amod->ob); - } - } - } - - /* materials */ - if( dupflag & USER_DUP_MAT) { - mao= G.main->mat.first; - while(mao) { - if(mao->id.newid) { - - ma= (Material *)mao->id.newid; - - if(dupflag & USER_DUP_TEX) { - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a]) { - id= (ID *)ma->mtex[a]->tex; - if(id) { - ID_NEW_US(ma->mtex[a]->tex) - else ma->mtex[a]->tex= copy_texture(ma->mtex[a]->tex); - id->us--; - } - } - } - } - id= (ID *)ma->ipo; - if(id) { - ID_NEW_US(ma->ipo) - else ma->ipo= copy_ipo(ma->ipo); - id->us--; - } - } - mao= mao->id.next; - } - } - - /* lamps */ - if( dupflag & USER_DUP_IPO) { - Lamp *la= G.main->lamp.first; - while(la) { - if(la->id.newid) { - Lamp *lan= (Lamp *)la->id.newid; - id= (ID *)lan->ipo; - if(id) { - ID_NEW_US(lan->ipo) - else lan->ipo= copy_ipo(lan->ipo); - id->us--; - } - } - la= la->id.next; - } - } - - /* ipos */ - ipo= G.main->ipo.first; - while(ipo) { - if(ipo->id.lib==NULL && ipo->id.newid) { - Ipo *ipon= (Ipo *)ipo->id.newid; - IpoCurve *icu; - for(icu= ipon->curve.first; icu; icu= icu->next) { - if(icu->driver) { - ID_NEW(icu->driver->ob); - } - } - } - ipo= ipo->id.next; - } - - set_sca_new_poins(); - - clear_id_newpoins(); - -} - - -void make_object_duplilist_real(Scene *scene, View3D *v3d, Base *base) -{ - Base *basen; - Object *ob; - ListBase *lb; - DupliObject *dob; - - if(!base && !(base = BASACT)) - return; - - if(!(base->object->transflag & OB_DUPLI)) - return; - - lb= object_duplilist(scene, base->object); - - for(dob= lb->first; dob; dob= dob->next) { - ob= copy_object(dob->ob); - /* font duplis can have a totcol without material, we get them from parent - * should be implemented better... - */ - if(ob->mat==NULL) ob->totcol= 0; - - basen= MEM_dupallocN(base); - basen->flag &= ~OB_FROMDUPLI; - BLI_addhead(&scene->base, basen); /* addhead: othwise eternal loop */ - basen->object= ob; - ob->ipo= NULL; /* make sure apply works */ - ob->parent= ob->track= NULL; - ob->disp.first= ob->disp.last= NULL; - ob->transflag &= ~OB_DUPLI; - - Mat4CpyMat4(ob->obmat, dob->mat); - ED_object_apply_obmat(ob); - } - - copy_object_set_idnew(scene, v3d, 0); - - free_object_duplilist(lb); - - base->object->transflag &= ~OB_DUPLI; -} - -void make_duplilist_real(Scene *scene, View3D *v3d) -{ - Base *base; - /* extern ListBase duplilist; */ - - if(okee("Make dupli objects real")==0) return; - - clear_id_newpoins(); - - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASE(v3d, base)) { - make_object_duplilist_real(scene, v3d, base); - } - } - - DAG_scene_sort(scene); - - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWOOPS, 0); - - BIF_undo_push("Make duplicates real"); -} - -void apply_object(Scene *scene, View3D *v3d) -{ - Object *ob; - int evt; - int shift= 0; - - if(scene->id.lib) return; - if(scene->obedit) return; // XXX get from context - - if(shift) { - ob= OBACT; - if(ob==0) return; - - if(ob->transflag & OB_DUPLI) { - make_duplilist_real(scene, v3d); - } - else { - if(okee("Apply deformation")) { -// XXX object_apply_deform(ob); - BIF_undo_push("Apply deformation"); - } - } - allqueue(REDRAWVIEW3D, 0); - - } - else { - ob= OBACT; - if(ob==0) return; - - if ((ob->pose) && (ob->flag & OB_POSEMODE)) - evt = pupmenu("Apply Object%t|Current Pose as RestPose%x3"); - else - evt = pupmenu("Apply Object%t|Scale and Rotation to ObData%x1|Visual Transform to Objects Loc/Scale/Rot%x2|Scale to ObData%x4|Rotation to ObData%x5"); - if (evt==-1) return; - - switch (evt) { - case 1: - apply_objects_locrot(scene, v3d); - break; - case 2: - apply_objects_visual_tx(scene, v3d); - break; - case 3: -// XXX apply_armature_pose2bones(); - break; - case 4: - apply_objects_scale(scene, v3d); - break; - case 5: - apply_objects_rot(scene, v3d); - break; - } - } -} - - - - /* ************************************** */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 11a6014d03d..8282e021dad 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5272,15 +5272,13 @@ static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float bglVertex3fv(co); } } -static int bbs_mesh_verts(DerivedMesh *dm, int offset) +static void bbs_mesh_verts(DerivedMesh *dm, int offset) { glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) ); bglBegin(GL_POINTS); dm->foreachMappedVert(dm, bbs_mesh_verts__mapFunc, (void*)(intptr_t) offset); bglEnd(); glPointSize(1.0); - - return offset + G.totvert; } static int bbs_mesh_wire__setDrawOptions(void *userData, int index) @@ -5295,11 +5293,9 @@ static int bbs_mesh_wire__setDrawOptions(void *userData, int index) return 0; } } -static int bbs_mesh_wire(DerivedMesh *dm, int offset) +static void bbs_mesh_wire(DerivedMesh *dm, int offset) { dm->drawMappedEdges(dm, bbs_mesh_wire__setDrawOptions, (void*)(intptr_t) offset); - - return offset + G.totedge; } static int bbs_mesh_solid__setSolidDrawOptions(void *userData, int index, int *drawSmooth_r) @@ -5326,7 +5322,7 @@ static void bbs_mesh_solid__drawCenter(void *userData, int index, float *cent, f } /* two options, facecolors or black */ -static int bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol) +static void bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh *dm, int facecol) { cpack(0); @@ -5341,10 +5337,8 @@ static int bbs_mesh_solid_EM(Scene *scene, View3D *v3d, Object *ob, DerivedMesh bglEnd(); } - return 1+G.totface; } else { dm->drawMappedFaces(dm, bbs_mesh_solid__setSolidDrawOptions, (void*) 0, 0); - return 1; } } @@ -5390,16 +5384,23 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, Object *ob) EM_init_index_arrays(em, 1, 1, 1); - em_solidoffs= bbs_mesh_solid_EM(scene, v3d, ob, dm, scene->selectmode & SCE_SELECT_FACE); + bbs_mesh_solid_EM(scene, v3d, ob, dm, scene->selectmode & SCE_SELECT_FACE); + if(scene->selectmode & SCE_SELECT_FACE) + em_solidoffs = 1+em->totface; + else + em_solidoffs= 1; bglPolygonOffset(v3d->dist, 1.0); // we draw edges always, for loop (select) tools - em_wireoffs= bbs_mesh_wire(dm, em_solidoffs); - + bbs_mesh_wire(dm, em_solidoffs); + em_wireoffs= em_solidoffs + em->totedge; + // we draw verts if vert select mode or if in transform (for snap). - if(scene->selectmode & SCE_SELECT_VERTEX || G.moving & G_TRANSFORM_EDIT) - em_vertoffs= bbs_mesh_verts(dm, em_wireoffs); + if(scene->selectmode & SCE_SELECT_VERTEX || G.moving & G_TRANSFORM_EDIT) { + bbs_mesh_verts(dm, em_wireoffs); + em_vertoffs= em_wireoffs + em->totvert; + } else em_vertoffs= em_wireoffs; bglPolygonOffset(v3d->dist, 0.0); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index d3a8ec82e4c..d85be9406d7 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1128,7 +1128,7 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) } -void check_backbuf(ViewContext *vc) +void view3d_validate_backbuf(ViewContext *vc) { if(vc->v3d->flag & V3D_NEEDBACKBUFDRAW) backdrawview3d(vc->scene, vc->ar, vc->v3d); @@ -1143,7 +1143,7 @@ unsigned int view3d_sample_backbuf(ViewContext *vc, int x, int y) x+= vc->ar->winrct.xmin; y+= vc->ar->winrct.ymin; - check_backbuf(vc); + view3d_validate_backbuf(vc); glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); glReadBuffer(GL_BACK); @@ -1172,7 +1172,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, ibuf= IMB_allocImBuf((xmaxc-xminc+1), (ymaxc-yminc+1), 32, IB_rect,0); - check_backbuf(vc); + view3d_validate_backbuf(vc); glReadPixels(vc->ar->winrct.xmin+xminc, vc->ar->winrct.ymin+yminc, (xmaxc-xminc+1), (ymaxc-yminc+1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glReadBuffer(GL_BACK); @@ -1207,7 +1207,9 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, } /* smart function to sample a rect spiralling outside, nice for backbuf selection */ -unsigned int view3d_sample_backbuf_rect(ViewContext *vc, short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, unsigned int (*indextest)(unsigned int index)) +unsigned int view3d_sample_backbuf_rect(ViewContext *vc, short mval[2], int size, + unsigned int min, unsigned int max, int *dist, short strict, + void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) { struct ImBuf *buf; unsigned int *bufmin, *bufmax, *tbuf; @@ -1242,7 +1244,7 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, short mval[2], int size for(b=0; b<nr; b++, distance++) { if (*tbuf && *tbuf>=min && *tbuf<max) { //we got a hit if(strict){ - indexok = indextest(*tbuf - min+1); + indexok = indextest(handle, *tbuf - min+1); if(indexok){ *dist= (short) sqrt( (float)distance ); index = *tbuf - min+1; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 3da65e9edb2..0d95ff2f7eb 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1411,11 +1411,12 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } else { /* no editmode, unified for bones and objects */ Bone *bone; + Object *ob= OBACT; unsigned int *vbuffer=NULL; /* selection buffer */ unsigned int *col; /* color in buffer */ short selecting = 0; - Object *ob= OBACT; int bone_only; + int totobj= MAXPICKBUF; // XXX solve later if((ob) && (ob->flag & OB_POSEMODE)) bone_only= 1; @@ -1426,8 +1427,8 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) selecting = 1; /* selection buffer now has bones potentially too, so we add MAXPICKBUF */ - vbuffer = MEM_mallocN(4 * (G.totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); - hits= view3d_opengl_select(&vc, vbuffer, 4*(G.totobj+MAXPICKBUF), &rect); + vbuffer = MEM_mallocN(4 * (totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer"); + hits= view3d_opengl_select(&vc, vbuffer, 4*(totobj+MAXPICKBUF), &rect); /* LOGIC NOTES (theeth): The buffer and ListBase have the same relative order, which makes the selection diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 4f9acd9fa4c..783636e3fdd 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1975,7 +1975,7 @@ static float *get_crazy_mapped_editverts(TransInfo *t) /* now get the cage */ dm= editmesh_get_derived_cage(t->scene, t->obedit, me->edit_mesh, CD_MASK_BAREMESH); - vertexcos= MEM_mallocN(3*sizeof(float)*G.totvert, "vertexcos map"); + vertexcos= MEM_mallocN(3*sizeof(float)*me->edit_mesh->totvert, "vertexcos map"); dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos); dm->release(dm); diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index bd0a97240a0..4605baa18f6 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -480,7 +480,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac } else { - if (G.totfacesel >= 1) + if (em->totfacesel >= 1) { EditFace *efa; @@ -496,7 +496,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac result = ORIENTATION_FACE; } - else if (G.totvertsel == 3) + else if (em->totvertsel == 3) { EditVert *v1 = NULL, *v2 = NULL, *v3 = NULL; float cotangent[3]; @@ -522,7 +522,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac } /* if there's an edge available, use that for the tangent */ - if (G.totedgesel >= 1) + if (em->totedgesel >= 1) { EditEdge *eed = NULL; @@ -536,7 +536,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac result = ORIENTATION_FACE; } - else if (G.totedgesel == 1) + else if (em->totedgesel == 1) { EditEdge *eed; @@ -551,7 +551,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac } result = ORIENTATION_EDGE; } - else if (G.totvertsel == 2) + else if (em->totvertsel == 2) { EditVert *v1 = NULL, *v2 = NULL; @@ -573,7 +573,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac } result = ORIENTATION_EDGE; } - else if (G.totvertsel == 1) + else if (em->totvertsel == 1) { for (eve = em->verts.first; eve; eve = eve->next) { @@ -584,7 +584,7 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac } result = ORIENTATION_VERT; } - else if (G.totvertsel > 3) + else if (em->totvertsel > 3) { normal[0] = normal[1] = normal[2] = 0; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e322da88438..759a0f7a452 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -514,6 +514,13 @@ typedef struct SculptData char pad[5]; } SculptData; +typedef struct bStats { + /* scene totals for visible layers */ + int totobj, totlamp, totobjsel, totcurve, totmesh, totarmature; + int totvert, totface; +} bStats; + + typedef struct Scene { ID id; struct Object *camera; @@ -548,7 +555,8 @@ typedef struct Scene { struct GameFraming framing; - struct ToolSettings *toolsettings; + struct ToolSettings *toolsettings; /* default allocated now */ + struct SceneStats *stats; /* default allocated now */ /* migrate or replace? depends on some internal things... */ /* no, is on the right place (ton) */ |