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:
authorJoshua Leung <aligorith@gmail.com>2012-07-23 17:33:09 +0400
committerJoshua Leung <aligorith@gmail.com>2012-07-23 17:33:09 +0400
commita5d08781fc9d113830d700181957b7ba3b37eb81 (patch)
treed4a073ee78bcd01ea3d86a4d2714eb9f9420e107 /source/blender/editors/mesh
parent02ec32b60e94913f3c7a742ba25797303379b4ec (diff)
Bugfix [#31994] Blend from Shape "Add" mode incorrectly added the full mesh
shape instead of just the difference/deltas applied by the source shape Apparently this was a regression from that crept in during the BMesh merge. I've just restored the pre-BMesh method, adapted for the BMesh style. Also, removed a somewhat superfluous (?) copy at the end of each step (from co back to sco). It didn't seem to be serving any purpose (i.e. we're not trying to modify the source shape at all).
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 072c66c60d8..0de4c148d95 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
@@ -2231,6 +2232,8 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
{
Object *obedit = CTX_data_edit_object(C);
Mesh *me = obedit->data;
+ Key *key = me->key;
+ KeyBlock *kb = NULL;
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMIter iter;
@@ -2244,24 +2247,34 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
totshape = CustomData_number_of_layers(&em->bm->vdata, CD_SHAPEKEY);
if (totshape == 0 || shape < 0 || shape >= totshape)
return OPERATOR_CANCELLED;
-
+
+ /* get shape key - needed for finding reference shape (for add mode only) */
+ if (key) {
+ kb = BLI_findlink(&key->block, shape);
+ }
+
+ /* perform blending on selected vertices*/
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_SELECT) || BM_elem_flag_test(eve, BM_ELEM_HIDDEN))
continue;
-
+
+ /* get coordinates of shapekey we're blending from */
sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape);
copy_v3_v3(co, sco);
-
-
+
if (add) {
- mul_v3_fl(co, blend);
- add_v3_v3v3(eve->co, eve->co, co);
+ /* in add mode, we add relative shape key offset */
+ if (kb) {
+ float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative);
+ sub_v3_v3v3(co, co, rco);
+ }
+
+ madd_v3_v3fl(eve->co, co, blend);
}
else {
+ /* in blend mode, we interpolate to the shape key */
interp_v3_v3v3(eve->co, eve->co, co, blend);
}
-
- copy_v3_v3(sco, co);
}
EDBM_update_generic(C, em, TRUE);