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:
Diffstat (limited to 'source/blender/editors/mesh/editmesh_tools.c')
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index d1ff06ec213..e22dab2f3c8 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -26,6 +26,11 @@
* ***** END GPL LICENSE BLOCK *****
*/
+/** \file blender/editors/mesh/editmesh_tools.c
+ * \ingroup edmesh
+ */
+
+
/*
editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise in mods.c
@@ -5199,27 +5204,38 @@ static int blend_from_shape_exec(bContext *C, wmOperator *op)
Key *key= me->key;
EditMesh *em= BKE_mesh_get_editmesh(me);
EditVert *eve;
- KeyBlock *kb;
- float *data, co[3];
+ KeyBlock *kb, *refkb= NULL;
+ float *data, *refdata= NULL, co[3];
float blend= RNA_float_get(op->ptr, "blend");
int shape= RNA_enum_get(op->ptr, "shape");
- int add= RNA_int_get(op->ptr, "add");
+ int add= RNA_boolean_get(op->ptr, "add");
int blended= 0;
if(key && (kb= BLI_findlink(&key->block, shape))) {
data= kb->data;
+ if(add) {
+ refkb= BLI_findlink(&key->block, kb->relative);
+ if(refkb)
+ refdata = refkb->data;
+ }
+
for(eve=em->verts.first; eve; eve=eve->next){
if(eve->f & SELECT) {
if(eve->keyindex >= 0 && eve->keyindex < kb->totelem) {
- VECCOPY(co, data + eve->keyindex*3);
+ copy_v3_v3(co, data + eve->keyindex*3);
if(add) {
- mul_v3_fl(co, blend);
- add_v3_v3(eve->co, co);
+ /* in add mode, we add relative shape key offset */
+ if(refdata && eve->keyindex < refkb->totelem)
+ sub_v3_v3v3(co, co, refdata + eve->keyindex*3);
+
+ madd_v3_v3fl(eve->co, co, blend);
}
- else
+ else {
+ /* in blend mode, we interpolate to the shape key */
interp_v3_v3v3(eve->co, eve->co, co, blend);
+ }
blended= 1;
}