diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-22 22:47:38 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-22 22:47:38 +0400 |
commit | 9e197399447007e64ee2f8aec36330fd55ddf44f (patch) | |
tree | 8aea7088bbb622398be33a158616bb1cf56af42a /source/blender/src | |
parent | fc169264cd9a6c6aa50e202b1bcb637bfccd65e0 (diff) |
Various stuff in one commit;
- Added (BKE_utildefines.h) POINTER_TO_INT(poin) and INT_TO_POINTER(int)
defines, to help fixing issues with switch to 64 bits systems. This
assumes that a) not more than 16GB mem is used and b) that address
space is below the 1<<35 value. The latter has to be confirmed, but it
seems to conform the current 64 bits generation of OSs (for mallocs).
Needless to say; use long if you want to store pointers! This is for
temporal fixing.
- Added editmesh version for mesh-octree lookups, not used yet.
- Fix: ESC on armature posemode restored the actions, should not happen
- Fix: If in NLA an action was 0 frame long, it caused draw error
- Fix: Click on name in Action Window now activates Bones
- Fix: "Snap to" options in Armature editmode now use X-axis mirror edit.
Diffstat (limited to 'source/blender/src')
-rw-r--r-- | source/blender/src/drawnla.c | 1 | ||||
-rw-r--r-- | source/blender/src/edit.c | 3 | ||||
-rw-r--r-- | source/blender/src/editaction.c | 67 | ||||
-rw-r--r-- | source/blender/src/editarmature.c | 64 | ||||
-rw-r--r-- | source/blender/src/editmesh_mods.c | 31 | ||||
-rw-r--r-- | source/blender/src/meshtools.c | 77 | ||||
-rw-r--r-- | source/blender/src/poseobject.c | 20 | ||||
-rwxr-xr-x | source/blender/src/transform_conversions.c | 10 | ||||
-rwxr-xr-x | source/blender/src/transform_generics.c | 33 |
9 files changed, 172 insertions, 134 deletions
diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index 120ce5c3d8d..5c8a9ade3d9 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -190,6 +190,7 @@ void map_active_strip(gla2DDrawInfo *di, Object *ob, int restore) map= stored; map.xmin= get_action_frame(ob, map.xmin); map.xmax= get_action_frame(ob, map.xmax); + if(map.xmin==map.xmax) map.xmax+= 1.0; gla2DSetMap(di, &map); } } diff --git a/source/blender/src/edit.c b/source/blender/src/edit.c index 877c0f000fd..bb694b189be 100644 --- a/source/blender/src/edit.c +++ b/source/blender/src/edit.c @@ -760,6 +760,7 @@ static void special_transvert_update(void) } } else if(G.obedit->type==OB_ARMATURE){ + bArmature *arm= G.obedit->data; EditBone *ebo; /* Ensure all bones are correctly adjusted */ @@ -776,6 +777,8 @@ static void special_transvert_update(void) } } } + if(arm->flag & ARM_MIRROR_EDIT) + transform_armature_mirror_update(); } else if(G.obedit->type==OB_LATTICE) { if(editLatt->flag & LT_OUTSIDE) outside_lattice(editLatt); diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index 8fb1186af1d..2e56fac2dbd 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -111,21 +111,29 @@ static void bottom_sel_action(void); short showsliders = 0; short ACTWIDTH = NAMEWIDTH; +/* messy call... */ static void select_poseelement_by_name (char *name, int select) { - /* Synchs selection of channels with selection of object elements in posemode */ - + /* Syncs selection of channels with selection of object elements in posemode */ Object *ob= OBACT; - - if (!ob) + bPoseChannel *pchan; + + if (!ob || ob->type!=OB_ARMATURE) return; - - switch (ob->type){ - case OB_ARMATURE: - select_bone_by_name ((bArmature*)ob->data, name, select); - break; - default: - break; + + if(select==2) { + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) + pchan->bone->flag &= ~(BONE_ACTIVE); + } + + pchan= get_pose_channel(ob->pose, name); + if(pchan) { + if(select) + pchan->bone->flag |= (BONE_SELECTED); + else + pchan->bone->flag &= ~(BONE_SELECTED); + if(select==2) + pchan->bone->flag |= (BONE_ACTIVE); } } @@ -187,16 +195,16 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance) for (pchan=armob->pose->chanbase.first; pchan; pchan=pchan->next){ /* Apply to keys */ - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_X); - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Y); - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Z); - insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_X); - insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_Y); - insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_Z); - insertkey(id, ID_AC, pchan->name, NULL, AC_QUAT_W); - insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_X); - insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_Y); - insertkey(id, ID_AC, pchan->name, NULL, AC_SIZE_Z); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z); + insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_X); + insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Y); + insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_Z); + insertkey(id, ID_PO, pchan->name, NULL, AC_QUAT_W); + insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_X); + insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Y); + insertkey(id, ID_PO, pchan->name, NULL, AC_SIZE_Z); } } @@ -225,6 +233,7 @@ bAction* bake_action_with_client (bAction *act, Object *armob, float tolerance) } /* apparently within active object context */ +/* called extern, like on bone selection */ void select_actionchannel_by_name (bAction *act, char *name, int select) { bActionChannel *chan; @@ -237,12 +246,10 @@ void select_actionchannel_by_name (bAction *act, char *name, int select) if (select){ chan->flag |= ACHAN_SELECTED; hilight_channel (act, chan, 1); - select_poseelement_by_name(chan->name, 1); } else{ chan->flag &= ~ACHAN_SELECTED; hilight_channel (act, chan, 0); - select_poseelement_by_name(chan->name, 0); } return; } @@ -571,7 +578,7 @@ static void mouse_action(int selectmode) chan->flag |= ACHAN_SELECTED; hilight_channel (act, chan, 1); - select_poseelement_by_name(chan->name, 1); + select_poseelement_by_name(chan->name, 2); /* 2 is activate */ } if (conchan) @@ -586,7 +593,8 @@ static void mouse_action(int selectmode) allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWACTION, 0); allqueue(REDRAWNLA, 0); - + allqueue(REDRAWOOPS, 0); + allqueue(REDRAWBUTSALL, 0); } } @@ -686,7 +694,7 @@ void borderselect_action(void) /* Check action */ ymin=ymax-(CHANNELHEIGHT+CHANNELSKIP); if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) - borderselect_ipo_key(chan->ipo, rectf.xmin, rectf.xmax, + borderselect_ipo_key(chan->ipo, rectf.xmin, rectf.xmax, selectmode); ymax=ymin; @@ -1378,7 +1386,7 @@ static int select_constraint_channel(bAction *act, return flag; } - +/* lefthand side */ static void mouse_actionchannels(bAction *act, short *mval, short *mvalo, int selectmode) { /* Select action channels, based on mouse values. @@ -1455,6 +1463,9 @@ static void mouse_actionchannels(bAction *act, short *mval, */ sel = (chan->flag & ACHAN_SELECTED); select_channel(act, chan, selectmode); + /* messy... */ + select_poseelement_by_name(chan->name, 2); + } --clickmin; --clickmax; @@ -1475,6 +1486,8 @@ static void mouse_actionchannels(bAction *act, short *mval, allqueue (REDRAWVIEW3D, 0); allqueue (REDRAWACTION, 0); allqueue (REDRAWNLA, 0); + allqueue (REDRAWOOPS, 0); + allqueue (REDRAWBUTSALL, 0); } void delete_meshchannel_keys(Key *key) diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 8d53d3b5246..68883e3ed3b 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -542,38 +542,6 @@ static void *get_nearest_bone (short findunsel) /* **************** END PoseMode & EditMode *************************** */ /* **************** Posemode stuff ********************** */ -static int select_bonechildren_by_name (Bone *bone, char *name, int select) -{ - Bone *curBone; - - if (!strcmp (bone->name, name)){ - if (select) - bone->flag |= BONE_SELECTED; - else - bone->flag &= ~(BONE_SELECTED|BONE_ACTIVE); - return 1; - } - - for (curBone=bone->childbase.first; curBone; curBone=curBone->next){ - if (select_bonechildren_by_name (curBone, name, select)) - return 1; - } - - return 0; -} - -/* called in editaction.c */ -void select_bone_by_name (bArmature *arm, char *name, int select) -{ - Bone *bone; - - if (!arm) - return; - - for (bone=arm->bonebase.first; bone; bone=bone->next) - if (select_bonechildren_by_name (bone, name, select)) - break; -} static void selectconnected_posebonechildren (Object *ob, Bone *bone) { @@ -2523,3 +2491,35 @@ EditBone *armature_bone_get_mirrored(EditBone *ebo) return eboflip; } +/* if editbone (partial) selected, copy data */ +/* context; editmode armature, with mirror editing enabled */ +void transform_armature_mirror_update(void) +{ + EditBone *ebo, *eboflip; + + for (ebo=G.edbo.first; ebo; ebo=ebo->next) { + if(ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) { + + eboflip= armature_bone_get_mirrored(ebo); + + if(eboflip) { + /* we assume X-axis flipping for now */ + if(ebo->flag & BONE_TIPSEL) { + eboflip->tail[0]= -ebo->tail[0]; + eboflip->tail[1]= ebo->tail[1]; + eboflip->tail[2]= ebo->tail[2]; + eboflip->rad_tail= ebo->rad_tail; + } + if(ebo->flag & BONE_ROOTSEL) { + eboflip->head[0]= -ebo->head[0]; + eboflip->head[1]= ebo->head[1]; + eboflip->head[2]= ebo->head[2]; + eboflip->rad_head= ebo->rad_head; + } + if(ebo->flag & BONE_SELECTED) + eboflip->dist= ebo->dist; + } + } + } +} + diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index 1a6fff07a8d..61115ba0e34 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -77,6 +77,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BIF_glutil.h" #include "BIF_graphics.h" #include "BIF_interface.h" +#include "BIF_meshtools.h" #include "BIF_mywindow.h" #include "BIF_resources.h" #include "BIF_screen.h" @@ -99,6 +100,36 @@ editmesh_mods.c, UI level access, no geometry changes #include "editmesh.h" +/* ****************************** MIRROR **************** */ + +static EditVert *get_x_mirror_vert(EditVert *eve) +{ + int index; + + index= mesh_get_x_mirror_vert(G.obedit, POINTER_TO_INT(eve)); + if(index != -1) + return INT_TO_POINTER(index); + return NULL; +} + +void EM_select_mirrored(void) +{ + if(G.scene->selectmode & SCE_SELECT_VERTEX) { + EditMesh *em = G.editMesh; + EditVert *eve, *v1; + + for(eve= em->verts.first; eve; eve= eve->next) { + if(eve->f & SELECT) { + v1= get_x_mirror_vert(eve); + if(v1) { + eve->f &= ~SELECT; + v1->f |= SELECT; + } + } + } + } +} + /* ****************************** SELECTION ROUTINES **************** */ unsigned int em_solidoffs=0, em_wireoffs=0, em_vertoffs=0; // set in drawobject.c ... for colorindices diff --git a/source/blender/src/meshtools.c b/source/blender/src/meshtools.c index d55df548bfb..13163703f75 100644 --- a/source/blender/src/meshtools.c +++ b/source/blender/src/meshtools.c @@ -84,6 +84,8 @@ void sort_faces(void); #include "BDR_editobject.h" #include "BDR_editface.h" +#include "BLI_editVert.h" + #include "mydevice.h" #include "blendef.h" @@ -644,28 +646,6 @@ static void mesh_octree_free_node(MocNode **bt) MEM_freeN(*bt); } -static int mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co) -{ - MVert *testvert; - int a; - - if(*bt==NULL) - return -1; - - for(a=0; a<MOC_NODE_RES; a++) { - if((*bt)->index[a]) { - testvert= mvert+(*bt)->index[a]-1; - - if(FloatCompare(testvert->co, co, MOC_THRESH)) - return (*bt)->index[a]-1; - } - else return -1; - } - if( (*bt)->next) - return mesh_octree_find_index(&(*bt)->next, mvert, co); - - return -1; -} /* temporal define, just to make nicer code below */ #define MOC_ADDNODE(vx, vy, vz) mesh_octree_add_node(basetable + ((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz), index) @@ -711,6 +691,34 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f } +static int mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co) +{ + float *vec; + int a; + + if(*bt==NULL) + return -1; + + for(a=0; a<MOC_NODE_RES; a++) { + if((*bt)->index[a]) { + /* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */ + if(mvert) + vec= (mvert+(*bt)->index[a]-1)->co; + else + vec= ((EditVert *)INT_TO_POINTER((*bt)->index[a]))->co; + + if(FloatCompare(vec, co, MOC_THRESH)) + return (*bt)->index[a]-1; + } + else return -1; + } + if( (*bt)->next) + return mesh_octree_find_index(&(*bt)->next, mvert, co); + + return -1; +} + + /* mode is 's' start, or 'e' end, or 'u' use */ /* if end, ob can be NULL */ int mesh_octree_table(Object *ob, float *co, char mode) @@ -718,20 +726,21 @@ int mesh_octree_table(Object *ob, float *co, char mode) MocNode **bt; static MocNode **basetable= NULL; static float offs[3], div[3]; - int a; if(mode=='u') { /* use table */ if(basetable) { Mesh *me= ob->data; bt= basetable + mesh_octree_get_base_offs(co, offs, div); - return mesh_octree_find_index(bt, me->mvert, co); + if(ob==G.obedit) + return mesh_octree_find_index(bt, NULL, co); + else + return mesh_octree_find_index(bt, me->mvert, co); } return -1; } else if(mode=='s') { /* start table */ Mesh *me= ob->data; BoundBox *bb = mesh_get_bb(me); - MVert *mvert; /* for quick unit coordinate calculus */ VECCOPY(offs, bb->vec[0]); @@ -746,12 +755,26 @@ int mesh_octree_table(Object *ob, float *co, char mode) basetable= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table"); - for(a=1, mvert= me->mvert; a<=me->totvert; a++, mvert++) { - mesh_octree_add_nodes(basetable, mvert->co, offs, div, a); + if(ob==G.obedit) { + EditVert *eve; + + for(eve= G.editMesh->verts.first; eve; eve= eve->next) { + mesh_octree_add_nodes(basetable, eve->co, offs, div, POINTER_TO_INT(eve)); + } + } + else { + MVert *mvert; + int a; + + for(a=1, mvert= me->mvert; a<=me->totvert; a++, mvert++) { + mesh_octree_add_nodes(basetable, mvert->co, offs, div, a); + } } } else if(mode=='e') { /* end table */ if(basetable) { + int a; + for(a=0, bt=basetable; a<MOC_RES*MOC_RES*MOC_RES; a++, bt++) { if(*bt) mesh_octree_free_node(bt); } diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index 499c55b688d..8d3d776eb91 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -540,20 +540,20 @@ void paste_posebuf (int flip) ID *id= &ob->id; /* Set keys on pose */ if (chan->flag & POSE_ROT){ - insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_X); - insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_Y); - insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_Z); - insertkey(id, ID_AC, chan->name, NULL, AC_QUAT_W); + insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_X); + insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_Y); + insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_Z); + insertkey(id, ID_PO, chan->name, NULL, AC_QUAT_W); } if (chan->flag & POSE_SIZE){ - insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_X); - insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_Y); - insertkey(id, ID_AC, chan->name, NULL, AC_SIZE_Z); + insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_X); + insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_Y); + insertkey(id, ID_PO, chan->name, NULL, AC_SIZE_Z); } if (chan->flag & POSE_LOC){ - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_X); - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Y); - insertkey(id, ID_AC, pchan->name, NULL, AC_LOC_Z); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_X); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Y); + insertkey(id, ID_PO, pchan->name, NULL, AC_LOC_Z); } } } diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index f50addf9aae..3abc2a45cff 100755 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -1618,11 +1618,10 @@ void special_aftertrans_update(TransInfo *t) ob= t->poseobj; arm= ob->data; - ob->pose->flag &= ~POSE_LOCKED; + /* this signal does one recalc on pose, then unlocks, so ESC or edit will work */ + ob->pose->flag |= POSE_DO_UNLOCK; - if(cancelled) /* if cancelled we do the update always */ - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - else if(G.flags & G_RECORDKEYS) { + if(G.flags & G_RECORDKEYS) { act= ob->action; pose= ob->pose; @@ -1661,7 +1660,8 @@ void special_aftertrans_update(TransInfo *t) DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); ob->recalc= 0; // is set on OK position already by recalcData() } - /* do not call DAG_object_flush_update always, we dont want actions to update, for inserting keys */ + else + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); if(t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE) allqueue(REDRAWBUTSEDIT, 0); diff --git a/source/blender/src/transform_generics.c b/source/blender/src/transform_generics.c index 9ad394a3d60..2173628a11b 100755 --- a/source/blender/src/transform_generics.c +++ b/source/blender/src/transform_generics.c @@ -122,39 +122,6 @@ void getViewVector(float coord[3], float vec[3]) /* ************************** GENERICS **************************** */ -/* if editbone (partial) selected, copy data */ -/* context; editmode armature, with mirror editing enabled */ -static void transform_armature_mirror_update(void) -{ - EditBone *ebo, *eboflip; - - for (ebo=G.edbo.first; ebo; ebo=ebo->next) { - if(ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) { - - eboflip= armature_bone_get_mirrored(ebo); - - if(eboflip) { - /* we assume X-axis flipping for now */ - if(ebo->flag & BONE_TIPSEL) { - eboflip->tail[0]= -ebo->tail[0]; - eboflip->tail[1]= ebo->tail[1]; - eboflip->tail[2]= ebo->tail[2]; - eboflip->rad_tail= ebo->rad_tail; - } - if(ebo->flag & BONE_ROOTSEL) { - eboflip->head[0]= -ebo->head[0]; - eboflip->head[1]= ebo->head[1]; - eboflip->head[2]= ebo->head[2]; - eboflip->rad_head= ebo->rad_head; - } - if(ebo->flag & BONE_SELECTED) - eboflip->dist= ebo->dist; - } - } - } -} - - /* called for objects updating while transform acts, once per redraw */ void recalcData(TransInfo *t) { |