diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-10-30 11:10:19 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-10-30 11:10:19 +0300 |
commit | ddba379e04e1d87ab06d08c0b25df99866ad581a (patch) | |
tree | 8839cbf120d2e7f7373b1ad630cf1694116b5c27 | |
parent | 9dc00e1a646e8c1610e9679664e2b45ec11f8d57 (diff) |
AnimSys2: Recentering Meshes with ShapeKeys
Meshes with ShapeKeys can now be recentered. Note that this may not be totally stable or thee may be some artifacts somewhere. However, in preliminary tests, this seems to work well enough.
Note: the only situation in which this will not work is if the object is showing a pinned shapekey. Perhaps it would be better to test for multiple mesh users instead, but feedback would be welcome on this...
-rw-r--r-- | source/blender/src/editobject.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 4a70e89dd07..c86c44a00ef 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1913,8 +1913,15 @@ void docenter(int centermode) tot_lib_error++; } else if(G.obedit==0 && (me=get_mesh(base->object)) ) { + short skey_bad= 0; - if(me->key) { + /* not all shapekeys are bad... just the pinned ones */ + if (me->key) { + if (base->object->shapeflag & OB_SHAPE_LOCK) + skey_bad= 1; + } + + if (skey_bad) { /*error("Can't change the center of a mesh with vertex keys"); return;*/ tot_key_error++; @@ -1943,6 +1950,18 @@ void docenter(int centermode) } me->flag |= ME_ISDONE; + if (me->key) { + KeyBlock *kb; + + for (kb=me->key->block.first; kb; kb=kb->next) { + float *fp= kb->data; + + for (a=0; a<kb->totelem; a++, fp+=3) { + VecSubf(fp, fp, cent); + } + } + } + if(centermode) { Mat3CpyMat4(omat, base->object->obmat); |