diff options
author | Joseph Eagar <joeedh@gmail.com> | 2011-04-15 05:19:13 +0400 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2011-04-15 05:19:13 +0400 |
commit | c98148a963d37fc2f25e125afeb4cf21df6fbf14 (patch) | |
tree | 691a051e27f08e35bf09d35b6fb9c88e4c37b8d2 /source/blender/editors/util | |
parent | 0bba684d08952d0be822f3906ffb2a03b2674cc2 (diff) | |
parent | fa63c297753636c149fbb1a3877d9b3d93601357 (diff) |
=bmesh= merge from trunk at r36153
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r-- | source/blender/editors/util/crazyspace.c | 81 | ||||
-rw-r--r-- | source/blender/editors/util/ed_util.c | 32 | ||||
-rw-r--r-- | source/blender/editors/util/editmode_undo.c | 5 | ||||
-rw-r--r-- | source/blender/editors/util/numinput.c | 11 | ||||
-rw-r--r-- | source/blender/editors/util/undo.c | 13 | ||||
-rw-r--r-- | source/blender/editors/util/util_intern.h | 5 |
6 files changed, 127 insertions, 20 deletions
diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 6b7292fe6c7..13c8204f8a3 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/crazyspace.c + * \ingroup edutil + */ + + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -46,6 +51,11 @@ #include "ED_util.h" +typedef struct { + float *vertexcos; + short *flags; +} MappedUserData; + #define TAN_MAKE_VEC(a, b, c) a[0]= b[0] + 0.2f*(b[0]-c[0]); a[1]= b[1] + 0.2f*(b[1]-c[1]); a[2]= b[2] + 0.2f*(b[2]-c[2]) static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, float *def1, float *def2, float *def3) { @@ -66,10 +76,16 @@ static void set_crazy_vertex_quat(float *quat, float *v1, float *v2, float *v3, static void make_vertexcos__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s)) { - float *vec = userData; + MappedUserData *mappedData= (MappedUserData*)userData; + float *vec = mappedData->vertexcos; vec+= 3*index; - VECCOPY(vec, co); + if(!mappedData->flags[index]) { + /* we need coord from prototype vertex, not it clones or images, + suppose they stored in the beginning of vertex array stored in DM */ + VECCOPY(vec, co); + mappedData->flags[index]= 1; + } } static int modifiers_disable_subsurf_temporary(Object *ob) @@ -93,6 +109,9 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) Mesh *me= obedit->data; DerivedMesh *dm; float *vertexcos; + 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)) { @@ -103,19 +122,73 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) /* now get the cage */ dm= editbmesh_get_derived_cage(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH); - vertexcos= MEM_mallocN(3*sizeof(float)*me->edit_btmesh->bm->totvert, "vertexcos map"); - dm->foreachMappedVert(dm, make_vertexcos__mapFunc, vertexcos); + vertexcos= MEM_callocN(3*sizeof(float)*nverts, "vertexcos map"); + flags= MEM_callocN(sizeof(short)*nverts, "vertexcos flags"); + + userData.vertexcos= vertexcos; + userData.flags= flags; + dm->foreachMappedVert(dm, make_vertexcos__mapFunc, &userData); dm->release(dm); /* set back the flag, no new cage needs to be built, transform does it */ modifiers_disable_subsurf_temporary(obedit); + MEM_freeN(flags); + return vertexcos; } void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mappedcos, float *quats) { + 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) { + 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; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 314fcdc601b..e83138acf46 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -26,6 +26,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/ed_util.c + * \ingroup edutil + */ + + #include <stdlib.h> #include <string.h> #include <math.h> @@ -52,6 +57,7 @@ #include "ED_util.h" #include "UI_interface.h" +#include "UI_resources.h" #include "WM_types.h" #include "RNA_access.h" @@ -151,13 +157,13 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl ctrl= !ctrl; if(ctrl && shift) { - if(fac3!= 0.0) *val= fac3*floor(*val/fac3 +.5); + if(fac3 != 0.0f) *val= fac3*floorf(*val/fac3 +0.5f); } else if(ctrl) { - if(fac2!= 0.0) *val= fac2*floor(*val/fac2 +.5); + if(fac2 != 0.0f) *val= fac2*floorf(*val/fac2 +0.5f); } else { - if(fac1!= 0.0) *val= fac1*floor(*val/fac1 +.5); + if(fac1 != 0.0f) *val= fac1*floorf(*val/fac1 +0.5f); } } @@ -179,11 +185,11 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha uiLayout *layout; char line[FILE_MAXDIR + FILE_MAXFILE + 100]; - pup= uiPupMenuBegin(C, "Unpack file", ICON_NULL); + pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE); layout= uiPupMenuLayout(pup); sprintf(line, "Remove Pack"); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_string_set(&props_ptr, "id", id_name); @@ -197,7 +203,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(local_name, pf)) { case PF_NOFILE: sprintf(line, "Create %s", local_name); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -205,7 +211,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha case PF_EQUAL: sprintf(line, "Use %s (identical)", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -213,13 +219,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha case PF_DIFFERS: sprintf(line, "Use %s (differs)", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); sprintf(line, "Overwrite %s", local_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; @@ -231,27 +237,27 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha case PF_NOFILE: sprintf(line, "Create %s", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: sprintf(line, "Use %s (identical)", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: sprintf(line, "Use %s (differs)", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); sprintf(line, "Overwrite %s", abs_name); //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NULL, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 1e6f7cd8804..6f4bbff8a0b 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/editmode_undo.c + * \ingroup edutil + */ + + #include <stdlib.h> #include <string.h> diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 6ae5963564e..1b58a1e2a58 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/numinput.c + * \ingroup edutil + */ + + #include <math.h> /* fabs */ #include <stdio.h> /* for sprintf */ @@ -80,7 +85,7 @@ void outputNumInput(NumInput *n, char *str) else inv[0] = 0; - if( n->val[i] > 1e10 || n->val[i] < -1e10 ) + if( n->val[i] > 1e10f || n->val[i] < -1e10f ) sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur); else switch (n->ctrl[i]) { @@ -276,7 +281,7 @@ char handleNumInput(NumInput *n, wmEvent *event) if (!n->ctrl[idx]) n->ctrl[idx] = 1; - if (fabs(n->val[idx]) > 9999999.0f); + if (fabsf(n->val[idx]) > 9999999.0f); else if (n->ctrl[idx] == 1) { n->val[idx] *= 10; n->val[idx] += Val; @@ -298,7 +303,7 @@ char handleNumInput(NumInput *n, wmEvent *event) } } - printf("%f\n", n->val[idx]); + // printf("%f\n", n->val[idx]); /* REDRAW SINCE NUMBERS HAVE CHANGED */ return 1; diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index c2f8ae16cb8..60f551afa6e 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -27,6 +27,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/undo.c + * \ingroup edutil + */ + + #include <stdlib.h> #include <string.h> @@ -75,6 +80,9 @@ void ED_undo_push(bContext *C, const char *str) Object *obedit= CTX_data_edit_object(C); Object *obact= CTX_data_active_object(C); + if (G.f & G_DEBUG) + printf("undo push %s\n", str); + if(obedit) { if (U.undosteps == 0) return; @@ -354,6 +362,11 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) if (G.f & G_DEBUG) printf("redo_cb: operator redo %s\n", op->type->name); ED_undo_pop_op(C, op); + + if(op->type->check) { + op->type->check(C, op); /* ignore return value since its running again anyway */ + } + retval= WM_operator_repeat(C, op); if((retval & OPERATOR_FINISHED)==0) { if (G.f & G_DEBUG) diff --git a/source/blender/editors/util/util_intern.h b/source/blender/editors/util/util_intern.h index c448377f6b0..9ecfb07d535 100644 --- a/source/blender/editors/util/util_intern.h +++ b/source/blender/editors/util/util_intern.h @@ -26,6 +26,11 @@ * ***** END GPL LICENSE BLOCK ***** */ +/** \file blender/editors/util/util_intern.h + * \ingroup edutil + */ + + #ifndef ED_UTIL_INTERN_H #define ED_UTIL_INTERN_H |