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/armature')
-rw-r--r--source/blender/editors/armature/CMakeLists.txt39
-rw-r--r--source/blender/editors/armature/Makefile3
-rw-r--r--source/blender/editors/armature/SConscript1
-rw-r--r--source/blender/editors/armature/armature_intern.h3
-rw-r--r--source/blender/editors/armature/armature_ops.c28
-rw-r--r--source/blender/editors/armature/editarmature.c263
-rw-r--r--source/blender/editors/armature/editarmature_generate.c11
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c13
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c59
-rw-r--r--source/blender/editors/armature/meshlaplacian.c224
-rw-r--r--source/blender/editors/armature/meshlaplacian.h2
-rw-r--r--source/blender/editors/armature/poseSlide.c8
-rw-r--r--source/blender/editors/armature/poseUtils.c7
-rw-r--r--source/blender/editors/armature/poselib.c41
-rw-r--r--source/blender/editors/armature/poseobject.c239
-rw-r--r--source/blender/editors/armature/reeb.c23
16 files changed, 519 insertions, 445 deletions
diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt
new file mode 100644
index 00000000000..9e22bbd7d44
--- /dev/null
+++ b/source/blender/editors/armature/CMakeLists.txt
@@ -0,0 +1,39 @@
+# $Id: CMakeLists.txt 12931 2007-12-17 18:20:48Z theeth $
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.c)
+
+SET(INC
+ ../include
+ ../../blenkernel
+ ../../blenlib
+ ../../makesdna
+ ../../makesrna
+ ../../windowmanager
+ ../../../../intern/guardedalloc
+ ../../../../intern/opennl/extern
+)
+
+IF(WIN32)
+ SET(INC ${INC} ${PTHREADS_INC})
+ENDIF(WIN32)
+
+BLENDERLIB(bf_editor_armature "${SRC}" "${INC}")
diff --git a/source/blender/editors/armature/Makefile b/source/blender/editors/armature/Makefile
index 0291bcb1830..707ceb55246 100644
--- a/source/blender/editors/armature/Makefile
+++ b/source/blender/editors/armature/Makefile
@@ -15,7 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# The Original Code is Copyright (C) 2007 Blender Foundation
# All rights reserved.
@@ -50,7 +50,6 @@ CPPFLAGS += -I../../imbuf
CPPFLAGS += -I../../python
CPPFLAGS += -I../../gpu
CPPFLAGS += -I../../makesrna
-CPPFLAGS += -I../../render/extern/include
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
# own include
diff --git a/source/blender/editors/armature/SConscript b/source/blender/editors/armature/SConscript
index fd4b885b730..33e237a14db 100644
--- a/source/blender/editors/armature/SConscript
+++ b/source/blender/editors/armature/SConscript
@@ -5,7 +5,6 @@ sources = env.Glob('*.c')
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
-incs += ' ../../render/extern/include'
incs += ' ../../gpu ../../makesrna #/intern/opennl/extern'
if env['OURPLATFORM'] == 'linux2':
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 099cfeddad7..fadb4f234d9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -107,6 +107,8 @@ void POSE_OT_group_remove(struct wmOperatorType *ot);
void POSE_OT_group_remove(struct wmOperatorType *ot);
void POSE_OT_group_assign(struct wmOperatorType *ot);
void POSE_OT_group_unassign(struct wmOperatorType *ot);
+void POSE_OT_group_select(struct wmOperatorType *ot);
+void POSE_OT_group_deselect(struct wmOperatorType *ot);
void POSE_OT_paths_calculate(struct wmOperatorType *ot);
void POSE_OT_paths_clear(struct wmOperatorType *ot);
@@ -130,6 +132,7 @@ void SKETCH_OT_draw_stroke(struct wmOperatorType *ot);
void SKETCH_OT_draw_preview(struct wmOperatorType *ot);
void SKETCH_OT_finish_stroke(struct wmOperatorType *ot);
void SKETCH_OT_cancel_stroke(struct wmOperatorType *ot);
+void SKETCH_OT_convert(struct wmOperatorType *ot);
void SKETCH_OT_select(struct wmOperatorType *ot);
/* ******************************************************* */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 4384e2c5f98..d5bd09cc8f1 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -29,15 +29,11 @@
#include <stdlib.h>
#include <math.h>
-#include "MEM_guardedalloc.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
-#include "BKE_context.h"
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -96,6 +92,7 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(SKETCH_OT_draw_preview);
WM_operatortype_append(SKETCH_OT_finish_stroke);
WM_operatortype_append(SKETCH_OT_cancel_stroke);
+ WM_operatortype_append(SKETCH_OT_convert);
WM_operatortype_append(SKETCH_OT_select);
/* POSE */
@@ -125,6 +122,8 @@ void ED_operatortypes_armature(void)
WM_operatortype_append(POSE_OT_group_remove);
WM_operatortype_append(POSE_OT_group_assign);
WM_operatortype_append(POSE_OT_group_unassign);
+ WM_operatortype_append(POSE_OT_group_select);
+ WM_operatortype_append(POSE_OT_group_deselect);
WM_operatortype_append(POSE_OT_paths_calculate);
WM_operatortype_append(POSE_OT_paths_clear);
@@ -189,14 +188,15 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* Armature -> Etch-A-Ton ------------------------ */
WM_keymap_add_item(keymap, "SKETCH_OT_delete", XKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", SELECTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
+ // Already part of view3d select
+ //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
/* sketch poll checks mode */
- WM_keymap_add_item(keymap, "SKETCH_OT_gesture", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0);
- WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", ACTIONMOUSE, KM_PRESS, 0, 0);
- kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", ACTIONMOUSE, KM_PRESS, KM_CTRL, 0);
+ WM_keymap_add_item(keymap, "SKETCH_OT_gesture", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, 0, 0);
+ kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "snap", 1);
WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, 0, 0);
kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_preview", MOUSEMOVE, KM_ANY, KM_CTRL, 0);
@@ -256,7 +256,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* special transforms: */
/* 1) envelope/b-bone size */
- kmi= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0);
+ kmi= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE);
/* 2) set roll */
kmi= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0);
@@ -277,9 +277,9 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
kmi= WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", 1);
WM_keymap_add_item(keymap, "POSE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
-
+
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0);
-
+
// TODO: clear pose
WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0);
@@ -333,10 +333,10 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
/* special transforms: */
/* 1) envelope/b-bone size */
- kmi= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0);
+ kmi= WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE);
- // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
+ /* keyframes management */
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 5f0c2e3d4be..174aadab687 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -27,11 +27,11 @@
#include <ctype.h>
#include <stdlib.h>
+#include <stddef.h>
#include <string.h>
#include <math.h>
#include <float.h>
-#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
#include "DNA_armature_types.h"
@@ -39,6 +39,8 @@
#include "DNA_meshdata_types.h"
#include "DNA_scene_types.h"
+#include "MEM_guardedalloc.h"
+
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
@@ -58,11 +60,10 @@
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_subsurf.h"
-#include "BKE_utildefines.h"
#include "BKE_modifier.h"
+#include "DNA_object_types.h"
#include "BIF_gl.h"
-#include "BIF_generate.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -88,7 +89,6 @@
#endif
/* ************* XXX *************** */
-static int okee() {return 0;}
static void BIF_undo_push(const char *msg) {}
/* ************* XXX *************** */
@@ -140,7 +140,7 @@ static void bone_free(bArmature *arm, EditBone *bone)
BLI_freelinkN(arm->edbo, bone);
}
-void ED_armature_edit_bone_remove(bArmature *arm, EditBone* exBone)
+void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
{
EditBone *curBone;
@@ -422,81 +422,81 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
/* exported for use in editors/object/ */
/* 0 == do center, 1 == center new, 2 == center cursor */
-void docenter_armature (Scene *scene, View3D *v3d, Object *ob, int centermode)
+void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermode, int around)
{
Object *obedit= scene->obedit; // XXX get from context
EditBone *ebone;
bArmature *arm= ob->data;
- float cent[3] = {0.0f, 0.0f, 0.0f};
- float min[3], max[3];
- float omat[3][3];
+ float cent[3];
/* Put the armature into editmode */
- if(ob!=obedit)
+ if(ob != obedit) {
ED_armature_to_edit(ob);
+ obedit= NULL; /* we cant use this so behave as if there is no obedit */
+ }
/* Find the centerpoint */
if (centermode == 2) {
- float *fp= give_cursor(scene, v3d);
- VECCOPY(cent, fp);
+ copy_v3_v3(cent, cursor);
invert_m4_m4(ob->imat, ob->obmat);
mul_m4_v3(ob->imat, cent);
}
else {
- INIT_MINMAX(min, max);
-
- for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
- DO_MINMAX(ebone->head, min, max);
- DO_MINMAX(ebone->tail, min, max);
+ if(around==V3D_CENTROID) {
+ int total= 0;
+ zero_v3(cent);
+ for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+ total+=2;
+ add_v3_v3(cent, ebone->head);
+ add_v3_v3(cent, ebone->tail);
+ }
+ mul_v3_fl(cent, 1.0f/(float)total);
+ }
+ else {
+ float min[3], max[3];
+ INIT_MINMAX(min, max);
+ for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+ DO_MINMAX(ebone->head, min, max);
+ DO_MINMAX(ebone->tail, min, max);
+ }
+ mid_v3_v3v3(cent, min, max);
}
-
- cent[0]= (min[0] + max[0]) / 2.0f;
- cent[1]= (min[1] + max[1]) / 2.0f;
- cent[2]= (min[2] + max[2]) / 2.0f;
}
/* Do the adjustments */
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
- sub_v3_v3v3(ebone->head, ebone->head, cent);
- sub_v3_v3v3(ebone->tail, ebone->tail, cent);
+ sub_v3_v3(ebone->head, cent);
+ sub_v3_v3(ebone->tail, cent);
}
/* Turn the list into an armature */
- ED_armature_from_edit(ob);
-
+ if(obedit==NULL) {
+ ED_armature_from_edit(ob);
+ ED_armature_edit_free(ob);
+ }
+
/* Adjust object location for new centerpoint */
if(centermode && obedit==NULL) {
- copy_m3_m4(omat, ob->obmat);
-
- mul_m3_v3(omat, cent);
- ob->loc[0] += cent[0];
- ob->loc[1] += cent[1];
- ob->loc[2] += cent[2];
+ mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
+ add_v3_v3(ob->loc, cent);
}
- else
- ED_armature_edit_free(ob);
}
/* ---------------------- */
-static EditBone *editbone_name_exists (ListBase *edbo, char *name)
+/* checks if an EditBone with a matching name already, returning the matching bone if it exists */
+static EditBone *editbone_name_exists (ListBase *edbo, const char *name)
{
- EditBone *eBone;
-
- for (eBone=edbo->first; eBone; eBone=eBone->next) {
- if (!strcmp(name, eBone->name))
- return eBone;
- }
- return NULL;
+ return BLI_findstring(edbo, name, offsetof(EditBone, name));
}
/* note: there's a unique_bone_name() too! */
void unique_editbone_name (ListBase *edbo, char *name, EditBone *bone)
{
EditBone *dupli;
- char tempname[64];
- int number;
- char *dot;
+ char tempname[64];
+ int number;
+ char *dot;
dupli = editbone_name_exists(edbo, name);
@@ -804,6 +804,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* join armature exec is exported for use in object->join objects operator... */
int join_armature_exec(bContext *C, wmOperator *op)
{
+ Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
bArmature *arm= (ob)? ob->data: NULL;
@@ -896,12 +897,12 @@ int join_armature_exec(bContext *C, wmOperator *op)
free_pose_channels_hash(pose);
}
- ED_base_object_free_and_unlink(scene, base);
+ ED_base_object_free_and_unlink(bmain, scene, base);
}
}
CTX_DATA_END;
- DAG_scene_sort(scene); // because we removed object(s)
+ DAG_scene_sort(bmain, scene); // because we removed object(s)
ED_armature_from_edit(ob);
ED_armature_edit_free(ob);
@@ -1113,6 +1114,7 @@ static void separate_armature_bones (Scene *scene, Object *ob, short sel)
/* separate selected bones into their armature */
static int separate_armature_exec (bContext *C, wmOperator *op)
{
+ Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *obedit= CTX_data_edit_object(C);
Object *oldob, *newob;
@@ -1153,7 +1155,7 @@ static int separate_armature_exec (bContext *C, wmOperator *op)
ED_armature_edit_free(obedit);
/* 2) duplicate base */
- newbase= ED_object_add_duplicate(scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
+ newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
newob= newbase->object;
newbase->flag &= ~SELECT;
@@ -1754,9 +1756,8 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
if (ebo == NULL)
return NULL;
-
- BLI_strncpy(name, ebo->name, sizeof(name));
- bone_flip_name(name, 0); // 0 = don't strip off number extensions
+
+ flip_side_name(name, ebo->name, FALSE);
for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) {
if (ebo != eboflip) {
@@ -1927,10 +1928,6 @@ void ED_armature_deselectall(Object *obedit, int toggle, int doundo)
}
ED_armature_sync_selection(arm->edbo);
- if (doundo) {
- if (sel==1) BIF_undo_push("Select All");
- else BIF_undo_push("Deselect All");
- }
}
@@ -2029,21 +2026,11 @@ void ED_armature_edit_free(struct Object *ob)
BLI_freelistN(arm->edbo);
}
-
MEM_freeN(arm->edbo);
arm->edbo= NULL;
}
}
-void ED_armature_edit_remake(Object *obedit)
-{
- if(okee("Reload original data")==0) return;
-
- ED_armature_to_edit(obedit);
-
-// BIF_undo_push("Delete bone");
-}
-
/* Put armature in EditMode */
void ED_armature_to_edit(Object *ob)
{
@@ -2343,12 +2330,10 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
Object *obedit= scene->obedit; // XXX get from context
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
EditBone *bone;
-
- VECCOPY(curs, give_cursor(scene, v3d));
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_m4_v3(obedit->imat, curs);
+ mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
copy_m3_m4(obmat, rv3d->viewmat);
@@ -2363,7 +2348,7 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
/* Create a bone */
bone= ED_armature_edit_bone_add(obedit->data, "Bone");
- VECCOPY(bone->head, curs);
+ copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
@@ -2956,17 +2941,14 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
}
else if (count == 1) {
EditBonePoint *ebp;
- float *fp, curs[3];
+ float curs[3];
/* Get Points - selected joint */
ebp= (EditBonePoint *)points.first;
/* Get points - cursor (tail) */
- fp= give_cursor(scene, v3d);
- VECCOPY (curs, fp);
-
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_m4_v3(obedit->imat, curs);
+ mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
/* Create a bone */
newbone= add_points_bone(obedit, ebp->vec, curs);
@@ -2994,15 +2976,13 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
/* find which one should be the 'head' */
if ((ebp->head_owner && ebp2->head_owner) || (ebp->tail_owner && ebp2->tail_owner)) {
/* rule: whichever one is closer to 3d-cursor */
- float curs[3], *fp= give_cursor(scene, v3d);
+ float curs[3];
float vecA[3], vecB[3];
float distA, distB;
/* get cursor location */
- VECCOPY(curs, fp);
-
invert_m4_m4(obedit->imat, obedit->obmat);
- mul_m4_v3(obedit->imat, curs);
+ mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d));
/* get distances */
sub_v3_v3v3(vecA, ebp->vec, curs);
@@ -3022,12 +3002,12 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
/* assign head/tail combinations */
if (headtail == 2) {
- VECCOPY(head, ebp->vec);
- VECCOPY(tail, ebp2->vec);
+ copy_v3_v3(head, ebp->vec);
+ copy_v3_v3(tail, ebp2->vec);
}
else if (headtail == 1) {
- VECCOPY(head, ebp2->vec);
- VECCOPY(tail, ebp->vec);
+ copy_v3_v3(head, ebp2->vec);
+ copy_v3_v3(tail, ebp->vec);
}
/* add new bone and parent it to the appropriate end */
@@ -3110,16 +3090,16 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
* - parent = parent of start
*/
if ((start->flag & BONE_TIPSEL) && ((start->flag & BONE_SELECTED) || start==arm->act_edbone)==0) {
- VECCOPY(head, start->tail);
+ copy_v3_v3(head, start->tail);
}
else {
- VECCOPY(head, start->head);
+ copy_v3_v3(head, start->head);
}
if ((end->flag & BONE_ROOTSEL) && ((end->flag & BONE_SELECTED) || end==arm->act_edbone)==0) {
- VECCOPY(tail, end->head);
+ copy_v3_v3(tail, end->head);
}
else {
- VECCOPY(tail, end->tail);
+ copy_v3_v3(tail, end->tail);
}
newbone= add_points_bone(obedit, head, tail);
newbone->parent = start->parent;
@@ -3391,8 +3371,8 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
if (do_extrude==1) {
- VECCOPY (newbone->head, ebone->tail);
- VECCOPY (newbone->tail, newbone->head);
+ copy_v3_v3(newbone->head, ebone->tail);
+ copy_v3_v3(newbone->tail, newbone->head);
newbone->parent = ebone;
newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
@@ -3400,8 +3380,8 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
else {
- VECCOPY(newbone->head, ebone->head);
- VECCOPY(newbone->tail, ebone->head);
+ copy_v3_v3(newbone->head, ebone->head);
+ copy_v3_v3(newbone->tail, ebone->head);
newbone->parent= ebone->parent;
newbone->flag= BONE_TIPSEL;
@@ -3491,7 +3471,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
RNA_string_get(op->ptr, "name", name);
- VECCOPY(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C)));
+ copy_v3_v3(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C)));
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
@@ -3510,7 +3490,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
/* Create a bone */
bone= ED_armature_edit_bone_add(obedit->data, name);
- VECCOPY(bone->head, curs);
+ copy_v3_v3(bone->head, curs);
if(rv3d && (U.flag & USER_ADD_VIEWALIGNED))
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
@@ -3580,17 +3560,17 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
BLI_addtail(arm->edbo, newbone);
/* calculate location of newbone->head */
- VECCOPY(val1, ebone->head);
- VECCOPY(val2, ebone->tail);
- VECCOPY(val3, newbone->head);
+ copy_v3_v3(val1, ebone->head);
+ copy_v3_v3(val2, ebone->tail);
+ copy_v3_v3(val3, newbone->head);
val3[0]= val1[0]*cutratio + val2[0]*cutratioI;
val3[1]= val1[1]*cutratio + val2[1]*cutratioI;
val3[2]= val1[2]*cutratio + val2[2]*cutratioI;
- VECCOPY(newbone->head, val3);
- VECCOPY(newbone->tail, ebone->tail);
- VECCOPY(ebone->tail, newbone->head);
+ copy_v3_v3(newbone->head, val3);
+ copy_v3_v3(newbone->tail, ebone->tail);
+ copy_v3_v3(ebone->tail, newbone->head);
newbone->rad_head= 0.5f * (ebone->rad_head + ebone->rad_tail);
ebone->rad_tail= newbone->rad_head;
@@ -3808,7 +3788,7 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
static void bone_connect_to_existing_parent(EditBone *bone)
{
bone->flag |= BONE_CONNECTED;
- VECCOPY(bone->head, bone->parent->tail);
+ copy_v3_v3(bone->head, bone->parent->tail);
bone->rad_head = bone->parent->rad_tail;
}
@@ -3836,10 +3816,10 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
selbone->flag |= BONE_CONNECTED;
sub_v3_v3v3(offset, actbone->tail, selbone->head);
- VECCOPY(selbone->head, actbone->tail);
+ copy_v3_v3(selbone->head, actbone->tail);
selbone->rad_head= actbone->rad_tail;
- add_v3_v3v3(selbone->tail, selbone->tail, offset);
+ add_v3_v3(selbone->tail, offset);
/* offset for all its children */
for (ebone = edbo->first; ebone; ebone=ebone->next) {
@@ -3847,8 +3827,8 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
for (par= ebone->parent; par; par= par->parent) {
if (par==selbone) {
- add_v3_v3v3(ebone->head, ebone->head, offset);
- add_v3_v3v3(ebone->tail, ebone->tail, offset);
+ add_v3_v3(ebone->head, offset);
+ add_v3_v3(ebone->tail, offset);
break;
}
}
@@ -4110,7 +4090,7 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "deselect all editbone";
+ ot->name= "Select or Deselect All";
ot->idname= "ARMATURE_OT_select_all";
/* api callbacks */
@@ -4218,8 +4198,8 @@ static void fix_connected_bone(EditBone *ebone)
/* if the parent has moved we translate child's head and tail accordingly*/
sub_v3_v3v3(diff, ebone->parent->tail, ebone->head);
- add_v3_v3v3(ebone->head, ebone->head, diff);
- add_v3_v3v3(ebone->tail, ebone->tail, diff);
+ add_v3_v3(ebone->head, diff);
+ add_v3_v3(ebone->tail, diff);
return;
}
@@ -4609,7 +4589,7 @@ static void add_vgroups__mapFunc(void *userData, int index, float *co, float *no
/* DerivedMesh mapFunc for getting final coords in weight paint mode */
float (*verts)[3] = userData;
- VECCOPY(verts[index], co);
+ copy_v3_v3(verts[index], co);
}
static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale)
@@ -4672,7 +4652,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m
bArmature *arm= par->data;
Bone **bonelist, *bone;
bDeformGroup **dgrouplist, **dgroupflip;
- bDeformGroup *dgroup, *curdg;
+ bDeformGroup *dgroup;
bPoseChannel *pchan;
Mesh *mesh;
Mat4 *bbone = NULL;
@@ -4736,18 +4716,17 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m
/* compute root and tip */
if (bbone) {
- VECCOPY(root[j], bbone[segments].mat[3]);
- mul_m4_v3(bone->arm_mat, root[j]);
+ mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]);
if ((segments+1) < bone->segments) {
- VECCOPY(tip[j], bbone[segments+1].mat[3])
- mul_m4_v3(bone->arm_mat, tip[j]);
+ mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]);
+ }
+ else {
+ copy_v3_v3(tip[j], bone->arm_tail);
}
- else
- VECCOPY(tip[j], bone->arm_tail)
}
else {
- VECCOPY(root[j], bone->arm_head);
- VECCOPY(tip[j], bone->arm_tail);
+ copy_v3_v3(root[j], bone->arm_head);
+ copy_v3_v3(tip[j], bone->arm_tail);
}
mul_m4_v3(par->obmat, root[j]);
@@ -4764,17 +4743,10 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m
/* find flipped group */
if (dgroup && mirror) {
char name[32];
-
- BLI_strncpy(name, dgroup->name, 32);
+
// 0 = don't strip off number extensions
- bone_flip_name(name, 0);
-
- for (curdg = ob->defbase.first; curdg; curdg=curdg->next) {
- if (!strcmp(curdg->name, name))
- break;
- }
-
- dgroupflip[j] = curdg;
+ flip_side_name(name, dgroup->name, FALSE);
+ dgroupflip[j] = defgroup_find_name(ob, name);
}
}
@@ -4804,7 +4776,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m
/* transform verts to global space */
for (i=0; i < mesh->totvert; i++) {
if (!vertsfilled)
- VECCOPY(verts[i], mesh->mvert[i].co)
+ copy_v3_v3(verts[i], mesh->mvert[i].co);
mul_m4_v3(ob->obmat, verts[i]);
}
@@ -5042,14 +5014,14 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
float eul[3], oldeul[3], quat1[4] = {0};
if (pchan->rotmode == ROT_MODE_QUAT) {
- QUATCOPY(quat1, pchan->quat);
+ copy_qt_qt(quat1, pchan->quat);
quat_to_eul( oldeul,pchan->quat);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle);
}
else {
- VECCOPY(oldeul, pchan->eul);
+ copy_v3_v3(oldeul, pchan->eul);
}
eul[0]= eul[1]= eul[2]= 0.0f;
@@ -5072,10 +5044,10 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT);
}
else {
- VECCOPY(pchan->eul, eul);
+ copy_v3_v3(pchan->eul, eul);
}
}
- }
+ } // Duplicated in source/blender/editors/object/object_transform.c
else {
if (pchan->rotmode == ROT_MODE_QUAT) {
pchan->quat[1]=pchan->quat[2]=pchan->quat[3]= 0.0f;
@@ -5228,7 +5200,7 @@ void POSE_OT_select_all(wmOperatorType *ot)
{
/* identifiers */
- ot->name= "deselect all bones";
+ ot->name= "Select or Deselect All";
ot->idname= "POSE_OT_select_all";
/* api callbacks */
@@ -5292,6 +5264,7 @@ static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr)
if (arm->layer & bone->layer) {
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_HIDDEN_P;
+ bone->flag &= ~BONE_SELECTED;
if(arm->act_bone==bone)
arm->act_bone= NULL;
}
@@ -5494,8 +5467,17 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
/* Rename the pose channel, if it exists */
if (ob->pose) {
bPoseChannel *pchan = get_pose_channel(ob->pose, oldname);
- if (pchan)
+ if (pchan) {
BLI_strncpy(pchan->name, newname, MAXBONENAME);
+
+ if (ob->pose->chanhash) {
+ GHash *gh = ob->pose->chanhash;
+
+ /* remove the old hash entry, and replace with the new name */
+ BLI_ghash_remove(gh, oldname, NULL, NULL);
+ BLI_ghash_insert(gh, pchan->name, pchan);
+ }
+ }
}
/* Update any object constraints to use the new bone name */
@@ -5521,11 +5503,9 @@ void ED_armature_bone_rename(bArmature *arm, char *oldnamep, char *newnamep)
}
if (modifiers_usesArmature(ob, arm)) {
- bDeformGroup *dg;
- /* bone name in defgroup */
- for (dg=ob->defbase.first; dg; dg=dg->next) {
- if (!strcmp(dg->name, oldname))
- BLI_strncpy(dg->name, newname, MAXBONENAME);
+ bDeformGroup *dg= defgroup_find_name(ob, oldname);
+ if(dg) {
+ BLI_strncpy(dg->name, newname, MAXBONENAME);
}
}
@@ -5554,8 +5534,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *op)
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
- BLI_strncpy(newname, ebone->name, sizeof(newname));
- bone_flip_name(newname, 1); // 1 = do strip off number extensions
+ flip_side_name(newname, ebone->name, TRUE); // 1 = do strip off number extensions
ED_armature_bone_rename(arm, ebone->name, newname);
}
CTX_DATA_END;
@@ -5601,8 +5580,8 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones)
{
BLI_strncpy(newname, ebone->name, sizeof(newname));
- bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]);
- ED_armature_bone_rename(arm, ebone->name, newname);
+ if(bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis]))
+ ED_armature_bone_rename(arm, ebone->name, newname);
}
CTX_DATA_END;
@@ -5885,7 +5864,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
ED_armature_to_edit(obedit);
- arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh");
BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
index a7f79bb6ff3..1c9024f6f91 100644
--- a/source/blender/editors/armature/editarmature_generate.c
+++ b/source/blender/editors/armature/editarmature_generate.c
@@ -32,7 +32,6 @@
#include <math.h>
#include <float.h>
-#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_armature_types.h"
@@ -42,8 +41,6 @@
#include "BLI_graph.h"
#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_context.h"
#include "ED_armature.h"
#include "armature_intern.h"
@@ -60,7 +57,7 @@ void setBoneRollFromNormal(EditBone *bone, float *no, float invmat[][4], float t
sub_v3_v3v3(tangent, bone->tail, bone->head);
project_v3_v3v3(vec, tangent, normal);
- sub_v3_v3v3(normal, normal, vec);
+ sub_v3_v3(normal, vec);
normalize_v3(normal);
@@ -102,7 +99,7 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl
IT_peek(iter, i);
sub_v3_v3v3(v, iter->p, v0);
project_v3_v3v3(d, v, n);
- sub_v3_v3v3(v, v, d);
+ sub_v3_v3(v, d);
dt = len_v3(d) - avg_t;
@@ -249,7 +246,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
{
VECCOPY(p, dv);
mul_v3_fl(p, f);
- add_v3_v3v3(p, p, vec0);
+ add_v3_v3(p, vec0);
}
else
{
@@ -265,7 +262,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
VECCOPY(p, dv);
mul_v3_fl(p, lengthLimit);
- add_v3_v3v3(p, p, head);
+ add_v3_v3(p, head);
}
return i - 1; /* restart at lower bound */
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 57224428476..637c6076314 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -29,10 +29,6 @@
#include <math.h>
#include <float.h>
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "MEM_guardedalloc.h"
#include "PIL_time.h"
@@ -40,6 +36,7 @@
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
@@ -51,8 +48,6 @@
//#include "BDR_editobject.h"
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
#include "BKE_constraint.h"
#include "BKE_armature.h"
#include "BKE_context.h"
@@ -320,8 +315,8 @@ static RigGraph *newRigGraph()
rg->head = NULL;
- rg->bones_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp);
- rg->controls_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp);
+ rg->bones_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph bones gh");
+ rg->controls_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph cont gh");
rg->free_arc = RIG_freeRigArc;
rg->free_node = NULL;
@@ -565,7 +560,7 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
RigControl *ctrl;
RigGraph *rg;
- ptr_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ ptr_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "cloneRigGraph gh");
rg = newRigGraph();
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index e9ad91c19e3..241301b8ee1 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_armature_types.h"
@@ -37,11 +38,6 @@
#include "BLI_graph.h"
#include "BLI_ghash.h"
-#include "BKE_utildefines.h"
-#include "BKE_global.h"
-#include "BKE_DerivedMesh.h"
-#include "BKE_object.h"
-#include "BKE_anim.h"
#include "BKE_context.h"
#include "BKE_sketch.h"
@@ -168,7 +164,7 @@ void BIF_makeListTemplates(const bContext *C)
BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
}
- TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp);
+ TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh");
TEMPLATES_CURRENT = 0;
for ( base = FIRSTBASE; base; base = base->next )
@@ -568,8 +564,8 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
{
float d_rgb[3] = {1, 1, 1};
- VECCOPY(rgb, color);
- sub_v3_v3v3(d_rgb, d_rgb, rgb);
+ copy_v3_v3(rgb, color);
+ sub_v3_v3(d_rgb, rgb);
mul_v3_fl(d_rgb, 1.0f / (float)stk->nb_points);
for (i = 0; i < stk->nb_points; i++)
@@ -607,7 +603,7 @@ void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int end)
glPopMatrix();
- add_v3_v3v3(rgb, rgb, d_rgb);
+ add_v3_v3(rgb, d_rgb);
}
}
@@ -1005,7 +1001,7 @@ void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end, float
viewray(ar, v3d, pval, ray_start, ray_normal);
mul_v3_fl(ray_normal, distance * progress / length);
- add_v3_v3v3(stk->points[i].p, stk->points[i].p, ray_normal);
+ add_v3_v3(stk->points[i].p, ray_normal);
progress += delta ;
}
@@ -1628,7 +1624,7 @@ int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gesture)
sub_v3_v3v3(isect->p, gesture->points[s_i + 1].p, gesture->points[s_i].p);
mul_v3_fl(isect->p, lambda);
- add_v3_v3v3(isect->p, isect->p, gesture->points[s_i].p);
+ add_v3_v3(isect->p, gesture->points[s_i].p);
BLI_addtail(list, isect);
@@ -2154,7 +2150,7 @@ void sk_applyGesture(bContext *C, SK_Sketch *sketch)
/********************************************/
-void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend)
+int sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend)
{
ViewContext vc;
rcti rect;
@@ -2199,7 +2195,10 @@ void sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend)
}
+ return 1;
}
+
+ return 0;
}
void sk_queueRedrawSketch(SK_Sketch *sketch)
@@ -2301,7 +2300,7 @@ void sk_drawSketch(Scene *scene, View3D *v3d, SK_Sketch *sketch, int with_names)
}
}
-#if 1
+#if 0
if (sketch->depth_peels.first != NULL)
{
float colors[8][3] = {
@@ -2471,7 +2470,8 @@ void BIF_sk_selectStroke(bContext *C, short mval[2], short extend)
if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING)
{
- sk_selectStroke(C, sketch, mval, extend);
+ if (sk_selectStroke(C, sketch, mval, extend))
+ ED_area_tag_redraw(CTX_wm_area(C));
}
}
@@ -2558,6 +2558,17 @@ SK_Sketch* viewcontextSketch(ViewContext *vc, int create)
return sketch;
}
+static int sketch_convert(bContext *C, wmOperator *op, wmEvent *event)
+{
+ SK_Sketch *sketch = contextSketch(C, 0);
+ if (sketch != NULL)
+ {
+ sk_convert(C, sketch);
+ ED_area_tag_redraw(CTX_wm_area(C));
+ }
+ return OPERATOR_FINISHED;
+}
+
static int sketch_cancel(bContext *C, wmOperator *op, wmEvent *event)
{
SK_Sketch *sketch = contextSketch(C, 0);
@@ -2590,8 +2601,8 @@ static int sketch_select(bContext *C, wmOperator *op, wmEvent *event)
if (sketch)
{
short extend = 0;
- sk_selectStroke(C, sketch, event->mval, extend);
- ED_area_tag_redraw(CTX_wm_area(C));
+ if (sk_selectStroke(C, sketch, event->mval, extend))
+ ED_area_tag_redraw(CTX_wm_area(C));
}
return OPERATOR_FINISHED;
@@ -2664,6 +2675,7 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
RNA_boolean_set(op->ptr, "snap", snap);
break;
case MOUSEMOVE:
+ case INBETWEEN_MOUSEMOVE:
dd->mval[0] = event->mval[0];
dd->mval[1] = event->mval[1];
sk_draw_stroke(C, sketch, stk, dd, snap);
@@ -2859,6 +2871,21 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot)
// ot->flag= OPTYPE_UNDO;
}
+void SKETCH_OT_convert(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "convert";
+ ot->idname= "SKETCH_OT_convert";
+
+ /* api callbacks */
+ ot->invoke= sketch_convert;
+
+ ot->poll= ED_operator_sketch_full_mode;
+
+ /* flags */
+ ot->flag= OPTYPE_UNDO;
+}
+
void SKETCH_OT_finish_stroke(wmOperatorType *ot)
{
/* identifiers */
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index c5e96dd5fd4..84b02b4796a 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -36,7 +36,6 @@
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
@@ -44,6 +43,7 @@
#include "BLI_memarena.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_modifier.h"
#include "BKE_utildefines.h"
#ifdef RIGID_DEFORM
@@ -51,8 +51,6 @@
#include "BLI_polardecomp.h"
#endif
-#include "RE_raytrace.h"
-
#include "ONL_opennl.h"
#include "BLO_sys_types.h" // for intptr_t support
@@ -64,7 +62,7 @@
/* ************* XXX *************** */
static void waitcursor(int val) {}
-static void progress_bar() {}
+static void progress_bar(int dummy_val, const char *dummy) {}
static void start_progress_bar() {}
static void end_progress_bar() {}
static void error(char *str) { printf("error: %s\n", str); }
@@ -106,8 +104,7 @@ struct LaplacianSystem {
float *p; /* values from all p vectors */
float *mindist; /* minimum distance to a bone for all vertices */
- RayObject *raytree; /* ray tracing acceleration structure */
- RayFace *faces; /* faces to add to the ray tracing struture */
+ BVHTree *bvhtree; /* ray tracing acceleration structure */
MFace **vface; /* a face that the vertex belongs to */
} heat;
@@ -395,29 +392,65 @@ float laplacian_system_get_solution(int v)
#define WEIGHT_LIMIT_END 0.025f
#define DISTANCE_EPSILON 1e-4f
+typedef struct BVHCallbackUserData {
+ float start[3];
+ float vec[3];
+ LaplacianSystem *sys;
+} BVHCallbackUserData;
+
+static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
+{
+ BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata;
+ MFace *mf = data->sys->heat.mface + index;
+ float (*verts)[3] = data->sys->heat.verts;
+ float lambda, uv[2], n[3], dir[3];
+
+ mul_v3_v3fl(dir, data->vec, hit->dist);
+
+ if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) {
+ normal_tri_v3(n, verts[mf->v1], verts[mf->v2], verts[mf->v3]);
+ if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) {
+ hit->index = index;
+ hit->dist *= lambda;
+ }
+ }
+
+ mul_v3_v3fl(dir, data->vec, hit->dist);
+
+ if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) {
+ normal_tri_v3(n, verts[mf->v1], verts[mf->v3], verts[mf->v4]);
+ if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) {
+ hit->index = index;
+ hit->dist *= lambda;
+ }
+ }
+}
+
/* Raytracing for vertex to bone/vertex visibility */
static void heat_ray_tree_create(LaplacianSystem *sys)
{
MFace *mface = sys->heat.mface;
+ float (*verts)[3] = sys->heat.verts;
int totface = sys->heat.totface;
int totvert = sys->heat.totvert;
int a;
- sys->heat.raytree = RE_rayobject_vbvh_create(totface);
- sys->heat.faces = MEM_callocN(sizeof(RayFace)*totface, "Heat RayFaces");
+ sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6);
sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces");
for(a=0; a<totface; a++) {
-
MFace *mf = mface+a;
- RayFace *rayface = sys->heat.faces+a;
-
- RayObject *obj = RE_rayface_from_coords(
- rayface, &sys->heat, mf,
- sys->heat.verts[mf->v1], sys->heat.verts[mf->v2],
- sys->heat.verts[mf->v3], mf->v4 ? sys->heat.verts[mf->v4] : 0
- );
- RE_rayobject_add(sys->heat.raytree, obj);
+ float bb[6];
+
+ INIT_MINMAX(bb, bb+3);
+ DO_MINMAX(verts[mf->v1], bb, bb+3);
+ DO_MINMAX(verts[mf->v2], bb, bb+3);
+ DO_MINMAX(verts[mf->v3], bb, bb+3);
+ if(mf->v4) {
+ DO_MINMAX(verts[mf->v4], bb, bb+3);
+ }
+
+ BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2);
//Setup inverse pointers to use on isect.orig
sys->heat.vface[mf->v1]= mf;
@@ -425,12 +458,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
sys->heat.vface[mf->v3]= mf;
if(mf->v4) sys->heat.vface[mf->v4]= mf;
}
- RE_rayobject_done(sys->heat.raytree);
+
+ BLI_bvhtree_balance(sys->heat.bvhtree);
}
static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
{
- Isect isec;
+ BVHTreeRayHit hit;
+ BVHCallbackUserData data;
MFace *mface;
float end[3];
int visible;
@@ -439,27 +474,24 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
if(!mface)
return 1;
- /* setup isec */
- memset(&isec, 0, sizeof(isec));
- isec.mode= RE_RAY_SHADOW;
- isec.lay= -1;
- isec.orig.ob = &sys->heat;
- isec.orig.face = mface;
- isec.skip = RE_SKIP_CULLFACE;
-
- copy_v3_v3(isec.start, sys->heat.verts[vertex]);
+ data.sys= sys;
+ copy_v3_v3(data.start, sys->heat.verts[vertex]);
if(sys->heat.root) /* bone */
- closest_to_line_segment_v3(end, isec.start,
+ closest_to_line_segment_v3(end, data.start,
sys->heat.root[source], sys->heat.tip[source]);
else /* vertex */
copy_v3_v3(end, sys->heat.source[source]);
- sub_v3_v3v3(isec.vec, end, isec.start);
- isec.labda = 1.0f - 1e-5;
- madd_v3_v3v3fl(isec.start, isec.start, isec.vec, 1e-5);
+ sub_v3_v3v3(data.vec, end, data.start);
+ madd_v3_v3v3fl(data.start, data.start, data.vec, 1e-5);
+ mul_v3_fl(data.vec, 1.0f - 2e-5);
+
+ /* pass normalized vec + distance to bvh */
+ hit.index = -1;
+ hit.dist = normalize_v3(data.vec);
- visible= !RE_rayobject_raycast(sys->heat.raytree, &isec);
+ visible= BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void*)&data) == -1;
return visible;
}
@@ -523,10 +555,8 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
/* compute H entry */
if(numclosest > 0) {
- if(mindist > 1e-5)
- h= numclosest*C_WEIGHT/(mindist*mindist);
- else
- h= 1e10f;
+ mindist= maxf(mindist, 1e-4f);
+ h= numclosest*C_WEIGHT/(mindist*mindist);
}
else
h= 0.0f;
@@ -548,9 +578,9 @@ void heat_calc_vnormals(LaplacianSystem *sys)
normal_tri_v3( fnor,sys->verts[v1], sys->verts[v2], sys->verts[v3]);
- add_v3_v3v3(sys->heat.vnors[v1], sys->heat.vnors[v1], fnor);
- add_v3_v3v3(sys->heat.vnors[v2], sys->heat.vnors[v2], fnor);
- add_v3_v3v3(sys->heat.vnors[v3], sys->heat.vnors[v3], fnor);
+ add_v3_v3(sys->heat.vnors[v1], fnor);
+ add_v3_v3(sys->heat.vnors[v2], fnor);
+ add_v3_v3(sys->heat.vnors[v3], fnor);
}
for(a=0; a<sys->totvert; a++)
@@ -588,9 +618,8 @@ static void heat_laplacian_create(LaplacianSystem *sys)
static void heat_system_free(LaplacianSystem *sys)
{
- RE_rayobject_free(sys->heat.raytree);
+ BLI_bvhtree_free(sys->heat.bvhtree);
MEM_freeN(sys->heat.vface);
- MEM_freeN(sys->heat.faces);
MEM_freeN(sys->heat.mindist);
MEM_freeN(sys->heat.H);
@@ -827,7 +856,7 @@ static void rigid_add_half_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditV
mul_v3_fl(rhs, 0.5f);
mul_v3_fl(rhs, w);
- add_v3_v3v3(sys->rigid.rhs[v1->tmp.l], sys->rigid.rhs[v1->tmp.l], rhs);
+ add_v3_v3(sys->rigid.rhs[v1->tmp.l], rhs);
}
static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *v2, float w)
@@ -1051,11 +1080,19 @@ typedef struct MeshDeformBind {
/* direct solver */
int *varidx;
-
- /* raytrace */
- RayObject *raytree;
} MeshDeformBind;
+typedef struct MeshDeformIsect {
+ float start[3];
+ float vec[3];
+ float labda;
+
+ void *face;
+ int isect;
+ float u, v;
+
+} MeshDeformIsect;
+
/* ray intersection */
/* our own triangle intersection, so we can fully control the epsilons and
@@ -1118,63 +1155,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
return 1;
}
-/* blender's raytracer is not use now, even though it is much faster. it can
- * give problems with rays falling through, so we use our own intersection
- * function above with tweaked epsilons */
-
-#if 0
-static MeshDeformBind *MESHDEFORM_BIND = NULL;
-
-static void meshdeform_ray_coords_func(RayFace *face, float **v1, float **v2, float **v3, float **v4)
-{
- MFace *mface= (MFace*)face;
- float (*cagecos)[3]= MESHDEFORM_BIND->cagecos;
-
- *v1= cagecos[mface->v1];
- *v2= cagecos[mface->v2];
- *v3= cagecos[mface->v3];
- *v4= (mface->v4)? cagecos[mface->v4]: NULL;
-}
-
-static int meshdeform_ray_check_func(Isect *is, RayFace *face)
-{
- return 1;
-}
-
-static void meshdeform_ray_tree_create(MeshDeformBind *mdb)
-{
- MFace *mface;
- float min[3], max[3];
- int a, totface;
-
- /* create a raytrace tree from the mesh */
- INIT_MINMAX(min, max);
-
- for(a=0; a<mdb->totcagevert; a++)
- DO_MINMAX(mdb->cagecos[a], min, max)
-
- MESHDEFORM_BIND= mdb;
-
- mface= mdb->cagedm->getFaceArray(mdb->cagedm);
- totface= mdb->cagedm->getNumFaces(mdb->cagedm);
-
- mdb->raytree= RE_ray_tree_create(64, totface, min, max,
- meshdeform_ray_coords_func, meshdeform_ray_check_func);
-
- for(a=0; a<totface; a++, mface++)
- RE_ray_tree_add_face(mdb->raytree, mface);
-
- RE_ray_tree_done(mdb->raytree);
-}
-
-static void meshdeform_ray_tree_free(MeshDeformBind *mdb)
-{
- MESHDEFORM_BIND= NULL;
- RE_ray_tree_free(mdb->raytree);
-}
-#endif
-
-static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec)
+static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec)
{
MFace *mface;
float face[4][3], co[3], uvw[3], len, nor[3], end[3];
@@ -1213,7 +1194,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec)
len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end);
if(len < isec->labda) {
isec->labda= len;
- isec->hit.face = mface;
+ isec->face = mface;
isec->isect= (INPR(isec->vec, nor) <= 0.0f);
is= 1;
}
@@ -1226,7 +1207,7 @@ static int meshdeform_intersect(MeshDeformBind *mdb, Isect *isec)
static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float *co1, float *co2)
{
MDefBoundIsect *isect;
- Isect isec;
+ MeshDeformIsect isec;
float (*cagecos)[3];
MFace *mface;
float vert[4][3], len, end[3];
@@ -1234,21 +1215,15 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float
/* setup isec */
memset(&isec, 0, sizeof(isec));
- isec.mode= RE_RAY_MIRROR; /* we want the closest intersection */
- isec.lay= -1;
isec.labda= 1e10f;
VECADD(isec.start, co1, epsilon);
VECADD(end, co2, epsilon);
sub_v3_v3v3(isec.vec, end, isec.start);
-#if 0
- /*if(RE_ray_tree_intersect(mdb->raytree, &isec)) {*/
-#endif
-
if(meshdeform_intersect(mdb, &isec)) {
len= isec.labda;
- mface=(MFace*)isec.hit.face;
+ mface=(MFace*)isec.face;
/* create MDefBoundIsect */
isect= BLI_memarena_alloc(mdb->memarena, sizeof(*isect));
@@ -1766,7 +1741,7 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
else
mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights");
- mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+ mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
BLI_memarena_use_calloc(mdb->memarena);
/* make bounding box equal size in all directions, add padding, and compute
@@ -1791,11 +1766,6 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
progress_bar(0, "Setting up mesh deform system");
-#if 0
- /* create ray tree */
- meshdeform_ray_tree_create(mdb);
-#endif
-
totinside= 0;
for(a=0; a<mdb->totvert; a++) {
copy_v3_v3(vec, mdb->vertexcos[a]);
@@ -1806,7 +1776,7 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
/* free temporary MDefBoundIsects */
BLI_memarena_free(mdb->memarena);
- mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE);
+ mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
/* start with all cells untyped */
for(a=0; a<mdb->size3; a++)
@@ -1818,11 +1788,6 @@ static void harmonic_coordinates_bind(Scene *scene, MeshDeformModifierData *mmd,
for(x=0; x<mdb->size; x++)
meshdeform_add_intersections(mdb, x, y, z);
-#if 0
- /* free ray tree */
- meshdeform_ray_tree_free(mdb);
-#endif
-
/* compute exterior and interior tags */
meshdeform_bind_floodfill(mdb);
@@ -1956,7 +1921,7 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie
}
#endif
-void mesh_deform_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifierData *mmd, float *vertexcos, int totvert, float cagemat[][4])
+void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexcos, int totvert, float cagemat[][4])
{
MeshDeformBind mdb;
MVert *mvert;
@@ -1993,19 +1958,22 @@ void mesh_deform_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifierData *mmd
#endif
/* assign bind variables */
- mmd->bindcos= (float*)mdb.cagecos;
+ mmd->bindcagecos= (float*)mdb.cagecos;
mmd->totvert= mdb.totvert;
mmd->totcagevert= mdb.totcagevert;
copy_m4_m4(mmd->bindmat, mmd->object->obmat);
- /* transform bindcos to world space */
+ /* transform bindcagecos to world space */
for(a=0; a<mdb.totcagevert; a++)
- mul_m4_v3(mmd->object->obmat, mmd->bindcos+a*3);
+ mul_m4_v3(mmd->object->obmat, mmd->bindcagecos+a*3);
/* free */
mdb.cagedm->release(mdb.cagedm);
MEM_freeN(mdb.vertexcos);
+ /* compact weights */
+ modifier_mdef_compact_influences((ModifierData*)mmd);
+
end_progress_bar();
waitcursor(0);
}
diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h
index 4e5fbec9c82..640eb33c945 100644
--- a/source/blender/editors/armature/meshlaplacian.h
+++ b/source/blender/editors/armature/meshlaplacian.h
@@ -78,7 +78,7 @@ void rigid_deform_end(int cancel);
/* Harmonic Coordinates */
-void mesh_deform_bind(struct Scene *scene, struct DerivedMesh *dm,
+void mesh_deform_bind(struct Scene *scene,
struct MeshDeformModifierData *mmd,
float *vertexcos, int totvert, float cagemat[][4]);
diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c
index 21b99bc10c0..8d8f1bf24ee 100644
--- a/source/blender/editors/armature/poseSlide.c
+++ b/source/blender/editors/armature/poseSlide.c
@@ -44,17 +44,10 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BKE_animsys.h"
-#include "BKE_action.h"
-#include "BKE_armature.h"
-#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
-#include "BKE_object.h"
-#include "BKE_global.h"
#include "BKE_context.h"
#include "BKE_report.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -63,7 +56,6 @@
#include "WM_types.h"
-#include "BIF_gl.h"
#include "ED_armature.h"
#include "ED_keyframes_draw.h"
diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c
index c9a80318050..b8b9c354d9a 100644
--- a/source/blender/editors/armature/poseUtils.c
+++ b/source/blender/editors/armature/poseUtils.c
@@ -44,17 +44,11 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
-#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
-#include "BKE_fcurve.h"
-#include "BKE_object.h"
-#include "BKE_global.h"
#include "BKE_context.h"
-#include "BKE_report.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
@@ -62,7 +56,6 @@
#include "WM_types.h"
-#include "BIF_gl.h"
#include "ED_armature.h"
#include "ED_keyframing.h"
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index e2ceb534066..f490158424c 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -48,13 +48,9 @@
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_depsgraph.h"
-#include "BKE_modifier.h"
-#include "BKE_object.h"
-#include "BKE_global.h"
#include "BKE_context.h"
#include "BKE_report.h"
-#include "BKE_utildefines.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -282,8 +278,16 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout,
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
/* add each marker to this menu */
- for (marker= act->markers.first; marker; marker= marker->next)
- uiItemIntO(layout, marker->name, ICON_ARMATURE_DATA, "POSELIB_OT_pose_add", "frame", marker->frame);
+ for (marker= act->markers.first; marker; marker= marker->next) {
+ PointerRNA props_ptr;
+
+ props_ptr = uiItemFullO(layout, "POSELIB_OT_pose_add",
+ marker->name, ICON_ARMATURE_DATA, NULL,
+ WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
+
+ RNA_int_set(&props_ptr, "frame", marker->frame);
+ RNA_string_set(&props_ptr, "name", marker->name);
+ }
}
static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *evt)
@@ -769,12 +773,19 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
if (pchan) {
if (autokeyframe_cfra_can_key(scene, &pld->ob->id)) {
ListBase dsources = {NULL, NULL};
+ KeyingSet *ks = NULL;
- /* get KeyingSet to use */
- // TODO: for getting the KeyingSet used, we should really check which channels were affected
- // TODO: this should get modified so that custom props are taken into account too!
+ /* get KeyingSet to use
+ * - use the active KeyingSet if defined (and user wants to use it for all autokeying),
+ * or otherwise key transforms only
+ */
if (poselib_ks_locrotscale == NULL)
poselib_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+
+ if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
+ ks = ANIM_scene_get_active_keyingset(scene);
+ else
+ ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
/* now insert the keyframe(s) using the Keying Set
* 1) add datasource override for the PoseChannel
@@ -782,7 +793,7 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
* 3) free the extra info
*/
ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan);
- ANIM_apply_keyingset(C, &dsources, NULL, poselib_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
BLI_freelistN(&dsources);
/* clear any unkeyed tags */
@@ -799,7 +810,7 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
}
/* send notifiers for this */
- WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_EDIT, NULL);
+ WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
}
/* Apply the relevant changes to the pose */
@@ -847,7 +858,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
/* get search-string */
index= pld->search_cursor;
- if (IN_RANGE(index, 0, 64)) {
+ if (index >= 0 && index <= 64) {
memcpy(&tempstr[0], &pld->searchstr[0], index);
tempstr[index]= '|';
memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
@@ -1483,6 +1494,8 @@ void POSELIB_OT_browse_interactive (wmOperatorType *ot)
/* properties */
// TODO: make the pose_index into a proper enum instead of a cryptic int...
ot->prop= RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX);
- // XXX: percentage vs factor?
- RNA_def_float_factor(ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor", "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f);
+
+ // XXX: percentage vs factor?
+ /* not used yet */
+ /* RNA_def_float_factor(ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor", "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f); */
}
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 102fbe2eafd..3bbbb271bda 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -41,26 +41,19 @@
#include "DNA_armature_types.h"
#include "DNA_constraint_types.h"
#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
#include "BKE_anim.h"
#include "BKE_idprop.h"
-#include "BKE_animsys.h"
#include "BKE_action.h"
#include "BKE_armature.h"
-#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_constraint.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
-#include "BKE_displist.h"
-#include "BKE_fcurve.h"
-#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_object.h"
-#include "BKE_utildefines.h"
#include "BKE_report.h"
-#include "BIF_gl.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -78,9 +71,9 @@
#include "armature_intern.h"
/* ************* XXX *************** */
-static int pupmenu() {return 0;}
-static void error() {};
-static void BIF_undo_push() {}
+static int pupmenu(const char *dummy) {return 0;}
+static void error(const char *dummy) {};
+static void BIF_undo_push(const char *dummy) {}
/* ************* XXX *************** */
/* This function is used to indicate that a bone is selected and needs keyframes inserted */
@@ -691,7 +684,7 @@ void pose_copy_menu(Scene *scene)
/* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
- copy_constraints(&tmp_constraints, &pchanact->constraints);
+ copy_constraints(&tmp_constraints, &pchanact->constraints, TRUE);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
bConstraint *con;
@@ -800,7 +793,7 @@ void pose_copy_menu(Scene *scene)
/* copy constraints to tmpbase and apply 'local' tags before
* appending to list of constraints for this channel
*/
- copy_constraints(&tmp_constraints, &const_copy);
+ copy_constraints(&tmp_constraints, &const_copy, TRUE);
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
bConstraint *con;
@@ -892,15 +885,11 @@ void POSE_OT_copy (wmOperatorType *ot)
/* ---- */
-/* Pointers to the builtin KeyingSets that we want to use */
-static KeyingSet *posePaste_ks_locrotscale = NULL; /* the only keyingset we'll need */
-
static int pose_paste_exec (bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
bPoseChannel *chan, *pchan;
- char name[32];
int flip= RNA_boolean_get(op->ptr, "flipped");
/* sanity checks */
@@ -916,10 +905,12 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) {
if (chan->flag & POSE_KEY) {
/* get the name - if flipping, we must flip this first */
- BLI_strncpy(name, chan->name, sizeof(name));
+ char name[32];
if (flip)
- bone_flip_name(name, 0); /* 0 = don't strip off number extensions */
-
+ flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */
+ else
+ BLI_strncpy(name, chan->name, sizeof(name));
+
/* only copy when channel exists, poses are not meant to add random channels to anymore */
pchan= get_pose_channel(ob->pose, name);
@@ -937,6 +928,10 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
if (pchan->rotmode > 0) {
VECCOPY(pchan->eul, chan->eul);
}
+ else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
+ VECCOPY(pchan->rotAxis, chan->rotAxis);
+ pchan->rotAngle = chan->rotAngle;
+ }
else {
QUATCOPY(pchan->quat, chan->quat);
}
@@ -979,13 +974,6 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
eul[1]*= -1;
eul[2]*= -1;
eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT);
-
- // experimental method (uncomment to test):
-#if 0
- /* experimental method: just flip the orientation of the axis on x/y axes */
- pchan->quat[1] *= -1;
- pchan->quat[2] *= -1;
-#endif
}
else {
float eul[3];
@@ -997,25 +985,36 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
}
}
- /* ID property */
- if (pchan->prop) {
- IDP_FreeProperty(pchan->prop);
- MEM_freeN(pchan->prop);
- pchan->prop= NULL;
+ /* ID properties
+ * - only free the existing properties if the channel we're copying from has them
+ * NOTE: this means that if the pose depends on some pchan property, the pose may not be ok,
+ * but this is better than loosing all the setting you've painstakingly added...
+ */
+ if (chan->prop) {
+ /* free the old properties since we want to replace them now */
+ if (pchan->prop) {
+ IDP_FreeProperty(pchan->prop);
+ MEM_freeN(pchan->prop);
+ pchan->prop= NULL;
+ }
+
+ /* now copy over the new copy of the properties */
+ pchan->prop= IDP_CopyProperty(chan->prop);
}
- if (chan->prop)
- pchan->prop= IDP_CopyProperty(chan->prop);
-
/* keyframing tagging */
- if (autokeyframe_cfra_can_key(scene, &ob->id)) {
+ if (autokeyframe_cfra_can_key(scene, &ob->id)) {
ListBase dsources = {NULL, NULL};
+ KeyingSet *ks = NULL;
- /* get KeyingSet to use */
- // TODO: for getting the KeyingSet used, we should really check which channels were affected
- // TODO: this should get modified so that custom props are taken into account too!
- if (posePaste_ks_locrotscale == NULL)
- posePaste_ks_locrotscale= ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
+ /* get KeyingSet to use
+ * - use the active KeyingSet if defined (and user wants to use it for all autokeying),
+ * or otherwise key transforms only
+ */
+ if (IS_AUTOKEY_FLAG(ONLYKEYINGSET) && (scene->active_keyingset))
+ ks = ANIM_scene_get_active_keyingset(scene);
+ else
+ ks = ANIM_builtin_keyingset_get_named(NULL, "LocRotScale");
/* now insert the keyframe(s) using the Keying Set
* 1) add datasource override for the PoseChannel
@@ -1023,7 +1022,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
* 3) free the extra info
*/
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
- ANIM_apply_keyingset(C, &dsources, NULL, posePaste_ks_locrotscale, MODIFYKEY_MODE_INSERT, (float)CFRA);
+ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA);
BLI_freelistN(&dsources);
/* clear any unkeyed tags */
@@ -1041,17 +1040,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
/* Update event for pose and deformation children */
DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
-
- if (IS_AUTOKEY_ON(scene)) {
-// XXX remake_action_ipos(ob->action);
- }
- else {
- /* need to trick depgraph, action is not allowed to execute on pose */
- // XXX: this is probably not an issue anymore
- where_is_pose(scene, ob);
- ob->recalc= 0;
- }
-
+
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1242,8 +1231,8 @@ static int pose_group_assign_exec (bContext *C, wmOperator *op)
pose_add_group(ob);
/* add selected bones to group then */
- // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
- CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) {
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
+ {
pchan->agrp_index= pose->active_group;
done= 1;
}
@@ -1285,7 +1274,6 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *op)
Object *ob;
bArmature *arm;
bPose *pose;
- bPoseChannel *pchan;
short done= 0;
/* since this call may also be used from the buttons window, we need to check for where to get the object */
@@ -1301,20 +1289,14 @@ static int pose_group_unassign_exec (bContext *C, wmOperator *op)
arm= ob->data;
/* find selected bones to remove from all bone groups */
- // NOTE: unfortunately, we cannot use the context-iterators here, since they might not be defined...
- // CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
- for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) {
- /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
- // NOTE: sync this view3d_context() in space_view3d.c
- if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
- if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
- if (pchan->agrp_index) {
- pchan->agrp_index= 0;
- done= 1;
- }
- }
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
+ {
+ if (pchan->agrp_index) {
+ pchan->agrp_index= 0;
+ done= 1;
}
}
+ CTX_DATA_END;
/* notifiers for updates */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1341,13 +1323,108 @@ void POSE_OT_group_unassign (wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
}
+static void pose_group_select(bContext *C, Object *ob, int select)
+{
+ bPose *pose= ob->pose;
+
+ CTX_DATA_BEGIN(C, bPoseChannel*, pchan, visible_pose_bones)
+ {
+ if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+ if (select) {
+ if (pchan->agrp_index == pose->active_group)
+ pchan->bone->flag |= BONE_SELECTED;
+ }
+ else {
+ if (pchan->agrp_index == pose->active_group)
+ pchan->bone->flag &= ~BONE_SELECTED;
+ }
+ }
+ }
+ CTX_DATA_END;
+}
+
+static int pose_group_select_exec (bContext *C, wmOperator *op)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa->spacetype == SPACE_BUTS)
+ ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ else
+ ob= CTX_data_active_object(C);
+
+ /* only continue if there's an object, and a pose there too */
+ if (ELEM(NULL, ob, ob->pose))
+ return OPERATOR_CANCELLED;
+
+ pose_group_select(C, ob, 1);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_select (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Select Bones of Bone Group";
+ ot->idname= "POSE_OT_group_select";
+ ot->description= "Select bones in active Bone Group";
+
+ /* api callbacks */
+ ot->exec= pose_group_select_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
+static int pose_group_deselect_exec (bContext *C, wmOperator *op)
+{
+ ScrArea *sa= CTX_wm_area(C);
+ Object *ob;
+
+ /* since this call may also be used from the buttons window, we need to check for where to get the object */
+ if (sa->spacetype == SPACE_BUTS)
+ ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
+ else
+ ob= CTX_data_active_object(C);
+
+ /* only continue if there's an object, and a pose there too */
+ if (ELEM(NULL, ob, ob->pose))
+ return OPERATOR_CANCELLED;
+
+ pose_group_select(C, ob, 0);
+
+ /* notifiers for updates */
+ WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void POSE_OT_group_deselect (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Deselecte Bone Group";
+ ot->idname= "POSE_OT_group_deselect";
+ ot->description= "Deselect bones of active Bone Group";
+
+ /* api callbacks */
+ ot->exec= pose_group_deselect_exec;
+ ot->poll= ED_operator_posemode;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
/* ********************************************** */
static int pose_flip_names_exec (bContext *C, wmOperator *op)
{
Object *ob= CTX_data_active_object(C);
bArmature *arm;
- char newname[32];
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose))
@@ -1357,8 +1434,8 @@ static int pose_flip_names_exec (bContext *C, wmOperator *op)
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
{
- BLI_strncpy(newname, pchan->name, sizeof(newname));
- bone_flip_name(newname, 1); // 1 = do strip off number extensions
+ char newname[32];
+ flip_side_name(newname, pchan->name, TRUE);
ED_armature_bone_rename(arm, pchan->name, newname);
}
CTX_DATA_END;
@@ -1405,8 +1482,8 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones)
{
BLI_strncpy(newname, pchan->name, sizeof(newname));
- bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]);
- ED_armature_bone_rename(arm, pchan->name, newname);
+ if(bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]))
+ ED_armature_bone_rename(arm, pchan->name, newname);
}
CTX_DATA_END;
@@ -1454,7 +1531,7 @@ void pose_activate_flipped_bone(Scene *scene)
if(ob==NULL) return;
- if(ob->mode && OB_MODE_WEIGHT_PAINT) {
+ if(ob->mode & OB_MODE_WEIGHT_PAINT) {
ob= modifiers_isDeformedByArmature(ob);
}
if(ob && (ob->mode & OB_MODE_POSE)) {
@@ -1462,10 +1539,8 @@ void pose_activate_flipped_bone(Scene *scene)
if(arm->act_bone) {
char name[32];
-
- BLI_strncpy(name, arm->act_bone->name, 32);
- bone_flip_name(name, 1); // 0 = do not strip off number extensions
-
+ flip_side_name(name, arm->act_bone->name, TRUE);
+
pchanf= get_pose_channel(ob->pose, name);
if(pchanf && pchanf->bone != arm->act_bone) {
arm->act_bone->flag &= ~BONE_SELECTED;
@@ -1503,7 +1578,7 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
/* get RNA pointer to armature data to use that to retrieve the layers as ints to init the operator */
RNA_id_pointer_create((ID *)arm, &ptr);
- RNA_boolean_get_array(&ptr, "layer", layers);
+ RNA_boolean_get_array(&ptr, "layers", layers);
RNA_boolean_set_array(op->ptr, "layers", layers);
/* part to sync with other similar operators... */
@@ -1523,7 +1598,7 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op)
/* get pointer for armature, and write data there... */
RNA_id_pointer_create((ID *)arm, &ptr);
- RNA_boolean_set_array(&ptr, "layer", layers);
+ RNA_boolean_set_array(&ptr, "layers", layers);
/* note, notifier might evolve */
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
@@ -1615,7 +1690,7 @@ static int pose_bone_layers_exec (bContext *C, wmOperator *op)
{
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)arm, &RNA_Bone, pchan->bone, &ptr);
- RNA_boolean_set_array(&ptr, "layer", layers);
+ RNA_boolean_set_array(&ptr, "layers", layers);
}
CTX_DATA_END;
@@ -1689,7 +1764,7 @@ static int armature_bone_layers_exec (bContext *C, wmOperator *op)
{
/* get pointer for pchan, and write flags this way */
RNA_pointer_create((ID *)arm, &RNA_EditBone, ebone, &ptr);
- RNA_boolean_set_array(&ptr, "layer", layers);
+ RNA_boolean_set_array(&ptr, "layers", layers);
}
CTX_DATA_END;
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 04bf5bce553..9602d80575a 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -31,14 +31,13 @@
#include <stdlib.h> // for qsort
#include <float.h>
-
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
-#include "BKE_context.h"
-
#include "MEM_guardedalloc.h"
+#include "BKE_context.h"
+
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
@@ -51,11 +50,7 @@
//#include "BIF_interface.h"
//#include "BIF_toolbox.h"
//#include "BIF_graphics.h"
-#include "BIF_gl.h"
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
-#include "BKE_customdata.h"
//#include "blendef.h"
@@ -348,7 +343,7 @@ ReebArc * copyArc(ReebGraph *rg, ReebArc *arc)
memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount);
/* copy faces map */
- cp_arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ cp_arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "copyArc gh");
mergeArcFaces(rg, cp_arc, arc);
/* find corresponding head and tail */
@@ -491,11 +486,11 @@ void repositionNodes(ReebGraph *rg)
VECCOPY(p, ((ReebArc*)arc)->buckets[0].p);
mul_v3_fl(p, 1.0f / arc->head->degree);
- add_v3_v3v3(arc->head->p, arc->head->p, p);
+ add_v3_v3(arc->head->p, p);
VECCOPY(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p);
mul_v3_fl(p, 1.0f / arc->tail->degree);
- add_v3_v3v3(arc->tail->p, arc->tail->p, p);
+ add_v3_v3(arc->tail->p, p);
}
}
}
@@ -632,7 +627,7 @@ void addVertToBucket(EmbedBucket *b, float co[3])
void removeVertFromBucket(EmbedBucket *b, float co[3])
{
mul_v3_fl(b->p, (float)b->nv);
- sub_v3_v3v3(b->p, b->p, co);
+ sub_v3_v3(b->p, co);
b->nv--;
mul_v3_fl(b->p, 1.0f / (float)b->nv);
}
@@ -1103,7 +1098,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr
BLI_mirrorAlongAxis(p, root_node->p, nor);
/* average with node1 */
- add_v3_v3v3(node1->p, node1->p, p);
+ add_v3_v3(node1->p, p);
mul_v3_fl(node1->p, 0.5f);
/* mirror back on node2 */
@@ -1821,7 +1816,7 @@ int filterSmartReebGraph(ReebGraph *rg, float threshold)
efa->tmp.fp = saacos(fabs(angle));
#endif
#else
- add_v3_v3v3(avg_vec, avg_vec, efa->n);
+ add_v3_v3(avg_vec, efa->n);
#endif
}
@@ -2440,7 +2435,7 @@ ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
arc->flag = 0; // clear flag on init
arc->symmetry_level = 0;
- arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp);
+ arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createArc gh");
if (node1->weight <= node2->weight)
{