style cleanup: graph & armature
This commit is contained in:
@@ -1353,7 +1353,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op)
|
||||
float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap
|
||||
|
||||
// XXX more comprehensive tests will be needed
|
||||
CTX_DATA_BEGIN(C, Object *, ob, selected_objects)
|
||||
CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
|
||||
{
|
||||
ID *id = (ID *)ob;
|
||||
FCurve *fcu, *fcn;
|
||||
|
||||
@@ -32,7 +32,7 @@ struct BArcIterator;
|
||||
struct bArmature;
|
||||
struct ListBase;
|
||||
|
||||
typedef int(NextSubdivisionFunc)(struct ToolSettings*, struct BArcIterator*, int, int, float[3], float[3]);
|
||||
typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]);
|
||||
|
||||
float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]);
|
||||
|
||||
@@ -40,7 +40,7 @@ int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator
|
||||
int nextLengthSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
|
||||
int nextAdaptativeSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]);
|
||||
|
||||
struct EditBone * subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion);
|
||||
struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion);
|
||||
|
||||
void setBoneRollFromNormal(struct EditBone *bone, float *no, float invmat[][4], float tmat[][3]);
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
* \ingroup edarmature
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __BIF_RETARGET_H__
|
||||
#define __BIF_RETARGET_H__
|
||||
|
||||
@@ -49,21 +48,21 @@ struct RigEdge;
|
||||
#define USE_THREADS
|
||||
|
||||
typedef struct RigGraph {
|
||||
ListBase arcs;
|
||||
ListBase nodes;
|
||||
ListBase arcs;
|
||||
ListBase nodes;
|
||||
|
||||
float length;
|
||||
|
||||
FreeArc free_arc;
|
||||
FreeNode free_node;
|
||||
RadialSymmetry radial_symmetry;
|
||||
AxialSymmetry axial_symmetry;
|
||||
FreeArc free_arc;
|
||||
FreeNode free_node;
|
||||
RadialSymmetry radial_symmetry;
|
||||
AxialSymmetry axial_symmetry;
|
||||
/*********************************/
|
||||
|
||||
int flag;
|
||||
int flag;
|
||||
|
||||
ListBase controls;
|
||||
ListBase* editbones;
|
||||
ListBase controls;
|
||||
ListBase *editbones;
|
||||
|
||||
struct RigNode *head;
|
||||
ReebGraph *link_mesh;
|
||||
@@ -71,8 +70,8 @@ typedef struct RigGraph {
|
||||
|
||||
struct ThreadedWorker *worker;
|
||||
|
||||
GHash *bones_map; /* map of editbones by name */
|
||||
GHash *controls_map; /* map of rigcontrols by bone pointer */
|
||||
GHash *bones_map; /* map of editbones by name */
|
||||
GHash *controls_map; /* map of rigcontrols by bone pointer */
|
||||
|
||||
struct Object *ob;
|
||||
} RigGraph;
|
||||
@@ -123,16 +122,16 @@ typedef struct RigEdge {
|
||||
} RigEdge;
|
||||
|
||||
/* Graph flags */
|
||||
#define RIG_FREE_BONELIST 1
|
||||
#define RIG_FREE_BONELIST 1
|
||||
|
||||
/* Control flags */
|
||||
#define RIG_CTRL_HEAD_DONE 1
|
||||
#define RIG_CTRL_TAIL_DONE 2
|
||||
#define RIG_CTRL_PARENT_DEFORM 4
|
||||
#define RIG_CTRL_FIT_ROOT 8
|
||||
#define RIG_CTRL_FIT_BONE 16
|
||||
#define RIG_CTRL_HEAD_DONE 1
|
||||
#define RIG_CTRL_TAIL_DONE 2
|
||||
#define RIG_CTRL_PARENT_DEFORM 4
|
||||
#define RIG_CTRL_FIT_ROOT 8
|
||||
#define RIG_CTRL_FIT_BONE 16
|
||||
|
||||
#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE|RIG_CTRL_TAIL_DONE)
|
||||
#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE | RIG_CTRL_TAIL_DONE)
|
||||
|
||||
/* Control tail flags */
|
||||
typedef enum {
|
||||
@@ -147,10 +146,10 @@ typedef struct RigControl {
|
||||
struct EditBone *bone;
|
||||
struct EditBone *link;
|
||||
struct EditBone *link_tail;
|
||||
float up_axis[3];
|
||||
float offset[3];
|
||||
float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */
|
||||
int flag;
|
||||
float up_axis[3];
|
||||
float offset[3];
|
||||
float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */
|
||||
int flag;
|
||||
LinkTailMode tail_mode;
|
||||
} RigControl;
|
||||
|
||||
|
||||
@@ -150,19 +150,19 @@ void SKETCH_OT_select(struct wmOperatorType *ot);
|
||||
typedef struct tPChanFCurveLink {
|
||||
struct tPChanFCurveLink *next, *prev;
|
||||
|
||||
ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */
|
||||
struct bPoseChannel *pchan; /* Pose Channel which data is attached to */
|
||||
ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */
|
||||
struct bPoseChannel *pchan; /* Pose Channel which data is attached to */
|
||||
|
||||
char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */
|
||||
char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */
|
||||
|
||||
float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */
|
||||
float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */
|
||||
float oldrot[3];
|
||||
float oldscale[3];
|
||||
float oldquat[4];
|
||||
float oldangle;
|
||||
float oldaxis[3];
|
||||
|
||||
struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */
|
||||
struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */
|
||||
} tPChanFCurveLink;
|
||||
|
||||
/* ----------- */
|
||||
|
||||
@@ -174,7 +174,7 @@ void ED_operatormacros_armature(void)
|
||||
|
||||
ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate",
|
||||
"Make copies of the selected bones within the same armature and move them",
|
||||
OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
if (ot) {
|
||||
WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
@@ -183,9 +183,9 @@ void ED_operatormacros_armature(void)
|
||||
|
||||
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude",
|
||||
"Create new bones from the selected joints and move them",
|
||||
OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
if (ot) {
|
||||
otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
|
||||
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
|
||||
RNA_boolean_set(otmacro->ptr, "forked", FALSE);
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
RNA_enum_set(otmacro->ptr, "proportional", 0);
|
||||
@@ -195,9 +195,9 @@ void ED_operatormacros_armature(void)
|
||||
// that would require fixing a properties bug 19733
|
||||
ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked",
|
||||
"Create new bones from the selected joints and move them",
|
||||
OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
if (ot) {
|
||||
otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
|
||||
otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
|
||||
RNA_boolean_set(otmacro->ptr, "forked", TRUE);
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
RNA_enum_set(otmacro->ptr, "proportional", 0);
|
||||
@@ -237,7 +237,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
RNA_boolean_set(kmi->ptr, "unselected", TRUE);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0);
|
||||
@@ -248,23 +248,23 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
@@ -279,27 +279,27 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
|
||||
/* set flags */
|
||||
/* set flags */
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
/* armature/bone layers */
|
||||
/* armature/bone layers */
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* special transforms: */
|
||||
/* 1) envelope/b-bone size */
|
||||
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 */
|
||||
/* special transforms: */
|
||||
/* 1) envelope/b-bone size */
|
||||
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);
|
||||
RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL);
|
||||
RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL);
|
||||
|
||||
/* menus */
|
||||
/* menus */
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* Pose ------------------------ */
|
||||
@@ -334,60 +334,60 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_boolean_set(kmi->ptr, "flipped", FALSE);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "flipped", TRUE);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE);
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
RNA_enum_set(kmi->ptr, "action", SEL_INVERT);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* set flags */
|
||||
/* set flags */
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0);
|
||||
|
||||
/* armature/bone layers */
|
||||
/* armature/bone layers */
|
||||
WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* special transforms: */
|
||||
/* 1) envelope/b-bone size */
|
||||
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);
|
||||
/* special transforms: */
|
||||
/* 1) envelope/b-bone size */
|
||||
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);
|
||||
|
||||
/* keyframes management */
|
||||
/* 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);
|
||||
WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0);
|
||||
|
||||
/* Pose -> PoseLib ------------- */
|
||||
/* only set in posemode, by space_view3d listener */
|
||||
@@ -395,7 +395,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
|
||||
|
||||
WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
|
||||
/* Pose -> Pose Sliding ------------- */
|
||||
/* only set in posemode, by space_view3d listener */
|
||||
|
||||
@@ -102,7 +102,7 @@ void ED_armature_sync_selection(ListBase *edbo)
|
||||
{
|
||||
EditBone *ebo;
|
||||
|
||||
for (ebo=edbo->first; ebo; ebo= ebo->next) {
|
||||
for (ebo = edbo->first; ebo; ebo = ebo->next) {
|
||||
/* if bone is not selectable, we shouldn't alter this setting... */
|
||||
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
|
||||
@@ -122,18 +122,18 @@ void ED_armature_sync_selection(ListBase *edbo)
|
||||
|
||||
void ED_armature_validate_active(struct bArmature *arm)
|
||||
{
|
||||
EditBone *ebone= arm->act_edbone;
|
||||
EditBone *ebone = arm->act_edbone;
|
||||
|
||||
if (ebone) {
|
||||
if (ebone->flag & BONE_HIDDEN_A)
|
||||
arm->act_edbone= NULL;
|
||||
arm->act_edbone = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void bone_free(bArmature *arm, EditBone *bone)
|
||||
{
|
||||
if (arm->act_edbone==bone)
|
||||
arm->act_edbone= NULL;
|
||||
if (arm->act_edbone == bone)
|
||||
arm->act_edbone = NULL;
|
||||
|
||||
if (bone->prop) {
|
||||
IDP_FreeProperty(bone->prop);
|
||||
@@ -148,9 +148,9 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
|
||||
EditBone *curBone;
|
||||
|
||||
/* Find any bones that refer to this bone */
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
if (curBone->parent==exBone) {
|
||||
curBone->parent=exBone->parent;
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (curBone->parent == exBone) {
|
||||
curBone->parent = exBone->parent;
|
||||
curBone->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
|
||||
/* context: editmode armature */
|
||||
EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
|
||||
{
|
||||
EditBone *eboflip= NULL;
|
||||
EditBone *eboflip = NULL;
|
||||
char name[MAXBONENAME];
|
||||
|
||||
if (ebo == NULL)
|
||||
@@ -169,9 +169,9 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
|
||||
|
||||
flip_side_name(name, ebo->name, FALSE);
|
||||
|
||||
for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) {
|
||||
for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) {
|
||||
if (ebo != eboflip) {
|
||||
if (!strcmp (name, eboflip->name))
|
||||
if (!strcmp(name, eboflip->name))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -187,10 +187,10 @@ static void armature_select_mirrored(bArmature *arm)
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
EditBone *curBone, *ebone_mirr;
|
||||
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (arm->layer & curBone->layer) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
if (ebone_mirr)
|
||||
ebone_mirr->flag |= BONE_SELECTED;
|
||||
}
|
||||
@@ -205,16 +205,16 @@ static void armature_tag_select_mirrored(bArmature *arm)
|
||||
EditBone *curBone;
|
||||
|
||||
/* always untag */
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
curBone->flag &= ~BONE_DONE;
|
||||
}
|
||||
|
||||
/* Select mirrored bones */
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (arm->layer & curBone->layer) {
|
||||
if (curBone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL)) {
|
||||
EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
|
||||
EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {
|
||||
ebone_mirr->flag |= BONE_DONE;
|
||||
}
|
||||
@@ -222,10 +222,10 @@ static void armature_tag_select_mirrored(bArmature *arm)
|
||||
}
|
||||
}
|
||||
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (curBone->flag & BONE_DONE) {
|
||||
EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
curBone->flag |= ebone_mirr->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
|
||||
EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,9 +237,9 @@ static void armature_tag_unselect(bArmature *arm)
|
||||
{
|
||||
EditBone *curBone;
|
||||
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (curBone->flag & BONE_DONE) {
|
||||
curBone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_DONE);
|
||||
curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,16 +247,16 @@ static void armature_tag_unselect(bArmature *arm)
|
||||
/* converts Bones to EditBone list, used for tools as well */
|
||||
EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone)
|
||||
{
|
||||
EditBone *eBone;
|
||||
EditBone *eBoneAct= NULL;
|
||||
EditBone *eBoneTest= NULL;
|
||||
Bone *curBone;
|
||||
EditBone *eBone;
|
||||
EditBone *eBoneAct = NULL;
|
||||
EditBone *eBoneTest = NULL;
|
||||
Bone *curBone;
|
||||
|
||||
for (curBone=bones->first; curBone; curBone=curBone->next) {
|
||||
eBone= MEM_callocN(sizeof(EditBone), "make_editbone");
|
||||
for (curBone = bones->first; curBone; curBone = curBone->next) {
|
||||
eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
|
||||
|
||||
/* Copy relevant data from bone to eBone */
|
||||
eBone->parent= parent;
|
||||
eBone->parent = parent;
|
||||
BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name));
|
||||
eBone->flag = curBone->flag;
|
||||
|
||||
@@ -295,32 +295,32 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
|
||||
eBone->roll = curBone->arm_roll;
|
||||
|
||||
/* rest of stuff copy */
|
||||
eBone->length= curBone->length;
|
||||
eBone->dist= curBone->dist;
|
||||
eBone->weight= curBone->weight;
|
||||
eBone->xwidth= curBone->xwidth;
|
||||
eBone->zwidth= curBone->zwidth;
|
||||
eBone->ease1= curBone->ease1;
|
||||
eBone->ease2= curBone->ease2;
|
||||
eBone->rad_head= curBone->rad_head;
|
||||
eBone->rad_tail= curBone->rad_tail;
|
||||
eBone->length = curBone->length;
|
||||
eBone->dist = curBone->dist;
|
||||
eBone->weight = curBone->weight;
|
||||
eBone->xwidth = curBone->xwidth;
|
||||
eBone->zwidth = curBone->zwidth;
|
||||
eBone->ease1 = curBone->ease1;
|
||||
eBone->ease2 = curBone->ease2;
|
||||
eBone->rad_head = curBone->rad_head;
|
||||
eBone->rad_tail = curBone->rad_tail;
|
||||
eBone->segments = curBone->segments;
|
||||
eBone->layer = curBone->layer;
|
||||
|
||||
if (curBone->prop)
|
||||
eBone->prop= IDP_CopyProperty(curBone->prop);
|
||||
eBone->prop = IDP_CopyProperty(curBone->prop);
|
||||
|
||||
BLI_addtail(edbo, eBone);
|
||||
|
||||
/* Add children if necessary */
|
||||
if (curBone->childbase.first) {
|
||||
eBoneTest= make_boneList(edbo, &curBone->childbase, eBone, actBone);
|
||||
eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone);
|
||||
if (eBoneTest)
|
||||
eBoneAct= eBoneTest;
|
||||
eBoneAct = eBoneTest;
|
||||
}
|
||||
|
||||
if (curBone==actBone)
|
||||
eBoneAct= eBone;
|
||||
if (curBone == actBone)
|
||||
eBoneAct = eBone;
|
||||
}
|
||||
|
||||
return eBoneAct;
|
||||
@@ -328,7 +328,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
|
||||
|
||||
/* nasty stuff for converting roll in editbones into bones */
|
||||
/* also sets restposition in armature (arm_mat) */
|
||||
static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
|
||||
static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
|
||||
{
|
||||
Bone *curBone;
|
||||
EditBone *ebone;
|
||||
@@ -338,13 +338,13 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
|
||||
float imat[3][3];
|
||||
float delta[3];
|
||||
|
||||
for (curBone=bonelist->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = bonelist->first; curBone; curBone = curBone->next) {
|
||||
/* sets local matrix and arm_mat (restpos) */
|
||||
BKE_armature_where_is_bone(curBone, curBone->parent);
|
||||
|
||||
/* Find the associated editbone */
|
||||
for (ebone = editbonelist->first; ebone; ebone=ebone->next)
|
||||
if ((Bone*)ebone->temp == curBone)
|
||||
for (ebone = editbonelist->first; ebone; ebone = ebone->next)
|
||||
if ((Bone *)ebone->temp == curBone)
|
||||
break;
|
||||
|
||||
if (ebone) {
|
||||
@@ -358,11 +358,11 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
|
||||
invert_m3_m3(imat, premat);
|
||||
mul_m3_m3m3(difmat, imat, postmat);
|
||||
#if 0
|
||||
printf ("Bone %s\n", curBone->name);
|
||||
printf("Bone %s\n", curBone->name);
|
||||
print_m4("premat", premat);
|
||||
print_m4("postmat", postmat);
|
||||
print_m4("difmat", difmat);
|
||||
printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
|
||||
printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
|
||||
#endif
|
||||
curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]);
|
||||
|
||||
@@ -376,25 +376,25 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
|
||||
/* put EditMode back in Object */
|
||||
void ED_armature_from_edit(Object *obedit)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *eBone, *neBone;
|
||||
Bone *newBone;
|
||||
Bone *newBone;
|
||||
Object *obt;
|
||||
|
||||
/* armature bones */
|
||||
BKE_armature_bonelist_free(&arm->bonebase);
|
||||
|
||||
/* remove zero sized bones, this gives instable restposes */
|
||||
for (eBone=arm->edbo->first; eBone; eBone= neBone) {
|
||||
float len= len_v3v3(eBone->head, eBone->tail);
|
||||
neBone= eBone->next;
|
||||
if (len <= 0.000001f) { /* FLT_EPSILON is too large? */
|
||||
for (eBone = arm->edbo->first; eBone; eBone = neBone) {
|
||||
float len = len_v3v3(eBone->head, eBone->tail);
|
||||
neBone = eBone->next;
|
||||
if (len <= 0.000001f) { /* FLT_EPSILON is too large? */
|
||||
EditBone *fBone;
|
||||
|
||||
/* Find any bones that refer to this bone */
|
||||
for (fBone=arm->edbo->first; fBone; fBone= fBone->next) {
|
||||
if (fBone->parent==eBone)
|
||||
fBone->parent= eBone->parent;
|
||||
for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
|
||||
if (fBone->parent == eBone)
|
||||
fBone->parent = eBone->parent;
|
||||
}
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("Warning: removed zero sized bone: %s\n", eBone->name);
|
||||
@@ -403,23 +403,23 @@ void ED_armature_from_edit(Object *obedit)
|
||||
}
|
||||
|
||||
/* Copy the bones from the editData into the armature */
|
||||
for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
|
||||
newBone= MEM_callocN(sizeof(Bone), "bone");
|
||||
eBone->temp= newBone; /* Associate the real Bones with the EditBones */
|
||||
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
|
||||
newBone = MEM_callocN(sizeof(Bone), "bone");
|
||||
eBone->temp = newBone; /* Associate the real Bones with the EditBones */
|
||||
|
||||
BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
|
||||
copy_v3_v3(newBone->arm_head, eBone->head);
|
||||
copy_v3_v3(newBone->arm_tail, eBone->tail);
|
||||
newBone->arm_roll = eBone->roll;
|
||||
|
||||
newBone->flag= eBone->flag;
|
||||
newBone->flag = eBone->flag;
|
||||
|
||||
if (eBone == arm->act_edbone) {
|
||||
/* don't change active selection, this messes up separate which uses
|
||||
* editmode toggle and can separate active bone which is de-selected originally */
|
||||
/* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */
|
||||
arm->act_edbone= NULL;
|
||||
arm->act_bone= newBone;
|
||||
arm->act_edbone = NULL;
|
||||
arm->act_bone = newBone;
|
||||
}
|
||||
newBone->roll = 0.0f;
|
||||
|
||||
@@ -428,29 +428,29 @@ void ED_armature_from_edit(Object *obedit)
|
||||
|
||||
newBone->xwidth = eBone->xwidth;
|
||||
newBone->zwidth = eBone->zwidth;
|
||||
newBone->ease1= eBone->ease1;
|
||||
newBone->ease2= eBone->ease2;
|
||||
newBone->rad_head= eBone->rad_head;
|
||||
newBone->rad_tail= eBone->rad_tail;
|
||||
newBone->segments= eBone->segments;
|
||||
newBone->ease1 = eBone->ease1;
|
||||
newBone->ease2 = eBone->ease2;
|
||||
newBone->rad_head = eBone->rad_head;
|
||||
newBone->rad_tail = eBone->rad_tail;
|
||||
newBone->segments = eBone->segments;
|
||||
newBone->layer = eBone->layer;
|
||||
|
||||
if (eBone->prop)
|
||||
newBone->prop= IDP_CopyProperty(eBone->prop);
|
||||
newBone->prop = IDP_CopyProperty(eBone->prop);
|
||||
}
|
||||
|
||||
/* Fix parenting in a separate pass to ensure ebone->bone connections
|
||||
* are valid at this point */
|
||||
for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
|
||||
newBone= (Bone *)eBone->temp;
|
||||
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
|
||||
newBone = (Bone *)eBone->temp;
|
||||
if (eBone->parent) {
|
||||
newBone->parent= (Bone *)eBone->parent->temp;
|
||||
newBone->parent = (Bone *)eBone->parent->temp;
|
||||
BLI_addtail(&newBone->parent->childbase, newBone);
|
||||
|
||||
{
|
||||
float M_parentRest[3][3];
|
||||
float iM_parentRest[3][3];
|
||||
float delta[3];
|
||||
float delta[3];
|
||||
|
||||
/* Get the parent's matrix (rotation only) */
|
||||
sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head);
|
||||
@@ -480,8 +480,8 @@ void ED_armature_from_edit(Object *obedit)
|
||||
fix_bonelist_roll(&arm->bonebase, arm->edbo);
|
||||
|
||||
/* so all users of this armature should get rebuilt */
|
||||
for (obt= G.main->object.first; obt; obt= obt->id.next) {
|
||||
if (obt->data==arm)
|
||||
for (obt = G.main->object.first; obt; obt = obt->id.next) {
|
||||
if (obt->data == arm)
|
||||
BKE_pose_rebuild(obt, arm);
|
||||
}
|
||||
|
||||
@@ -491,8 +491,8 @@ void ED_armature_from_edit(Object *obedit)
|
||||
void ED_armature_apply_transform(Object *ob, float mat[4][4])
|
||||
{
|
||||
EditBone *ebone;
|
||||
bArmature *arm= ob->data;
|
||||
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
|
||||
bArmature *arm = ob->data;
|
||||
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
|
||||
float mat3[3][3];
|
||||
|
||||
copy_m3_m4(mat3, mat);
|
||||
@@ -502,8 +502,8 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
|
||||
ED_armature_to_edit(ob);
|
||||
|
||||
/* Do the rotations */
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
float delta[3], tmat[3][3];
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
float delta[3], tmat[3][3];
|
||||
|
||||
/* find the current bone's roll matrix */
|
||||
sub_v3_v3v3(delta, ebone->tail, ebone->head);
|
||||
@@ -519,13 +519,13 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
|
||||
/* apply the transfiormed roll back */
|
||||
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
|
||||
|
||||
ebone->rad_head *= scale;
|
||||
ebone->rad_tail *= scale;
|
||||
ebone->dist *= scale;
|
||||
ebone->rad_head *= scale;
|
||||
ebone->rad_tail *= scale;
|
||||
ebone->dist *= scale;
|
||||
|
||||
/* we could be smarter and scale by the matrix along the x & z axis */
|
||||
ebone->xwidth *= scale;
|
||||
ebone->zwidth *= scale;
|
||||
ebone->xwidth *= scale;
|
||||
ebone->zwidth *= scale;
|
||||
}
|
||||
|
||||
/* Turn the list into an armature */
|
||||
@@ -537,15 +537,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
|
||||
/* 0 == do center, 1 == center new, 2 == center cursor */
|
||||
void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode, int around)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
EditBone *ebone;
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
float cent[3];
|
||||
|
||||
/* Put the armature into editmode */
|
||||
if (ob != obedit) {
|
||||
ED_armature_to_edit(ob);
|
||||
obedit= NULL; /* we cant use this so behave as if there is no obedit */
|
||||
obedit = NULL; /* we cant use this so behave as if there is no obedit */
|
||||
}
|
||||
|
||||
/* Find the centerpoint */
|
||||
@@ -555,20 +555,20 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
|
||||
mul_m4_v3(ob->imat, cent);
|
||||
}
|
||||
else {
|
||||
if (around==V3D_CENTROID) {
|
||||
int total= 0;
|
||||
if (around == V3D_CENTROID) {
|
||||
int total = 0;
|
||||
zero_v3(cent);
|
||||
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
total+=2;
|
||||
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);
|
||||
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) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
DO_MINMAX(ebone->head, min, max);
|
||||
DO_MINMAX(ebone->tail, min, max);
|
||||
}
|
||||
@@ -577,19 +577,19 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
|
||||
}
|
||||
|
||||
/* Do the adjustments */
|
||||
for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
sub_v3_v3(ebone->head, cent);
|
||||
sub_v3_v3(ebone->tail, cent);
|
||||
}
|
||||
|
||||
/* Turn the list into an armature */
|
||||
if (obedit==NULL) {
|
||||
if (obedit == NULL) {
|
||||
ED_armature_from_edit(ob);
|
||||
ED_armature_edit_free(ob);
|
||||
}
|
||||
|
||||
/* Adjust object location for new centerpoint */
|
||||
if (centermode && obedit==NULL) {
|
||||
if (centermode && obedit == NULL) {
|
||||
mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
|
||||
add_v3_v3(ob->loc, cent);
|
||||
}
|
||||
@@ -598,7 +598,7 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
|
||||
/* ---------------------- */
|
||||
|
||||
/* 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)
|
||||
static EditBone *editbone_name_exists(ListBase *edbo, const char *name)
|
||||
{
|
||||
return BLI_findstring(edbo, name, offsetof(EditBone, name));
|
||||
}
|
||||
@@ -606,27 +606,27 @@ static EditBone *editbone_name_exists (ListBase *edbo, const char *name)
|
||||
/* note: there's a unique_bone_name() too! */
|
||||
static int editbone_unique_check(void *arg, const char *name)
|
||||
{
|
||||
struct {ListBase *lb;void *bone;} *data= arg;
|
||||
EditBone *dupli= editbone_name_exists(data->lb, name);
|
||||
struct {ListBase *lb; void *bone; } *data = arg;
|
||||
EditBone *dupli = editbone_name_exists(data->lb, name);
|
||||
return dupli && dupli != data->bone;
|
||||
}
|
||||
|
||||
void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone)
|
||||
{
|
||||
struct {ListBase *lb; void *bone;} data;
|
||||
data.lb= edbo;
|
||||
data.bone= bone;
|
||||
struct {ListBase *lb; void *bone; } data;
|
||||
data.lb = edbo;
|
||||
data.bone = bone;
|
||||
|
||||
BLI_uniquename_cb(editbone_unique_check, &data, "Bone", '.', name, sizeof(bone->name));
|
||||
}
|
||||
|
||||
/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
|
||||
static void applyarmature_fix_boneparents (Scene *scene, Object *armob)
|
||||
static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
|
||||
{
|
||||
Object workob, *ob;
|
||||
|
||||
/* go through all objects in database */
|
||||
for (ob= G.main->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
/* if parent is bone in this armature, apply corrections */
|
||||
if ((ob->parent == armob) && (ob->partype == PARBONE)) {
|
||||
/* apply current transform from parent (not yet destroyed),
|
||||
@@ -641,17 +641,17 @@ static void applyarmature_fix_boneparents (Scene *scene, Object *armob)
|
||||
}
|
||||
|
||||
/* set the current pose as the restpose */
|
||||
static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
|
||||
static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
|
||||
bArmature *arm= BKE_armature_from_object(ob);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
|
||||
bArmature *arm = BKE_armature_from_object(ob);
|
||||
bPose *pose;
|
||||
bPoseChannel *pchan;
|
||||
EditBone *curbone;
|
||||
|
||||
/* don't check if editmode (should be done by caller) */
|
||||
if (ob->type!=OB_ARMATURE)
|
||||
if (ob->type != OB_ARMATURE)
|
||||
return OPERATOR_CANCELLED;
|
||||
if (BKE_object_obdata_is_libdata(ob)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata();
|
||||
@@ -667,10 +667,10 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
|
||||
ED_armature_to_edit(ob);
|
||||
|
||||
/* get pose of active object and move it out of posemode */
|
||||
pose= ob->pose;
|
||||
pose = ob->pose;
|
||||
|
||||
for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
|
||||
curbone= editbone_name_exists(arm->edbo, pchan->name);
|
||||
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
curbone = editbone_name_exists(arm->edbo, pchan->name);
|
||||
|
||||
/* simply copy the head/tail values from pchan over to curbone */
|
||||
copy_v3_v3(curbone->head, pchan->pose_head);
|
||||
@@ -697,7 +697,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
|
||||
mat3_to_eul(eul, tmat);
|
||||
|
||||
/* just use this euler-y as new roll value */
|
||||
curbone->roll= eul[1];
|
||||
curbone->roll = eul[1];
|
||||
}
|
||||
|
||||
/* clear transform values for pchan */
|
||||
@@ -705,7 +705,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
|
||||
zero_v3(pchan->eul);
|
||||
unit_qt(pchan->quat);
|
||||
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
|
||||
pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f;
|
||||
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
|
||||
|
||||
/* set anim lock */
|
||||
curbone->flag |= BONE_UNKEYED;
|
||||
@@ -722,7 +722,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
|
||||
applyarmature_fix_boneparents(scene, ob);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -739,17 +739,17 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
/* set the current pose as the restpose */
|
||||
static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
|
||||
|
||||
/* don't check if editmode (should be done by caller) */
|
||||
if (ob->type!=OB_ARMATURE)
|
||||
if (ob->type != OB_ARMATURE)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* loop over all selected pchans
|
||||
@@ -773,7 +773,7 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -790,7 +790,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ---------------------- */
|
||||
@@ -804,13 +804,13 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
bConstraint *con;
|
||||
|
||||
/* let's go through all objects in database */
|
||||
for (ob= G.main->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
/* do some object-type specific things */
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
pose= ob->pose;
|
||||
for (pchant= pose->chanbase.first; pchant; pchant= pchant->next) {
|
||||
for (con= pchant->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
pose = ob->pose;
|
||||
for (pchant = pose->chanbase.first; pchant; pchant = pchant->next) {
|
||||
for (con = pchant->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -818,12 +818,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if (ct->tar == srcArm) {
|
||||
if (ct->subtarget[0] == '\0') {
|
||||
ct->tar = tarArm;
|
||||
}
|
||||
else if (strcmp(ct->subtarget, pchan->name)==0) {
|
||||
else if (strcmp(ct->subtarget, pchan->name) == 0) {
|
||||
ct->tar = tarArm;
|
||||
BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget));
|
||||
}
|
||||
@@ -836,15 +836,15 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
|
||||
/* action constraint? */
|
||||
if (con->type == CONSTRAINT_TYPE_ACTION) {
|
||||
bActionConstraint *data= con->data; // XXX old animation system
|
||||
bActionConstraint *data = con->data; // XXX old animation system
|
||||
bAction *act;
|
||||
bActionChannel *achan;
|
||||
|
||||
if (data->act) {
|
||||
act= data->act;
|
||||
act = data->act;
|
||||
|
||||
for (achan= act->chanbase.first; achan; achan= achan->next) {
|
||||
if (strcmp(achan->name, pchan->name)==0)
|
||||
for (achan = act->chanbase.first; achan; achan = achan->next) {
|
||||
if (strcmp(achan->name, pchan->name) == 0)
|
||||
BLI_strncpy(achan->name, curbone->name, sizeof(achan->name));
|
||||
}
|
||||
}
|
||||
@@ -856,8 +856,8 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
|
||||
/* fix object-level constraints */
|
||||
if (ob != srcArm) {
|
||||
for (con= ob->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -865,12 +865,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if (ct->tar == srcArm) {
|
||||
if (ct->subtarget[0] == '\0') {
|
||||
ct->tar = tarArm;
|
||||
}
|
||||
else if (strcmp(ct->subtarget, pchan->name)==0) {
|
||||
else if (strcmp(ct->subtarget, pchan->name) == 0) {
|
||||
ct->tar = tarArm;
|
||||
BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget));
|
||||
}
|
||||
@@ -886,7 +886,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
|
||||
/* See if an object is parented to this armature */
|
||||
if (ob->parent && (ob->parent == srcArm)) {
|
||||
/* Is object parented to a bone of this src armature? */
|
||||
if (ob->partype==PARBONE) {
|
||||
if (ob->partype == PARBONE) {
|
||||
/* bone name in object */
|
||||
if (!strcmp(ob->parsubstr, pchan->name))
|
||||
BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr));
|
||||
@@ -901,17 +901,17 @@ 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 *UNUSED(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;
|
||||
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;
|
||||
bPose *pose, *opose;
|
||||
bPoseChannel *pchan, *pchann;
|
||||
EditBone *curbone;
|
||||
float mat[4][4], oimat[4][4];
|
||||
float mat[4][4], oimat[4][4];
|
||||
|
||||
/* Ensure we're not in editmode and that the active object is an armature*/
|
||||
if (!ob || ob->type!=OB_ARMATURE)
|
||||
if (!ob || ob->type != OB_ARMATURE)
|
||||
return OPERATOR_CANCELLED;
|
||||
if (!arm || arm->edbo)
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -920,19 +920,19 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ED_armature_to_edit(ob);
|
||||
|
||||
/* get pose of active object and move it out of posemode */
|
||||
pose= ob->pose;
|
||||
pose = ob->pose;
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
|
||||
CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases)
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
|
||||
{
|
||||
if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) {
|
||||
bArmature *curarm= base->object->data;
|
||||
if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
|
||||
bArmature *curarm = base->object->data;
|
||||
|
||||
/* Make a list of editbones in current armature */
|
||||
ED_armature_to_edit(base->object);
|
||||
|
||||
/* Get Pose of current armature */
|
||||
opose= base->object->pose;
|
||||
opose = base->object->pose;
|
||||
base->object->mode &= ~OB_MODE_POSE;
|
||||
//BASACT->flag &= ~OB_MODE_POSE;
|
||||
|
||||
@@ -941,9 +941,9 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
mult_m4_m4m4(mat, oimat, base->object->obmat);
|
||||
|
||||
/* Copy bones and posechannels from the object to the edit armature */
|
||||
for (pchan=opose->chanbase.first; pchan; pchan=pchann) {
|
||||
pchann= pchan->next;
|
||||
curbone= editbone_name_exists(curarm->edbo, pchan->name);
|
||||
for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
|
||||
pchann = pchan->next;
|
||||
curbone = editbone_name_exists(curarm->edbo, pchan->name);
|
||||
|
||||
/* Get new name */
|
||||
unique_editbone_name(arm->edbo, curbone->name, NULL);
|
||||
@@ -1000,12 +1000,12 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
DAG_scene_sort(bmain, 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);
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1021,16 +1021,16 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
ListBase *opchans, *npchans;
|
||||
|
||||
/* get reference to list of bones in original and new armatures */
|
||||
opchans= &origArm->pose->chanbase;
|
||||
npchans= &newArm->pose->chanbase;
|
||||
opchans = &origArm->pose->chanbase;
|
||||
npchans = &newArm->pose->chanbase;
|
||||
|
||||
/* let's go through all objects in database */
|
||||
for (ob= G.main->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
/* do some object-type specific things */
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -1038,7 +1038,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
/* any targets which point to original armature are redirected to the new one only if:
|
||||
* - the target isn't origArm/newArm itself
|
||||
* - the target is one that can be found in newArm/origArm
|
||||
@@ -1046,12 +1046,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
if (ct->subtarget[0] != 0) {
|
||||
if (ct->tar == origArm) {
|
||||
if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
|
||||
ct->tar= newArm;
|
||||
ct->tar = newArm;
|
||||
}
|
||||
}
|
||||
else if (ct->tar == newArm) {
|
||||
if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
|
||||
ct->tar= origArm;
|
||||
ct->tar = origArm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1067,8 +1067,8 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
|
||||
/* fix object-level constraints */
|
||||
if (ob != origArm) {
|
||||
for (con= ob->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = ob->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -1076,7 +1076,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
/* any targets which point to original armature are redirected to the new one only if:
|
||||
* - the target isn't origArm/newArm itself
|
||||
* - the target is one that can be found in newArm/origArm
|
||||
@@ -1084,12 +1084,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
if (ct->subtarget[0] != '\0') {
|
||||
if (ct->tar == origArm) {
|
||||
if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
|
||||
ct->tar= newArm;
|
||||
ct->tar = newArm;
|
||||
}
|
||||
}
|
||||
else if (ct->tar == newArm) {
|
||||
if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
|
||||
ct->tar= origArm;
|
||||
ct->tar = origArm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1107,7 +1107,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
/* Is object parented to a bone of this src armature? */
|
||||
if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
|
||||
if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
|
||||
ob->parent= newArm;
|
||||
ob->parent = newArm;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1120,7 +1120,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
|
||||
*/
|
||||
static void separate_armature_bones(Object *ob, short sel)
|
||||
{
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
bPoseChannel *pchan, *pchann;
|
||||
EditBone *curbone;
|
||||
|
||||
@@ -1128,30 +1128,30 @@ static void separate_armature_bones(Object *ob, short sel)
|
||||
ED_armature_to_edit(ob);
|
||||
|
||||
/* go through pose-channels, checking if a bone should be removed */
|
||||
for (pchan=ob->pose->chanbase.first; pchan; pchan=pchann) {
|
||||
pchann= pchan->next;
|
||||
curbone= editbone_name_exists(arm->edbo, pchan->name);
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) {
|
||||
pchann = pchan->next;
|
||||
curbone = editbone_name_exists(arm->edbo, pchan->name);
|
||||
|
||||
/* check if bone needs to be removed */
|
||||
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
|
||||
(!sel && !(curbone->flag & BONE_SELECTED)) )
|
||||
(!sel && !(curbone->flag & BONE_SELECTED)) )
|
||||
{
|
||||
EditBone *ebo;
|
||||
bPoseChannel *pchn;
|
||||
|
||||
/* clear the bone->parent var of any bone that had this as its parent */
|
||||
for (ebo= arm->edbo->first; ebo; ebo= ebo->next) {
|
||||
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
||||
if (ebo->parent == curbone) {
|
||||
ebo->parent= NULL;
|
||||
ebo->temp= NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */
|
||||
ebo->parent = NULL;
|
||||
ebo->temp = NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */
|
||||
ebo->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
/* clear the pchan->parent var of any pchan that had this as its parent */
|
||||
for (pchn= ob->pose->chanbase.first; pchn; pchn=pchn->next) {
|
||||
for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
|
||||
if (pchn->parent == pchan)
|
||||
pchn->parent= NULL;
|
||||
pchn->parent = NULL;
|
||||
}
|
||||
|
||||
/* free any of the extra-data this pchan might have */
|
||||
@@ -1170,11 +1170,11 @@ static void separate_armature_bones(Object *ob, short sel)
|
||||
}
|
||||
|
||||
/* separate selected bones into their armature */
|
||||
static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Object *oldob, *newob;
|
||||
Base *oldbase, *newbase;
|
||||
|
||||
@@ -1197,14 +1197,14 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
// TODO: use context iterators for this?
|
||||
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
|
||||
{
|
||||
if (base->object==obedit) base->flag |= 1;
|
||||
if (base->object == obedit) base->flag |= 1;
|
||||
else base->flag &= ~1;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* 1) store starting settings and exit editmode */
|
||||
oldob= obedit;
|
||||
oldbase= BASACT;
|
||||
oldob = obedit;
|
||||
oldbase = BASACT;
|
||||
oldob->mode &= ~OB_MODE_POSE;
|
||||
//oldbase->flag &= ~OB_POSEMODE;
|
||||
|
||||
@@ -1212,8 +1212,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
ED_armature_edit_free(obedit);
|
||||
|
||||
/* 2) duplicate base */
|
||||
newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
|
||||
newob= newbase->object;
|
||||
newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
|
||||
newob = newbase->object;
|
||||
newbase->flag &= ~SELECT;
|
||||
|
||||
|
||||
@@ -1225,17 +1225,17 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
/* 4) fix links before depsgraph flushes */ // err... or after?
|
||||
separated_armature_fix_links(oldob, newob);
|
||||
|
||||
DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
|
||||
DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
|
||||
DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
|
||||
DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
|
||||
|
||||
|
||||
/* 5) restore original conditions */
|
||||
obedit= oldob;
|
||||
obedit = oldob;
|
||||
|
||||
ED_armature_to_edit(obedit);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
|
||||
|
||||
/* recalc/redraw + cleanup */
|
||||
WM_cursor_wait(0);
|
||||
@@ -1256,20 +1256,20 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* **************** END tools on Editmode Armature **************** */
|
||||
/* **************** PoseMode & EditMode *************************** */
|
||||
|
||||
/* only for opengl selection indices */
|
||||
Bone *get_indexed_bone (Object *ob, int index)
|
||||
Bone *get_indexed_bone(Object *ob, int index)
|
||||
{
|
||||
bPoseChannel *pchan;
|
||||
if (ob->pose==NULL) return NULL;
|
||||
index>>=16; // bone selection codes use left 2 bytes
|
||||
if (ob->pose == NULL) return NULL;
|
||||
index >>= 16; // bone selection codes use left 2 bytes
|
||||
|
||||
pchan= BLI_findlink(&ob->pose->chanbase, index);
|
||||
pchan = BLI_findlink(&ob->pose->chanbase, index);
|
||||
return pchan ? pchan->bone : NULL;
|
||||
}
|
||||
|
||||
@@ -1277,22 +1277,22 @@ Bone *get_indexed_bone (Object *ob, int index)
|
||||
/* only bones from base are checked on */
|
||||
static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short findunsel)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
Bone *bone;
|
||||
EditBone *ebone;
|
||||
void *firstunSel=NULL, *firstSel=NULL, *data;
|
||||
void *firstunSel = NULL, *firstSel = NULL, *data;
|
||||
unsigned int hitresult;
|
||||
short i, takeNext=0, sel;
|
||||
short i, takeNext = 0, sel;
|
||||
|
||||
for (i=0; i< hits; i++) {
|
||||
hitresult = buffer[3+(i*4)];
|
||||
for (i = 0; i < hits; i++) {
|
||||
hitresult = buffer[3 + (i * 4)];
|
||||
|
||||
if (!(hitresult & BONESEL_NOSEL)) { // -1
|
||||
if (hitresult & BONESEL_ANY) { // to avoid including objects in selection
|
||||
if (!(hitresult & BONESEL_NOSEL)) { // -1
|
||||
if (hitresult & BONESEL_ANY) { // to avoid including objects in selection
|
||||
|
||||
hitresult &= ~(BONESEL_ANY);
|
||||
/* Determine what the current bone is */
|
||||
if (obedit==NULL || base->object!=obedit) {
|
||||
if (obedit == NULL || base->object != obedit) {
|
||||
/* no singular posemode, so check for correct object */
|
||||
if (base->selcol == (hitresult & 0xFFFF)) {
|
||||
bone = get_indexed_bone(base->object, hitresult);
|
||||
@@ -1305,12 +1305,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
|
||||
data = bone;
|
||||
}
|
||||
else {
|
||||
data= NULL;
|
||||
sel= 0;
|
||||
data = NULL;
|
||||
sel = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
bArmature *arm= obedit->data;
|
||||
bArmature *arm = obedit->data;
|
||||
|
||||
ebone = BLI_findlink(arm->edbo, hitresult);
|
||||
if (findunsel)
|
||||
@@ -1323,12 +1323,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
|
||||
|
||||
if (data) {
|
||||
if (sel) {
|
||||
if (!firstSel) firstSel= data;
|
||||
takeNext=1;
|
||||
if (!firstSel) firstSel = data;
|
||||
takeNext = 1;
|
||||
}
|
||||
else {
|
||||
if (!firstunSel)
|
||||
firstunSel=data;
|
||||
firstunSel = data;
|
||||
if (takeNext)
|
||||
return data;
|
||||
}
|
||||
@@ -1348,7 +1348,7 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
|
||||
/* used by posemode as well editmode */
|
||||
/* only checks scene->basact! */
|
||||
/* x and y are mouse coords (area space) */
|
||||
static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
|
||||
static void *get_nearest_bone(bContext *C, short findunsel, int x, int y)
|
||||
{
|
||||
ViewContext vc;
|
||||
rcti rect;
|
||||
@@ -1362,9 +1362,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
|
||||
rect.ymin = rect.ymax = y;
|
||||
|
||||
glInitNames();
|
||||
hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
|
||||
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
|
||||
|
||||
if (hits>0)
|
||||
if (hits > 0)
|
||||
return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel);
|
||||
|
||||
return NULL;
|
||||
@@ -1373,9 +1373,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
|
||||
/* Get the first available child of an editbone */
|
||||
static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_visibility)
|
||||
{
|
||||
EditBone *curbone, *chbone=NULL;
|
||||
EditBone *curbone, *chbone = NULL;
|
||||
|
||||
for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
|
||||
for (curbone = arm->edbo->first; curbone; curbone = curbone->next) {
|
||||
if (curbone->parent == pabone) {
|
||||
if (use_visibility) {
|
||||
if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) {
|
||||
@@ -1394,7 +1394,7 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_
|
||||
/* **************** Posemode stuff ********************** */
|
||||
|
||||
|
||||
static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend)
|
||||
static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
|
||||
{
|
||||
Bone *curBone;
|
||||
|
||||
@@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
|
||||
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
|
||||
return;
|
||||
|
||||
// XXX old cruft! use notifiers instead
|
||||
// XXX old cruft! use notifiers instead
|
||||
//select_actionchannel_by_name (ob->action, bone->name, !(shift));
|
||||
|
||||
if (extend)
|
||||
@@ -1410,7 +1410,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
|
||||
else
|
||||
bone->flag |= BONE_SELECTED;
|
||||
|
||||
for (curBone=bone->childbase.first; curBone; curBone=curBone->next)
|
||||
for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
|
||||
selectconnected_posebonechildren(ob, curBone, extend);
|
||||
}
|
||||
|
||||
@@ -1418,25 +1418,25 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
|
||||
/* previously known as "selectconnected_posearmature" */
|
||||
static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
Bone *bone, *curBone, *next= NULL;
|
||||
int extend= RNA_boolean_get(op->ptr, "extend");
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
Bone *bone, *curBone, *next = NULL;
|
||||
int extend = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if (extend)
|
||||
bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
|
||||
bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
|
||||
else
|
||||
bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
|
||||
bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
|
||||
|
||||
if (!bone)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* Select parents */
|
||||
for (curBone=bone; curBone; curBone=next) {
|
||||
for (curBone = bone; curBone; curBone = next) {
|
||||
/* ignore bone if cannot be selected */
|
||||
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
// XXX old cruft! use notifiers instead
|
||||
// XXX old cruft! use notifiers instead
|
||||
//select_actionchannel_by_name (ob->action, curBone->name, !(shift));
|
||||
|
||||
if (extend)
|
||||
@@ -1445,26 +1445,26 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev
|
||||
curBone->flag |= BONE_SELECTED;
|
||||
|
||||
if (curBone->flag & BONE_CONNECTED)
|
||||
next=curBone->parent;
|
||||
next = curBone->parent;
|
||||
else
|
||||
next=NULL;
|
||||
next = NULL;
|
||||
}
|
||||
else
|
||||
next= NULL;
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
/* Select children */
|
||||
for (curBone=bone->childbase.first; curBone; curBone=next)
|
||||
for (curBone = bone->childbase.first; curBone; curBone = next)
|
||||
selectconnected_posebonechildren(ob, curBone, extend);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int pose_select_linked_poll(bContext *C)
|
||||
{
|
||||
return ( ED_operator_view3d_active(C) && ED_operator_posemode(C) );
|
||||
return (ED_operator_view3d_active(C) && ED_operator_posemode(C) );
|
||||
}
|
||||
|
||||
void POSE_OT_select_linked(wmOperatorType *ot)
|
||||
@@ -1480,7 +1480,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
|
||||
ot->poll = pose_select_linked_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
|
||||
@@ -1495,70 +1495,70 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e
|
||||
{
|
||||
bArmature *arm;
|
||||
EditBone *bone, *curBone, *next;
|
||||
int extend= RNA_boolean_get(op->ptr, "extend");
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
arm= obedit->data;
|
||||
int extend = RNA_boolean_get(op->ptr, "extend");
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
arm = obedit->data;
|
||||
|
||||
view3d_operator_needs_opengl(C);
|
||||
|
||||
if (extend)
|
||||
bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
|
||||
bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
|
||||
else
|
||||
bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
|
||||
bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
|
||||
|
||||
if (!bone)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* Select parents */
|
||||
for (curBone=bone; curBone; curBone=next) {
|
||||
for (curBone = bone; curBone; curBone = next) {
|
||||
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if (extend) {
|
||||
curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else {
|
||||
curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
}
|
||||
|
||||
if (curBone->flag & BONE_CONNECTED)
|
||||
next=curBone->parent;
|
||||
next = curBone->parent;
|
||||
else
|
||||
next=NULL;
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
/* Select children */
|
||||
while (bone) {
|
||||
for (curBone=arm->edbo->first; curBone; curBone=next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = next) {
|
||||
next = curBone->next;
|
||||
if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if (curBone->flag & BONE_CONNECTED) {
|
||||
if (extend)
|
||||
curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
else
|
||||
curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
bone=curBone;
|
||||
curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
bone = curBone;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
bone=NULL;
|
||||
bone = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!curBone)
|
||||
bone=NULL;
|
||||
bone = NULL;
|
||||
}
|
||||
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int armature_select_linked_poll(bContext *C)
|
||||
{
|
||||
return ( ED_operator_view3d_active(C) && ED_operator_editarmature(C) );
|
||||
return (ED_operator_view3d_active(C) && ED_operator_editarmature(C) );
|
||||
}
|
||||
|
||||
void ARMATURE_OT_select_linked(wmOperatorType *ot)
|
||||
@@ -1574,7 +1574,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
|
||||
ot->poll = armature_select_linked_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties s*/
|
||||
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
|
||||
@@ -1582,71 +1582,71 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
|
||||
|
||||
/* does bones and points */
|
||||
/* note that BONE ROOT only gets drawn for root bones (or without IK) */
|
||||
static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask)
|
||||
static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask)
|
||||
{
|
||||
EditBone *ebone;
|
||||
rcti rect;
|
||||
unsigned int buffer[MAXPICKBUF];
|
||||
unsigned int hitresult, besthitresult=BONESEL_NOSEL;
|
||||
int i, mindep= 4;
|
||||
unsigned int hitresult, besthitresult = BONESEL_NOSEL;
|
||||
int i, mindep = 4;
|
||||
short hits;
|
||||
|
||||
glInitNames();
|
||||
|
||||
rect.xmin = mval[0]-5;
|
||||
rect.xmax = mval[0]+5;
|
||||
rect.ymin = mval[1]-5;
|
||||
rect.ymax = mval[1]+5;
|
||||
|
||||
hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
|
||||
if (hits==0) {
|
||||
rect.xmin = mval[0]-12;
|
||||
rect.xmax = mval[0]+12;
|
||||
rect.ymin = mval[1]-12;
|
||||
rect.ymax = mval[1]+12;
|
||||
hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
|
||||
rect.xmin = mval[0] - 5;
|
||||
rect.xmax = mval[0] + 5;
|
||||
rect.ymin = mval[1] - 5;
|
||||
rect.ymax = mval[1] + 5;
|
||||
|
||||
hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
|
||||
if (hits == 0) {
|
||||
rect.xmin = mval[0] - 12;
|
||||
rect.xmax = mval[0] + 12;
|
||||
rect.ymin = mval[1] - 12;
|
||||
rect.ymax = mval[1] + 12;
|
||||
hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
|
||||
}
|
||||
/* See if there are any selected bones in this group */
|
||||
if (hits>0) {
|
||||
if (hits > 0) {
|
||||
|
||||
if (hits==1) {
|
||||
if (hits == 1) {
|
||||
if (!(buffer[3] & BONESEL_NOSEL))
|
||||
besthitresult= buffer[3];
|
||||
besthitresult = buffer[3];
|
||||
}
|
||||
else {
|
||||
for (i=0; i< hits; i++) {
|
||||
hitresult= buffer[3+(i*4)];
|
||||
for (i = 0; i < hits; i++) {
|
||||
hitresult = buffer[3 + (i * 4)];
|
||||
if (!(hitresult & BONESEL_NOSEL)) {
|
||||
int dep;
|
||||
|
||||
ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY);
|
||||
|
||||
/* clicks on bone points get advantage */
|
||||
if ( hitresult & (BONESEL_ROOT|BONESEL_TIP)) {
|
||||
if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
|
||||
/* but also the unselected one */
|
||||
if (findunsel) {
|
||||
if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0)
|
||||
dep= 1;
|
||||
else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0)
|
||||
dep= 1;
|
||||
if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0)
|
||||
dep = 1;
|
||||
else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
|
||||
dep = 1;
|
||||
else
|
||||
dep= 2;
|
||||
dep = 2;
|
||||
}
|
||||
else dep= 2;
|
||||
else dep = 2;
|
||||
}
|
||||
else {
|
||||
/* bone found */
|
||||
if (findunsel) {
|
||||
if ((ebone->flag & BONE_SELECTED)==0)
|
||||
dep= 2;
|
||||
if ((ebone->flag & BONE_SELECTED) == 0)
|
||||
dep = 2;
|
||||
else
|
||||
dep= 3;
|
||||
dep = 3;
|
||||
}
|
||||
else dep= 3;
|
||||
else dep = 3;
|
||||
}
|
||||
if (dep < mindep) {
|
||||
mindep= dep;
|
||||
besthitresult= hitresult;
|
||||
mindep = dep;
|
||||
besthitresult = hitresult;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1654,7 +1654,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2],
|
||||
|
||||
if (!(besthitresult & BONESEL_NOSEL)) {
|
||||
|
||||
ebone= BLI_findlink(edbo, besthitresult & ~BONESEL_ANY);
|
||||
ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY);
|
||||
|
||||
*selmask = 0;
|
||||
if (besthitresult & BONESEL_ROOT)
|
||||
@@ -1675,9 +1675,9 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2],
|
||||
static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bArmature *arm;
|
||||
EditBone *curBone, *ebone_next;
|
||||
EditBone *curBone, *ebone_next;
|
||||
bConstraint *con;
|
||||
Object *obedit= CTX_data_edit_object(C); // XXX get from context
|
||||
Object *obedit = CTX_data_edit_object(C); // XXX get from context
|
||||
arm = obedit->data;
|
||||
|
||||
/* cancel if nothing selected */
|
||||
@@ -1689,31 +1689,31 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* First erase any associated pose channel */
|
||||
if (obedit->pose) {
|
||||
bPoseChannel *pchan, *pchan_next;
|
||||
for (pchan=obedit->pose->chanbase.first; pchan; pchan= pchan_next) {
|
||||
pchan_next= pchan->next;
|
||||
for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) {
|
||||
pchan_next = pchan->next;
|
||||
curBone = editbone_name_exists(arm->edbo, pchan->name);
|
||||
|
||||
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
|
||||
BKE_pose_channel_free(pchan);
|
||||
BKE_pose_channels_hash_free(obedit->pose);
|
||||
BLI_freelinkN (&obedit->pose->chanbase, pchan);
|
||||
BLI_freelinkN(&obedit->pose->chanbase, pchan);
|
||||
}
|
||||
else {
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if (ct->tar == obedit) {
|
||||
if (ct->subtarget[0]) {
|
||||
curBone = editbone_name_exists(arm->edbo, ct->subtarget);
|
||||
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
|
||||
con->flag |= CONSTRAINT_DISABLE;
|
||||
ct->subtarget[0]= 0;
|
||||
ct->subtarget[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1728,11 +1728,11 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
|
||||
|
||||
for (curBone=arm->edbo->first; curBone; curBone= ebone_next) {
|
||||
ebone_next= curBone->next;
|
||||
for (curBone = arm->edbo->first; curBone; curBone = ebone_next) {
|
||||
ebone_next = curBone->next;
|
||||
if (arm->layer & curBone->layer) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
if (curBone==arm->act_edbone) arm->act_edbone= NULL;
|
||||
if (curBone == arm->act_edbone) arm->act_edbone = NULL;
|
||||
ED_armature_edit_bone_remove(arm, curBone);
|
||||
}
|
||||
}
|
||||
@@ -1741,7 +1741,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1759,7 +1759,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* toggle==0: deselect
|
||||
@@ -1768,35 +1768,35 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
|
||||
*/
|
||||
void ED_armature_deselect_all(Object *obedit, int toggle)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
EditBone *eBone;
|
||||
int sel=1;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *eBone;
|
||||
int sel = 1;
|
||||
|
||||
if (toggle==1) {
|
||||
if (toggle == 1) {
|
||||
/* Determine if there are any selected bones
|
||||
* and therefore whether we are selecting or deselecting */
|
||||
for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
|
||||
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
|
||||
// if (arm->layer & eBone->layer) {
|
||||
if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
|
||||
sel=0;
|
||||
sel = 0;
|
||||
break;
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
else sel= toggle;
|
||||
else sel = toggle;
|
||||
|
||||
/* Set the flags */
|
||||
for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
|
||||
if (sel==2) {
|
||||
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
|
||||
if (sel == 2) {
|
||||
/* invert selection of bone */
|
||||
if (EBONE_VISIBLE(arm, eBone)) {
|
||||
eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
if (arm->act_edbone==eBone)
|
||||
arm->act_edbone= NULL;
|
||||
if (arm->act_edbone == eBone)
|
||||
arm->act_edbone = NULL;
|
||||
}
|
||||
}
|
||||
else if (sel==1) {
|
||||
else if (sel == 1) {
|
||||
/* select bone */
|
||||
if (EBONE_VISIBLE(arm, eBone)) {
|
||||
eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
@@ -1807,8 +1807,8 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
|
||||
else {
|
||||
/* deselect bone */
|
||||
eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
if (arm->act_edbone==eBone)
|
||||
arm->act_edbone= NULL;
|
||||
if (arm->act_edbone == eBone)
|
||||
arm->act_edbone = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1817,12 +1817,12 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
|
||||
|
||||
void ED_armature_deselect_all_visible(Object *obedit)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
EditBone *ebone;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
/* first and foremost, bone must be visible and selected */
|
||||
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
}
|
||||
@@ -1834,27 +1834,27 @@ void ED_armature_deselect_all_visible(Object *obedit)
|
||||
static int ebone_select_flag(EditBone *ebone)
|
||||
{
|
||||
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
|
||||
return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL));
|
||||
return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED | BONE_TIPSEL));
|
||||
}
|
||||
else {
|
||||
return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
|
||||
return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
|
||||
}
|
||||
}
|
||||
|
||||
/* context: editmode armature in view3d */
|
||||
int mouse_armature(bContext *C, const int mval[2], int extend)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = obedit->data;
|
||||
ViewContext vc;
|
||||
EditBone *nearBone = NULL;
|
||||
int selmask;
|
||||
int selmask;
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
BIF_sk_selectStroke(C, mval, extend);
|
||||
|
||||
nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
|
||||
nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
|
||||
if (nearBone) {
|
||||
|
||||
if (!extend)
|
||||
@@ -1870,7 +1870,7 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
|
||||
/* hold shift inverts this bone's selection */
|
||||
if (nearBone->flag & BONE_SELECTED) {
|
||||
/* deselect this bone */
|
||||
nearBone->flag &= ~(BONE_TIPSEL|BONE_SELECTED);
|
||||
nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
|
||||
/* only deselect parent tip if it is not selected */
|
||||
if (!(nearBone->parent->flag & BONE_SELECTED))
|
||||
nearBone->parent->flag &= ~BONE_TIPSEL;
|
||||
@@ -1891,11 +1891,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
|
||||
if (extend) {
|
||||
/* hold shift inverts this bone's selection */
|
||||
if (nearBone->flag & BONE_SELECTED)
|
||||
nearBone->flag &= ~(BONE_TIPSEL|BONE_ROOTSEL);
|
||||
nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
|
||||
else
|
||||
nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL);
|
||||
nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL);
|
||||
else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1910,11 +1910,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
|
||||
if (nearBone) {
|
||||
/* then now check for active status */
|
||||
if (ebone_select_flag(nearBone)) {
|
||||
arm->act_edbone= nearBone;
|
||||
arm->act_edbone = nearBone;
|
||||
}
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1923,13 +1923,13 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
|
||||
|
||||
void ED_armature_edit_free(struct Object *ob)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
EditBone *eBone;
|
||||
|
||||
/* Clear the editbones list */
|
||||
if (arm->edbo) {
|
||||
if (arm->edbo->first) {
|
||||
for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
|
||||
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
|
||||
if (eBone->prop) {
|
||||
IDP_FreeProperty(eBone->prop);
|
||||
MEM_freeN(eBone->prop);
|
||||
@@ -1939,19 +1939,19 @@ void ED_armature_edit_free(struct Object *ob)
|
||||
BLI_freelistN(arm->edbo);
|
||||
}
|
||||
MEM_freeN(arm->edbo);
|
||||
arm->edbo= NULL;
|
||||
arm->edbo = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Put armature in EditMode */
|
||||
void ED_armature_to_edit(Object *ob)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
ED_armature_edit_free(ob);
|
||||
arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature");
|
||||
arm->act_edbone= make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
|
||||
arm->act_bone= NULL;
|
||||
arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
|
||||
arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
|
||||
arm->act_bone = NULL;
|
||||
|
||||
// BIF_freeTemplates(); /* force template update when entering editmode */
|
||||
}
|
||||
@@ -1977,7 +1977,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short
|
||||
sub_v3_v3v3(align_axis_proj, align_axis, vec);
|
||||
|
||||
if (axis_only) {
|
||||
if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) {
|
||||
if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI / 2.0)) {
|
||||
negate_v3(align_axis_proj);
|
||||
}
|
||||
}
|
||||
@@ -2010,44 +2010,44 @@ static EnumPropertyItem prop_calc_roll_types[] = {
|
||||
|
||||
static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
const short type= RNA_enum_get(op->ptr, "type");
|
||||
const short axis_only= RNA_boolean_get(op->ptr, "axis_only");
|
||||
const short axis_flip= RNA_boolean_get(op->ptr, "axis_flip");
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
const short type = RNA_enum_get(op->ptr, "type");
|
||||
const short axis_only = RNA_boolean_get(op->ptr, "axis_only");
|
||||
const short axis_flip = RNA_boolean_get(op->ptr, "axis_flip");
|
||||
|
||||
float imat[3][3];
|
||||
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
EditBone *ebone;
|
||||
|
||||
copy_m3_m4(imat, ob->obmat);
|
||||
invert_m3(imat);
|
||||
|
||||
if (type==7) { /* Cursor */
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C); /* can be NULL */
|
||||
if (type == 7) { /* Cursor */
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
|
||||
float cursor_local[3];
|
||||
float *cursor= give_cursor(scene, v3d);
|
||||
float *cursor = give_cursor(scene, v3d);
|
||||
|
||||
|
||||
copy_v3_v3(cursor_local, cursor);
|
||||
mul_m3_v3(imat, cursor_local);
|
||||
|
||||
/* cursor */
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
|
||||
float cursor_rel[3];
|
||||
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
|
||||
if (axis_flip) negate_v3(cursor_rel);
|
||||
ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only);
|
||||
ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
float vec[3]= {0.0f, 0.0f, 0.0f};
|
||||
if (type==6) { /* View */
|
||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||
if (rv3d==NULL) {
|
||||
float vec[3] = {0.0f, 0.0f, 0.0f};
|
||||
if (type == 6) { /* View */
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
if (rv3d == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No region view3d available");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -2055,10 +2055,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
||||
copy_v3_v3(vec, rv3d->viewinv[2]);
|
||||
mul_m3_v3(imat, vec);
|
||||
}
|
||||
else if (type==5) {
|
||||
else if (type == 5) {
|
||||
float mat[3][3], nor[3];
|
||||
ebone= (EditBone *)arm->act_edbone;
|
||||
if (ebone==NULL) {
|
||||
ebone = (EditBone *)arm->act_edbone;
|
||||
if (ebone == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No active bone set");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@@ -2069,34 +2069,34 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
else { /* Axis */
|
||||
assert(type >= 0 && type <= 5);
|
||||
if (type<3) vec[type]= 1.0f;
|
||||
else vec[type-2]= -1.0f;
|
||||
if (type < 3) vec[type] = 1.0f;
|
||||
else vec[type - 2] = -1.0f;
|
||||
mul_m3_v3(imat, vec);
|
||||
}
|
||||
|
||||
if (axis_flip) negate_v3(vec);
|
||||
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
|
||||
/* roll func is a callback which assumes that all is well */
|
||||
ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only);
|
||||
ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
|
||||
EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
|
||||
ebone->roll= -ebone_mirr->roll;
|
||||
ebone->roll = -ebone_mirr->roll;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2114,7 +2114,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", "");
|
||||
@@ -2131,61 +2131,61 @@ typedef struct UndoArmature {
|
||||
|
||||
static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data))
|
||||
{
|
||||
UndoArmature *uarm= uarmv;
|
||||
bArmature *arm= armv;
|
||||
UndoArmature *uarm = uarmv;
|
||||
bArmature *arm = armv;
|
||||
EditBone *ebo, *newebo;
|
||||
|
||||
BLI_freelistN(arm->edbo);
|
||||
|
||||
/* copy */
|
||||
for (ebo= uarm->lb.first; ebo; ebo= ebo->next) {
|
||||
newebo= MEM_dupallocN(ebo);
|
||||
ebo->temp= newebo;
|
||||
for (ebo = uarm->lb.first; ebo; ebo = ebo->next) {
|
||||
newebo = MEM_dupallocN(ebo);
|
||||
ebo->temp = newebo;
|
||||
BLI_addtail(arm->edbo, newebo);
|
||||
}
|
||||
|
||||
/* active bone */
|
||||
if (uarm->act_edbone) {
|
||||
ebo= uarm->act_edbone;
|
||||
arm->act_edbone= ebo->temp;
|
||||
ebo = uarm->act_edbone;
|
||||
arm->act_edbone = ebo->temp;
|
||||
}
|
||||
else
|
||||
arm->act_edbone= NULL;
|
||||
arm->act_edbone = NULL;
|
||||
|
||||
/* set pointers */
|
||||
for (newebo= arm->edbo->first; newebo; newebo= newebo->next) {
|
||||
if (newebo->parent) newebo->parent= newebo->parent->temp;
|
||||
for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
|
||||
if (newebo->parent) newebo->parent = newebo->parent->temp;
|
||||
}
|
||||
/* be sure they don't hang ever */
|
||||
for (newebo= arm->edbo->first; newebo; newebo= newebo->next) {
|
||||
newebo->temp= NULL;
|
||||
for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
|
||||
newebo->temp = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata))
|
||||
{
|
||||
bArmature *arm= armv;
|
||||
bArmature *arm = armv;
|
||||
UndoArmature *uarm;
|
||||
EditBone *ebo, *newebo;
|
||||
|
||||
uarm= MEM_callocN(sizeof(UndoArmature), "listbase undo");
|
||||
uarm = MEM_callocN(sizeof(UndoArmature), "listbase undo");
|
||||
|
||||
/* copy */
|
||||
for (ebo= arm->edbo->first; ebo; ebo= ebo->next) {
|
||||
newebo= MEM_dupallocN(ebo);
|
||||
ebo->temp= newebo;
|
||||
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
||||
newebo = MEM_dupallocN(ebo);
|
||||
ebo->temp = newebo;
|
||||
BLI_addtail(&uarm->lb, newebo);
|
||||
}
|
||||
|
||||
/* active bone */
|
||||
if (arm->act_edbone) {
|
||||
ebo= arm->act_edbone;
|
||||
uarm->act_edbone= ebo->temp;
|
||||
ebo = arm->act_edbone;
|
||||
uarm->act_edbone = ebo->temp;
|
||||
}
|
||||
|
||||
/* set pointers */
|
||||
for (newebo= uarm->lb.first; newebo; newebo= newebo->next) {
|
||||
if (newebo->parent) newebo->parent= newebo->parent->temp;
|
||||
for (newebo = uarm->lb.first; newebo; newebo = newebo->next) {
|
||||
if (newebo->parent) newebo->parent = newebo->parent->temp;
|
||||
}
|
||||
|
||||
return uarm;
|
||||
@@ -2193,7 +2193,7 @@ static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata))
|
||||
|
||||
static void free_undoBones(void *uarmv)
|
||||
{
|
||||
UndoArmature *uarm= uarmv;
|
||||
UndoArmature *uarm = uarmv;
|
||||
|
||||
BLI_freelistN(&uarm->lb);
|
||||
MEM_freeN(uarm);
|
||||
@@ -2201,8 +2201,8 @@ static void free_undoBones(void *uarmv)
|
||||
|
||||
static void *get_armature_edit(bContext *C)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
if (obedit && obedit->type==OB_ARMATURE) {
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
if (obedit && obedit->type == OB_ARMATURE) {
|
||||
return obedit->data;
|
||||
}
|
||||
return NULL;
|
||||
@@ -2223,7 +2223,7 @@ void undo_push_armature(bContext *C, const char *name)
|
||||
/* default bone add, returns it selected, but without tail set */
|
||||
EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
|
||||
{
|
||||
EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone");
|
||||
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
|
||||
|
||||
BLI_strncpy(bone->name, name, sizeof(bone->name));
|
||||
unique_editbone_name(arm->edbo, bone->name, NULL);
|
||||
@@ -2231,16 +2231,16 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
|
||||
BLI_addtail(arm->edbo, bone);
|
||||
|
||||
bone->flag |= BONE_TIPSEL;
|
||||
bone->weight= 1.0f;
|
||||
bone->dist= 0.25f;
|
||||
bone->xwidth= 0.1f;
|
||||
bone->zwidth= 0.1f;
|
||||
bone->ease1= 1.0f;
|
||||
bone->ease2= 1.0f;
|
||||
bone->rad_head= 0.10f;
|
||||
bone->rad_tail= 0.05f;
|
||||
bone->segments= 1;
|
||||
bone->layer= arm->layer;
|
||||
bone->weight = 1.0f;
|
||||
bone->dist = 0.25f;
|
||||
bone->xwidth = 0.1f;
|
||||
bone->zwidth = 0.1f;
|
||||
bone->ease1 = 1.0f;
|
||||
bone->ease2 = 1.0f;
|
||||
bone->rad_head = 0.10f;
|
||||
bone->rad_tail = 0.05f;
|
||||
bone->segments = 1;
|
||||
bone->layer = arm->layer;
|
||||
|
||||
return bone;
|
||||
}
|
||||
@@ -2248,10 +2248,10 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
|
||||
/* v3d and rv3d are allowed to be NULL */
|
||||
void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
|
||||
EditBone *bone;
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
bArmature *arm = obedit->data;
|
||||
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
|
||||
EditBone *bone;
|
||||
|
||||
/* Get inverse point for head and orientation for tail */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
@@ -2268,16 +2268,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
|
||||
ED_armature_deselect_all(obedit, 0);
|
||||
|
||||
/* Create a bone */
|
||||
bone= ED_armature_edit_bone_add(arm, "Bone");
|
||||
bone = ED_armature_edit_bone_add(arm, "Bone");
|
||||
|
||||
arm->act_edbone= bone;
|
||||
arm->act_edbone = bone;
|
||||
|
||||
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
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
|
||||
else
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
|
||||
|
||||
}
|
||||
|
||||
@@ -2290,25 +2290,25 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
bArmature *arm;
|
||||
EditBone *ebone, *newbone, *flipbone;
|
||||
float *curs, mat[3][3], imat[3][3];
|
||||
int a, to_root= 0;
|
||||
int a, to_root = 0;
|
||||
Object *obedit;
|
||||
Scene *scene;
|
||||
|
||||
scene = CTX_data_scene(C);
|
||||
v3d= CTX_wm_view3d(C);
|
||||
obedit= CTX_data_edit_object(C);
|
||||
arm= obedit->data;
|
||||
v3d = CTX_wm_view3d(C);
|
||||
obedit = CTX_data_edit_object(C);
|
||||
arm = obedit->data;
|
||||
|
||||
/* find the active or selected bone */
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ebone==NULL) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
if (ebone == NULL) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone)
|
||||
break;
|
||||
@@ -2317,60 +2317,60 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
if (ebone == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
to_root= 1;
|
||||
to_root = 1;
|
||||
}
|
||||
|
||||
ED_armature_deselect_all(obedit, 0);
|
||||
|
||||
/* we re-use code for mirror editing... */
|
||||
flipbone= NULL;
|
||||
flipbone = NULL;
|
||||
if (arm->flag & ARM_MIRROR_EDIT)
|
||||
flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
|
||||
for (a=0; a<2; a++) {
|
||||
if (a==1) {
|
||||
if (flipbone==NULL)
|
||||
for (a = 0; a < 2; a++) {
|
||||
if (a == 1) {
|
||||
if (flipbone == NULL)
|
||||
break;
|
||||
else {
|
||||
SWAP(EditBone *, flipbone, ebone);
|
||||
}
|
||||
}
|
||||
|
||||
newbone= ED_armature_edit_bone_add(arm, ebone->name);
|
||||
arm->act_edbone= newbone;
|
||||
newbone = ED_armature_edit_bone_add(arm, ebone->name);
|
||||
arm->act_edbone = newbone;
|
||||
|
||||
if (to_root) {
|
||||
copy_v3_v3(newbone->head, ebone->head);
|
||||
newbone->rad_head= ebone->rad_tail;
|
||||
newbone->parent= ebone->parent;
|
||||
newbone->rad_head = ebone->rad_tail;
|
||||
newbone->parent = ebone->parent;
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(newbone->head, ebone->tail);
|
||||
newbone->rad_head= ebone->rad_tail;
|
||||
newbone->parent= ebone;
|
||||
newbone->rad_head = ebone->rad_tail;
|
||||
newbone->parent = ebone;
|
||||
newbone->flag |= BONE_CONNECTED;
|
||||
}
|
||||
|
||||
curs= give_cursor(scene, v3d);
|
||||
curs = give_cursor(scene, v3d);
|
||||
copy_v3_v3(newbone->tail, curs);
|
||||
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
|
||||
|
||||
if (a==1)
|
||||
newbone->tail[0]= -newbone->tail[0];
|
||||
if (a == 1)
|
||||
newbone->tail[0] = -newbone->tail[0];
|
||||
|
||||
copy_m3_m4(mat, obedit->obmat);
|
||||
invert_m3_m3(imat, mat);
|
||||
mul_m3_v3(imat, newbone->tail);
|
||||
|
||||
newbone->length= len_v3v3(newbone->head, newbone->tail);
|
||||
newbone->rad_tail= newbone->length*0.05f;
|
||||
newbone->dist= newbone->length*0.25f;
|
||||
newbone->length = len_v3v3(newbone->head, newbone->tail);
|
||||
newbone->rad_tail = newbone->length * 0.05f;
|
||||
newbone->dist = newbone->length * 0.25f;
|
||||
|
||||
}
|
||||
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2387,11 +2387,11 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
|
||||
float *fp = NULL, tvec[3], oldcurs[3], mval_f[2];
|
||||
int retv;
|
||||
|
||||
scene= CTX_data_scene(C);
|
||||
ar= CTX_wm_region(C);
|
||||
scene = CTX_data_scene(C);
|
||||
ar = CTX_wm_region(C);
|
||||
v3d = CTX_wm_view3d(C);
|
||||
|
||||
fp= give_cursor(scene, v3d);
|
||||
fp = give_cursor(scene, v3d);
|
||||
|
||||
copy_v3_v3(oldcurs, fp);
|
||||
|
||||
@@ -2400,7 +2400,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
|
||||
copy_v3_v3(fp, tvec);
|
||||
|
||||
/* extrude to the where new cursor is and store the operation result */
|
||||
retv= armature_click_extrude_exec(C, op);
|
||||
retv = armature_click_extrude_exec(C, op);
|
||||
|
||||
/* restore previous 3d cursor position */
|
||||
copy_v3_v3(fp, oldcurs);
|
||||
@@ -2421,17 +2421,17 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
}
|
||||
|
||||
/* adds an EditBone between the nominated locations (should be in the right space) */
|
||||
static EditBone *add_points_bone (Object *obedit, float head[], float tail[])
|
||||
static EditBone *add_points_bone(Object *obedit, float head[], float tail[])
|
||||
{
|
||||
EditBone *ebo;
|
||||
|
||||
ebo= ED_armature_edit_bone_add(obedit->data, "Bone");
|
||||
ebo = ED_armature_edit_bone_add(obedit->data, "Bone");
|
||||
|
||||
copy_v3_v3(ebo->head, head);
|
||||
copy_v3_v3(ebo->tail, tail);
|
||||
@@ -2445,7 +2445,7 @@ static EditBone *get_named_editbone(ListBase *edbo, char *name)
|
||||
EditBone *eBone;
|
||||
|
||||
if (name) {
|
||||
for (eBone=edbo->first; eBone; eBone=eBone->next) {
|
||||
for (eBone = edbo->first; eBone; eBone = eBone->next) {
|
||||
if (!strcmp(name, eBone->name))
|
||||
return eBone;
|
||||
}
|
||||
@@ -2483,18 +2483,18 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
|
||||
|
||||
if ( (pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name)) ) {
|
||||
if ( (conlist = &pchan->constraints) ) {
|
||||
for (curcon = conlist->first; curcon; curcon=curcon->next) {
|
||||
for (curcon = conlist->first; curcon; curcon = curcon->next) {
|
||||
/* does this constraint have a subtarget in
|
||||
* this armature?
|
||||
*/
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(curcon, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if ((ct->tar == src_ob) && (ct->subtarget[0])) {
|
||||
ct->tar = dst_ob; /* update target */
|
||||
oldtarget = get_named_editbone(editbones, ct->subtarget);
|
||||
@@ -2544,7 +2544,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
|
||||
|
||||
/* copy the ID property */
|
||||
if (curBone->prop)
|
||||
eBone->prop= IDP_CopyProperty(curBone->prop);
|
||||
eBone->prop = IDP_CopyProperty(curBone->prop);
|
||||
|
||||
/* Lets duplicate the list of constraints that the
|
||||
* current bone has.
|
||||
@@ -2557,7 +2557,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
|
||||
/* WARNING: this creates a new posechannel, but there will not be an attached bone
|
||||
* yet as the new bones created here are still 'EditBones' not 'Bones'.
|
||||
*/
|
||||
channew= BKE_pose_channel_verify(dst_ob->pose, eBone->name);
|
||||
channew = BKE_pose_channel_verify(dst_ob->pose, eBone->name);
|
||||
|
||||
if (channew) {
|
||||
BKE_pose_channel_copy_data(channew, chanold);
|
||||
@@ -2577,12 +2577,12 @@ EditBone *duplicateEditBone(EditBone *curBone, const char *name, ListBase *editb
|
||||
static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bArmature *arm;
|
||||
EditBone *eBone = NULL;
|
||||
EditBone *curBone;
|
||||
EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */
|
||||
EditBone *eBone = NULL;
|
||||
EditBone *curBone;
|
||||
EditBone *firstDup = NULL; /* The beginning of the duplicated bones in the edbo list */
|
||||
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
arm= obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
arm = obedit->data;
|
||||
|
||||
/* cancel if nothing selected */
|
||||
if (CTX_DATA_COUNT(C, selected_bones) == 0)
|
||||
@@ -2594,7 +2594,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* Select mirrored bones */
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
|
||||
if (EBONE_VISIBLE(arm, curBone)) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
eBone = ED_armature_bone_get_mirrored(arm->edbo, curBone);
|
||||
@@ -2607,24 +2607,24 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
|
||||
/* Find the selected bones and duplicate them as needed */
|
||||
for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
|
||||
if (EBONE_VISIBLE(arm, curBone)) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
|
||||
eBone= duplicateEditBone(curBone, curBone->name, arm->edbo, obedit);
|
||||
eBone = duplicateEditBone(curBone, curBone->name, arm->edbo, obedit);
|
||||
|
||||
if (!firstDup)
|
||||
firstDup=eBone;
|
||||
firstDup = eBone;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Run though the list and fix the pointers */
|
||||
for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
|
||||
if (EBONE_VISIBLE(arm, curBone)) {
|
||||
if (curBone->flag & BONE_SELECTED) {
|
||||
eBone=(EditBone*) curBone->temp;
|
||||
eBone = (EditBone *) curBone->temp;
|
||||
|
||||
if (!curBone->parent) {
|
||||
/* If this bone has no parent,
|
||||
@@ -2636,13 +2636,13 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* If this bone has a parent that was duplicated,
|
||||
* Set the duplicate->parent to the curBone->parent->temp
|
||||
*/
|
||||
eBone->parent= (EditBone *)curBone->parent->temp;
|
||||
eBone->parent = (EditBone *)curBone->parent->temp;
|
||||
}
|
||||
else {
|
||||
/* If this bone has a parent that IS not selected,
|
||||
* Set the duplicate->parent to the curBone->parent
|
||||
*/
|
||||
eBone->parent=(EditBone*) curBone->parent;
|
||||
eBone->parent = (EditBone *) curBone->parent;
|
||||
eBone->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -2656,20 +2656,20 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* correct the active bone */
|
||||
if (arm->act_edbone) {
|
||||
eBone= arm->act_edbone;
|
||||
eBone = arm->act_edbone;
|
||||
if (eBone->temp)
|
||||
arm->act_edbone= eBone->temp;
|
||||
arm->act_edbone = eBone->temp;
|
||||
}
|
||||
|
||||
/* Deselect the old bones and select the new ones */
|
||||
for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
|
||||
for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
|
||||
if (EBONE_VISIBLE(arm, curBone))
|
||||
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
|
||||
ED_armature_validate_active(arm);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2687,7 +2687,7 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -2698,27 +2698,27 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
|
||||
typedef struct EditBonePoint {
|
||||
struct EditBonePoint *next, *prev;
|
||||
|
||||
EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
|
||||
EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
|
||||
EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
|
||||
EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
|
||||
|
||||
float vec[3]; /* the actual location of the point in local/EditMode space */
|
||||
float vec[3]; /* the actual location of the point in local/EditMode space */
|
||||
} EditBonePoint;
|
||||
|
||||
/* find chain-tips (i.e. bones without children) */
|
||||
static void chains_find_tips (ListBase *edbo, ListBase *list)
|
||||
static void chains_find_tips(ListBase *edbo, ListBase *list)
|
||||
{
|
||||
EditBone *curBone, *ebo;
|
||||
LinkData *ld;
|
||||
|
||||
/* note: this is potentially very slow ... there's got to be a better way */
|
||||
for (curBone= edbo->first; curBone; curBone= curBone->next) {
|
||||
short stop= 0;
|
||||
for (curBone = edbo->first; curBone; curBone = curBone->next) {
|
||||
short stop = 0;
|
||||
|
||||
/* is this bone contained within any existing chain? (skip if so) */
|
||||
for (ld= list->first; ld; ld= ld->next) {
|
||||
for (ebo= ld->data; ebo; ebo= ebo->parent) {
|
||||
for (ld = list->first; ld; ld = ld->next) {
|
||||
for (ebo = ld->data; ebo; ebo = ebo->parent) {
|
||||
if (ebo == curBone) {
|
||||
stop= 1;
|
||||
stop = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2729,12 +2729,12 @@ static void chains_find_tips (ListBase *edbo, ListBase *list)
|
||||
if (stop) continue;
|
||||
|
||||
/* is any existing chain part of the chain formed by this bone? */
|
||||
stop= 0;
|
||||
for (ebo= curBone->parent; ebo; ebo= ebo->parent) {
|
||||
for (ld= list->first; ld; ld= ld->next) {
|
||||
stop = 0;
|
||||
for (ebo = curBone->parent; ebo; ebo = ebo->parent) {
|
||||
for (ld = list->first; ld; ld = ld->next) {
|
||||
if (ld->data == ebo) {
|
||||
ld->data= curBone;
|
||||
stop= 1;
|
||||
ld->data = curBone;
|
||||
stop = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2745,19 +2745,19 @@ static void chains_find_tips (ListBase *edbo, ListBase *list)
|
||||
if (stop) continue;
|
||||
|
||||
/* add current bone to a new chain */
|
||||
ld= MEM_callocN(sizeof(LinkData), "BoneChain");
|
||||
ld->data= curBone;
|
||||
ld = MEM_callocN(sizeof(LinkData), "BoneChain");
|
||||
ld->data = curBone;
|
||||
BLI_addtail(list, ld);
|
||||
}
|
||||
}
|
||||
|
||||
/* --------------------- */
|
||||
|
||||
static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
|
||||
static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
|
||||
{
|
||||
EditBonePoint *ebp;
|
||||
float vec[3];
|
||||
short found= 0;
|
||||
short found = 0;
|
||||
|
||||
if (eb_tail) {
|
||||
copy_v3_v3(vec, ebo->tail);
|
||||
@@ -2766,20 +2766,20 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
|
||||
copy_v3_v3(vec, ebo->head);
|
||||
}
|
||||
|
||||
for (ebp= points->first; ebp; ebp= ebp->next) {
|
||||
for (ebp = points->first; ebp; ebp = ebp->next) {
|
||||
if (equals_v3v3(ebp->vec, vec)) {
|
||||
if (eb_tail) {
|
||||
if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) {
|
||||
/* so this bone's tail owner is this bone */
|
||||
ebp->tail_owner= ebo;
|
||||
found= 1;
|
||||
ebp->tail_owner = ebo;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((ebp->tail_owner) && (ebo->parent == ebp->tail_owner)) {
|
||||
/* so this bone's head owner is this bone */
|
||||
ebp->head_owner= ebo;
|
||||
ebp->head_owner = ebo;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
@@ -2789,15 +2789,15 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
|
||||
|
||||
/* allocate a new point if no existing point was related */
|
||||
if (found == 0) {
|
||||
ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
|
||||
ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
|
||||
|
||||
if (eb_tail) {
|
||||
copy_v3_v3(ebp->vec, ebo->tail);
|
||||
ebp->tail_owner= ebo;
|
||||
ebp->tail_owner = ebo;
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(ebp->vec, ebo->head);
|
||||
ebp->head_owner= ebo;
|
||||
ebp->head_owner = ebo;
|
||||
}
|
||||
|
||||
BLI_addtail(points, ebp);
|
||||
@@ -2805,12 +2805,12 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
|
||||
}
|
||||
|
||||
/* bone adding between selected joints */
|
||||
static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
static int armature_fill_bones_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
View3D *v3d= CTX_wm_view3d(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = (obedit) ? obedit->data : NULL;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
ListBase points = {NULL, NULL};
|
||||
int count;
|
||||
|
||||
@@ -2829,11 +2829,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
CTX_DATA_END;
|
||||
|
||||
/* the number of joints determines how we fill:
|
||||
* 1) between joint and cursor (joint=head, cursor=tail)
|
||||
* 2) between the two joints (order is dependent on active-bone/hierachy)
|
||||
* 3+) error (a smarter method involving finding chains needs to be worked out
|
||||
* 1) between joint and cursor (joint=head, cursor=tail)
|
||||
* 2) between the two joints (order is dependent on active-bone/hierachy)
|
||||
* 3+) error (a smarter method involving finding chains needs to be worked out
|
||||
*/
|
||||
count= BLI_countlist(&points);
|
||||
count = BLI_countlist(&points);
|
||||
|
||||
if (count == 0) {
|
||||
BKE_report(op->reports, RPT_ERROR, "No joints selected");
|
||||
@@ -2844,7 +2844,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
float curs[3];
|
||||
|
||||
/* Get Points - selected joint */
|
||||
ebp= (EditBonePoint *)points.first;
|
||||
ebp = (EditBonePoint *)points.first;
|
||||
|
||||
/* Get points - cursor (tail) */
|
||||
invert_m4_m4(obedit->imat, obedit->obmat);
|
||||
@@ -2859,15 +2859,15 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
short headtail = 0;
|
||||
|
||||
/* check that the points don't belong to the same bone */
|
||||
ebp= (EditBonePoint *)points.first;
|
||||
ebp2= ebp->next;
|
||||
ebp = (EditBonePoint *)points.first;
|
||||
ebp2 = ebp->next;
|
||||
|
||||
if ((ebp->head_owner==ebp2->tail_owner) && (ebp->head_owner!=NULL)) {
|
||||
if ((ebp->head_owner == ebp2->tail_owner) && (ebp->head_owner != NULL)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Same bone selected...");
|
||||
BLI_freelistN(&points);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
if ((ebp->tail_owner==ebp2->head_owner) && (ebp->tail_owner!=NULL)) {
|
||||
if ((ebp->tail_owner == ebp2->head_owner) && (ebp->tail_owner != NULL)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Same bone selected...");
|
||||
BLI_freelistN(&points);
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -2887,11 +2887,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
/* get distances */
|
||||
sub_v3_v3v3(vecA, ebp->vec, curs);
|
||||
sub_v3_v3v3(vecB, ebp2->vec, curs);
|
||||
distA= len_v3(vecA);
|
||||
distB= len_v3(vecB);
|
||||
distA = len_v3(vecA);
|
||||
distB = len_v3(vecB);
|
||||
|
||||
/* compare distances - closer one therefore acts as direction for bone to go */
|
||||
headtail= (distA < distB) ? 2 : 1;
|
||||
headtail = (distA < distB) ? 2 : 1;
|
||||
}
|
||||
else if (ebp->head_owner) {
|
||||
headtail = 1;
|
||||
@@ -2912,22 +2912,22 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* add new bone and parent it to the appropriate end */
|
||||
if (headtail) {
|
||||
EditBone *newbone= add_points_bone(obedit, head, tail);
|
||||
EditBone *newbone = add_points_bone(obedit, head, tail);
|
||||
|
||||
/* do parenting (will need to set connected flag too) */
|
||||
if (headtail == 2) {
|
||||
/* ebp tail or head - tail gets priority */
|
||||
if (ebp->tail_owner)
|
||||
newbone->parent= ebp->tail_owner;
|
||||
newbone->parent = ebp->tail_owner;
|
||||
else
|
||||
newbone->parent= ebp->head_owner;
|
||||
newbone->parent = ebp->head_owner;
|
||||
}
|
||||
else {
|
||||
/* ebp2 tail or head - tail gets priority */
|
||||
if (ebp2->tail_owner)
|
||||
newbone->parent= ebp2->tail_owner;
|
||||
newbone->parent = ebp2->tail_owner;
|
||||
else
|
||||
newbone->parent= ebp2->head_owner;
|
||||
newbone->parent = ebp2->head_owner;
|
||||
}
|
||||
|
||||
newbone->flag |= BONE_CONNECTED;
|
||||
@@ -2941,7 +2941,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
|
||||
|
||||
/* free points */
|
||||
BLI_freelistN(&points);
|
||||
@@ -2961,7 +2961,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* --------------------- */
|
||||
@@ -2971,7 +2971,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
|
||||
*/
|
||||
static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebo, *ebone, *newbone;
|
||||
LinkData *chain;
|
||||
float head[3], tail[3];
|
||||
@@ -2989,23 +2989,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
|
||||
* - tail = head/tail of end (default tail)
|
||||
* - parent = parent of start
|
||||
*/
|
||||
if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) {
|
||||
if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED) == 0) {
|
||||
copy_v3_v3(head, start->tail);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(head, start->head);
|
||||
}
|
||||
if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) {
|
||||
if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED) == 0) {
|
||||
copy_v3_v3(tail, end->head);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(tail, end->tail);
|
||||
}
|
||||
newbone= add_points_bone(obedit, head, tail);
|
||||
newbone = add_points_bone(obedit, head, tail);
|
||||
newbone->parent = start->parent;
|
||||
|
||||
/* TODO, copy more things to the new bone */
|
||||
newbone->flag= start->flag & (BONE_HINGE|BONE_NO_DEFORM|BONE_NO_SCALE|BONE_NO_CYCLICOFFSET|BONE_NO_LOCAL_LOCATION|BONE_DONE);
|
||||
newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
|
||||
|
||||
/* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
|
||||
* - potentially several tips for side chains leading to some tree exist...
|
||||
@@ -3037,24 +3037,24 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
|
||||
|
||||
/* step 2b: parent child of end to newbone (child from this chain) */
|
||||
if (endchild)
|
||||
endchild->parent= newbone;
|
||||
endchild->parent = newbone;
|
||||
|
||||
/* step 3: delete all bones between and including start and end */
|
||||
for (ebo= end; ebo; ebo= ebone) {
|
||||
ebone= (ebo == start) ? (NULL) : (ebo->parent);
|
||||
for (ebo = end; ebo; ebo = ebone) {
|
||||
ebone = (ebo == start) ? (NULL) : (ebo->parent);
|
||||
bone_free(arm, ebo);
|
||||
}
|
||||
|
||||
newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
|
||||
newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
}
|
||||
|
||||
|
||||
static int armature_merge_exec (bContext *C, wmOperator *op)
|
||||
static int armature_merge_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= (obedit) ? obedit->data : NULL;
|
||||
short type= RNA_enum_get(op->ptr, "type");
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = (obedit) ? obedit->data : NULL;
|
||||
short type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* sanity checks */
|
||||
if (ELEM(NULL, obedit, arm))
|
||||
@@ -3074,28 +3074,28 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
|
||||
if (chains.first == NULL) return OPERATOR_CANCELLED;
|
||||
|
||||
/* each 'chain' is the last bone in the chain (with no children) */
|
||||
for (chain= chains.first; chain; chain= nchain) {
|
||||
EditBone *bstart= NULL, *bend= NULL;
|
||||
EditBone *bchild= NULL, *child=NULL;
|
||||
for (chain = chains.first; chain; chain = nchain) {
|
||||
EditBone *bstart = NULL, *bend = NULL;
|
||||
EditBone *bchild = NULL, *child = NULL;
|
||||
|
||||
/* temporarily remove chain from list of chains */
|
||||
nchain= chain->next;
|
||||
nchain = chain->next;
|
||||
BLI_remlink(&chains, chain);
|
||||
|
||||
/* only consider bones that are visible and selected */
|
||||
for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) {
|
||||
for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) {
|
||||
/* check if visible + selected */
|
||||
if ( EBONE_VISIBLE(arm, ebo) &&
|
||||
((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
|
||||
(ebo->flag & BONE_SELECTED) )
|
||||
if (EBONE_VISIBLE(arm, ebo) &&
|
||||
((ebo->flag & BONE_CONNECTED) || (ebo->parent == NULL)) &&
|
||||
(ebo->flag & BONE_SELECTED) )
|
||||
{
|
||||
/* set either end or start (end gets priority, unless it is already set) */
|
||||
if (bend == NULL) {
|
||||
bend= ebo;
|
||||
bchild= child;
|
||||
bend = ebo;
|
||||
bchild = child;
|
||||
}
|
||||
else
|
||||
bstart= ebo;
|
||||
bstart = ebo;
|
||||
}
|
||||
else {
|
||||
/* chain is broken... merge any continous segments then clear */
|
||||
@@ -3123,7 +3123,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* updates */
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3146,7 +3146,7 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", "");
|
||||
@@ -3157,19 +3157,19 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
|
||||
|
||||
static int armature_hide_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
|
||||
const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
|
||||
|
||||
/* cancel if nothing selected */
|
||||
if (CTX_DATA_COUNT(C, selected_bones) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if ((ebone->flag & BONE_SELECTED) != invert) {
|
||||
ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
ebone->flag |= BONE_HIDDEN_A;
|
||||
}
|
||||
}
|
||||
@@ -3177,7 +3177,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
|
||||
ED_armature_validate_active(arm);
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3194,7 +3194,7 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
|
||||
@@ -3202,14 +3202,14 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
|
||||
|
||||
static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (arm->layer & ebone->layer) {
|
||||
if (ebone->flag & BONE_HIDDEN_A) {
|
||||
ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
ebone->flag &= ~BONE_HIDDEN_A;
|
||||
}
|
||||
}
|
||||
@@ -3217,7 +3217,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ED_armature_validate_active(arm);
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3234,20 +3234,20 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
}
|
||||
#if 0 // remove this?
|
||||
static void hide_selected_armature_bones(Scene *scene)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_SELECTED) {
|
||||
ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
ebone->flag |= BONE_HIDDEN_A;
|
||||
}
|
||||
}
|
||||
@@ -3258,14 +3258,14 @@ static void hide_selected_armature_bones(Scene *scene)
|
||||
|
||||
static void hide_unselected_armature_bones(Scene *scene)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
bArmature *arm= obedit->data;
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
bArmature *arm = obedit->data;
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL));
|
||||
if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ;
|
||||
else {
|
||||
ebone->flag |= BONE_HIDDEN_A;
|
||||
}
|
||||
@@ -3278,14 +3278,14 @@ static void hide_unselected_armature_bones(Scene *scene)
|
||||
|
||||
void show_all_armature_bones(Scene *scene)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebone;
|
||||
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (arm->layer & ebone->layer) {
|
||||
if (ebone->flag & BONE_HIDDEN_A) {
|
||||
ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
ebone->flag &= ~BONE_HIDDEN_A;
|
||||
}
|
||||
}
|
||||
@@ -3302,15 +3302,15 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit;
|
||||
bArmature *arm;
|
||||
EditBone *newbone, *ebone, *flipbone, *first=NULL;
|
||||
int a, totbone= 0, do_extrude;
|
||||
EditBone *newbone, *ebone, *flipbone, *first = NULL;
|
||||
int a, totbone = 0, do_extrude;
|
||||
int forked = RNA_boolean_get(op->ptr, "forked");
|
||||
|
||||
obedit= CTX_data_edit_object(C);
|
||||
arm= obedit->data;
|
||||
obedit = CTX_data_edit_object(C);
|
||||
arm = obedit->data;
|
||||
|
||||
/* since we allow root extrude too, we have to make sure selection is OK */
|
||||
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
if (ebone->flag & BONE_ROOTSEL) {
|
||||
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
|
||||
@@ -3322,36 +3322,36 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Duplicate the necessary bones */
|
||||
for (ebone = arm->edbo->first; ((ebone) && (ebone!=first)); ebone=ebone->next) {
|
||||
for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone)) {
|
||||
/* we extrude per definition the tip */
|
||||
do_extrude= 0;
|
||||
if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED))
|
||||
do_extrude= 1;
|
||||
do_extrude = 0;
|
||||
if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED))
|
||||
do_extrude = 1;
|
||||
else if (ebone->flag & BONE_ROOTSEL) {
|
||||
/* but, a bone with parent deselected we do the root... */
|
||||
if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL));
|
||||
else do_extrude= 2;
|
||||
if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ;
|
||||
else do_extrude = 2;
|
||||
}
|
||||
|
||||
if (do_extrude) {
|
||||
/* we re-use code for mirror editing... */
|
||||
flipbone= NULL;
|
||||
flipbone = NULL;
|
||||
if (arm->flag & ARM_MIRROR_EDIT) {
|
||||
flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
|
||||
if (flipbone) {
|
||||
forked= 0; // we extrude 2 different bones
|
||||
if (flipbone->flag & (BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED))
|
||||
forked = 0; // we extrude 2 different bones
|
||||
if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED))
|
||||
/* don't want this bone to be selected... */
|
||||
flipbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
}
|
||||
if ((flipbone==NULL) && (forked))
|
||||
flipbone= ebone;
|
||||
if ((flipbone == NULL) && (forked))
|
||||
flipbone = ebone;
|
||||
}
|
||||
|
||||
for (a=0; a<2; a++) {
|
||||
if (a==1) {
|
||||
if (flipbone==NULL)
|
||||
for (a = 0; a < 2; a++) {
|
||||
if (a == 1) {
|
||||
if (flipbone == NULL)
|
||||
break;
|
||||
else {
|
||||
SWAP(EditBone *, flipbone, ebone);
|
||||
@@ -3361,43 +3361,43 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
|
||||
totbone++;
|
||||
newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
|
||||
|
||||
if (do_extrude==1) {
|
||||
if (do_extrude == 1) {
|
||||
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
|
||||
newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
|
||||
|
||||
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(newbone->head, ebone->head);
|
||||
copy_v3_v3(newbone->tail, ebone->head);
|
||||
newbone->parent= ebone->parent;
|
||||
newbone->parent = ebone->parent;
|
||||
|
||||
newbone->flag= BONE_TIPSEL;
|
||||
newbone->flag = BONE_TIPSEL;
|
||||
|
||||
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
|
||||
newbone->flag |= BONE_CONNECTED;
|
||||
}
|
||||
}
|
||||
|
||||
newbone->weight= ebone->weight;
|
||||
newbone->dist= ebone->dist;
|
||||
newbone->xwidth= ebone->xwidth;
|
||||
newbone->zwidth= ebone->zwidth;
|
||||
newbone->ease1= ebone->ease1;
|
||||
newbone->ease2= ebone->ease2;
|
||||
newbone->rad_head= ebone->rad_tail; // don't copy entire bone...
|
||||
newbone->rad_tail= ebone->rad_tail;
|
||||
newbone->segments= 1;
|
||||
newbone->layer= ebone->layer;
|
||||
|
||||
BLI_strncpy (newbone->name, ebone->name, sizeof(newbone->name));
|
||||
|
||||
if (flipbone && forked) { // only set if mirror edit
|
||||
if (strlen(newbone->name)<30) {
|
||||
if (a==0) strcat(newbone->name, "_L");
|
||||
newbone->weight = ebone->weight;
|
||||
newbone->dist = ebone->dist;
|
||||
newbone->xwidth = ebone->xwidth;
|
||||
newbone->zwidth = ebone->zwidth;
|
||||
newbone->ease1 = ebone->ease1;
|
||||
newbone->ease2 = ebone->ease2;
|
||||
newbone->rad_head = ebone->rad_tail; // don't copy entire bone...
|
||||
newbone->rad_tail = ebone->rad_tail;
|
||||
newbone->segments = 1;
|
||||
newbone->layer = ebone->layer;
|
||||
|
||||
BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
|
||||
|
||||
if (flipbone && forked) { // only set if mirror edit
|
||||
if (strlen(newbone->name) < 30) {
|
||||
if (a == 0) strcat(newbone->name, "_L");
|
||||
else strcat(newbone->name, "_R");
|
||||
}
|
||||
}
|
||||
@@ -3409,24 +3409,24 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
|
||||
first = newbone;
|
||||
|
||||
/* restore ebone if we were flipping */
|
||||
if (a==1 && flipbone)
|
||||
if (a == 1 && flipbone)
|
||||
SWAP(EditBone *, flipbone, ebone);
|
||||
}
|
||||
}
|
||||
|
||||
/* Deselect the old bone */
|
||||
ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
}
|
||||
}
|
||||
/* if only one bone, make this one active */
|
||||
if (totbone==1 && first) arm->act_edbone= first;
|
||||
if (totbone == 1 && first) arm->act_edbone = first;
|
||||
|
||||
if (totbone==0) return OPERATOR_CANCELLED;
|
||||
if (totbone == 0) return OPERATOR_CANCELLED;
|
||||
|
||||
/* Transform the endpoints */
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3443,7 +3443,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "forked", 0, "Forked", "");
|
||||
@@ -3454,7 +3454,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
|
||||
|
||||
static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
EditBone *bone;
|
||||
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
|
||||
@@ -3479,17 +3479,17 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
|
||||
ED_armature_deselect_all(obedit, 0);
|
||||
|
||||
/* Create a bone */
|
||||
bone= ED_armature_edit_bone_add(obedit->data, name);
|
||||
bone = ED_armature_edit_bone_add(obedit->data, name);
|
||||
|
||||
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
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
|
||||
else
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
|
||||
add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3506,7 +3506,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone");
|
||||
|
||||
@@ -3523,28 +3523,28 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
|
||||
|
||||
static int armature_subdivide_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
bArmature *arm= obedit->data;
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *newbone, *tbone;
|
||||
int numcuts, i;
|
||||
|
||||
/* there may not be a number_cuts property defined (for 'simple' subdivide) */
|
||||
numcuts= RNA_int_get(op->ptr, "number_cuts");
|
||||
numcuts = RNA_int_get(op->ptr, "number_cuts");
|
||||
|
||||
/* loop over all editable bones */
|
||||
// XXX the old code did this in reverse order though!
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
for (i=numcuts+1; i>1; i--) {
|
||||
for (i = numcuts + 1; i > 1; i--) {
|
||||
/* compute cut ratio first */
|
||||
float cutratio= 1.0f / (float)i;
|
||||
float cutratioI= 1.0f - cutratio;
|
||||
float cutratio = 1.0f / (float)i;
|
||||
float cutratioI = 1.0f - cutratio;
|
||||
|
||||
float val1[3];
|
||||
float val2[3];
|
||||
float val3[3];
|
||||
|
||||
newbone= MEM_mallocN(sizeof(EditBone), "ebone subdiv");
|
||||
newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv");
|
||||
*newbone = *ebone;
|
||||
BLI_addtail(arm->edbo, newbone);
|
||||
|
||||
@@ -3553,33 +3553,33 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
|
||||
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;
|
||||
val3[0] = val1[0] * cutratio + val2[0] * cutratioI;
|
||||
val3[1] = val1[1] * cutratio + val2[1] * cutratioI;
|
||||
val3[2] = val1[2] * cutratio + val2[2] * cutratioI;
|
||||
|
||||
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;
|
||||
newbone->rad_head = 0.5f * (ebone->rad_head + ebone->rad_tail);
|
||||
ebone->rad_tail = newbone->rad_head;
|
||||
|
||||
newbone->flag |= BONE_CONNECTED;
|
||||
|
||||
unique_editbone_name(arm->edbo, newbone->name, NULL);
|
||||
|
||||
/* correct parent bones */
|
||||
for (tbone = arm->edbo->first; tbone; tbone=tbone->next) {
|
||||
if (tbone->parent==ebone)
|
||||
tbone->parent= newbone;
|
||||
for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
|
||||
if (tbone->parent == ebone)
|
||||
tbone->parent = newbone;
|
||||
}
|
||||
newbone->parent= ebone;
|
||||
newbone->parent = ebone;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3598,7 +3598,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* Properties */
|
||||
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);
|
||||
@@ -3616,8 +3616,8 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
|
||||
|
||||
static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
ListBase chains = {NULL, NULL};
|
||||
LinkData *chain;
|
||||
|
||||
@@ -3628,16 +3628,16 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
armature_tag_select_mirrored(arm);
|
||||
|
||||
/* loop over chains, only considering selected and visible bones */
|
||||
for (chain= chains.first; chain; chain= chain->next) {
|
||||
EditBone *ebo, *child=NULL, *parent=NULL;
|
||||
for (chain = chains.first; chain; chain = chain->next) {
|
||||
EditBone *ebo, *child = NULL, *parent = NULL;
|
||||
|
||||
/* loop over bones in chain */
|
||||
for (ebo= chain->data; ebo; ebo= parent) {
|
||||
for (ebo = chain->data; ebo; ebo = parent) {
|
||||
/* parent is this bone's original parent
|
||||
* - we store this, as the next bone that is checked is this one
|
||||
* but the value of ebo->parent may change here...
|
||||
*/
|
||||
parent= ebo->parent;
|
||||
parent = ebo->parent;
|
||||
|
||||
/* only if selected and editable */
|
||||
if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
|
||||
@@ -3650,7 +3650,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
* - use 'child' as new parent
|
||||
* - connected flag is only set if points are coincidental
|
||||
*/
|
||||
ebo->parent= child;
|
||||
ebo->parent = child;
|
||||
if ((child) && equals_v3v3(ebo->head, child->tail))
|
||||
ebo->flag |= BONE_CONNECTED;
|
||||
else
|
||||
@@ -3659,14 +3659,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* get next bones
|
||||
* - child will become the new parent of next bone
|
||||
*/
|
||||
child= ebo;
|
||||
child = ebo;
|
||||
}
|
||||
else {
|
||||
/* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
|
||||
* as it will be facing in opposite direction
|
||||
*/
|
||||
if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) {
|
||||
ebo->parent= NULL;
|
||||
ebo->parent = NULL;
|
||||
ebo->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
|
||||
@@ -3674,7 +3674,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
* - child will become new parent of next bone (not swapping occurred,
|
||||
* so set to NULL to prevent infinite-loop)
|
||||
*/
|
||||
child= NULL;
|
||||
child = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3685,7 +3685,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
armature_tag_unselect(arm);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3702,13 +3702,13 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
/* ***************** Parenting *********************** */
|
||||
|
||||
/* armature parenting options */
|
||||
#define ARM_PAR_CONNECT 1
|
||||
#define ARM_PAR_OFFSET 2
|
||||
#define ARM_PAR_OFFSET 2
|
||||
|
||||
/* check for null, before calling! */
|
||||
static void bone_connect_to_existing_parent(EditBone *bone)
|
||||
@@ -3727,12 +3727,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
|
||||
selbone->parent->flag &= ~(BONE_TIPSEL);
|
||||
|
||||
/* make actbone the parent of selbone */
|
||||
selbone->parent= actbone;
|
||||
selbone->parent = actbone;
|
||||
|
||||
/* in actbone tree we cannot have a loop */
|
||||
for (ebone= actbone->parent; ebone; ebone= ebone->parent) {
|
||||
if (ebone->parent==selbone) {
|
||||
ebone->parent= NULL;
|
||||
for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
|
||||
if (ebone->parent == selbone) {
|
||||
ebone->parent = NULL;
|
||||
ebone->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
}
|
||||
@@ -3743,16 +3743,16 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
|
||||
sub_v3_v3v3(offset, actbone->tail, selbone->head);
|
||||
|
||||
copy_v3_v3(selbone->head, actbone->tail);
|
||||
selbone->rad_head= actbone->rad_tail;
|
||||
selbone->rad_head = actbone->rad_tail;
|
||||
|
||||
add_v3_v3(selbone->tail, offset);
|
||||
|
||||
/* offset for all its children */
|
||||
for (ebone = edbo->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = edbo->first; ebone; ebone = ebone->next) {
|
||||
EditBone *par;
|
||||
|
||||
for (par= ebone->parent; par; par= par->parent) {
|
||||
if (par==selbone) {
|
||||
for (par = ebone->parent; par; par = par->parent) {
|
||||
if (par == selbone) {
|
||||
add_v3_v3(ebone->head, offset);
|
||||
add_v3_v3(ebone->tail, offset);
|
||||
break;
|
||||
@@ -3774,8 +3774,8 @@ static EnumPropertyItem prop_editarm_make_parent_types[] = {
|
||||
|
||||
static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
EditBone *actbone = CTX_data_active_bone(C);
|
||||
EditBone *actmirb = NULL;
|
||||
short val = RNA_enum_get(op->ptr, "type");
|
||||
@@ -3793,9 +3793,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
|
||||
* then just use actbone. Useful when doing upper arm to spine.
|
||||
*/
|
||||
actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
if (actmirb == NULL)
|
||||
actmirb= actbone;
|
||||
actmirb = actbone;
|
||||
}
|
||||
|
||||
/* if there is only 1 selected bone, we assume that that is the active bone,
|
||||
@@ -3817,7 +3817,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
* - the context iterator contains both selected bones and their mirrored copies,
|
||||
* so we assume that unselected bones are mirrored copies of some selected bone
|
||||
* - since the active one (and/or its mirror) will also be selected, we also need
|
||||
* to check that we are not trying to operate on them, since such an operation
|
||||
* to check that we are not trying to operate on them, since such an operation
|
||||
* would cause errors
|
||||
*/
|
||||
|
||||
@@ -3836,7 +3836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3844,14 +3844,14 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
|
||||
static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
|
||||
{
|
||||
EditBone *actbone = CTX_data_active_bone(C);
|
||||
uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", ICON_NONE);
|
||||
uiLayout *layout= uiPupMenuLayout(pup);
|
||||
uiPopupMenu *pup = uiPupMenuBegin(C, "Make Parent ", ICON_NONE);
|
||||
uiLayout *layout = uiPupMenuLayout(pup);
|
||||
int allchildbones = 0;
|
||||
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
{
|
||||
if (ebone != actbone) {
|
||||
if (ebone->parent != actbone) allchildbones= 1;
|
||||
if (ebone->parent != actbone) allchildbones = 1;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -3880,7 +3880,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting");
|
||||
}
|
||||
@@ -3898,14 +3898,14 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
|
||||
ebone->parent->flag &= ~(BONE_TIPSEL);
|
||||
}
|
||||
|
||||
if (mode==1) ebone->parent= NULL;
|
||||
if (mode == 1) ebone->parent = NULL;
|
||||
ebone->flag &= ~BONE_CONNECTED;
|
||||
}
|
||||
|
||||
static int armature_parent_clear_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
int val = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
@@ -3917,7 +3917,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3935,7 +3935,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting");
|
||||
}
|
||||
@@ -3955,7 +3955,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -3972,7 +3972,7 @@ void ARMATURE_OT_select_inverse(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
}
|
||||
static int armature_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
@@ -3993,30 +3993,30 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
/* ignore bone if selection can't change */
|
||||
if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
if (ebone->parent)
|
||||
ebone->parent->flag |= (BONE_TIPSEL);
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
if (ebone->flag & BONE_SELECTED) {
|
||||
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else {
|
||||
case SEL_SELECT:
|
||||
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
if (ebone->parent)
|
||||
ebone->parent->flag |= (BONE_TIPSEL);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
if (ebone->flag & BONE_SELECTED) {
|
||||
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else {
|
||||
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
if (ebone->parent)
|
||||
ebone->parent->flag |= (BONE_TIPSEL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -4033,7 +4033,7 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
WM_operator_properties_select_all(ot);
|
||||
}
|
||||
@@ -4077,7 +4077,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo
|
||||
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
|
||||
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if ((ebone->length >= len_min) &&
|
||||
(ebone->length <= len_max))
|
||||
(ebone->length <= len_max))
|
||||
{
|
||||
ED_armature_edit_bone_select(ebone);
|
||||
}
|
||||
@@ -4227,30 +4227,30 @@ void ARMATURE_OT_select_similar(wmOperatorType *ot) {
|
||||
|
||||
static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
Object *ob;
|
||||
bArmature *arm;
|
||||
EditBone *curbone, *pabone, *chbone;
|
||||
int direction = RNA_enum_get(op->ptr, "direction");
|
||||
int add_to_sel = RNA_boolean_get(op->ptr, "extend");
|
||||
|
||||
ob= obedit;
|
||||
arm= (bArmature *)ob->data;
|
||||
ob = obedit;
|
||||
arm = (bArmature *)ob->data;
|
||||
|
||||
for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
|
||||
for (curbone = arm->edbo->first; curbone; curbone = curbone->next) {
|
||||
/* only work on bone if it is visible and its selection can change */
|
||||
if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if (curbone == arm->act_edbone) {
|
||||
if (direction == BONE_SELECT_PARENT) {
|
||||
if (curbone->parent == NULL) continue;
|
||||
else pabone = curbone->parent;
|
||||
|
||||
if (EBONE_VISIBLE(arm, pabone)) {
|
||||
pabone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
arm->act_edbone= pabone;
|
||||
if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
|
||||
pabone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
arm->act_edbone = pabone;
|
||||
if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
|
||||
|
||||
if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4259,12 +4259,12 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
chbone = editbone_get_child(arm, curbone, 1);
|
||||
if (chbone == NULL) continue;
|
||||
|
||||
if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE)==0) {
|
||||
chbone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
arm->act_edbone= chbone;
|
||||
if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
chbone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
arm->act_edbone = chbone;
|
||||
|
||||
if (!add_to_sel) {
|
||||
curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL);
|
||||
curbone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL);
|
||||
if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL;
|
||||
}
|
||||
break;
|
||||
@@ -4276,17 +4276,17 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
|
||||
ED_armature_sync_selection(arm->edbo);
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem direction_items[]= {
|
||||
{BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
|
||||
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
static EnumPropertyItem direction_items[] = {
|
||||
{BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
|
||||
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
@@ -4299,7 +4299,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_enum(ot->srna, "direction", direction_items,
|
||||
@@ -4329,7 +4329,7 @@ static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
|
||||
{
|
||||
EditBone *selbone;
|
||||
|
||||
for (selbone = edbo->first; selbone; selbone=selbone->next) {
|
||||
for (selbone = edbo->first; selbone; selbone = selbone->next) {
|
||||
if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) {
|
||||
fix_connected_bone(selbone);
|
||||
fix_editbone_connected_children(edbo, selbone);
|
||||
@@ -4361,10 +4361,10 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
|
||||
|
||||
static int armature_align_bones_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
EditBone *actbone= CTX_data_active_bone(C);
|
||||
EditBone *actmirb= NULL;
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
EditBone *actbone = CTX_data_active_bone(C);
|
||||
EditBone *actmirb = NULL;
|
||||
|
||||
/* there must be an active bone */
|
||||
if (actbone == NULL) {
|
||||
@@ -4379,9 +4379,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
|
||||
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
|
||||
* then just use actbone. Useful when doing upper arm to spine.
|
||||
*/
|
||||
actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
|
||||
if (actmirb == NULL)
|
||||
actmirb= actbone;
|
||||
actmirb = actbone;
|
||||
}
|
||||
|
||||
/* if there is only 1 selected bone, we assume that that is the active bone,
|
||||
@@ -4422,7 +4422,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
|
||||
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -4440,14 +4440,14 @@ void ARMATURE_OT_align(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ***************** Pose tools ********************* */
|
||||
|
||||
// XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer
|
||||
static int bone_looper(Object *ob, Bone *bone, void *data,
|
||||
int (*bone_func)(Object *, Bone *, void *))
|
||||
int (*bone_func)(Object *, Bone *, void *))
|
||||
{
|
||||
/* We want to apply the function bone_func to every bone
|
||||
* in an armature -- feed bone_looper the first bone and
|
||||
@@ -4477,49 +4477,49 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
|
||||
/* assumes scene obact and basact is still on old situation */
|
||||
int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
|
||||
{
|
||||
Object *ob= base->object;
|
||||
Object *ob = base->object;
|
||||
Bone *nearBone;
|
||||
|
||||
if (!ob || !ob->pose) return 0;
|
||||
|
||||
nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
|
||||
nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
|
||||
|
||||
/* if the bone cannot be affected, don't do anything */
|
||||
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
|
||||
Object *ob_act= OBACT;
|
||||
bArmature *arm= ob->data;
|
||||
Object *ob_act = OBACT;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
/* since we do unified select, we don't shift+select a bone if the
|
||||
* armature object was not active yet.
|
||||
* note, special exception for armature mode so we can do multi-select
|
||||
* we could check for multi-select explicitly but think its fine to
|
||||
* always give predictable behavior in weight paint mode - campbell */
|
||||
if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT)==0))) {
|
||||
if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
|
||||
ED_pose_deselectall(ob, 0);
|
||||
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
arm->act_bone= nearBone;
|
||||
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
arm->act_bone = nearBone;
|
||||
|
||||
// XXX old cruft! use notifiers instead
|
||||
// XXX old cruft! use notifiers instead
|
||||
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
|
||||
}
|
||||
else {
|
||||
if (nearBone->flag & BONE_SELECTED) {
|
||||
/* if not active, we make it active */
|
||||
if (nearBone != arm->act_bone) {
|
||||
arm->act_bone= nearBone;
|
||||
arm->act_bone = nearBone;
|
||||
}
|
||||
else {
|
||||
nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
|
||||
// XXX old cruft! use notifiers instead
|
||||
// XXX old cruft! use notifiers instead
|
||||
//select_actionchannel_by_name(ob->action, nearBone->name, 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
arm->act_bone= nearBone;
|
||||
nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
arm->act_bone = nearBone;
|
||||
|
||||
// XXX old cruft! use notifiers instead
|
||||
// XXX old cruft! use notifiers instead
|
||||
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
|
||||
}
|
||||
}
|
||||
@@ -4534,7 +4534,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
|
||||
|
||||
}
|
||||
|
||||
return nearBone!=NULL;
|
||||
return nearBone != NULL;
|
||||
}
|
||||
|
||||
/* test==0: deselect all
|
||||
@@ -4544,16 +4544,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
|
||||
*/
|
||||
void ED_pose_deselectall(Object *ob, int test)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
bPoseChannel *pchan;
|
||||
int selectmode= 0;
|
||||
int selectmode = 0;
|
||||
|
||||
/* we call this from outliner too */
|
||||
if (ELEM(NULL, ob, ob->pose)) return;
|
||||
|
||||
/* Determine if we're selecting or deselecting */
|
||||
if (test==1) {
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
if (test == 1) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (PBONE_VISIBLE(arm, pchan->bone)) {
|
||||
if (pchan->bone->flag & BONE_SELECTED)
|
||||
break;
|
||||
@@ -4561,21 +4561,21 @@ void ED_pose_deselectall(Object *ob, int test)
|
||||
}
|
||||
|
||||
if (pchan == NULL)
|
||||
selectmode= 1;
|
||||
selectmode = 1;
|
||||
}
|
||||
else if (test == 2)
|
||||
selectmode= 2;
|
||||
selectmode = 2;
|
||||
|
||||
/* Set the flags accordingly */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
|
||||
if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) {
|
||||
if (test==3) {
|
||||
pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) {
|
||||
if (test == 3) {
|
||||
pchan->bone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else {
|
||||
if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED;
|
||||
if (selectmode == 0) pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
else if (selectmode == 1) pchan->bone->flag |= BONE_SELECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4619,7 +4619,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
|
||||
if (data->list != NULL) {
|
||||
hbone = (Bone ***) &data->list;
|
||||
|
||||
for (a=0; a<segments; a++) {
|
||||
for (a = 0; a < segments; a++) {
|
||||
**hbone = bone;
|
||||
++*hbone;
|
||||
}
|
||||
@@ -4670,14 +4670,14 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
|
||||
* pointers to bDeformGroups, all with names
|
||||
* of skinnable bones.
|
||||
*/
|
||||
bDeformGroup ***hgroup, *defgroup= NULL;
|
||||
bDeformGroup ***hgroup, *defgroup = NULL;
|
||||
int a, segments;
|
||||
struct { Object *armob; void *list; int heat; } *data= datap;
|
||||
struct { Object *armob; void *list; int heat; } *data = datap;
|
||||
int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
|
||||
bArmature *arm= data->armob->data;
|
||||
bArmature *arm = data->armob->data;
|
||||
|
||||
if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) {
|
||||
if (!(bone->flag & BONE_NO_DEFORM)) {
|
||||
if (!(bone->flag & BONE_NO_DEFORM)) {
|
||||
if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name))
|
||||
segments = bone->segments;
|
||||
else
|
||||
@@ -4690,7 +4690,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
|
||||
if (data->list != NULL) {
|
||||
hgroup = (bDeformGroup ***) &data->list;
|
||||
|
||||
for (a=0; a<segments; a++) {
|
||||
for (a = 0; a < segments; a++) {
|
||||
**hgroup = defgroup;
|
||||
++*hgroup;
|
||||
}
|
||||
@@ -4720,11 +4720,11 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
|
||||
int i, iflip, j;
|
||||
|
||||
/* for each vertex in the mesh */
|
||||
for (i=0; i < mesh->totvert; i++) {
|
||||
iflip = (dgroupflip)? mesh_get_x_mirror_vert(ob, i): 0;
|
||||
for (i = 0; i < mesh->totvert; i++) {
|
||||
iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i) : 0;
|
||||
|
||||
/* for each skinnable bone */
|
||||
for (j=0; j < numbones; ++j) {
|
||||
for (j = 0; j < numbones; ++j) {
|
||||
if (!selected[j])
|
||||
continue;
|
||||
|
||||
@@ -4732,22 +4732,22 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
|
||||
dgroup = dgrouplist[j];
|
||||
|
||||
/* store the distance-factor from the vertex to the bone */
|
||||
distance = distfactor_to_bone (verts[i], root[j], tip[j],
|
||||
bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
|
||||
distance = distfactor_to_bone(verts[i], root[j], tip[j],
|
||||
bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
|
||||
|
||||
/* add the vert to the deform group if weight!=0.0 */
|
||||
if (distance != 0.0f)
|
||||
ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE);
|
||||
ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
|
||||
else
|
||||
ED_vgroup_vert_remove (ob, dgroup, i);
|
||||
ED_vgroup_vert_remove(ob, dgroup, i);
|
||||
|
||||
/* do same for mirror */
|
||||
if (dgroupflip && dgroupflip[j] && iflip >= 0) {
|
||||
if (distance != 0.0f)
|
||||
ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance,
|
||||
WEIGHT_REPLACE);
|
||||
ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance,
|
||||
WEIGHT_REPLACE);
|
||||
else
|
||||
ED_vgroup_vert_remove (ob, dgroupflip[j], iflip);
|
||||
ED_vgroup_vert_remove(ob, dgroupflip[j], iflip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4767,7 +4767,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
* when parenting, or simply the original mesh coords.
|
||||
*/
|
||||
|
||||
bArmature *arm= par->data;
|
||||
bArmature *arm = par->data;
|
||||
Bone **bonelist, *bone;
|
||||
bDeformGroup **dgrouplist, **dgroupflip;
|
||||
bDeformGroup *dgroup;
|
||||
@@ -4781,8 +4781,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
struct { Object *armob; void *list; int heat; } looper_data;
|
||||
|
||||
looper_data.armob = par;
|
||||
looper_data.heat= heat;
|
||||
looper_data.list= NULL;
|
||||
looper_data.heat = heat;
|
||||
looper_data.list = NULL;
|
||||
|
||||
/* count the number of skinnable bones */
|
||||
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
|
||||
@@ -4792,26 +4792,26 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
|
||||
/* create an array of pointer to bones that are skinnable
|
||||
* and fill it with all of the skinnable bones */
|
||||
bonelist = MEM_callocN(numbones*sizeof(Bone *), "bonelist");
|
||||
looper_data.list= bonelist;
|
||||
bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist");
|
||||
looper_data.list = bonelist;
|
||||
bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
|
||||
|
||||
/* create an array of pointers to the deform groups that
|
||||
* coorespond to the skinnable bones (creating them
|
||||
* as necessary. */
|
||||
dgrouplist = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgrouplist");
|
||||
dgroupflip = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgroupflip");
|
||||
dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist");
|
||||
dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip");
|
||||
|
||||
looper_data.list= dgrouplist;
|
||||
looper_data.list = dgrouplist;
|
||||
bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb);
|
||||
|
||||
/* create an array of root and tip positions transformed into
|
||||
* global coords */
|
||||
root = MEM_callocN(numbones*sizeof(float)*3, "root");
|
||||
tip = MEM_callocN(numbones*sizeof(float)*3, "tip");
|
||||
selected = MEM_callocN(numbones*sizeof(int), "selected");
|
||||
root = MEM_callocN(numbones * sizeof(float) * 3, "root");
|
||||
tip = MEM_callocN(numbones * sizeof(float) * 3, "tip");
|
||||
selected = MEM_callocN(numbones * sizeof(int), "selected");
|
||||
|
||||
for (j=0; j < numbones; ++j) {
|
||||
for (j = 0; j < numbones; ++j) {
|
||||
bone = bonelist[j];
|
||||
dgroup = dgrouplist[j];
|
||||
|
||||
@@ -4821,7 +4821,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
segments = 1;
|
||||
bbone = NULL;
|
||||
|
||||
if ((par->pose) && (pchan=BKE_pose_channel_find_name(par->pose, bone->name))) {
|
||||
if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
|
||||
if (bone->segments > 1) {
|
||||
segments = bone->segments;
|
||||
bbone = b_bone_spline_setup(pchan, 1);
|
||||
@@ -4835,8 +4835,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
/* compute root and tip */
|
||||
if (bbone) {
|
||||
mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]);
|
||||
if ((segments+1) < bone->segments) {
|
||||
mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]);
|
||||
if ((segments + 1) < bone->segments) {
|
||||
mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments + 1].mat[3]);
|
||||
}
|
||||
else {
|
||||
copy_v3_v3(tip[j], bone->arm_tail);
|
||||
@@ -4869,15 +4869,15 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
}
|
||||
|
||||
/* create verts */
|
||||
mesh = (Mesh*)ob->data;
|
||||
verts = MEM_callocN(mesh->totvert*sizeof(*verts), "closestboneverts");
|
||||
mesh = (Mesh *)ob->data;
|
||||
verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts");
|
||||
|
||||
if (wpmode) {
|
||||
/* if in weight paint mode, use final verts from derivedmesh */
|
||||
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
|
||||
|
||||
if (dm->foreachMappedVert) {
|
||||
dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void*)verts);
|
||||
dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void *)verts);
|
||||
vertsfilled = 1;
|
||||
}
|
||||
|
||||
@@ -4892,7 +4892,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
}
|
||||
|
||||
/* transform verts to global space */
|
||||
for (i=0; i < mesh->totvert; i++) {
|
||||
for (i = 0; i < mesh->totvert; i++) {
|
||||
if (!vertsfilled)
|
||||
copy_v3_v3(verts[i], mesh->mvert[i].co);
|
||||
mul_m4_v3(ob->obmat, verts[i]);
|
||||
@@ -4900,9 +4900,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
|
||||
/* compute the weights based on gathered vertices and bones */
|
||||
if (heat) {
|
||||
const char *error= NULL;
|
||||
const char *error = NULL;
|
||||
heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip,
|
||||
root, tip, selected, &error);
|
||||
root, tip, selected, &error);
|
||||
|
||||
if (error) {
|
||||
BKE_report(reports, RPT_WARNING, error);
|
||||
@@ -4910,7 +4910,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
|
||||
}
|
||||
else {
|
||||
envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist,
|
||||
dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
|
||||
dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
|
||||
}
|
||||
|
||||
/* only generated in some cases but can call anyway */
|
||||
@@ -4931,7 +4931,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
|
||||
/* Lets try to create some vertex groups
|
||||
* based on the bones of the parent armature.
|
||||
*/
|
||||
bArmature *arm= par->data;
|
||||
bArmature *arm = par->data;
|
||||
|
||||
if (mode == ARM_GROUPS_NAME) {
|
||||
/* Traverse the bone list, trying to create empty vertex
|
||||
@@ -4955,41 +4955,41 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
|
||||
/* clear scale of pose-channel */
|
||||
static void pchan_clear_scale(bPoseChannel *pchan)
|
||||
{
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
|
||||
pchan->size[0]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
|
||||
pchan->size[1]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
|
||||
pchan->size[2]= 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEX) == 0)
|
||||
pchan->size[0] = 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEY) == 0)
|
||||
pchan->size[1] = 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
|
||||
pchan->size[2] = 1.0f;
|
||||
}
|
||||
|
||||
/* clear location of pose-channel */
|
||||
static void pchan_clear_loc(bPoseChannel *pchan)
|
||||
{
|
||||
if ((pchan->protectflag & OB_LOCK_LOCX)==0)
|
||||
pchan->loc[0]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCY)==0)
|
||||
pchan->loc[1]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
|
||||
pchan->loc[2]= 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
|
||||
pchan->loc[0] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
|
||||
pchan->loc[1] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
|
||||
pchan->loc[2] = 0.0f;
|
||||
}
|
||||
|
||||
/* clear rotation of pose-channel */
|
||||
static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
{
|
||||
if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) {
|
||||
if (pchan->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) {
|
||||
/* check if convert to eulers for locking... */
|
||||
if (pchan->protectflag & OB_LOCK_ROT4D) {
|
||||
/* perform clamping on a component by component basis */
|
||||
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
|
||||
pchan->rotAngle= 0.0f;
|
||||
pchan->rotAngle = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
|
||||
pchan->rotAxis[0]= 0.0f;
|
||||
pchan->rotAxis[0] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
|
||||
pchan->rotAxis[1]= 0.0f;
|
||||
pchan->rotAxis[1] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
|
||||
pchan->rotAxis[2]= 0.0f;
|
||||
pchan->rotAxis[2] = 0.0f;
|
||||
|
||||
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
|
||||
if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
|
||||
@@ -4997,22 +4997,22 @@ static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_QUAT) {
|
||||
if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
|
||||
pchan->quat[0]= 1.0f;
|
||||
pchan->quat[0] = 1.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
|
||||
pchan->quat[1]= 0.0f;
|
||||
pchan->quat[1] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
|
||||
pchan->quat[2]= 0.0f;
|
||||
pchan->quat[2] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
|
||||
pchan->quat[3]= 0.0f;
|
||||
pchan->quat[3] = 0.0f;
|
||||
}
|
||||
else {
|
||||
/* the flag may have been set for the other modes, so just ignore the extra flag... */
|
||||
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
|
||||
pchan->eul[0]= 0.0f;
|
||||
pchan->eul[0] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
|
||||
pchan->eul[1]= 0.0f;
|
||||
pchan->eul[1] = 0.0f;
|
||||
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
|
||||
pchan->eul[2]= 0.0f;
|
||||
pchan->eul[2] = 0.0f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -5021,7 +5021,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
float qlen = 0.0f;
|
||||
|
||||
if (pchan->rotmode == ROT_MODE_QUAT) {
|
||||
qlen= normalize_qt_qt(quat1, pchan->quat);
|
||||
qlen = normalize_qt_qt(quat1, pchan->quat);
|
||||
quat_to_eul(oldeul, quat1);
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
@@ -5031,14 +5031,14 @@ static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
copy_v3_v3(oldeul, pchan->eul);
|
||||
}
|
||||
|
||||
eul[0]= eul[1]= eul[2]= 0.0f;
|
||||
eul[0] = eul[1] = eul[2] = 0.0f;
|
||||
|
||||
if (pchan->protectflag & OB_LOCK_ROTX)
|
||||
eul[0]= oldeul[0];
|
||||
eul[0] = oldeul[0];
|
||||
if (pchan->protectflag & OB_LOCK_ROTY)
|
||||
eul[1]= oldeul[1];
|
||||
eul[1] = oldeul[1];
|
||||
if (pchan->protectflag & OB_LOCK_ROTZ)
|
||||
eul[2]= oldeul[2];
|
||||
eul[2] = oldeul[2];
|
||||
|
||||
if (pchan->rotmode == ROT_MODE_QUAT) {
|
||||
eul_to_quat(pchan->quat, eul);
|
||||
@@ -5047,7 +5047,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
mul_qt_fl(pchan->quat, qlen);
|
||||
|
||||
/* quaternions flip w sign to accumulate rotations correctly */
|
||||
if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
|
||||
if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) {
|
||||
mul_qt_fl(pchan->quat, -1.0f);
|
||||
}
|
||||
}
|
||||
@@ -5058,7 +5058,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
|
||||
copy_v3_v3(pchan->eul, eul);
|
||||
}
|
||||
}
|
||||
} // Duplicated in source/blender/editors/object/object_transform.c
|
||||
} /* Duplicated in source/blender/editors/object/object_transform.c */
|
||||
else {
|
||||
if (pchan->rotmode == ROT_MODE_QUAT) {
|
||||
unit_qt(pchan->quat);
|
||||
@@ -5085,10 +5085,10 @@ static void pchan_clear_transforms(bPoseChannel *pchan)
|
||||
|
||||
/* generic exec for clear-pose operators */
|
||||
static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
|
||||
void (*clear_func)(bPoseChannel*), const char default_ksName[])
|
||||
void (*clear_func)(bPoseChannel *), const char default_ksName[])
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
short autokey = 0;
|
||||
|
||||
/* sanity checks */
|
||||
@@ -5098,7 +5098,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
|
||||
}
|
||||
|
||||
/* only clear relevant transforms for selected bones */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
/* run provided clearing function */
|
||||
clear_func(pchan);
|
||||
@@ -5136,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -5160,7 +5160,7 @@ void POSE_OT_scale_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -5181,7 +5181,7 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -5202,7 +5202,7 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -5223,7 +5223,7 @@ void POSE_OT_transforms_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ***************** selections ********************** */
|
||||
@@ -5232,11 +5232,11 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
int action = RNA_enum_get(op->ptr, "action");
|
||||
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
int multipaint = scene->toolsettings->multipaint;
|
||||
|
||||
if (action == SEL_TOGGLE) {
|
||||
action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
|
||||
action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
|
||||
}
|
||||
|
||||
/* Set the flags */
|
||||
@@ -5244,26 +5244,26 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
/* select pchan only if selectable, but deselect works always */
|
||||
switch (action) {
|
||||
case SEL_SELECT:
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE)==0)
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
if (pchan->bone->flag & BONE_SELECTED) {
|
||||
pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
|
||||
}
|
||||
else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
|
||||
case SEL_SELECT:
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case SEL_DESELECT:
|
||||
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
break;
|
||||
case SEL_INVERT:
|
||||
if (pchan->bone->flag & BONE_SELECTED) {
|
||||
pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
|
||||
}
|
||||
else if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
|
||||
|
||||
if (multipaint) {
|
||||
Object *ob = ED_object_context(C);
|
||||
@@ -5285,24 +5285,24 @@ void POSE_OT_select_all(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
WM_operator_properties_select_all(ot);
|
||||
}
|
||||
|
||||
static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bPoseChannel *pchan, *parent;
|
||||
|
||||
/* Determine if there is an active bone */
|
||||
pchan=CTX_data_active_pose_bone(C);
|
||||
pchan = CTX_data_active_pose_bone(C);
|
||||
if (pchan) {
|
||||
bArmature *arm= ob->data;
|
||||
parent=pchan->parent;
|
||||
if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) {
|
||||
bArmature *arm = ob->data;
|
||||
parent = pchan->parent;
|
||||
if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) {
|
||||
parent->bone->flag |= BONE_SELECTED;
|
||||
arm->act_bone= parent->bone;
|
||||
arm->act_bone = parent->bone;
|
||||
}
|
||||
else {
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -5312,7 +5312,7 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -5329,7 +5329,7 @@ void POSE_OT_select_parent(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
}
|
||||
|
||||
@@ -5337,14 +5337,14 @@ void POSE_OT_select_parent(wmOperatorType *ot)
|
||||
|
||||
static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
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;
|
||||
if (arm->act_bone == bone)
|
||||
arm->act_bone = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -5352,14 +5352,14 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
|
||||
|
||||
static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
if (arm->layer & bone->layer) {
|
||||
// hrm... typo here?
|
||||
if ((bone->flag & BONE_SELECTED)==0) {
|
||||
if ((bone->flag & BONE_SELECTED) == 0) {
|
||||
bone->flag |= BONE_HIDDEN_P;
|
||||
if (arm->act_bone==bone)
|
||||
arm->act_bone= NULL;
|
||||
if (arm->act_bone == bone)
|
||||
arm->act_bone = NULL;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -5368,8 +5368,8 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr
|
||||
/* active object is armature in posemode, poll checked */
|
||||
static int pose_hide_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm= ob->data;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
if (RNA_boolean_get(op->ptr, "unselected"))
|
||||
bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb);
|
||||
@@ -5377,7 +5377,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op)
|
||||
bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -5394,7 +5394,7 @@ void POSE_OT_hide(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "");
|
||||
@@ -5402,7 +5402,7 @@ void POSE_OT_hide(wmOperatorType *ot)
|
||||
|
||||
static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
if (arm->layer & bone->layer) {
|
||||
if (bone->flag & BONE_HIDDEN_P) {
|
||||
@@ -5417,13 +5417,13 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
|
||||
/* active object is armature in posemode, poll checked */
|
||||
static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm= ob->data;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -5440,7 +5440,7 @@ void POSE_OT_reveal(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************* RENAMING DISASTERS ************ */
|
||||
@@ -5461,14 +5461,14 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
|
||||
bConstraint *curcon;
|
||||
bConstraintTarget *ct;
|
||||
|
||||
for (curcon = conlist->first; curcon; curcon=curcon->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
|
||||
for (curcon = conlist->first; curcon; curcon = curcon->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon);
|
||||
ListBase targets = {NULL, NULL};
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(curcon, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if (ct->tar == ob) {
|
||||
if (!strcmp(ct->subtarget, oldname) )
|
||||
BLI_strncpy(ct->subtarget, newname, MAXBONENAME);
|
||||
@@ -5500,7 +5500,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
|
||||
/* now check if we're in editmode, we need to find the unique name */
|
||||
if (arm->edbo) {
|
||||
EditBone *eBone= editbone_name_exists(arm->edbo, oldname);
|
||||
EditBone *eBone = editbone_name_exists(arm->edbo, oldname);
|
||||
|
||||
if (eBone) {
|
||||
unique_editbone_name(arm->edbo, newname, NULL);
|
||||
@@ -5509,7 +5509,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
else return;
|
||||
}
|
||||
else {
|
||||
Bone *bone= BKE_armature_find_bone_name(arm, oldname);
|
||||
Bone *bone = BKE_armature_find_bone_name(arm, oldname);
|
||||
|
||||
if (bone) {
|
||||
unique_bone_name(arm, newname);
|
||||
@@ -5519,11 +5519,11 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
}
|
||||
|
||||
/* do entire dbase - objects */
|
||||
for (ob= G.main->object.first; ob; ob= ob->id.next) {
|
||||
for (ob = G.main->object.first; ob; ob = ob->id.next) {
|
||||
ModifierData *md;
|
||||
|
||||
/* we have the object using the armature */
|
||||
if (arm==ob->data) {
|
||||
if (arm == ob->data) {
|
||||
Object *cob;
|
||||
|
||||
/* Rename the pose channel, if it exists */
|
||||
@@ -5543,12 +5543,12 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
}
|
||||
|
||||
/* Update any object constraints to use the new bone name */
|
||||
for (cob= G.main->object.first; cob; cob= cob->id.next) {
|
||||
for (cob = G.main->object.first; cob; cob = cob->id.next) {
|
||||
if (cob->constraints.first)
|
||||
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
|
||||
if (cob->pose) {
|
||||
bPoseChannel *pchan;
|
||||
for (pchan = cob->pose->chanbase.first; pchan; pchan=pchan->next) {
|
||||
for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname);
|
||||
}
|
||||
}
|
||||
@@ -5557,7 +5557,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
|
||||
/* See if an object is parented to this armature */
|
||||
if (ob->parent && (ob->parent->data == arm)) {
|
||||
if (ob->partype==PARBONE) {
|
||||
if (ob->partype == PARBONE) {
|
||||
/* bone name in object */
|
||||
if (!strcmp(ob->parsubstr, oldname))
|
||||
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
|
||||
@@ -5565,14 +5565,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
}
|
||||
|
||||
if (modifiers_usesArmature(ob, arm)) {
|
||||
bDeformGroup *dg= defgroup_find_name(ob, oldname);
|
||||
bDeformGroup *dg = defgroup_find_name(ob, oldname);
|
||||
if (dg) {
|
||||
BLI_strncpy(dg->name, newname, MAXBONENAME);
|
||||
}
|
||||
}
|
||||
|
||||
/* fix modifiers that might be using this name */
|
||||
for (md= ob->modifiers.first; md; md= md->next) {
|
||||
for (md = ob->modifiers.first; md; md = md->next) {
|
||||
if (md->type == eModifierType_Hook) {
|
||||
HookModifierData *hmd = (HookModifierData *)md;
|
||||
|
||||
@@ -5596,14 +5596,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
/* correct view locking */
|
||||
{
|
||||
bScreen *screen;
|
||||
for (screen= G.main->screen.first; screen; screen= screen->id.next) {
|
||||
for (screen = G.main->screen.first; screen; screen = screen->id.next) {
|
||||
ScrArea *sa;
|
||||
/* add regions */
|
||||
for (sa= screen->areabase.first; sa; sa= sa->next) {
|
||||
for (sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
SpaceLink *sl;
|
||||
for (sl= sa->spacedata.first; sl; sl= sl->next) {
|
||||
if (sl->spacetype==SPACE_VIEW3D) {
|
||||
View3D *v3d= (View3D *)sl;
|
||||
for (sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
if (v3d->ob_centre && v3d->ob_centre->data == arm) {
|
||||
if (!strcmp(v3d->ob_centre_bone, oldname)) {
|
||||
BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME);
|
||||
@@ -5618,16 +5618,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
|
||||
}
|
||||
|
||||
|
||||
static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm;
|
||||
char newname[MAXBONENAME];
|
||||
|
||||
/* paranoia checks */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return OPERATOR_CANCELLED;
|
||||
arm= ob->data;
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
@@ -5641,7 +5641,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -5658,21 +5658,21 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
static int armature_autoside_names_exec (bContext *C, wmOperator *op)
|
||||
static int armature_autoside_names_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm;
|
||||
char newname[MAXBONENAME];
|
||||
short axis= RNA_enum_get(op->ptr, "type");
|
||||
short axis = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* paranoia checks */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return OPERATOR_CANCELLED;
|
||||
arm= ob->data;
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
@@ -5687,15 +5687,15 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void ARMATURE_OT_autoside_names(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem axis_items[]= {
|
||||
{0, "XAXIS", 0, "X-Axis", "Left/Right"},
|
||||
static EnumPropertyItem axis_items[] = {
|
||||
{0, "XAXIS", 0, "X-Axis", "Left/Right"},
|
||||
{1, "YAXIS", 0, "Y-Axis", "Front/Back"},
|
||||
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
@@ -5711,7 +5711,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* settings */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with");
|
||||
@@ -5723,27 +5723,27 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
|
||||
/* context; editmode armature, with mirror editing enabled */
|
||||
void transform_armature_mirror_update(Object *obedit)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *ebo, *eboflip;
|
||||
|
||||
for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
|
||||
for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
|
||||
/* no layer check, correct mirror is more important */
|
||||
if (ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) {
|
||||
eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
|
||||
eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo);
|
||||
|
||||
if (eboflip) {
|
||||
/* we assume X-axis flipping for now */
|
||||
if (ebo->flag & BONE_TIPSEL) {
|
||||
EditBone *children;
|
||||
|
||||
eboflip->tail[0]= -ebo->tail[0];
|
||||
eboflip->tail[1]= ebo->tail[1];
|
||||
eboflip->tail[2]= ebo->tail[2];
|
||||
eboflip->rad_tail= ebo->rad_tail;
|
||||
eboflip->roll= -ebo->roll;
|
||||
eboflip->tail[0] = -ebo->tail[0];
|
||||
eboflip->tail[1] = ebo->tail[1];
|
||||
eboflip->tail[2] = ebo->tail[2];
|
||||
eboflip->rad_tail = ebo->rad_tail;
|
||||
eboflip->roll = -ebo->roll;
|
||||
|
||||
/* Also move connected children, in case children's name aren't mirrored properly */
|
||||
for (children=arm->edbo->first; children; children=children->next) {
|
||||
for (children = arm->edbo->first; children; children = children->next) {
|
||||
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
|
||||
copy_v3_v3(children->head, eboflip->tail);
|
||||
children->rad_head = ebo->rad_tail;
|
||||
@@ -5751,11 +5751,11 @@ void transform_armature_mirror_update(Object *obedit)
|
||||
}
|
||||
}
|
||||
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;
|
||||
eboflip->roll= -ebo->roll;
|
||||
eboflip->head[0] = -ebo->head[0];
|
||||
eboflip->head[1] = ebo->head[1];
|
||||
eboflip->head[2] = ebo->head[2];
|
||||
eboflip->rad_head = ebo->rad_head;
|
||||
eboflip->roll = -ebo->roll;
|
||||
|
||||
/* Also move connected parent, in case parent's name isn't mirrored properly */
|
||||
if (eboflip->parent && eboflip->flag & BONE_CONNECTED) {
|
||||
@@ -5765,10 +5765,10 @@ void transform_armature_mirror_update(Object *obedit)
|
||||
}
|
||||
}
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
eboflip->dist= ebo->dist;
|
||||
eboflip->roll= -ebo->roll;
|
||||
eboflip->xwidth= ebo->xwidth;
|
||||
eboflip->zwidth= ebo->zwidth;
|
||||
eboflip->dist = ebo->dist;
|
||||
eboflip->roll = -ebo->roll;
|
||||
eboflip->xwidth = ebo->xwidth;
|
||||
eboflip->zwidth = ebo->zwidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5784,14 +5784,14 @@ void transform_armature_mirror_update(Object *obedit)
|
||||
|
||||
/**************************************** SUBDIVISION ALGOS ******************************************/
|
||||
|
||||
EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
EditBone *subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
{
|
||||
bArmature *arm= obedit->data;
|
||||
bArmature *arm = obedit->data;
|
||||
EditBone *lastBone = NULL;
|
||||
|
||||
if (scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE) {
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
float *previous = NULL, *current = NULL;
|
||||
EditBone *child = NULL;
|
||||
EditBone *parent = NULL;
|
||||
@@ -5799,7 +5799,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
|
||||
float angleLimit = (float)cos(scene->toolsettings->skgen_angle_limit * M_PI / 180.0f);
|
||||
|
||||
parent = ED_armature_edit_bone_add(arm, "Bone");
|
||||
parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
parent->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
copy_v3_v3(parent->head, head->p);
|
||||
|
||||
root = parent;
|
||||
@@ -5809,8 +5809,8 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
|
||||
previous = iter->p;
|
||||
|
||||
for (IT_next(iter);
|
||||
IT_stopped(iter) == 0;
|
||||
previous = iter->p, IT_next(iter))
|
||||
IT_stopped(iter) == 0;
|
||||
previous = iter->p, IT_next(iter))
|
||||
{
|
||||
float vec1[3], vec2[3];
|
||||
float len1, len2;
|
||||
@@ -5829,7 +5829,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
|
||||
child = ED_armature_edit_bone_add(arm, "Bone");
|
||||
copy_v3_v3(child->head, parent->tail);
|
||||
child->parent = parent;
|
||||
child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
child->flag |= BONE_CONNECTED | BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
|
||||
parent = child; /* new child is next parent */
|
||||
}
|
||||
@@ -5840,7 +5840,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
|
||||
* to let subsequent subdivision methods do their thing.
|
||||
* */
|
||||
if (parent == root) {
|
||||
if (parent==arm->act_edbone) arm->act_edbone= NULL;
|
||||
if (parent == arm->act_edbone) arm->act_edbone = NULL;
|
||||
ED_armature_edit_bone_remove(arm, parent);
|
||||
parent = NULL;
|
||||
}
|
||||
@@ -5851,16 +5851,16 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
|
||||
return lastBone;
|
||||
}
|
||||
|
||||
EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
EditBone *test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
{
|
||||
EditBone *lastBone = NULL;
|
||||
|
||||
if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION) {
|
||||
float invmat[4][4]= MAT4_UNITY;
|
||||
float tmat[3][3]= MAT3_UNITY;
|
||||
float invmat[4][4] = MAT4_UNITY;
|
||||
float tmat[3][3] = MAT3_UNITY;
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
bArmature *arm= obedit->data;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
bArmature *arm = obedit->data;
|
||||
|
||||
initArcIterator(iter, arc, head);
|
||||
|
||||
@@ -5894,17 +5894,17 @@ float arcLengthRatio(ReebArc *arc)
|
||||
return embedLength / arcLength;
|
||||
}
|
||||
|
||||
EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
|
||||
{
|
||||
EditBone *lastBone = NULL;
|
||||
if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) &&
|
||||
arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
|
||||
arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
|
||||
{
|
||||
float invmat[4][4]= MAT4_UNITY;
|
||||
float tmat[3][3]= MAT3_UNITY;
|
||||
float invmat[4][4] = MAT4_UNITY;
|
||||
float tmat[3][3] = MAT3_UNITY;
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
bArmature *arm= obedit->data;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
bArmature *arm = obedit->data;
|
||||
|
||||
initArcIterator(iter, arc, head);
|
||||
|
||||
@@ -5918,7 +5918,7 @@ EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, Re
|
||||
|
||||
void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX get from context
|
||||
Object *obedit = scene->obedit; // XXX get from context
|
||||
GHash *arcBoneMap = NULL;
|
||||
ReebArc *arc = NULL;
|
||||
ReebNode *node = NULL;
|
||||
@@ -5933,8 +5933,8 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
|
||||
}
|
||||
|
||||
dst = BKE_object_add(scene, OB_ARMATURE);
|
||||
ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot
|
||||
obedit= scene->basact->object;
|
||||
ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot
|
||||
obedit = scene->basact->object;
|
||||
|
||||
/* Copy orientation from source */
|
||||
copy_v3_v3(dst->loc, src->obmat[3]);
|
||||
@@ -5947,7 +5947,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
|
||||
|
||||
arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh");
|
||||
|
||||
BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
|
||||
BLI_markdownSymmetry((BGraph *)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
|
||||
|
||||
for (arc = rg->arcs.first; arc; arc = arc->next)
|
||||
{
|
||||
@@ -6008,9 +6008,9 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
|
||||
}
|
||||
|
||||
if (lastBone == NULL) {
|
||||
EditBone *bone;
|
||||
EditBone *bone;
|
||||
bone = ED_armature_edit_bone_add(obedit->data, "Bone");
|
||||
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
|
||||
copy_v3_v3(bone->head, head->p);
|
||||
copy_v3_v3(bone->tail, tail->p);
|
||||
@@ -6029,7 +6029,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < node->degree; i++) {
|
||||
arc = (ReebArc*)node->arcs[i];
|
||||
arc = (ReebArc *)node->arcs[i];
|
||||
|
||||
/* if arc is incoming into the node */
|
||||
if ((arc->head == node && arc->flag == -1) ||
|
||||
|
||||
@@ -257,7 +257,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
|
||||
return -1;
|
||||
}
|
||||
|
||||
EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion)
|
||||
EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion)
|
||||
{
|
||||
EditBone *lastBone = NULL;
|
||||
EditBone *child = NULL;
|
||||
|
||||
@@ -70,15 +70,15 @@
|
||||
/************ RIG RETARGET DATA STRUCTURES ***************/
|
||||
|
||||
typedef struct MemoNode {
|
||||
float weight;
|
||||
int next;
|
||||
float weight;
|
||||
int next;
|
||||
} MemoNode;
|
||||
|
||||
typedef struct RetargetParam {
|
||||
RigGraph *rigg;
|
||||
RigArc *iarc;
|
||||
RigNode *inode_start;
|
||||
bContext *context;
|
||||
RigGraph *rigg;
|
||||
RigArc *iarc;
|
||||
RigNode *inode_start;
|
||||
bContext *context;
|
||||
} RetargetParam;
|
||||
|
||||
typedef enum
|
||||
@@ -128,7 +128,7 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent)
|
||||
return count;
|
||||
}
|
||||
|
||||
static EditBone* nextEditBoneChild(ListBase *list, EditBone *parent, int n)
|
||||
static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n)
|
||||
{
|
||||
EditBone *ebone;
|
||||
|
||||
@@ -247,12 +247,12 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
|
||||
|
||||
static void RIG_freeRigArc(BArc *arc)
|
||||
{
|
||||
BLI_freelistN(&((RigArc*)arc)->edges);
|
||||
BLI_freelistN(&((RigArc *)arc)->edges);
|
||||
}
|
||||
|
||||
void RIG_freeRigGraph(BGraph *rg)
|
||||
{
|
||||
RigGraph *rigg = (RigGraph*)rg;
|
||||
RigGraph *rigg = (RigGraph *)rg;
|
||||
BNode *node;
|
||||
BArc *arc;
|
||||
|
||||
@@ -270,7 +270,7 @@ void RIG_freeRigGraph(BGraph *rg)
|
||||
BLI_freelistN(&rg->arcs);
|
||||
|
||||
for (node = rg->nodes.first; node; node = node->next) {
|
||||
BLI_freeNode(rg, (BNode*)node);
|
||||
BLI_freeNode(rg, (BNode *)node);
|
||||
}
|
||||
BLI_freelistN(&rg->nodes);
|
||||
|
||||
@@ -311,7 +311,7 @@ static RigGraph *newRigGraph(void)
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
totthread = BLI_system_thread_count();
|
||||
totthread = BLI_system_thread_count();
|
||||
// }
|
||||
|
||||
rg->worker = BLI_create_worker(exec_retargetArctoArc, totthread, 20); /* fix number of threads */
|
||||
@@ -428,13 +428,13 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = 0, j = 0; i < (MAXBONENAME-1) && j < (MAXBONENAME-1) && template_name[i] != '\0'; i++) {
|
||||
for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) {
|
||||
if (template_name[i] == '&') {
|
||||
if (template_name[i+1] == 'S' || template_name[i+1] == 's') {
|
||||
if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') {
|
||||
j += sprintf(name + j, "%s", side_string);
|
||||
i++;
|
||||
}
|
||||
else if (template_name[i+1] == 'N' || template_name[i+1] == 'n') {
|
||||
else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') {
|
||||
j += sprintf(name + j, "%s", num_string);
|
||||
i++;
|
||||
}
|
||||
@@ -471,7 +471,7 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_
|
||||
|
||||
renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string);
|
||||
ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob);
|
||||
ctrl->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone);
|
||||
|
||||
ctrl->link = src_ctrl->link;
|
||||
@@ -514,7 +514,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
|
||||
char name[MAXBONENAME];
|
||||
renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
|
||||
edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
|
||||
edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
|
||||
edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
|
||||
BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone);
|
||||
}
|
||||
|
||||
@@ -526,7 +526,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
|
||||
|
||||
static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string)
|
||||
{
|
||||
GHash *ptr_hash;
|
||||
GHash *ptr_hash;
|
||||
RigNode *node;
|
||||
RigArc *arc;
|
||||
RigControl *ctrl;
|
||||
@@ -691,7 +691,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
|
||||
}
|
||||
|
||||
/* if there's already a link
|
||||
* overwrite only if new link is higher in the chain */
|
||||
* overwrite only if new link is higher in the chain */
|
||||
if (ctrl->link && flag == ctrl->flag) {
|
||||
EditBone *bone = NULL;
|
||||
|
||||
@@ -732,9 +732,9 @@ static void RIG_reconnectControlBones(RigGraph *rg)
|
||||
int found = 0;
|
||||
|
||||
/* DO SOME MAGIC HERE */
|
||||
for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -744,7 +744,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
|
||||
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (target_index = 0, ct= targets.first; ct; target_index++, ct= ct->next) {
|
||||
for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) {
|
||||
if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) {
|
||||
/* SET bone link to bone corresponding to pchan */
|
||||
EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name);
|
||||
@@ -857,9 +857,9 @@ static void RIG_reconnectControlBones(RigGraph *rg)
|
||||
/* check constraints first */
|
||||
|
||||
/* DO SOME MAGIC HERE */
|
||||
for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
@@ -867,7 +867,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) {
|
||||
/* SET bone link to ctrl corresponding to pchan */
|
||||
RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name);
|
||||
@@ -918,8 +918,8 @@ static void RIG_reconnectControlBones(RigGraph *rg)
|
||||
/* look on deform bones first */
|
||||
BLI_ghashIterator_init(&ghi, rg->bones_map);
|
||||
|
||||
for ( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) {
|
||||
EditBone *bone = (EditBone*)BLI_ghashIterator_getValue(&ghi);
|
||||
for (; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) {
|
||||
EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi);
|
||||
|
||||
/* don't link with parent */
|
||||
if (bone->parent != ctrl->bone) {
|
||||
@@ -972,9 +972,9 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr
|
||||
|
||||
joined_arc2->edges.first = joined_arc2->edges.last = NULL;
|
||||
|
||||
BLI_removeArc((BGraph*)rg, (BArc*)joined_arc2);
|
||||
BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)node);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)node);
|
||||
}
|
||||
|
||||
static void RIG_removeNormalNodes(RigGraph *rg)
|
||||
@@ -1020,12 +1020,12 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
|
||||
MEM_freeN(first_edge);
|
||||
}
|
||||
else if (arc->head->degree == 1) {
|
||||
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001f);
|
||||
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f);
|
||||
|
||||
if (new_node) {
|
||||
BLI_remlink(&arc->edges, first_edge);
|
||||
MEM_freeN(first_edge);
|
||||
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head);
|
||||
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
|
||||
}
|
||||
else {
|
||||
RigEdge *next_edge = first_edge->next;
|
||||
@@ -1062,7 +1062,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
|
||||
}
|
||||
|
||||
if (other_arc == NULL) {
|
||||
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001);
|
||||
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001);
|
||||
|
||||
if (new_node) {
|
||||
/* remove null edge in other arcs too */
|
||||
@@ -1070,13 +1070,13 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
|
||||
if (other_arc != arc) {
|
||||
RigEdge *test_edge;
|
||||
if (other_arc->head == arc->head) {
|
||||
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->head);
|
||||
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head);
|
||||
test_edge = other_arc->edges.first;
|
||||
BLI_remlink(&other_arc->edges, test_edge);
|
||||
MEM_freeN(test_edge);
|
||||
}
|
||||
else if (other_arc->tail == arc->head) {
|
||||
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->tail);
|
||||
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail);
|
||||
test_edge = other_arc->edges.last;
|
||||
BLI_remlink(&other_arc->edges, test_edge);
|
||||
MEM_freeN(test_edge);
|
||||
@@ -1086,7 +1086,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
|
||||
|
||||
BLI_remlink(&arc->edges, first_edge);
|
||||
MEM_freeN(first_edge);
|
||||
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head);
|
||||
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head);
|
||||
}
|
||||
else {
|
||||
RigEdge *next_edge = first_edge->next;
|
||||
@@ -1125,14 +1125,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
|
||||
MEM_freeN(last_edge);
|
||||
}
|
||||
else if (arc->tail->degree == 1) {
|
||||
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001f);
|
||||
RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f);
|
||||
|
||||
if (new_node) {
|
||||
RigEdge *previous_edge = last_edge->prev;
|
||||
|
||||
BLI_remlink(&arc->edges, last_edge);
|
||||
MEM_freeN(last_edge);
|
||||
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->tail);
|
||||
BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail);
|
||||
|
||||
/* set previous angle to 0, since there's no following edges */
|
||||
if (previous_edge) {
|
||||
@@ -1235,7 +1235,7 @@ static void RIG_findHead(RigGraph *rg)
|
||||
if (BLI_countlist(&rg->arcs) == 1) {
|
||||
RigArc *arc = rg->arcs.first;
|
||||
|
||||
rg->head = (RigNode*)arc->head;
|
||||
rg->head = (RigNode *)arc->head;
|
||||
}
|
||||
else {
|
||||
RigArc *arc;
|
||||
@@ -1243,7 +1243,7 @@ static void RIG_findHead(RigGraph *rg)
|
||||
for (arc = rg->arcs.first; arc; arc = arc->next) {
|
||||
RigEdge *edge = arc->edges.last;
|
||||
|
||||
if (edge->bone->flag & (BONE_TIPSEL|BONE_SELECTED)) {
|
||||
if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
|
||||
rg->head = arc->tail;
|
||||
break;
|
||||
}
|
||||
@@ -1323,7 +1323,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc)
|
||||
{
|
||||
RigEdge *edge;
|
||||
|
||||
RIG_printNode((RigNode*)arc->head, "head");
|
||||
RIG_printNode((RigNode *)arc->head, "head");
|
||||
|
||||
for (edge = arc->edges.first; edge; edge = edge->next) {
|
||||
printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]);
|
||||
@@ -1336,7 +1336,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc)
|
||||
}
|
||||
printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group);
|
||||
|
||||
RIG_printNode((RigNode*)arc->tail, "tail");
|
||||
RIG_printNode((RigNode *)arc->tail, "tail");
|
||||
}
|
||||
|
||||
void RIG_printGraph(RigGraph *rg)
|
||||
@@ -1380,27 +1380,27 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
|
||||
rg->ob = ob;
|
||||
|
||||
/* Do the rotations */
|
||||
for (ebone = rg->editbones->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
|
||||
if (ebone->parent == NULL) {
|
||||
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_removeDoubleNodes((BGraph*)rg, 0.001);
|
||||
BLI_removeDoubleNodes((BGraph *)rg, 0.001);
|
||||
|
||||
RIG_removeNormalNodes(rg);
|
||||
|
||||
RIG_removeUneededOffsets(rg);
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
RIG_findHead(rg);
|
||||
|
||||
BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit);
|
||||
BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
|
||||
|
||||
RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
|
||||
|
||||
if (BLI_isGraphCyclic((BGraph*)rg)) {
|
||||
if (BLI_isGraphCyclic((BGraph *)rg)) {
|
||||
printf("armature cyclic\n");
|
||||
}
|
||||
|
||||
@@ -1428,27 +1428,27 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
|
||||
rg->ob = ob;
|
||||
|
||||
/* Do the rotations */
|
||||
for (ebone = rg->editbones->first; ebone; ebone=ebone->next) {
|
||||
for (ebone = rg->editbones->first; ebone; ebone = ebone->next) {
|
||||
if (ebone->parent == NULL) {
|
||||
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
|
||||
}
|
||||
}
|
||||
|
||||
BLI_removeDoubleNodes((BGraph*)rg, 0.001);
|
||||
BLI_removeDoubleNodes((BGraph *)rg, 0.001);
|
||||
|
||||
RIG_removeNormalNodes(rg);
|
||||
|
||||
RIG_removeUneededOffsets(rg);
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
RIG_findHead(rg);
|
||||
|
||||
BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit);
|
||||
BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit);
|
||||
|
||||
RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */
|
||||
|
||||
if (BLI_isGraphCyclic((BGraph*)rg)) {
|
||||
if (BLI_isGraphCyclic((BGraph *)rg)) {
|
||||
printf("armature cyclic\n");
|
||||
}
|
||||
|
||||
@@ -1459,7 +1459,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
|
||||
#if 0
|
||||
static EditBone *add_editbonetolist(char *name, ListBase *list)
|
||||
{
|
||||
EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone");
|
||||
EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
|
||||
|
||||
BLI_strncpy(bone->name, name, sizeof(bone->name));
|
||||
unique_editbone_name(list, bone->name, NULL);
|
||||
@@ -1467,16 +1467,16 @@ static EditBone *add_editbonetolist(char *name, ListBase *list)
|
||||
BLI_addtail(list, bone);
|
||||
|
||||
bone->flag |= BONE_TIPSEL;
|
||||
bone->weight= 1.0F;
|
||||
bone->dist= 0.25F;
|
||||
bone->xwidth= 0.1;
|
||||
bone->zwidth= 0.1;
|
||||
bone->ease1= 1.0;
|
||||
bone->ease2= 1.0;
|
||||
bone->rad_head= 0.10;
|
||||
bone->rad_tail= 0.05;
|
||||
bone->segments= 1;
|
||||
bone->layer= 1;//arm->layer;
|
||||
bone->weight = 1.0F;
|
||||
bone->dist = 0.25F;
|
||||
bone->xwidth = 0.1;
|
||||
bone->zwidth = 0.1;
|
||||
bone->ease1 = 1.0;
|
||||
bone->ease2 = 1.0;
|
||||
bone->rad_head = 0.10;
|
||||
bone->rad_tail = 0.05;
|
||||
bone->segments = 1;
|
||||
bone->layer = 1; //arm->layer;
|
||||
|
||||
return bone;
|
||||
}
|
||||
@@ -1887,7 +1887,7 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions,
|
||||
}
|
||||
}
|
||||
|
||||
static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight)
|
||||
static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight)
|
||||
{
|
||||
MemoNode *node;
|
||||
int index = indexMemoNode(nb_positions, previous, current, joints_left);
|
||||
@@ -1910,8 +1910,8 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
|
||||
MemoNode *min_node = NULL;
|
||||
float *vec0 = vec_cache[previous];
|
||||
float *vec1 = vec_cache[current];
|
||||
float min_weight= 0.0f;
|
||||
int min_next= 0;
|
||||
float min_weight = 0.0f;
|
||||
int min_next = 0;
|
||||
int next;
|
||||
|
||||
for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
|
||||
@@ -1969,7 +1969,7 @@ static int testFlipArc(RigArc *iarc, RigNode *inode_start)
|
||||
static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
|
||||
{
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
RigEdge *edge;
|
||||
EmbedBucket *bucket = NULL;
|
||||
ReebNode *node_start, *node_end;
|
||||
@@ -2019,7 +2019,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
|
||||
#ifndef USE_THREADS
|
||||
MemoNode *result;
|
||||
#endif
|
||||
float **positions_cache = MEM_callocN(sizeof(float*) * (nb_positions + 2), "positions cache");
|
||||
float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache");
|
||||
int i;
|
||||
|
||||
positions_cache[0] = node_start->p;
|
||||
@@ -2084,7 +2084,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
|
||||
static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start)
|
||||
{
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
ReebArc *earc = iarc->link_mesh;
|
||||
ReebNode *node_start, *node_end;
|
||||
RigEdge *edge;
|
||||
@@ -2096,12 +2096,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
|
||||
|
||||
|
||||
if (testFlipArc(iarc, inode_start)) {
|
||||
node_start = (ReebNode*)earc->tail;
|
||||
node_end = (ReebNode*)earc->head;
|
||||
node_start = (ReebNode *)earc->tail;
|
||||
node_end = (ReebNode *)earc->head;
|
||||
}
|
||||
else {
|
||||
node_start = (ReebNode*)earc->head;
|
||||
node_end = (ReebNode*)earc->tail;
|
||||
node_start = (ReebNode *)earc->head;
|
||||
node_end = (ReebNode *)earc->tail;
|
||||
}
|
||||
|
||||
initArcIterator(iter, earc, node_start);
|
||||
@@ -2183,7 +2183,7 @@ static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode
|
||||
|
||||
void *exec_retargetArctoArc(void *param)
|
||||
{
|
||||
RetargetParam *p = (RetargetParam*)param;
|
||||
RetargetParam *p = (RetargetParam *)param;
|
||||
RigGraph *rigg = p->rigg;
|
||||
RigArc *iarc = p->iarc;
|
||||
bContext *C = p->context;
|
||||
@@ -2224,8 +2224,8 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
|
||||
ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
|
||||
int ishape, eshape;
|
||||
|
||||
ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
|
||||
inode->link_mesh = enode;
|
||||
|
||||
@@ -2234,7 +2234,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
|
||||
|
||||
enode = enode->link_down;
|
||||
reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */
|
||||
eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2243,7 +2243,7 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < enode->degree; i++) {
|
||||
ReebArc *earc = (ReebArc*)enode->arcs[i];
|
||||
ReebArc *earc = (ReebArc *)enode->arcs[i];
|
||||
|
||||
if (earc->flag == ARC_FREE) {
|
||||
earc->flag = ARC_TAKEN;
|
||||
@@ -2260,7 +2260,7 @@ static void markMultiResolutionArc(ReebArc *start_earc)
|
||||
{
|
||||
if (start_earc->link_up) {
|
||||
ReebArc *earc;
|
||||
for (earc = start_earc->link_up ; earc; earc = earc->link_up) {
|
||||
for (earc = start_earc->link_up; earc; earc = earc->link_up) {
|
||||
earc->flag = ARC_TAKEN;
|
||||
|
||||
if (earc->tail->index != start_earc->tail->index) {
|
||||
@@ -2276,8 +2276,8 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
|
||||
ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode);
|
||||
int ishape, eshape;
|
||||
|
||||
ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)start_node, (BArc*)next_iarc, 1) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS;
|
||||
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
|
||||
|
||||
while (ishape != eshape && next_earc->link_up) {
|
||||
next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
|
||||
@@ -2285,7 +2285,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
|
||||
next_earc = next_earc->link_up;
|
||||
reebg = reebg->link_up;
|
||||
enode = next_earc->head;
|
||||
eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS;
|
||||
}
|
||||
|
||||
next_earc->flag = ARC_USED;
|
||||
@@ -2307,15 +2307,15 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R
|
||||
|
||||
enode = reebg->nodes.first;
|
||||
|
||||
ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph*)rigg->link_mesh, (BNode*)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
|
||||
while (ishape != eshape && reebg->link_up) {
|
||||
reebg = reebg->link_up;
|
||||
|
||||
enode = reebg->nodes.first;
|
||||
|
||||
eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS;
|
||||
}
|
||||
|
||||
inode->link_mesh = enode;
|
||||
@@ -2340,7 +2340,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
|
||||
// }
|
||||
|
||||
for (i = 0; i < enode->degree; i++) {
|
||||
next_earc = (ReebArc*)enode->arcs[i];
|
||||
next_earc = (ReebArc *)enode->arcs[i];
|
||||
|
||||
// if (next_earc->flag == ARC_FREE)
|
||||
// {
|
||||
@@ -2351,9 +2351,9 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
|
||||
// }
|
||||
|
||||
if (next_earc->flag == ARC_FREE &&
|
||||
next_earc->symmetry_flag == symmetry_flag &&
|
||||
next_earc->symmetry_group == symmetry_group &&
|
||||
next_earc->symmetry_level == symmetry_level)
|
||||
next_earc->symmetry_flag == symmetry_flag &&
|
||||
next_earc->symmetry_group == symmetry_group &&
|
||||
next_earc->symmetry_level == symmetry_level)
|
||||
{
|
||||
// printf("CORRESPONDING ARC FOUND\n");
|
||||
// printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group);
|
||||
@@ -2394,7 +2394,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
|
||||
|
||||
/* Emergency matching */
|
||||
for (i = 0; i < enode->degree; i++) {
|
||||
next_earc = (ReebArc*)enode->arcs[i];
|
||||
next_earc = (ReebArc *)enode->arcs[i];
|
||||
|
||||
if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
|
||||
// printf("USING:\n");
|
||||
@@ -2420,14 +2420,14 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig
|
||||
retargetArctoArc(C, rigg, start_arc, start_node);
|
||||
|
||||
enode = BIF_otherNodeFromIndex(earc, enode);
|
||||
inode = (RigNode*)BLI_otherNode((BArc*)start_arc, (BNode*)inode);
|
||||
inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode);
|
||||
|
||||
/* match with lowest node with correct shape */
|
||||
matchMultiResolutionNode(rigg, inode, enode);
|
||||
}
|
||||
|
||||
for (i = 0; i < inode->degree; i++) {
|
||||
RigArc *next_iarc = (RigArc*)inode->arcs[i];
|
||||
RigArc *next_iarc = (RigArc *)inode->arcs[i];
|
||||
|
||||
/* no back tracking */
|
||||
if (next_iarc != start_arc) {
|
||||
@@ -2448,7 +2448,7 @@ static void finishRetarget(RigGraph *rigg)
|
||||
|
||||
static void adjustGraphs(bContext *C, RigGraph *rigg)
|
||||
{
|
||||
bArmature *arm= rigg->ob->data;
|
||||
bArmature *arm = rigg->ob->data;
|
||||
RigArc *arc;
|
||||
|
||||
for (arc = rigg->arcs.first; arc; arc = arc->next) {
|
||||
@@ -2468,7 +2468,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg)
|
||||
|
||||
static void retargetGraphs(bContext *C, RigGraph *rigg)
|
||||
{
|
||||
bArmature *arm= rigg->ob->data;
|
||||
bArmature *arm = rigg->ob->data;
|
||||
ReebGraph *reebg = rigg->link_mesh;
|
||||
RigNode *inode;
|
||||
|
||||
@@ -2534,7 +2534,7 @@ int RIG_nbJoints(RigGraph *rg)
|
||||
static void BIF_freeRetarget(void)
|
||||
{
|
||||
if (GLOBAL_RIGG) {
|
||||
RIG_freeRigGraph((BGraph*)GLOBAL_RIGG);
|
||||
RIG_freeRigGraph((BGraph *)GLOBAL_RIGG);
|
||||
GLOBAL_RIGG = NULL;
|
||||
}
|
||||
}
|
||||
@@ -2544,7 +2544,7 @@ void BIF_retargetArmature(bContext *C)
|
||||
ReebGraph *reebg;
|
||||
double start_time, end_time;
|
||||
double gstart_time, gend_time;
|
||||
double reeb_time, rig_time=0.0, retarget_time=0.0, total_time;
|
||||
double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time;
|
||||
|
||||
gstart_time = start_time = PIL_check_seconds_timer();
|
||||
|
||||
@@ -2555,11 +2555,11 @@ void BIF_retargetArmature(bContext *C)
|
||||
|
||||
printf("Reeb Graph created\n");
|
||||
|
||||
CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases)
|
||||
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
|
||||
{
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->type==OB_ARMATURE) {
|
||||
if (ob->type == OB_ARMATURE) {
|
||||
RigGraph *rigg;
|
||||
bArmature *arm;
|
||||
|
||||
@@ -2658,9 +2658,9 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
|
||||
|
||||
/* free template if it comes from the edit armature */
|
||||
if (free_template) {
|
||||
RIG_freeRigGraph((BGraph*)template_rigg);
|
||||
RIG_freeRigGraph((BGraph *)template_rigg);
|
||||
}
|
||||
RIG_freeRigGraph((BGraph*)rigg);
|
||||
RIG_freeRigGraph((BGraph *)rigg);
|
||||
|
||||
ED_armature_validate_active(armedit);
|
||||
|
||||
|
||||
@@ -70,31 +70,31 @@
|
||||
|
||||
|
||||
|
||||
typedef int (*GestureDetectFct)(bContext*, SK_Gesture*, SK_Sketch *);
|
||||
typedef void (*GestureApplyFct)(bContext*, SK_Gesture*, SK_Sketch *);
|
||||
typedef int (*GestureDetectFct)(bContext *, SK_Gesture *, SK_Sketch *);
|
||||
typedef void (*GestureApplyFct)(bContext *, SK_Gesture *, SK_Sketch *);
|
||||
|
||||
typedef struct SK_GestureAction {
|
||||
char name[64];
|
||||
GestureDetectFct detect;
|
||||
GestureApplyFct apply;
|
||||
GestureDetectFct detect;
|
||||
GestureApplyFct apply;
|
||||
} SK_GestureAction;
|
||||
|
||||
#if 0 /* UNUSED 2.5 */
|
||||
static SK_Point boneSnap;
|
||||
#endif
|
||||
|
||||
static int LAST_SNAP_POINT_VALID = 0;
|
||||
static float LAST_SNAP_POINT[3];
|
||||
static int LAST_SNAP_POINT_VALID = 0;
|
||||
static float LAST_SNAP_POINT[3];
|
||||
|
||||
|
||||
typedef struct SK_StrokeIterator {
|
||||
HeadFct head;
|
||||
TailFct tail;
|
||||
PeekFct peek;
|
||||
NextFct next;
|
||||
NextNFct nextN;
|
||||
PreviousFct previous;
|
||||
StoppedFct stopped;
|
||||
HeadFct head;
|
||||
TailFct tail;
|
||||
PeekFct peek;
|
||||
NextFct next;
|
||||
NextNFct nextN;
|
||||
PreviousFct previous;
|
||||
StoppedFct stopped;
|
||||
|
||||
float *p, *no;
|
||||
float size;
|
||||
@@ -127,30 +127,29 @@ void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
|
||||
int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
|
||||
void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch);
|
||||
|
||||
SK_Sketch* contextSketch(const bContext *c, int create);
|
||||
SK_Sketch* viewcontextSketch(ViewContext *vc, int create);
|
||||
SK_Sketch *contextSketch(const bContext *c, int create);
|
||||
SK_Sketch *viewcontextSketch(ViewContext *vc, int create);
|
||||
|
||||
void sk_resetOverdraw(SK_Sketch *sketch);
|
||||
int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk);
|
||||
|
||||
/******************** GESTURE ACTIONS ******************************/
|
||||
|
||||
static SK_GestureAction GESTURE_ACTIONS[] =
|
||||
{
|
||||
{"Cut", sk_detectCutGesture, sk_applyCutGesture},
|
||||
{"Trim", sk_detectTrimGesture, sk_applyTrimGesture},
|
||||
{"Command", sk_detectCommandGesture, sk_applyCommandGesture},
|
||||
{"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture},
|
||||
{"Merge", sk_detectMergeGesture, sk_applyMergeGesture},
|
||||
{"Reverse", sk_detectReverseGesture, sk_applyReverseGesture},
|
||||
{"Convert", sk_detectConvertGesture, sk_applyConvertGesture},
|
||||
{"", NULL, NULL}
|
||||
};
|
||||
static SK_GestureAction GESTURE_ACTIONS[] = {
|
||||
{"Cut", sk_detectCutGesture, sk_applyCutGesture},
|
||||
{"Trim", sk_detectTrimGesture, sk_applyTrimGesture},
|
||||
{"Command", sk_detectCommandGesture, sk_applyCommandGesture},
|
||||
{"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture},
|
||||
{"Merge", sk_detectMergeGesture, sk_applyMergeGesture},
|
||||
{"Reverse", sk_detectReverseGesture, sk_applyReverseGesture},
|
||||
{"Convert", sk_detectConvertGesture, sk_applyConvertGesture},
|
||||
{"", NULL, NULL}
|
||||
};
|
||||
|
||||
/******************** TEMPLATES UTILS *************************/
|
||||
|
||||
static char *TEMPLATES_MENU = NULL;
|
||||
static int TEMPLATES_CURRENT = 0;
|
||||
static int TEMPLATES_CURRENT = 0;
|
||||
static GHash *TEMPLATES_HASH = NULL;
|
||||
static RigGraph *TEMPLATE_RIGG = NULL;
|
||||
|
||||
@@ -169,7 +168,7 @@ void BIF_makeListTemplates(const bContext *C)
|
||||
TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh");
|
||||
TEMPLATES_CURRENT = 0;
|
||||
|
||||
for ( base = FIRSTBASE; base; base = base->next ) {
|
||||
for (base = FIRSTBASE; base; base = base->next) {
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob != obedit && ob->type == OB_ARMATURE) {
|
||||
@@ -205,7 +204,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C))
|
||||
Object *ob = BLI_ghashIterator_getValue(&ghi);
|
||||
int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
|
||||
|
||||
p += sprintf(p, "|%s%%x%i", ob->id.name+2, key);
|
||||
p += sprintf(p, "|%s%%x%i", ob->id.name + 2, key);
|
||||
|
||||
BLI_ghashIterator_step(&ghi);
|
||||
}
|
||||
@@ -237,7 +236,7 @@ int BIF_currentTemplate(const bContext *C)
|
||||
return TEMPLATES_CURRENT;
|
||||
}
|
||||
|
||||
static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob)
|
||||
static RigGraph *sk_makeTemplateGraph(const bContext *C, Object *ob)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
if (ob == obedit) {
|
||||
@@ -246,7 +245,7 @@ static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob)
|
||||
|
||||
if (ob != NULL) {
|
||||
if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) {
|
||||
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
|
||||
RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
|
||||
TEMPLATE_RIGG = NULL;
|
||||
}
|
||||
|
||||
@@ -275,7 +274,7 @@ int BIF_nbJointsTemplate(const bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
const char * BIF_nameBoneTemplate(const bContext *C)
|
||||
const char *BIF_nameBoneTemplate(const bContext *C)
|
||||
{
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
SK_Sketch *stk = contextSketch(C, 1);
|
||||
@@ -308,7 +307,7 @@ void BIF_freeTemplates(bContext *UNUSED(C))
|
||||
}
|
||||
|
||||
if (TEMPLATE_RIGG != NULL) {
|
||||
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
|
||||
RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
|
||||
TEMPLATE_RIGG = NULL;
|
||||
}
|
||||
}
|
||||
@@ -323,7 +322,7 @@ void BIF_setTemplate(bContext *C, int index)
|
||||
ts->skgen_template = NULL;
|
||||
|
||||
if (TEMPLATE_RIGG != NULL) {
|
||||
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
|
||||
RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG);
|
||||
}
|
||||
TEMPLATE_RIGG = NULL;
|
||||
}
|
||||
@@ -349,21 +348,21 @@ static void sk_autoname(bContext *C, ReebArc *arc)
|
||||
if (side[0] == '\0') {
|
||||
valid = 1;
|
||||
}
|
||||
else if (strcmp(side, "R")==0 || strcmp(side, "L")==0) {
|
||||
else if (strcmp(side, "R") == 0 || strcmp(side, "L") == 0) {
|
||||
valid = 1;
|
||||
caps = 1;
|
||||
}
|
||||
else if (strcmp(side, "r")==0 || strcmp(side, "l")==0) {
|
||||
else if (strcmp(side, "r") == 0 || strcmp(side, "l") == 0) {
|
||||
valid = 1;
|
||||
caps = 0;
|
||||
}
|
||||
|
||||
if (valid) {
|
||||
if (arc->head->p[0] < 0) {
|
||||
BLI_snprintf(side, 8, caps?"R":"r");
|
||||
BLI_snprintf(side, 8, caps ? "R" : "r");
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(side, 8, caps?"L":"l");
|
||||
BLI_snprintf(side, 8, caps ? "L" : "l");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -433,7 +432,7 @@ static void sk_retargetStroke(bContext *C, SK_Stroke *stk)
|
||||
|
||||
MEM_freeN(arc->head);
|
||||
MEM_freeN(arc->tail);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
@@ -473,7 +472,7 @@ static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float si
|
||||
|
||||
angle = angle_normalized_v3v3(vec2, vec1);
|
||||
|
||||
glRotatef(angle * (float)(180.0/M_PI) + 180.0f, axis[0], axis[1], axis[2]);
|
||||
glRotatef(angle * (float)(180.0 / M_PI) + 180.0f, axis[0], axis[1], axis[2]);
|
||||
|
||||
gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8);
|
||||
}
|
||||
@@ -493,7 +492,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig
|
||||
|
||||
angle = angle_normalized_v3v3(vec2, pt->no);
|
||||
|
||||
glRotatef(angle * (float)(180.0/M_PI), axis[0], axis[1], axis[2]);
|
||||
glRotatef(angle * (float)(180.0 / M_PI), axis[0], axis[1], axis[2]);
|
||||
|
||||
glColor3f(0, 1, 1);
|
||||
gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2);
|
||||
@@ -569,7 +568,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
|
||||
|
||||
static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion)
|
||||
{
|
||||
SK_Stroke *stk = ((SK_StrokeIterator*)iter)->stroke;
|
||||
SK_Stroke *stk = ((SK_StrokeIterator *)iter)->stroke;
|
||||
float head[3], tail[3];
|
||||
int bone_start = 0;
|
||||
int end = iter->length;
|
||||
@@ -622,7 +621,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
|
||||
else {
|
||||
if (i - head_index > 1) {
|
||||
SK_StrokeIterator sk_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&sk_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&sk_iter;
|
||||
|
||||
initStrokeIterator(iter, stk, head_index, i);
|
||||
|
||||
@@ -733,10 +732,10 @@ void sk_resetOverdraw(SK_Sketch *sketch)
|
||||
|
||||
int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk)
|
||||
{
|
||||
return sketch->over.target &&
|
||||
sketch->over.count >= SK_OVERDRAW_LIMIT &&
|
||||
(sketch->over.target == stk || stk == NULL) &&
|
||||
(sketch->over.start != -1 || sketch->over.end != -1);
|
||||
return sketch->over.target &&
|
||||
sketch->over.count >= SK_OVERDRAW_LIMIT &&
|
||||
(sketch->over.target == stk || stk == NULL) &&
|
||||
(sketch->over.start != -1 || sketch->over.end != -1);
|
||||
}
|
||||
|
||||
static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
|
||||
@@ -991,8 +990,8 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
|
||||
BLI_freelistN(&sketch->depth_peels);
|
||||
sketch->depth_peels.first = sketch->depth_peels.last = NULL;
|
||||
|
||||
mvalf[0]= dd->mval[0];
|
||||
mvalf[1]= dd->mval[1];
|
||||
mvalf[0] = dd->mval[0];
|
||||
mvalf[1] = dd->mval[1];
|
||||
peelObjectsContext(C, &sketch->depth_peels, mvalf, SNAP_ALL);
|
||||
|
||||
if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) {
|
||||
@@ -1195,12 +1194,12 @@ static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_S
|
||||
|
||||
/********************************************/
|
||||
|
||||
static void* headPoint(void *arg);
|
||||
static void* tailPoint(void *arg);
|
||||
static void* nextPoint(void *arg);
|
||||
static void* nextNPoint(void *arg, int n);
|
||||
static void* peekPoint(void *arg, int n);
|
||||
static void* previousPoint(void *arg);
|
||||
static void *headPoint(void *arg);
|
||||
static void *tailPoint(void *arg);
|
||||
static void *nextPoint(void *arg);
|
||||
static void *nextNPoint(void *arg, int n);
|
||||
static void *peekPoint(void *arg, int n);
|
||||
static void *previousPoint(void *arg);
|
||||
static int iteratorStopped(void *arg);
|
||||
|
||||
static void initIteratorFct(SK_StrokeIterator *iter)
|
||||
@@ -1214,7 +1213,7 @@ static void initIteratorFct(SK_StrokeIterator *iter)
|
||||
iter->stopped = iteratorStopped;
|
||||
}
|
||||
|
||||
static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index)
|
||||
static SK_Point *setIteratorValues(SK_StrokeIterator *iter, int index)
|
||||
{
|
||||
SK_Point *pt = NULL;
|
||||
|
||||
@@ -1235,7 +1234,7 @@ static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index)
|
||||
|
||||
void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
|
||||
initIteratorFct(iter);
|
||||
iter->stroke = stk;
|
||||
@@ -1257,9 +1256,9 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end)
|
||||
}
|
||||
|
||||
|
||||
static void* headPoint(void *arg)
|
||||
static void *headPoint(void *arg)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
|
||||
result = &(iter->stroke->points[iter->start - iter->stride]);
|
||||
@@ -1270,9 +1269,9 @@ static void* headPoint(void *arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* tailPoint(void *arg)
|
||||
static void *tailPoint(void *arg)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
|
||||
result = &(iter->stroke->points[iter->end + iter->stride]);
|
||||
@@ -1283,9 +1282,9 @@ static void* tailPoint(void *arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* nextPoint(void *arg)
|
||||
static void *nextPoint(void *arg)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
|
||||
iter->index++;
|
||||
@@ -1296,9 +1295,9 @@ static void* nextPoint(void *arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* nextNPoint(void *arg, int n)
|
||||
static void *nextNPoint(void *arg, int n)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
|
||||
iter->index += n;
|
||||
@@ -1311,9 +1310,9 @@ static void* nextNPoint(void *arg, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* peekPoint(void *arg, int n)
|
||||
static void *peekPoint(void *arg, int n)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
int index = iter->index + n;
|
||||
|
||||
@@ -1325,9 +1324,9 @@ static void* peekPoint(void *arg, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* previousPoint(void *arg)
|
||||
static void *previousPoint(void *arg)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
SK_Point *result = NULL;
|
||||
|
||||
if (iter->index > 0) {
|
||||
@@ -1340,7 +1339,7 @@ static void* previousPoint(void *arg)
|
||||
|
||||
static int iteratorStopped(void *arg)
|
||||
{
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
|
||||
SK_StrokeIterator *iter = (SK_StrokeIterator *)arg;
|
||||
|
||||
if (iter->index >= iter->length) {
|
||||
return 1;
|
||||
@@ -1383,7 +1382,7 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk)
|
||||
|
||||
if (i - head_index > 1) {
|
||||
SK_StrokeIterator sk_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&sk_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&sk_iter;
|
||||
|
||||
initStrokeIterator(iter, stk, head_index, i);
|
||||
|
||||
@@ -1410,12 +1409,12 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk)
|
||||
}
|
||||
|
||||
new_parent = bone;
|
||||
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
|
||||
/* move to end of chain */
|
||||
while (bone->parent != NULL) {
|
||||
bone = bone->parent;
|
||||
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
}
|
||||
|
||||
if (parent != NULL) {
|
||||
@@ -1594,7 +1593,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
|
||||
static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
|
||||
{
|
||||
SK_StrokeIterator sk_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&sk_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&sk_iter;
|
||||
|
||||
float CORRELATION_THRESHOLD = 0.99f;
|
||||
float *vec;
|
||||
@@ -1706,7 +1705,7 @@ int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
|
||||
SK_Intersection *isect, *self_isect;
|
||||
|
||||
/* get the the last intersection of the first pair */
|
||||
for ( isect = gest->intersections.first; isect; isect = isect->next ) {
|
||||
for (isect = gest->intersections.first; isect; isect = isect->next) {
|
||||
if (isect->stroke == isect->next->stroke) {
|
||||
isect = isect->next;
|
||||
break;
|
||||
@@ -1801,7 +1800,7 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc
|
||||
dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1]));
|
||||
|
||||
/* if gesture is a circle */
|
||||
if ( dist <= 20 ) {
|
||||
if (dist <= 20) {
|
||||
SK_Intersection *isect;
|
||||
|
||||
/* check if it circled around an exact point */
|
||||
@@ -1971,14 +1970,14 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in
|
||||
|
||||
view3d_set_viewcontext(C, &vc);
|
||||
|
||||
rect.xmin = mval[0]-5;
|
||||
rect.xmax = mval[0]+5;
|
||||
rect.ymin = mval[1]-5;
|
||||
rect.ymax = mval[1]+5;
|
||||
rect.xmin = mval[0] - 5;
|
||||
rect.xmax = mval[0] + 5;
|
||||
rect.ymin = mval[1] - 5;
|
||||
rect.ymax = mval[1] + 5;
|
||||
|
||||
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
|
||||
|
||||
if (hits>0) {
|
||||
if (hits > 0) {
|
||||
int besthitresult = -1;
|
||||
|
||||
if (hits == 1) {
|
||||
@@ -2027,7 +2026,7 @@ static void sk_queueRedrawSketch(SK_Sketch *sketch)
|
||||
|
||||
static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, int with_names)
|
||||
{
|
||||
ToolSettings *ts= scene->toolsettings;
|
||||
ToolSettings *ts = scene->toolsettings;
|
||||
SK_Stroke *stk;
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
@@ -2053,7 +2052,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
|
||||
sk_adjustIndexes(sketch, &start, &end);
|
||||
}
|
||||
|
||||
sk_drawStroke(stk, -1, (stk->selected==1?selected_rgb:unselected_rgb), start, end);
|
||||
sk_drawStroke(stk, -1, (stk->selected == 1 ? selected_rgb : unselected_rgb), start, end);
|
||||
|
||||
if (stk->selected == 1) {
|
||||
sk_drawStrokeSubdivision(ts, stk);
|
||||
@@ -2204,11 +2203,11 @@ static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra
|
||||
static int ValidSketchViewContext(ViewContext *vc)
|
||||
{
|
||||
Object *obedit = vc->obedit;
|
||||
Scene *scene= vc->scene;
|
||||
Scene *scene = vc->scene;
|
||||
|
||||
if (obedit &&
|
||||
obedit->type == OB_ARMATURE &&
|
||||
scene->toolsettings->bone_sketching & BONE_SKETCHING)
|
||||
obedit->type == OB_ARMATURE &&
|
||||
scene->toolsettings->bone_sketching & BONE_SKETCHING)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -2247,7 +2246,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev
|
||||
sk_deleteSelectedStrokes(sketch);
|
||||
// allqueue(REDRAWVIEW3D, 0);
|
||||
}
|
||||
WM_event_add_notifier(C, NC_SCREEN|ND_SKETCH|NA_REMOVED, NULL);
|
||||
WM_event_add_notifier(C, NC_SCREEN | ND_SKETCH | NA_REMOVED, NULL);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
@@ -2303,7 +2302,7 @@ void BIF_selectAllSketch(bContext *C, int mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
SK_Sketch* contextSketch(const bContext *C, int create)
|
||||
SK_Sketch *contextSketch(const bContext *C, int create)
|
||||
{
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
SK_Sketch *sketch = NULL;
|
||||
@@ -2320,7 +2319,7 @@ SK_Sketch* contextSketch(const bContext *C, int create)
|
||||
return sketch;
|
||||
}
|
||||
|
||||
SK_Sketch* viewcontextSketch(ViewContext *vc, int create)
|
||||
SK_Sketch *viewcontextSketch(ViewContext *vc, int create)
|
||||
{
|
||||
Object *obedit = vc->obedit;
|
||||
SK_Sketch *sketch = NULL;
|
||||
@@ -2442,51 +2441,51 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
|
||||
int retval = OPERATOR_RUNNING_MODAL;
|
||||
|
||||
switch (event->type) {
|
||||
case LEFTCTRLKEY:
|
||||
case RIGHTCTRLKEY:
|
||||
snap = event->ctrl;
|
||||
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);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
case ESCKEY:
|
||||
op->type->cancel(C, op);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
retval = OPERATOR_CANCELLED;
|
||||
break;
|
||||
case LEFTMOUSE:
|
||||
if (event->val == KM_RELEASE) {
|
||||
if (gesture == 0) {
|
||||
sk_endContinuousStroke(stk);
|
||||
sk_filterLastContinuousStroke(stk);
|
||||
sk_updateNextPoint(sketch, stk);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
MEM_freeN(op->customdata);
|
||||
retval = OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
sk_endContinuousStroke(stk);
|
||||
sk_filterLastContinuousStroke(stk);
|
||||
|
||||
if (stk->nb_points > 1) {
|
||||
/* apply gesture here */
|
||||
sk_applyGesture(C, sketch);
|
||||
case LEFTCTRLKEY:
|
||||
case RIGHTCTRLKEY:
|
||||
snap = event->ctrl;
|
||||
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);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
break;
|
||||
case ESCKEY:
|
||||
op->type->cancel(C, op);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
retval = OPERATOR_CANCELLED;
|
||||
break;
|
||||
case LEFTMOUSE:
|
||||
if (event->val == KM_RELEASE) {
|
||||
if (gesture == 0) {
|
||||
sk_endContinuousStroke(stk);
|
||||
sk_filterLastContinuousStroke(stk);
|
||||
sk_updateNextPoint(sketch, stk);
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
MEM_freeN(op->customdata);
|
||||
retval = OPERATOR_FINISHED;
|
||||
}
|
||||
else {
|
||||
sk_endContinuousStroke(stk);
|
||||
sk_filterLastContinuousStroke(stk);
|
||||
|
||||
sk_freeStroke(stk);
|
||||
sketch->gesture = NULL;
|
||||
if (stk->nb_points > 1) {
|
||||
/* apply gesture here */
|
||||
sk_applyGesture(C, sketch);
|
||||
}
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
MEM_freeN(op->customdata);
|
||||
retval = OPERATOR_FINISHED;
|
||||
sk_freeStroke(stk);
|
||||
sketch->gesture = NULL;
|
||||
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
MEM_freeN(op->customdata);
|
||||
retval = OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return retval;
|
||||
@@ -2517,7 +2516,7 @@ static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event)
|
||||
ED_area_tag_redraw(CTX_wm_area(C));
|
||||
}
|
||||
|
||||
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
|
||||
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
/* ============================================== Poll Functions ============================================= */
|
||||
@@ -2528,8 +2527,8 @@ int ED_operator_sketch_mode_active_stroke(bContext *C)
|
||||
SK_Sketch *sketch = contextSketch(C, 0);
|
||||
|
||||
if (ts->bone_sketching & BONE_SKETCHING &&
|
||||
sketch != NULL &&
|
||||
sketch->active_stroke != NULL)
|
||||
sketch != NULL &&
|
||||
sketch->active_stroke != NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -2544,9 +2543,9 @@ static int ED_operator_sketch_mode_gesture(bContext *C)
|
||||
SK_Sketch *sketch = contextSketch(C, 0);
|
||||
|
||||
if (ts->bone_sketching & BONE_SKETCHING &&
|
||||
(ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 &&
|
||||
sketch != NULL &&
|
||||
sketch->active_stroke == NULL)
|
||||
(ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 &&
|
||||
sketch != NULL &&
|
||||
sketch->active_stroke == NULL)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -2561,9 +2560,9 @@ int ED_operator_sketch_full_mode(bContext *C)
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
if (obedit &&
|
||||
obedit->type == OB_ARMATURE &&
|
||||
ts->bone_sketching & BONE_SKETCHING &&
|
||||
(ts->bone_sketching & BONE_SKETCHING_QUICK) == 0)
|
||||
obedit->type == OB_ARMATURE &&
|
||||
ts->bone_sketching & BONE_SKETCHING &&
|
||||
(ts->bone_sketching & BONE_SKETCHING_QUICK) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -2578,8 +2577,8 @@ int ED_operator_sketch_mode(const bContext *C)
|
||||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
|
||||
if (obedit &&
|
||||
obedit->type == OB_ARMATURE &&
|
||||
ts->bone_sketching & BONE_SKETCHING)
|
||||
obedit->type == OB_ARMATURE &&
|
||||
ts->bone_sketching & BONE_SKETCHING)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -80,40 +80,40 @@ static void error(const char *str) { printf("error: %s\n", str); }
|
||||
/************************** Laplacian System *****************************/
|
||||
|
||||
struct LaplacianSystem {
|
||||
NLContext context; /* opennl context */
|
||||
NLContext context; /* opennl context */
|
||||
|
||||
int totvert, totface;
|
||||
|
||||
float **verts; /* vertex coordinates */
|
||||
float *varea; /* vertex weights for laplacian computation */
|
||||
char *vpinned; /* vertex pinning */
|
||||
int (*faces)[3]; /* face vertex indices */
|
||||
float (*fweights)[3]; /* cotangent weights per face */
|
||||
float **verts; /* vertex coordinates */
|
||||
float *varea; /* vertex weights for laplacian computation */
|
||||
char *vpinned; /* vertex pinning */
|
||||
int (*faces)[3]; /* face vertex indices */
|
||||
float (*fweights)[3]; /* cotangent weights per face */
|
||||
|
||||
int areaweights; /* use area in cotangent weights? */
|
||||
int storeweights; /* store cotangent weights in fweights */
|
||||
int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */
|
||||
int areaweights; /* use area in cotangent weights? */
|
||||
int storeweights; /* store cotangent weights in fweights */
|
||||
int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */
|
||||
|
||||
EdgeHash *edgehash; /* edge hash for construction */
|
||||
EdgeHash *edgehash; /* edge hash for construction */
|
||||
|
||||
struct HeatWeighting {
|
||||
MFace *mface;
|
||||
int totvert;
|
||||
int totface;
|
||||
float (*verts)[3]; /* vertex coordinates */
|
||||
float (*vnors)[3]; /* vertex normals */
|
||||
float (*verts)[3]; /* vertex coordinates */
|
||||
float (*vnors)[3]; /* vertex normals */
|
||||
|
||||
float (*root)[3]; /* bone root */
|
||||
float (*tip)[3]; /* bone tip */
|
||||
float (*root)[3]; /* bone root */
|
||||
float (*tip)[3]; /* bone tip */
|
||||
float (*source)[3]; /* vertex source */
|
||||
int numsource;
|
||||
|
||||
float *H; /* diagonal H matrix */
|
||||
float *p; /* values from all p vectors */
|
||||
float *mindist; /* minimum distance to a bone for all vertices */
|
||||
float *H; /* diagonal H matrix */
|
||||
float *p; /* values from all p vectors */
|
||||
float *mindist; /* minimum distance to a bone for all vertices */
|
||||
|
||||
BVHTree *bvhtree; /* ray tracing acceleration structure */
|
||||
MFace **vface; /* a face that the vertex belongs to */
|
||||
BVHTree *bvhtree; /* ray tracing acceleration structure */
|
||||
MFace **vface; /* a face that the vertex belongs to */
|
||||
} heat;
|
||||
|
||||
#ifdef RIGID_DEFORM
|
||||
@@ -143,9 +143,9 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2)
|
||||
void **p = BLI_edgehash_lookup_p(edgehash, v1, v2);
|
||||
|
||||
if (p)
|
||||
*p = (void*)((intptr_t)*p + (intptr_t)1);
|
||||
*p = (void *)((intptr_t)*p + (intptr_t)1);
|
||||
else
|
||||
BLI_edgehash_insert(edgehash, v1, v2, (void*)(intptr_t)1);
|
||||
BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1);
|
||||
}
|
||||
|
||||
static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2)
|
||||
@@ -166,81 +166,81 @@ static float cotan_weight(float *v1, float *v2, float *v3)
|
||||
if (clen == 0.0f)
|
||||
return 0.0f;
|
||||
|
||||
return dot_v3v3(a, b)/clen;
|
||||
return dot_v3v3(a, b) / clen;
|
||||
}
|
||||
|
||||
static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3)
|
||||
{
|
||||
float t1, t2, t3, len1, len2, len3, area;
|
||||
float *varea= sys->varea, *v1, *v2, *v3;
|
||||
float *varea = sys->varea, *v1, *v2, *v3;
|
||||
int obtuse = 0;
|
||||
|
||||
v1= sys->verts[i1];
|
||||
v2= sys->verts[i2];
|
||||
v3= sys->verts[i3];
|
||||
v1 = sys->verts[i1];
|
||||
v2 = sys->verts[i2];
|
||||
v3 = sys->verts[i3];
|
||||
|
||||
t1= cotan_weight(v1, v2, v3);
|
||||
t2= cotan_weight(v2, v3, v1);
|
||||
t3= cotan_weight(v3, v1, v2);
|
||||
t1 = cotan_weight(v1, v2, v3);
|
||||
t2 = cotan_weight(v2, v3, v1);
|
||||
t3 = cotan_weight(v3, v1, v2);
|
||||
|
||||
if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse= 1;
|
||||
else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2;
|
||||
else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3;
|
||||
if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse = 1;
|
||||
else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse = 2;
|
||||
else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse = 3;
|
||||
|
||||
if (obtuse > 0) {
|
||||
area= area_tri_v3(v1, v2, v3);
|
||||
area = area_tri_v3(v1, v2, v3);
|
||||
|
||||
varea[i1] += (obtuse == 1)? area: area*0.5f;
|
||||
varea[i2] += (obtuse == 2)? area: area*0.5f;
|
||||
varea[i3] += (obtuse == 3)? area: area*0.5f;
|
||||
varea[i1] += (obtuse == 1) ? area : area * 0.5f;
|
||||
varea[i2] += (obtuse == 2) ? area : area * 0.5f;
|
||||
varea[i3] += (obtuse == 3) ? area : area * 0.5f;
|
||||
}
|
||||
else {
|
||||
len1= len_v3v3(v2, v3);
|
||||
len2= len_v3v3(v1, v3);
|
||||
len3= len_v3v3(v1, v2);
|
||||
len1 = len_v3v3(v2, v3);
|
||||
len2 = len_v3v3(v1, v3);
|
||||
len3 = len_v3v3(v1, v2);
|
||||
|
||||
t1 *= len1*len1;
|
||||
t2 *= len2*len2;
|
||||
t3 *= len3*len3;
|
||||
t1 *= len1 * len1;
|
||||
t2 *= len2 * len2;
|
||||
t3 *= len3 * len3;
|
||||
|
||||
varea[i1] += (t2 + t3)*0.25f;
|
||||
varea[i2] += (t1 + t3)*0.25f;
|
||||
varea[i3] += (t1 + t2)*0.25f;
|
||||
varea[i1] += (t2 + t3) * 0.25f;
|
||||
varea[i2] += (t1 + t3) * 0.25f;
|
||||
varea[i3] += (t1 + t2) * 0.25f;
|
||||
}
|
||||
}
|
||||
|
||||
static void laplacian_triangle_weights(LaplacianSystem *sys, int f, int i1, int i2, int i3)
|
||||
{
|
||||
float t1, t2, t3;
|
||||
float *varea= sys->varea, *v1, *v2, *v3;
|
||||
float *varea = sys->varea, *v1, *v2, *v3;
|
||||
|
||||
v1= sys->verts[i1];
|
||||
v2= sys->verts[i2];
|
||||
v3= sys->verts[i3];
|
||||
v1 = sys->verts[i1];
|
||||
v2 = sys->verts[i2];
|
||||
v3 = sys->verts[i3];
|
||||
|
||||
/* instead of *0.5 we divided by the number of faces of the edge, it still
|
||||
* needs to be verified that this is indeed the correct thing to do! */
|
||||
t1= cotan_weight(v1, v2, v3)/laplacian_edge_count(sys->edgehash, i2, i3);
|
||||
t2= cotan_weight(v2, v3, v1)/laplacian_edge_count(sys->edgehash, i3, i1);
|
||||
t3= cotan_weight(v3, v1, v2)/laplacian_edge_count(sys->edgehash, i1, i2);
|
||||
t1 = cotan_weight(v1, v2, v3) / laplacian_edge_count(sys->edgehash, i2, i3);
|
||||
t2 = cotan_weight(v2, v3, v1) / laplacian_edge_count(sys->edgehash, i3, i1);
|
||||
t3 = cotan_weight(v3, v1, v2) / laplacian_edge_count(sys->edgehash, i1, i2);
|
||||
|
||||
nlMatrixAdd(i1, i1, (t2+t3)*varea[i1]);
|
||||
nlMatrixAdd(i2, i2, (t1+t3)*varea[i2]);
|
||||
nlMatrixAdd(i3, i3, (t1+t2)*varea[i3]);
|
||||
nlMatrixAdd(i1, i1, (t2 + t3) * varea[i1]);
|
||||
nlMatrixAdd(i2, i2, (t1 + t3) * varea[i2]);
|
||||
nlMatrixAdd(i3, i3, (t1 + t2) * varea[i3]);
|
||||
|
||||
nlMatrixAdd(i1, i2, -t3*varea[i1]);
|
||||
nlMatrixAdd(i2, i1, -t3*varea[i2]);
|
||||
nlMatrixAdd(i1, i2, -t3 * varea[i1]);
|
||||
nlMatrixAdd(i2, i1, -t3 * varea[i2]);
|
||||
|
||||
nlMatrixAdd(i2, i3, -t1*varea[i2]);
|
||||
nlMatrixAdd(i3, i2, -t1*varea[i3]);
|
||||
nlMatrixAdd(i2, i3, -t1 * varea[i2]);
|
||||
nlMatrixAdd(i3, i2, -t1 * varea[i3]);
|
||||
|
||||
nlMatrixAdd(i3, i1, -t2*varea[i3]);
|
||||
nlMatrixAdd(i1, i3, -t2*varea[i1]);
|
||||
nlMatrixAdd(i3, i1, -t2 * varea[i3]);
|
||||
nlMatrixAdd(i1, i3, -t2 * varea[i1]);
|
||||
|
||||
if (sys->storeweights) {
|
||||
sys->fweights[f][0]= t1*varea[i1];
|
||||
sys->fweights[f][1]= t2*varea[i2];
|
||||
sys->fweights[f][2]= t3*varea[i3];
|
||||
sys->fweights[f][0] = t1 * varea[i1];
|
||||
sys->fweights[f][1] = t2 * varea[i2];
|
||||
sys->fweights[f][2] = t3 * varea[i3];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,17 +248,17 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac
|
||||
{
|
||||
LaplacianSystem *sys;
|
||||
|
||||
sys= MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem");
|
||||
sys = MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem");
|
||||
|
||||
sys->verts= MEM_callocN(sizeof(float*)*totvert, "LaplacianSystemVerts");
|
||||
sys->vpinned= MEM_callocN(sizeof(char)*totvert, "LaplacianSystemVpinned");
|
||||
sys->faces= MEM_callocN(sizeof(int)*3*totface, "LaplacianSystemFaces");
|
||||
sys->verts = MEM_callocN(sizeof(float *) * totvert, "LaplacianSystemVerts");
|
||||
sys->vpinned = MEM_callocN(sizeof(char) * totvert, "LaplacianSystemVpinned");
|
||||
sys->faces = MEM_callocN(sizeof(int) * 3 * totface, "LaplacianSystemFaces");
|
||||
|
||||
sys->totvert= 0;
|
||||
sys->totface= 0;
|
||||
sys->totvert = 0;
|
||||
sys->totface = 0;
|
||||
|
||||
sys->areaweights= 1;
|
||||
sys->storeweights= 0;
|
||||
sys->areaweights = 1;
|
||||
sys->storeweights = 0;
|
||||
|
||||
/* create opennl context */
|
||||
nlNewContext();
|
||||
@@ -266,53 +266,53 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac
|
||||
if (lsq)
|
||||
nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
|
||||
|
||||
sys->context= nlGetCurrent();
|
||||
sys->context = nlGetCurrent();
|
||||
|
||||
return sys;
|
||||
}
|
||||
|
||||
void laplacian_add_vertex(LaplacianSystem *sys, float *co, int pinned)
|
||||
{
|
||||
sys->verts[sys->totvert]= co;
|
||||
sys->vpinned[sys->totvert]= pinned;
|
||||
sys->verts[sys->totvert] = co;
|
||||
sys->vpinned[sys->totvert] = pinned;
|
||||
sys->totvert++;
|
||||
}
|
||||
|
||||
void laplacian_add_triangle(LaplacianSystem *sys, int v1, int v2, int v3)
|
||||
{
|
||||
sys->faces[sys->totface][0]= v1;
|
||||
sys->faces[sys->totface][1]= v2;
|
||||
sys->faces[sys->totface][2]= v3;
|
||||
sys->faces[sys->totface][0] = v1;
|
||||
sys->faces[sys->totface][1] = v2;
|
||||
sys->faces[sys->totface][2] = v3;
|
||||
sys->totface++;
|
||||
}
|
||||
|
||||
static void laplacian_system_construct_end(LaplacianSystem *sys)
|
||||
{
|
||||
int (*face)[3];
|
||||
int a, totvert=sys->totvert, totface=sys->totface;
|
||||
int a, totvert = sys->totvert, totface = sys->totface;
|
||||
|
||||
laplacian_begin_solve(sys, 0);
|
||||
|
||||
sys->varea= MEM_callocN(sizeof(float)*totvert, "LaplacianSystemVarea");
|
||||
sys->varea = MEM_callocN(sizeof(float) * totvert, "LaplacianSystemVarea");
|
||||
|
||||
sys->edgehash= BLI_edgehash_new();
|
||||
for (a=0, face=sys->faces; a<sys->totface; a++, face++) {
|
||||
sys->edgehash = BLI_edgehash_new();
|
||||
for (a = 0, face = sys->faces; a < sys->totface; a++, face++) {
|
||||
laplacian_increase_edge_count(sys->edgehash, (*face)[0], (*face)[1]);
|
||||
laplacian_increase_edge_count(sys->edgehash, (*face)[1], (*face)[2]);
|
||||
laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]);
|
||||
}
|
||||
|
||||
if (sys->areaweights)
|
||||
for (a=0, face=sys->faces; a<sys->totface; a++, face++)
|
||||
for (a = 0, face = sys->faces; a < sys->totface; a++, face++)
|
||||
laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]);
|
||||
|
||||
for (a=0; a<totvert; a++) {
|
||||
for (a = 0; a < totvert; a++) {
|
||||
if (sys->areaweights) {
|
||||
if (sys->varea[a] != 0.0f)
|
||||
sys->varea[a]= 0.5f/sys->varea[a];
|
||||
sys->varea[a] = 0.5f / sys->varea[a];
|
||||
}
|
||||
else
|
||||
sys->varea[a]= 1.0f;
|
||||
sys->varea[a] = 1.0f;
|
||||
|
||||
/* for heat weighting */
|
||||
if (sys->heat.H)
|
||||
@@ -320,21 +320,21 @@ static void laplacian_system_construct_end(LaplacianSystem *sys)
|
||||
}
|
||||
|
||||
if (sys->storeweights)
|
||||
sys->fweights= MEM_callocN(sizeof(float)*3*totface, "LaplacianFWeight");
|
||||
sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight");
|
||||
|
||||
for (a=0, face=sys->faces; a<totface; a++, face++)
|
||||
for (a = 0, face = sys->faces; a < totface; a++, face++)
|
||||
laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]);
|
||||
|
||||
MEM_freeN(sys->faces);
|
||||
sys->faces= NULL;
|
||||
sys->faces = NULL;
|
||||
|
||||
if (sys->varea) {
|
||||
MEM_freeN(sys->varea);
|
||||
sys->varea= NULL;
|
||||
sys->varea = NULL;
|
||||
}
|
||||
|
||||
BLI_edgehash_free(sys->edgehash, NULL);
|
||||
sys->edgehash= NULL;
|
||||
sys->edgehash = NULL;
|
||||
}
|
||||
|
||||
static void laplacian_system_delete(LaplacianSystem *sys)
|
||||
@@ -357,7 +357,7 @@ void laplacian_begin_solve(LaplacianSystem *sys, int index)
|
||||
nlBegin(NL_SYSTEM);
|
||||
|
||||
if (index >= 0) {
|
||||
for (a=0; a<sys->totvert; a++) {
|
||||
for (a = 0; a < sys->totvert; a++) {
|
||||
if (sys->vpinned[a]) {
|
||||
nlSetVariable(0, a, sys->verts[a][index]);
|
||||
nlLockVariable(a);
|
||||
@@ -395,10 +395,10 @@ float laplacian_system_get_solution(int v)
|
||||
/* From "Automatic Rigging and Animation of 3D Characters"
|
||||
* Ilya Baran and Jovan Popovic, SIGGRAPH 2007 */
|
||||
|
||||
#define C_WEIGHT 1.0f
|
||||
#define WEIGHT_LIMIT_START 0.05f
|
||||
#define WEIGHT_LIMIT_END 0.025f
|
||||
#define DISTANCE_EPSILON 1e-4f
|
||||
#define C_WEIGHT 1.0f
|
||||
#define WEIGHT_LIMIT_START 0.05f
|
||||
#define WEIGHT_LIMIT_END 0.025f
|
||||
#define DISTANCE_EPSILON 1e-4f
|
||||
|
||||
typedef struct BVHCallbackUserData {
|
||||
float start[3];
|
||||
@@ -408,7 +408,7 @@ typedef struct BVHCallbackUserData {
|
||||
|
||||
static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit)
|
||||
{
|
||||
BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata;
|
||||
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];
|
||||
@@ -444,27 +444,27 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
|
||||
int a;
|
||||
|
||||
sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6);
|
||||
sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces");
|
||||
sys->heat.vface = MEM_callocN(sizeof(MFace *) * totvert, "HeatVFaces");
|
||||
|
||||
for (a=0; a<totface; a++) {
|
||||
MFace *mf = mface+a;
|
||||
for (a = 0; a < totface; a++) {
|
||||
MFace *mf = mface + a;
|
||||
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);
|
||||
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);
|
||||
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;
|
||||
sys->heat.vface[mf->v2]= mf;
|
||||
sys->heat.vface[mf->v3]= mf;
|
||||
if (mf->v4) sys->heat.vface[mf->v4]= mf;
|
||||
sys->heat.vface[mf->v1] = mf;
|
||||
sys->heat.vface[mf->v2] = mf;
|
||||
sys->heat.vface[mf->v3] = mf;
|
||||
if (mf->v4) sys->heat.vface[mf->v4] = mf;
|
||||
}
|
||||
|
||||
BLI_bvhtree_balance(sys->heat.bvhtree);
|
||||
@@ -478,16 +478,16 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
|
||||
float end[3];
|
||||
int visible;
|
||||
|
||||
mface= sys->heat.vface[vertex];
|
||||
mface = sys->heat.vface[vertex];
|
||||
if (!mface)
|
||||
return 1;
|
||||
|
||||
data.sys= sys;
|
||||
data.sys = sys;
|
||||
copy_v3_v3(data.start, sys->heat.verts[vertex]);
|
||||
|
||||
if (sys->heat.root) /* bone */
|
||||
closest_to_line_segment_v3(end, data.start,
|
||||
sys->heat.root[source], sys->heat.tip[source]);
|
||||
sys->heat.root[source], sys->heat.tip[source]);
|
||||
else /* vertex */
|
||||
copy_v3_v3(end, sys->heat.source[source]);
|
||||
|
||||
@@ -499,7 +499,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source)
|
||||
hit.index = -1;
|
||||
hit.dist = normalize_v3(data.vec);
|
||||
|
||||
visible= BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void*)&data) == -1;
|
||||
visible = BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void *)&data) == -1;
|
||||
|
||||
return visible;
|
||||
}
|
||||
@@ -511,26 +511,26 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source)
|
||||
/* compute euclidian distance */
|
||||
if (sys->heat.root) /* bone */
|
||||
closest_to_line_segment_v3(closest, sys->heat.verts[vertex],
|
||||
sys->heat.root[source], sys->heat.tip[source]);
|
||||
sys->heat.root[source], sys->heat.tip[source]);
|
||||
else /* vertex */
|
||||
copy_v3_v3(closest, sys->heat.source[source]);
|
||||
|
||||
sub_v3_v3v3(d, sys->heat.verts[vertex], closest);
|
||||
dist= normalize_v3(d);
|
||||
dist = normalize_v3(d);
|
||||
|
||||
/* if the vertex normal does not point along the bone, increase distance */
|
||||
cosine= dot_v3v3(d, sys->heat.vnors[vertex]);
|
||||
cosine = dot_v3v3(d, sys->heat.vnors[vertex]);
|
||||
|
||||
return dist/(0.5f*(cosine + 1.001f));
|
||||
return dist / (0.5f * (cosine + 1.001f));
|
||||
}
|
||||
|
||||
static int heat_source_closest(LaplacianSystem *sys, int vertex, int source)
|
||||
{
|
||||
float dist;
|
||||
|
||||
dist= heat_source_distance(sys, vertex, source);
|
||||
dist = heat_source_distance(sys, vertex, source);
|
||||
|
||||
if (dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON))
|
||||
if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON))
|
||||
if (heat_ray_source_visible(sys, vertex, source))
|
||||
return 1;
|
||||
|
||||
@@ -542,34 +542,34 @@ static void heat_set_H(LaplacianSystem *sys, int vertex)
|
||||
float dist, mindist, h;
|
||||
int j, numclosest = 0;
|
||||
|
||||
mindist= 1e10;
|
||||
mindist = 1e10;
|
||||
|
||||
/* compute minimum distance */
|
||||
for (j=0; j<sys->heat.numsource; j++) {
|
||||
dist= heat_source_distance(sys, vertex, j);
|
||||
for (j = 0; j < sys->heat.numsource; j++) {
|
||||
dist = heat_source_distance(sys, vertex, j);
|
||||
|
||||
if (dist < mindist)
|
||||
mindist= dist;
|
||||
mindist = dist;
|
||||
}
|
||||
|
||||
sys->heat.mindist[vertex]= mindist;
|
||||
sys->heat.mindist[vertex] = mindist;
|
||||
|
||||
/* count number of sources with approximately this minimum distance */
|
||||
for (j=0; j<sys->heat.numsource; j++)
|
||||
for (j = 0; j < sys->heat.numsource; j++)
|
||||
if (heat_source_closest(sys, vertex, j))
|
||||
numclosest++;
|
||||
|
||||
sys->heat.p[vertex]= (numclosest > 0)? 1.0f/numclosest: 0.0f;
|
||||
sys->heat.p[vertex] = (numclosest > 0) ? 1.0f / numclosest : 0.0f;
|
||||
|
||||
/* compute H entry */
|
||||
if (numclosest > 0) {
|
||||
mindist= maxf(mindist, 1e-4f);
|
||||
h= numclosest*C_WEIGHT/(mindist*mindist);
|
||||
mindist = maxf(mindist, 1e-4f);
|
||||
h = numclosest * C_WEIGHT / (mindist * mindist);
|
||||
}
|
||||
else
|
||||
h= 0.0f;
|
||||
h = 0.0f;
|
||||
|
||||
sys->heat.H[vertex]= h;
|
||||
sys->heat.H[vertex] = h;
|
||||
}
|
||||
|
||||
static void heat_calc_vnormals(LaplacianSystem *sys)
|
||||
@@ -577,12 +577,12 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
|
||||
float fnor[3];
|
||||
int a, v1, v2, v3, (*face)[3];
|
||||
|
||||
sys->heat.vnors= MEM_callocN(sizeof(float)*3*sys->totvert, "HeatVNors");
|
||||
sys->heat.vnors = MEM_callocN(sizeof(float) * 3 * sys->totvert, "HeatVNors");
|
||||
|
||||
for (a=0, face=sys->faces; a<sys->totface; a++, face++) {
|
||||
v1= (*face)[0];
|
||||
v2= (*face)[1];
|
||||
v3= (*face)[2];
|
||||
for (a = 0, face = sys->faces; a < sys->totface; a++, face++) {
|
||||
v1 = (*face)[0];
|
||||
v2 = (*face)[1];
|
||||
v3 = (*face)[2];
|
||||
|
||||
normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]);
|
||||
|
||||
@@ -591,27 +591,27 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
|
||||
add_v3_v3(sys->heat.vnors[v3], fnor);
|
||||
}
|
||||
|
||||
for (a=0; a<sys->totvert; a++)
|
||||
for (a = 0; a < sys->totvert; a++)
|
||||
normalize_v3(sys->heat.vnors[a]);
|
||||
}
|
||||
|
||||
static void heat_laplacian_create(LaplacianSystem *sys)
|
||||
{
|
||||
MFace *mface = sys->heat.mface, *mf;
|
||||
int totface= sys->heat.totface;
|
||||
int totvert= sys->heat.totvert;
|
||||
int totface = sys->heat.totface;
|
||||
int totvert = sys->heat.totvert;
|
||||
int a;
|
||||
|
||||
/* heat specific definitions */
|
||||
sys->heat.mindist= MEM_callocN(sizeof(float)*totvert, "HeatMinDist");
|
||||
sys->heat.H= MEM_callocN(sizeof(float)*totvert, "HeatH");
|
||||
sys->heat.p= MEM_callocN(sizeof(float)*totvert, "HeatP");
|
||||
sys->heat.mindist = MEM_callocN(sizeof(float) * totvert, "HeatMinDist");
|
||||
sys->heat.H = MEM_callocN(sizeof(float) * totvert, "HeatH");
|
||||
sys->heat.p = MEM_callocN(sizeof(float) * totvert, "HeatP");
|
||||
|
||||
/* add verts and faces to laplacian */
|
||||
for (a=0; a<totvert; a++)
|
||||
for (a = 0; a < totvert; a++)
|
||||
laplacian_add_vertex(sys, sys->heat.verts[a], 0);
|
||||
|
||||
for (a=0, mf=mface; a<totface; a++, mf++) {
|
||||
for (a = 0, mf = mface; a < totface; a++, mf++) {
|
||||
laplacian_add_triangle(sys, mf->v1, mf->v2, mf->v3);
|
||||
if (mf->v4)
|
||||
laplacian_add_triangle(sys, mf->v1, mf->v3, mf->v4);
|
||||
@@ -620,7 +620,7 @@ static void heat_laplacian_create(LaplacianSystem *sys)
|
||||
/* for distance computation in set_H */
|
||||
heat_calc_vnormals(sys);
|
||||
|
||||
for (a=0; a<totvert; a++)
|
||||
for (a = 0; a < totvert; a++)
|
||||
heat_set_H(sys, a);
|
||||
}
|
||||
|
||||
@@ -643,8 +643,8 @@ static float heat_limit_weight(float weight)
|
||||
return 0.0f;
|
||||
}
|
||||
else if (weight < WEIGHT_LIMIT_START) {
|
||||
t= (weight - WEIGHT_LIMIT_END)/(WEIGHT_LIMIT_START - WEIGHT_LIMIT_END);
|
||||
return t*WEIGHT_LIMIT_START;
|
||||
t = (weight - WEIGHT_LIMIT_END) / (WEIGHT_LIMIT_START - WEIGHT_LIMIT_END);
|
||||
return t * WEIGHT_LIMIT_START;
|
||||
}
|
||||
else
|
||||
return weight;
|
||||
@@ -657,23 +657,23 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
MLoop *ml;
|
||||
MFace *mf;
|
||||
float solution, weight;
|
||||
int *vertsflipped = NULL, *mask= NULL;
|
||||
int *vertsflipped = NULL, *mask = NULL;
|
||||
int a, tottri, j, bbone, firstsegment, lastsegment;
|
||||
|
||||
MVert *mvert = me->mvert;
|
||||
int use_vert_sel= FALSE;
|
||||
int use_face_sel= FALSE;
|
||||
int use_vert_sel = FALSE;
|
||||
int use_face_sel = FALSE;
|
||||
|
||||
*err_str= NULL;
|
||||
*err_str = NULL;
|
||||
|
||||
/* count triangles and create mask */
|
||||
if ( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
|
||||
(use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
|
||||
if ( (use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
|
||||
(use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
|
||||
{
|
||||
mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask");
|
||||
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");
|
||||
}
|
||||
|
||||
for (a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) {
|
||||
for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) {
|
||||
/* (added selectedVerts content for vertex mask, they used to just equal 1) */
|
||||
if (use_vert_sel) {
|
||||
for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) {
|
||||
@@ -702,13 +702,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
/* create laplacian */
|
||||
sys = laplacian_system_construct_begin(me->totvert, tottri, 1);
|
||||
|
||||
sys->heat.mface= me->mface;
|
||||
sys->heat.totface= me->totface;
|
||||
sys->heat.totvert= me->totvert;
|
||||
sys->heat.verts= verts;
|
||||
sys->heat.root= root;
|
||||
sys->heat.tip= tip;
|
||||
sys->heat.numsource= numsource;
|
||||
sys->heat.mface = me->mface;
|
||||
sys->heat.totface = me->totface;
|
||||
sys->heat.totvert = me->totvert;
|
||||
sys->heat.verts = verts;
|
||||
sys->heat.root = root;
|
||||
sys->heat.tip = tip;
|
||||
sys->heat.numsource = numsource;
|
||||
|
||||
heat_ray_tree_create(sys);
|
||||
heat_laplacian_create(sys);
|
||||
@@ -716,23 +716,23 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
laplacian_system_construct_end(sys);
|
||||
|
||||
if (dgroupflip) {
|
||||
vertsflipped = MEM_callocN(sizeof(int)*me->totvert, "vertsflipped");
|
||||
for (a=0; a<me->totvert; a++)
|
||||
vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped");
|
||||
for (a = 0; a < me->totvert; a++)
|
||||
vertsflipped[a] = mesh_get_x_mirror_vert(ob, a);
|
||||
}
|
||||
|
||||
/* compute weights per bone */
|
||||
for (j=0; j<numsource; j++) {
|
||||
for (j = 0; j < numsource; j++) {
|
||||
if (!selected[j])
|
||||
continue;
|
||||
|
||||
firstsegment= (j == 0 || dgrouplist[j-1] != dgrouplist[j]);
|
||||
lastsegment= (j == numsource-1 || dgrouplist[j] != dgrouplist[j+1]);
|
||||
bbone= !(firstsegment && lastsegment);
|
||||
firstsegment = (j == 0 || dgrouplist[j - 1] != dgrouplist[j]);
|
||||
lastsegment = (j == numsource - 1 || dgrouplist[j] != dgrouplist[j + 1]);
|
||||
bbone = !(firstsegment && lastsegment);
|
||||
|
||||
/* clear weights */
|
||||
if (bbone && firstsegment) {
|
||||
for (a=0; a<me->totvert; a++) {
|
||||
for (a = 0; a < me->totvert; a++) {
|
||||
if (mask && !mask[a])
|
||||
continue;
|
||||
|
||||
@@ -745,30 +745,30 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
/* fill right hand side */
|
||||
laplacian_begin_solve(sys, -1);
|
||||
|
||||
for (a=0; a<me->totvert; a++)
|
||||
for (a = 0; a < me->totvert; a++)
|
||||
if (heat_source_closest(sys, a, j))
|
||||
laplacian_add_right_hand_side(sys, a,
|
||||
sys->heat.H[a]*sys->heat.p[a]);
|
||||
sys->heat.H[a] * sys->heat.p[a]);
|
||||
|
||||
/* solve */
|
||||
if (laplacian_system_solve(sys)) {
|
||||
/* load solution into vertex groups */
|
||||
for (a=0; a<me->totvert; a++) {
|
||||
for (a = 0; a < me->totvert; a++) {
|
||||
if (mask && !mask[a])
|
||||
continue;
|
||||
|
||||
solution= laplacian_system_get_solution(a);
|
||||
solution = laplacian_system_get_solution(a);
|
||||
|
||||
if (bbone) {
|
||||
if (solution > 0.0f)
|
||||
ED_vgroup_vert_add(ob, dgrouplist[j], a, solution,
|
||||
WEIGHT_ADD);
|
||||
WEIGHT_ADD);
|
||||
}
|
||||
else {
|
||||
weight= heat_limit_weight(solution);
|
||||
weight = heat_limit_weight(solution);
|
||||
if (weight > 0.0f)
|
||||
ED_vgroup_vert_add(ob, dgrouplist[j], a, weight,
|
||||
WEIGHT_REPLACE);
|
||||
WEIGHT_REPLACE);
|
||||
else
|
||||
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
|
||||
}
|
||||
@@ -778,13 +778,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
if (bbone) {
|
||||
if (solution > 0.0f)
|
||||
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a],
|
||||
solution, WEIGHT_ADD);
|
||||
solution, WEIGHT_ADD);
|
||||
}
|
||||
else {
|
||||
weight= heat_limit_weight(solution);
|
||||
weight = heat_limit_weight(solution);
|
||||
if (weight > 0.0f)
|
||||
ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a],
|
||||
weight, WEIGHT_REPLACE);
|
||||
weight, WEIGHT_REPLACE);
|
||||
else
|
||||
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
|
||||
}
|
||||
@@ -792,24 +792,24 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
|
||||
}
|
||||
}
|
||||
else if (*err_str == NULL) {
|
||||
*err_str= "Bone Heat Weighting: failed to find solution for one or more bones";
|
||||
*err_str = "Bone Heat Weighting: failed to find solution for one or more bones";
|
||||
break;
|
||||
}
|
||||
|
||||
/* remove too small vertex weights */
|
||||
if (bbone && lastsegment) {
|
||||
for (a=0; a<me->totvert; a++) {
|
||||
for (a = 0; a < me->totvert; a++) {
|
||||
if (mask && !mask[a])
|
||||
continue;
|
||||
|
||||
weight= ED_vgroup_vert_weight(ob, dgrouplist[j], a);
|
||||
weight= heat_limit_weight(weight);
|
||||
weight = ED_vgroup_vert_weight(ob, dgrouplist[j], a);
|
||||
weight = heat_limit_weight(weight);
|
||||
if (weight <= 0.0f)
|
||||
ED_vgroup_vert_remove(ob, dgrouplist[j], a);
|
||||
|
||||
if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) {
|
||||
weight= ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]);
|
||||
weight= heat_limit_weight(weight);
|
||||
weight = ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]);
|
||||
weight = heat_limit_weight(weight);
|
||||
if (weight <= 0.0f)
|
||||
ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]);
|
||||
}
|
||||
@@ -848,10 +848,10 @@ static void rigid_add_half_edge_to_R(LaplacianSystem *sys, EditVert *v1, EditVer
|
||||
sub_v3_v3v3(e_, v1->co, v2->co);
|
||||
|
||||
/* formula (5) */
|
||||
for (i=0; i<3; i++) {
|
||||
sys->rigid.R[v1->tmp.l][i][0] += w*e[0]*e_[i];
|
||||
sys->rigid.R[v1->tmp.l][i][1] += w*e[1]*e_[i];
|
||||
sys->rigid.R[v1->tmp.l][i][2] += w*e[2]*e_[i];
|
||||
for (i = 0; i < 3; i++) {
|
||||
sys->rigid.R[v1->tmp.l][i][0] += w * e[0] * e_[i];
|
||||
sys->rigid.R[v1->tmp.l][i][1] += w * e[1] * e_[i];
|
||||
sys->rigid.R[v1->tmp.l][i][2] += w * e[2] * e_[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,7 +897,7 @@ static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert *
|
||||
|
||||
void rigid_deform_iteration()
|
||||
{
|
||||
LaplacianSystem *sys= RigidDeformSystem;
|
||||
LaplacianSystem *sys = RigidDeformSystem;
|
||||
EditMesh *em;
|
||||
EditVert *eve;
|
||||
EditFace *efa;
|
||||
@@ -907,13 +907,13 @@ void rigid_deform_iteration()
|
||||
return;
|
||||
|
||||
nlMakeCurrent(sys->context);
|
||||
em= sys->rigid.mesh;
|
||||
em = sys->rigid.mesh;
|
||||
|
||||
/* compute R */
|
||||
memset(sys->rigid.R, 0, sizeof(float)*3*3*sys->totvert);
|
||||
memset(sys->rigid.rhs, 0, sizeof(float)*3*sys->totvert);
|
||||
memset(sys->rigid.R, 0, sizeof(float) * 3 * 3 * sys->totvert);
|
||||
memset(sys->rigid.rhs, 0, sizeof(float) * 3 * sys->totvert);
|
||||
|
||||
for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) {
|
||||
for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) {
|
||||
rigid_add_edge_to_R(sys, efa->v1, efa->v2, sys->fweights[a][2]);
|
||||
rigid_add_edge_to_R(sys, efa->v2, efa->v3, sys->fweights[a][0]);
|
||||
rigid_add_edge_to_R(sys, efa->v3, efa->v1, sys->fweights[a][1]);
|
||||
@@ -926,13 +926,13 @@ void rigid_deform_iteration()
|
||||
}
|
||||
}
|
||||
|
||||
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) {
|
||||
for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) {
|
||||
rigid_orthogonalize_R(sys->rigid.R[a]);
|
||||
eve->tmp.l= a;
|
||||
eve->tmp.l = a;
|
||||
}
|
||||
|
||||
/* compute right hand sides for solving */
|
||||
for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) {
|
||||
for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) {
|
||||
rigid_add_edge_to_rhs(sys, efa->v1, efa->v2, sys->fweights[a][2]);
|
||||
rigid_add_edge_to_rhs(sys, efa->v2, efa->v3, sys->fweights[a][0]);
|
||||
rigid_add_edge_to_rhs(sys, efa->v3, efa->v1, sys->fweights[a][1]);
|
||||
@@ -946,21 +946,21 @@ void rigid_deform_iteration()
|
||||
}
|
||||
|
||||
/* solve for positions, for X, Y and Z separately */
|
||||
for (i=0; i<3; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
laplacian_begin_solve(sys, i);
|
||||
|
||||
for (a=0; a<sys->totvert; a++)
|
||||
for (a = 0; a < sys->totvert; a++)
|
||||
if (!sys->vpinned[a])
|
||||
laplacian_add_right_hand_side(sys, a, sys->rigid.rhs[a][i]);
|
||||
|
||||
if (laplacian_system_solve(sys)) {
|
||||
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++)
|
||||
eve->co[i]= laplacian_system_get_solution(a);
|
||||
for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++)
|
||||
eve->co[i] = laplacian_system_get_solution(a);
|
||||
}
|
||||
else {
|
||||
if (!sys->rigid.thrownerror) {
|
||||
error("RigidDeform: failed to find solution");
|
||||
sys->rigid.thrownerror= 1;
|
||||
sys->rigid.thrownerror = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -975,17 +975,17 @@ static void rigid_laplacian_create(LaplacianSystem *sys)
|
||||
int a;
|
||||
|
||||
/* add verts and faces to laplacian */
|
||||
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) {
|
||||
for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) {
|
||||
laplacian_add_vertex(sys, eve->co, eve->pinned);
|
||||
eve->tmp.l= a;
|
||||
eve->tmp.l = a;
|
||||
}
|
||||
|
||||
for (efa=em->faces.first; efa; efa=efa->next) {
|
||||
for (efa = em->faces.first; efa; efa = efa->next) {
|
||||
laplacian_add_triangle(sys,
|
||||
efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l);
|
||||
efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l);
|
||||
if (efa->v4)
|
||||
laplacian_add_triangle(sys,
|
||||
efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l);
|
||||
efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -997,10 +997,10 @@ void rigid_deform_begin(EditMesh *em)
|
||||
int a, totvert, totface;
|
||||
|
||||
/* count vertices, triangles */
|
||||
for (totvert=0, eve=em->verts.first; eve; eve=eve->next)
|
||||
for (totvert = 0, eve = em->verts.first; eve; eve = eve->next)
|
||||
totvert++;
|
||||
|
||||
for (totface=0, efa=em->faces.first; efa; efa=efa->next) {
|
||||
for (totface = 0, efa = em->faces.first; efa; efa = efa->next) {
|
||||
totface++;
|
||||
if (efa->v4) totface++;
|
||||
}
|
||||
@@ -1008,16 +1008,16 @@ void rigid_deform_begin(EditMesh *em)
|
||||
/* create laplacian */
|
||||
sys = laplacian_system_construct_begin(totvert, totface, 0);
|
||||
|
||||
sys->rigid.mesh= em;
|
||||
sys->rigid.R = MEM_callocN(sizeof(float)*3*3*totvert, "RigidDeformR");
|
||||
sys->rigid.rhs = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformRHS");
|
||||
sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo");
|
||||
sys->rigid.mesh = em;
|
||||
sys->rigid.R = MEM_callocN(sizeof(float) * 3 * 3 * totvert, "RigidDeformR");
|
||||
sys->rigid.rhs = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformRHS");
|
||||
sys->rigid.origco = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformCo");
|
||||
|
||||
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++)
|
||||
for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++)
|
||||
copy_v3_v3(sys->rigid.origco[a], eve->co);
|
||||
|
||||
sys->areaweights= 0;
|
||||
sys->storeweights= 1;
|
||||
sys->areaweights = 0;
|
||||
sys->storeweights = 1;
|
||||
|
||||
rigid_laplacian_create(sys);
|
||||
|
||||
@@ -1036,7 +1036,7 @@ void rigid_deform_end(int cancel)
|
||||
int a;
|
||||
|
||||
if (cancel)
|
||||
for (a=0, eve=em->verts.first; eve; eve=eve->next, a++)
|
||||
for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++)
|
||||
if (!eve->pinned)
|
||||
copy_v3_v3(eve->co, sys->rigid.origco[a]);
|
||||
|
||||
@@ -1068,8 +1068,9 @@ void rigid_deform_end(int cancel)
|
||||
|
||||
#define MESHDEFORM_MIN_INFLUENCE 0.0005f
|
||||
|
||||
static int MESHDEFORM_OFFSET[7][3] =
|
||||
{{0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}};
|
||||
static int MESHDEFORM_OFFSET[7][3] = {
|
||||
{0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}
|
||||
};
|
||||
|
||||
typedef struct MDefBoundIsect {
|
||||
float co[3], uvw[4];
|
||||
@@ -1154,7 +1155,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
|
||||
|
||||
/* calculate U parameter and test bounds */
|
||||
u = dot_v3v3(tvec, pvec) * inv_det;
|
||||
if (u < -EPSILON || u > 1.0f+EPSILON)
|
||||
if (u < -EPSILON || u > 1.0f + EPSILON)
|
||||
return 0;
|
||||
|
||||
/* prepare to test V parameter */
|
||||
@@ -1162,16 +1163,16 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3],
|
||||
|
||||
/* calculate V parameter and test bounds */
|
||||
v = dot_v3v3(dir, qvec) * inv_det;
|
||||
if (v < -EPSILON || u + v > 1.0f+EPSILON)
|
||||
if (v < -EPSILON || u + v > 1.0f + EPSILON)
|
||||
return 0;
|
||||
|
||||
isectco[0]= (1.0f - u - v)*vert0[0] + u*vert1[0] + v*vert2[0];
|
||||
isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1];
|
||||
isectco[2]= (1.0f - u - v)*vert0[2] + u*vert1[2] + v*vert2[2];
|
||||
isectco[0] = (1.0f - u - v) * vert0[0] + u * vert1[0] + v * vert2[0];
|
||||
isectco[1] = (1.0f - u - v) * vert0[1] + u * vert1[1] + v * vert2[1];
|
||||
isectco[2] = (1.0f - u - v) * vert0[2] + u * vert1[2] + v * vert2[2];
|
||||
|
||||
uvw[0]= 1.0f - u - v;
|
||||
uvw[1]= u;
|
||||
uvw[2]= v;
|
||||
uvw[0] = 1.0f - u - v;
|
||||
uvw[1] = u;
|
||||
uvw[2] = v;
|
||||
|
||||
/* check if it is within the length of the line segment */
|
||||
sub_v3_v3v3(isectdir, isectco, orig);
|
||||
@@ -1189,16 +1190,16 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec)
|
||||
{
|
||||
MFace *mface;
|
||||
float face[4][3], co[3], uvw[3], len, nor[3], end[3];
|
||||
int f, hit, is= 0, totface;
|
||||
int f, hit, is = 0, totface;
|
||||
|
||||
isec->labda= 1e10;
|
||||
isec->labda = 1e10;
|
||||
|
||||
mface= mdb->cagedm->getTessFaceArray(mdb->cagedm);
|
||||
totface= mdb->cagedm->getNumTessFaces(mdb->cagedm);
|
||||
mface = mdb->cagedm->getTessFaceArray(mdb->cagedm);
|
||||
totface = mdb->cagedm->getNumTessFaces(mdb->cagedm);
|
||||
|
||||
add_v3_v3v3(end, isec->start, isec->vec);
|
||||
|
||||
for (f=0; f<totface; f++, mface++) {
|
||||
for (f = 0; f < totface; f++, mface++) {
|
||||
copy_v3_v3(face[0], mdb->cagecos[mface->v1]);
|
||||
copy_v3_v3(face[1], mdb->cagecos[mface->v2]);
|
||||
copy_v3_v3(face[2], mdb->cagecos[mface->v3]);
|
||||
@@ -1211,22 +1212,22 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec)
|
||||
normal_tri_v3(nor, face[0], face[1], face[2]);
|
||||
}
|
||||
else {
|
||||
hit= meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw);
|
||||
hit = meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw);
|
||||
normal_tri_v3(nor, face[0], face[2], face[3]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
hit= meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw);
|
||||
hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw);
|
||||
normal_tri_v3(nor, face[0], face[1], face[2]);
|
||||
}
|
||||
|
||||
if (hit) {
|
||||
len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end);
|
||||
len = len_v3v3(isec->start, co) / len_v3v3(isec->start, end);
|
||||
if (len < isec->labda) {
|
||||
isec->labda= len;
|
||||
isec->labda = len;
|
||||
isec->face = mface;
|
||||
isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f);
|
||||
is= 1;
|
||||
isec->isect = (dot_v3v3(isec->vec, nor) <= 0.0f);
|
||||
is = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1241,42 +1242,42 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float
|
||||
float (*cagecos)[3];
|
||||
MFace *mface;
|
||||
float vert[4][3], len, end[3];
|
||||
static float epsilon[3]= {0, 0, 0}; //1e-4, 1e-4, 1e-4};
|
||||
static float epsilon[3] = {0, 0, 0}; //1e-4, 1e-4, 1e-4};
|
||||
|
||||
/* setup isec */
|
||||
memset(&isec, 0, sizeof(isec));
|
||||
isec.labda= 1e10f;
|
||||
isec.labda = 1e10f;
|
||||
|
||||
add_v3_v3v3(isec.start, co1, epsilon);
|
||||
add_v3_v3v3(end, co2, epsilon);
|
||||
sub_v3_v3v3(isec.vec, end, isec.start);
|
||||
|
||||
if (meshdeform_intersect(mdb, &isec)) {
|
||||
len= isec.labda;
|
||||
mface=(MFace*)isec.face;
|
||||
len = isec.labda;
|
||||
mface = (MFace *)isec.face;
|
||||
|
||||
/* create MDefBoundIsect */
|
||||
isect= BLI_memarena_alloc(mdb->memarena, sizeof(*isect));
|
||||
isect = BLI_memarena_alloc(mdb->memarena, sizeof(*isect));
|
||||
|
||||
/* compute intersection coordinate */
|
||||
isect->co[0]= co1[0] + isec.vec[0]*len;
|
||||
isect->co[1]= co1[1] + isec.vec[1]*len;
|
||||
isect->co[2]= co1[2] + isec.vec[2]*len;
|
||||
isect->co[0] = co1[0] + isec.vec[0] * len;
|
||||
isect->co[1] = co1[1] + isec.vec[1] * len;
|
||||
isect->co[2] = co1[2] + isec.vec[2] * len;
|
||||
|
||||
isect->len= len_v3v3(co1, isect->co);
|
||||
isect->len = len_v3v3(co1, isect->co);
|
||||
if (isect->len < MESHDEFORM_LEN_THRESHOLD)
|
||||
isect->len= MESHDEFORM_LEN_THRESHOLD;
|
||||
isect->len = MESHDEFORM_LEN_THRESHOLD;
|
||||
|
||||
isect->v[0]= mface->v1;
|
||||
isect->v[1]= mface->v2;
|
||||
isect->v[2]= mface->v3;
|
||||
isect->v[3]= mface->v4;
|
||||
isect->nvert= (mface->v4)? 4: 3;
|
||||
isect->v[0] = mface->v1;
|
||||
isect->v[1] = mface->v2;
|
||||
isect->v[2] = mface->v3;
|
||||
isect->v[3] = mface->v4;
|
||||
isect->nvert = (mface->v4) ? 4 : 3;
|
||||
|
||||
isect->facing= isec.isect;
|
||||
isect->facing = isec.isect;
|
||||
|
||||
/* compute mean value coordinates for interpolation */
|
||||
cagecos= mdb->cagecos;
|
||||
cagecos = mdb->cagecos;
|
||||
copy_v3_v3(vert[0], cagecos[mface->v1]);
|
||||
copy_v3_v3(vert[1], cagecos[mface->v2]);
|
||||
copy_v3_v3(vert[2], cagecos[mface->v3]);
|
||||
@@ -1295,10 +1296,10 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
|
||||
float outside[3], start[3], dir[3];
|
||||
int i;
|
||||
|
||||
for (i=1; i<=6; i++) {
|
||||
outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0];
|
||||
outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1];
|
||||
outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2];
|
||||
for (i = 1; i <= 6; i++) {
|
||||
outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f) * MESHDEFORM_OFFSET[i][0];
|
||||
outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f) * MESHDEFORM_OFFSET[i][1];
|
||||
outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f) * MESHDEFORM_OFFSET[i][2];
|
||||
|
||||
copy_v3_v3(start, co);
|
||||
sub_v3_v3v3(dir, outside, start);
|
||||
@@ -1316,7 +1317,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co)
|
||||
|
||||
static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
|
||||
{
|
||||
int size= mdb->size;
|
||||
int size = mdb->size;
|
||||
|
||||
x += MESHDEFORM_OFFSET[n][0];
|
||||
y += MESHDEFORM_OFFSET[n][1];
|
||||
@@ -1329,7 +1330,7 @@ static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n)
|
||||
if (z < 0 || z >= mdb->size)
|
||||
return -1;
|
||||
|
||||
return x + y*size + z*size*size;
|
||||
return x + y * size + z * size * size;
|
||||
}
|
||||
|
||||
static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int n, float *center)
|
||||
@@ -1338,9 +1339,9 @@ static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int
|
||||
y += MESHDEFORM_OFFSET[n][1];
|
||||
z += MESHDEFORM_OFFSET[n][2];
|
||||
|
||||
center[0]= mdb->min[0] + x*mdb->width[0] + mdb->halfwidth[0];
|
||||
center[1]= mdb->min[1] + y*mdb->width[1] + mdb->halfwidth[1];
|
||||
center[2]= mdb->min[2] + z*mdb->width[2] + mdb->halfwidth[2];
|
||||
center[0] = mdb->min[0] + x * mdb->width[0] + mdb->halfwidth[0];
|
||||
center[1] = mdb->min[1] + y * mdb->width[1] + mdb->halfwidth[1];
|
||||
center[2] = mdb->min[2] + z * mdb->width[2] + mdb->halfwidth[2];
|
||||
}
|
||||
|
||||
static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int z)
|
||||
@@ -1349,72 +1350,72 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int
|
||||
float center[3], ncenter[3];
|
||||
int i, a;
|
||||
|
||||
a= meshdeform_index(mdb, x, y, z, 0);
|
||||
a = meshdeform_index(mdb, x, y, z, 0);
|
||||
meshdeform_cell_center(mdb, x, y, z, 0, center);
|
||||
|
||||
/* check each outgoing edge for intersection */
|
||||
for (i=1; i<=6; i++) {
|
||||
for (i = 1; i <= 6; i++) {
|
||||
if (meshdeform_index(mdb, x, y, z, i) == -1)
|
||||
continue;
|
||||
|
||||
meshdeform_cell_center(mdb, x, y, z, i, ncenter);
|
||||
|
||||
isect= meshdeform_ray_tree_intersect(mdb, center, ncenter);
|
||||
isect = meshdeform_ray_tree_intersect(mdb, center, ncenter);
|
||||
if (isect) {
|
||||
mdb->boundisect[a][i-1]= isect;
|
||||
mdb->tag[a]= MESHDEFORM_TAG_BOUNDARY;
|
||||
mdb->boundisect[a][i - 1] = isect;
|
||||
mdb->tag[a] = MESHDEFORM_TAG_BOUNDARY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void meshdeform_bind_floodfill(MeshDeformBind *mdb)
|
||||
{
|
||||
int *stack, *tag= mdb->tag;
|
||||
int a, b, i, xyz[3], stacksize, size= mdb->size;
|
||||
int *stack, *tag = mdb->tag;
|
||||
int a, b, i, xyz[3], stacksize, size = mdb->size;
|
||||
|
||||
stack= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindStack");
|
||||
stack = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindStack");
|
||||
|
||||
/* we know lower left corner is EXTERIOR because of padding */
|
||||
tag[0]= MESHDEFORM_TAG_EXTERIOR;
|
||||
stack[0]= 0;
|
||||
stacksize= 1;
|
||||
tag[0] = MESHDEFORM_TAG_EXTERIOR;
|
||||
stack[0] = 0;
|
||||
stacksize = 1;
|
||||
|
||||
/* floodfill exterior tag */
|
||||
while (stacksize > 0) {
|
||||
a= stack[--stacksize];
|
||||
a = stack[--stacksize];
|
||||
|
||||
xyz[2]= a/(size*size);
|
||||
xyz[1]= (a - xyz[2]*size*size)/size;
|
||||
xyz[0]= a - xyz[1]*size - xyz[2]*size*size;
|
||||
xyz[2] = a / (size * size);
|
||||
xyz[1] = (a - xyz[2] * size * size) / size;
|
||||
xyz[0] = a - xyz[1] * size - xyz[2] * size * size;
|
||||
|
||||
for (i=1; i<=6; i++) {
|
||||
b= meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i);
|
||||
for (i = 1; i <= 6; i++) {
|
||||
b = meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i);
|
||||
|
||||
if (b != -1) {
|
||||
if (tag[b] == MESHDEFORM_TAG_UNTYPED ||
|
||||
(tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i-1])) {
|
||||
tag[b]= MESHDEFORM_TAG_EXTERIOR;
|
||||
stack[stacksize++]= b;
|
||||
(tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i - 1])) {
|
||||
tag[b] = MESHDEFORM_TAG_EXTERIOR;
|
||||
stack[stacksize++] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* other cells are interior */
|
||||
for (a=0; a<size*size*size; a++)
|
||||
if (tag[a]==MESHDEFORM_TAG_UNTYPED)
|
||||
tag[a]= MESHDEFORM_TAG_INTERIOR;
|
||||
for (a = 0; a < size * size * size; a++)
|
||||
if (tag[a] == MESHDEFORM_TAG_UNTYPED)
|
||||
tag[a] = MESHDEFORM_TAG_INTERIOR;
|
||||
|
||||
#if 0
|
||||
{
|
||||
int tb, ti, te, ts;
|
||||
tb= ti= te= ts= 0;
|
||||
for (a=0; a<size*size*size; a++)
|
||||
if (tag[a]==MESHDEFORM_TAG_BOUNDARY)
|
||||
tb = ti = te = ts = 0;
|
||||
for (a = 0; a < size * size * size; a++)
|
||||
if (tag[a] == MESHDEFORM_TAG_BOUNDARY)
|
||||
tb++;
|
||||
else if (tag[a]==MESHDEFORM_TAG_INTERIOR)
|
||||
else if (tag[a] == MESHDEFORM_TAG_INTERIOR)
|
||||
ti++;
|
||||
else if (tag[a]==MESHDEFORM_TAG_EXTERIOR) {
|
||||
else if (tag[a] == MESHDEFORM_TAG_EXTERIOR) {
|
||||
te++;
|
||||
|
||||
if (mdb->semibound[a])
|
||||
@@ -1432,7 +1433,7 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect
|
||||
{
|
||||
int a;
|
||||
|
||||
for (a=0; a<isect->nvert; a++)
|
||||
for (a = 0; a < isect->nvert; a++)
|
||||
if (isect->v[a] == cagevert)
|
||||
return isect->uvw[a];
|
||||
|
||||
@@ -1441,32 +1442,32 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect
|
||||
|
||||
static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNUSED(vec), int UNUSED(cagevert))
|
||||
{
|
||||
float dvec[3], ivec[3], wx, wy, wz, result=0.0f;
|
||||
float weight, totweight= 0.0f;
|
||||
float dvec[3], ivec[3], wx, wy, wz, result = 0.0f;
|
||||
float weight, totweight = 0.0f;
|
||||
int i, a, x, y, z;
|
||||
|
||||
for (i=0; i<3; i++) {
|
||||
ivec[i]= (int)gridvec[i];
|
||||
dvec[i]= gridvec[i] - ivec[i];
|
||||
for (i = 0; i < 3; i++) {
|
||||
ivec[i] = (int)gridvec[i];
|
||||
dvec[i] = gridvec[i] - ivec[i];
|
||||
}
|
||||
|
||||
for (i=0; i<8; i++) {
|
||||
if (i & 1) { x= ivec[0]+1; wx= dvec[0]; }
|
||||
else { x= ivec[0]; wx= 1.0f-dvec[0]; }
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; }
|
||||
else { x = ivec[0]; wx = 1.0f - dvec[0]; }
|
||||
|
||||
if (i & 2) { y= ivec[1]+1; wy= dvec[1]; }
|
||||
else { y= ivec[1]; wy= 1.0f-dvec[1]; }
|
||||
if (i & 2) { y = ivec[1] + 1; wy = dvec[1]; }
|
||||
else { y = ivec[1]; wy = 1.0f - dvec[1]; }
|
||||
|
||||
if (i & 4) { z= ivec[2]+1; wz= dvec[2]; }
|
||||
else { z= ivec[2]; wz= 1.0f-dvec[2]; }
|
||||
if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; }
|
||||
else { z = ivec[2]; wz = 1.0f - dvec[2]; }
|
||||
|
||||
CLAMP(x, 0, mdb->size-1);
|
||||
CLAMP(y, 0, mdb->size-1);
|
||||
CLAMP(z, 0, mdb->size-1);
|
||||
CLAMP(x, 0, mdb->size - 1);
|
||||
CLAMP(y, 0, mdb->size - 1);
|
||||
CLAMP(z, 0, mdb->size - 1);
|
||||
|
||||
a= meshdeform_index(mdb, x, y, z, 0);
|
||||
weight= wx*wy*wz;
|
||||
result += weight*mdb->phi[a];
|
||||
a = meshdeform_index(mdb, x, y, z, 0);
|
||||
weight = wx * wy * wz;
|
||||
result += weight * mdb->phi[a];
|
||||
totweight += weight;
|
||||
}
|
||||
|
||||
@@ -1480,33 +1481,33 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z)
|
||||
{
|
||||
int i, a;
|
||||
|
||||
a= meshdeform_index(mdb, x, y, z, 0);
|
||||
a = meshdeform_index(mdb, x, y, z, 0);
|
||||
if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR)
|
||||
return;
|
||||
|
||||
for (i=1; i<=6; i++)
|
||||
if (mdb->boundisect[a][i-1])
|
||||
mdb->semibound[a]= 1;
|
||||
for (i = 1; i <= 6; i++)
|
||||
if (mdb->boundisect[a][i - 1])
|
||||
mdb->semibound[a] = 1;
|
||||
}
|
||||
|
||||
static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, int z)
|
||||
{
|
||||
float weight, totweight= 0.0f;
|
||||
float weight, totweight = 0.0f;
|
||||
int i, a;
|
||||
|
||||
a= meshdeform_index(mdb, x, y, z, 0);
|
||||
a = meshdeform_index(mdb, x, y, z, 0);
|
||||
|
||||
/* count weight for neighbor cells */
|
||||
for (i=1; i<=6; i++) {
|
||||
for (i = 1; i <= 6; i++) {
|
||||
if (meshdeform_index(mdb, x, y, z, i) == -1)
|
||||
continue;
|
||||
|
||||
if (mdb->boundisect[a][i-1])
|
||||
weight= 1.0f/mdb->boundisect[a][i-1]->len;
|
||||
if (mdb->boundisect[a][i - 1])
|
||||
weight = 1.0f / mdb->boundisect[a][i - 1]->len;
|
||||
else if (!mdb->semibound[a])
|
||||
weight= 1.0f/mdb->width[0];
|
||||
weight = 1.0f / mdb->width[0];
|
||||
else
|
||||
weight= 0.0f;
|
||||
weight = 0.0f;
|
||||
|
||||
totweight += weight;
|
||||
}
|
||||
@@ -1520,21 +1521,21 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, int x, int y, int z)
|
||||
float weight, totweight;
|
||||
int i, a, acenter;
|
||||
|
||||
acenter= meshdeform_index(mdb, x, y, z, 0);
|
||||
acenter = meshdeform_index(mdb, x, y, z, 0);
|
||||
if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
|
||||
return;
|
||||
|
||||
nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[acenter], 1.0f);
|
||||
|
||||
totweight= meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i=1; i<=6; i++) {
|
||||
a= meshdeform_index(mdb, x, y, z, i);
|
||||
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i = 1; i <= 6; i++) {
|
||||
a = meshdeform_index(mdb, x, y, z, i);
|
||||
if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)
|
||||
continue;
|
||||
|
||||
isect= mdb->boundisect[acenter][i-1];
|
||||
isect = mdb->boundisect[acenter][i - 1];
|
||||
if (!isect) {
|
||||
weight= (1.0f/mdb->width[0])/totweight;
|
||||
weight = (1.0f / mdb->width[0]) / totweight;
|
||||
nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[a], -weight);
|
||||
}
|
||||
}
|
||||
@@ -1546,21 +1547,21 @@ static void meshdeform_matrix_add_rhs(MeshDeformBind *mdb, int x, int y, int z,
|
||||
float rhs, weight, totweight;
|
||||
int i, a, acenter;
|
||||
|
||||
acenter= meshdeform_index(mdb, x, y, z, 0);
|
||||
acenter = meshdeform_index(mdb, x, y, z, 0);
|
||||
if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR)
|
||||
return;
|
||||
|
||||
totweight= meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i=1; i<=6; i++) {
|
||||
a= meshdeform_index(mdb, x, y, z, i);
|
||||
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i = 1; i <= 6; i++) {
|
||||
a = meshdeform_index(mdb, x, y, z, i);
|
||||
if (a == -1)
|
||||
continue;
|
||||
|
||||
isect= mdb->boundisect[acenter][i-1];
|
||||
isect = mdb->boundisect[acenter][i - 1];
|
||||
|
||||
if (isect) {
|
||||
weight= (1.0f/isect->len)/totweight;
|
||||
rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert);
|
||||
weight = (1.0f / isect->len) / totweight;
|
||||
rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert);
|
||||
nlRightHandSideAdd(0, mdb->varidx[acenter], rhs);
|
||||
}
|
||||
}
|
||||
@@ -1572,19 +1573,19 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int
|
||||
float rhs, weight, totweight;
|
||||
int i, a;
|
||||
|
||||
a= meshdeform_index(mdb, x, y, z, 0);
|
||||
a = meshdeform_index(mdb, x, y, z, 0);
|
||||
if (!mdb->semibound[a])
|
||||
return;
|
||||
|
||||
mdb->phi[a]= 0.0f;
|
||||
mdb->phi[a] = 0.0f;
|
||||
|
||||
totweight= meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i=1; i<=6; i++) {
|
||||
isect= mdb->boundisect[a][i-1];
|
||||
totweight = meshdeform_boundary_total_weight(mdb, x, y, z);
|
||||
for (i = 1; i <= 6; i++) {
|
||||
isect = mdb->boundisect[a][i - 1];
|
||||
|
||||
if (isect) {
|
||||
weight= (1.0f/isect->len)/totweight;
|
||||
rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert);
|
||||
weight = (1.0f / isect->len) / totweight;
|
||||
rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert);
|
||||
mdb->phi[a] += rhs;
|
||||
}
|
||||
}
|
||||
@@ -1595,14 +1596,14 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y
|
||||
float phi, totweight;
|
||||
int i, a, acenter;
|
||||
|
||||
acenter= meshdeform_index(mdb, x, y, z, 0);
|
||||
acenter = meshdeform_index(mdb, x, y, z, 0);
|
||||
if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter])
|
||||
return;
|
||||
|
||||
phi= 0.0f;
|
||||
totweight= 0.0f;
|
||||
for (i=1; i<=6; i++) {
|
||||
a= meshdeform_index(mdb, x, y, z, i);
|
||||
phi = 0.0f;
|
||||
totweight = 0.0f;
|
||||
for (i = 1; i <= 6; i++) {
|
||||
a = meshdeform_index(mdb, x, y, z, i);
|
||||
|
||||
if (a != -1 && mdb->semibound[a]) {
|
||||
phi += mdb->phi[a];
|
||||
@@ -1611,7 +1612,7 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y
|
||||
}
|
||||
|
||||
if (totweight != 0.0f)
|
||||
mdb->phi[acenter]= phi/totweight;
|
||||
mdb->phi[acenter] = phi / totweight;
|
||||
}
|
||||
|
||||
static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind *mdb)
|
||||
@@ -1622,9 +1623,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
char message[256];
|
||||
|
||||
/* setup variable indices */
|
||||
mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx");
|
||||
for (a=0, totvar=0; a<mdb->size3; a++)
|
||||
mdb->varidx[a]= (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)? -1: totvar++;
|
||||
mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx");
|
||||
for (a = 0, totvar = 0; a < mdb->size3; a++)
|
||||
mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++;
|
||||
|
||||
if (totvar == 0) {
|
||||
MEM_freeN(mdb->varidx);
|
||||
@@ -1635,7 +1636,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
|
||||
/* setup opennl solver */
|
||||
nlNewContext();
|
||||
context= nlGetCurrent();
|
||||
context = nlGetCurrent();
|
||||
|
||||
nlSolverParameteri(NL_NB_VARIABLES, totvar);
|
||||
nlSolverParameteri(NL_NB_ROWS, totvar);
|
||||
@@ -1645,22 +1646,22 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
nlBegin(NL_MATRIX);
|
||||
|
||||
/* build matrix */
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_matrix_add_cell(mdb, x, y, z);
|
||||
|
||||
/* solve for each cage vert */
|
||||
for (a=0; a<mdb->totcagevert; a++) {
|
||||
for (a = 0; a < mdb->totcagevert; a++) {
|
||||
if (a != 0) {
|
||||
nlBegin(NL_SYSTEM);
|
||||
nlBegin(NL_MATRIX);
|
||||
}
|
||||
|
||||
/* fill in right hand side and solve */
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_matrix_add_rhs(mdb, x, y, z, a);
|
||||
|
||||
nlEnd(NL_MATRIX);
|
||||
@@ -1671,32 +1672,32 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
#endif
|
||||
|
||||
if (nlSolveAdvanced(NULL, NL_TRUE)) {
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a);
|
||||
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a);
|
||||
|
||||
for (b=0; b<mdb->size3; b++) {
|
||||
for (b = 0; b < mdb->size3; b++) {
|
||||
if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR)
|
||||
mdb->phi[b]= nlGetVariable(0, mdb->varidx[b]);
|
||||
mdb->phi[b] = nlGetVariable(0, mdb->varidx[b]);
|
||||
mdb->totalphi[b] += mdb->phi[b];
|
||||
}
|
||||
|
||||
if (mdb->weights) {
|
||||
/* static bind : compute weights for each vertex */
|
||||
for (b=0; b<mdb->totvert; b++) {
|
||||
for (b = 0; b < mdb->totvert; b++) {
|
||||
if (mdb->inside[b]) {
|
||||
copy_v3_v3(vec, mdb->vertexcos[b]);
|
||||
gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0];
|
||||
gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1];
|
||||
gridvec[2]= (vec[2] - mdb->min[2] - mdb->halfwidth[2])/mdb->width[2];
|
||||
gridvec[0] = (vec[0] - mdb->min[0] - mdb->halfwidth[0]) / mdb->width[0];
|
||||
gridvec[1] = (vec[1] - mdb->min[1] - mdb->halfwidth[1]) / mdb->width[1];
|
||||
gridvec[2] = (vec[2] - mdb->min[2] - mdb->halfwidth[2]) / mdb->width[2];
|
||||
|
||||
mdb->weights[b*mdb->totcagevert + a]= meshdeform_interp_w(mdb, gridvec, vec, a);
|
||||
mdb->weights[b * mdb->totcagevert + a] = meshdeform_interp_w(mdb, gridvec, vec, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1704,13 +1705,13 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
MDefBindInfluence *inf;
|
||||
|
||||
/* dynamic bind */
|
||||
for (b=0; b<mdb->size3; b++) {
|
||||
for (b = 0; b < mdb->size3; b++) {
|
||||
if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) {
|
||||
inf= BLI_memarena_alloc(mdb->memarena, sizeof(*inf));
|
||||
inf->vertex= a;
|
||||
inf->weight= mdb->phi[b];
|
||||
inf->next= mdb->dyngrid[b];
|
||||
mdb->dyngrid[b]= inf;
|
||||
inf = BLI_memarena_alloc(mdb->memarena, sizeof(*inf));
|
||||
inf->vertex = a;
|
||||
inf->weight = mdb->phi[b];
|
||||
inf->next = mdb->dyngrid[b];
|
||||
mdb->dyngrid[b] = inf;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1721,17 +1722,17 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
|
||||
break;
|
||||
}
|
||||
|
||||
BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert);
|
||||
progress_bar((float)(a+1)/(float)(mdb->totcagevert), message);
|
||||
BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a + 1, mdb->totcagevert);
|
||||
progress_bar((float)(a + 1) / (float)(mdb->totcagevert), message);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* sanity check */
|
||||
for (b=0; b<mdb->size3; b++)
|
||||
for (b = 0; b < mdb->size3; b++)
|
||||
if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR)
|
||||
if (fabs(mdb->totalphi[b] - 1.0f) > 1e-4)
|
||||
printf("totalphi deficiency [%s|%d] %d: %.10f\n",
|
||||
(mdb->tag[b] == MESHDEFORM_TAG_INTERIOR)? "interior": "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]);
|
||||
(mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]);
|
||||
#endif
|
||||
|
||||
/* free */
|
||||
@@ -1751,78 +1752,78 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
|
||||
/* compute bounding box of the cage mesh */
|
||||
INIT_MINMAX(mdb->min, mdb->max);
|
||||
|
||||
for (a=0; a<mdb->totcagevert; a++)
|
||||
for (a = 0; a < mdb->totcagevert; a++)
|
||||
DO_MINMAX(mdb->cagecos[a], mdb->min, mdb->max);
|
||||
|
||||
/* allocate memory */
|
||||
mdb->size= (2<<(mmd->gridsize-1)) + 2;
|
||||
mdb->size3= mdb->size*mdb->size*mdb->size;
|
||||
mdb->tag= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindTag");
|
||||
mdb->phi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindPhi");
|
||||
mdb->totalphi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindTotalPhi");
|
||||
mdb->boundisect= MEM_callocN(sizeof(*mdb->boundisect)*mdb->size3, "MDefBoundIsect");
|
||||
mdb->semibound= MEM_callocN(sizeof(int)*mdb->size3, "MDefSemiBound");
|
||||
mdb->size = (2 << (mmd->gridsize - 1)) + 2;
|
||||
mdb->size3 = mdb->size * mdb->size * mdb->size;
|
||||
mdb->tag = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindTag");
|
||||
mdb->phi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindPhi");
|
||||
mdb->totalphi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi");
|
||||
mdb->boundisect = MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect");
|
||||
mdb->semibound = MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound");
|
||||
|
||||
mdb->inside= MEM_callocN(sizeof(int)*mdb->totvert, "MDefInside");
|
||||
mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside");
|
||||
|
||||
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND)
|
||||
mdb->dyngrid= MEM_callocN(sizeof(MDefBindInfluence*)*mdb->size3, "MDefDynGrid");
|
||||
mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid");
|
||||
else
|
||||
mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights");
|
||||
mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights");
|
||||
|
||||
mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
|
||||
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
|
||||
* width of the cells */
|
||||
maxwidth = -1.0f;
|
||||
for (a=0; a<3; a++)
|
||||
if (mdb->max[a]-mdb->min[a] > maxwidth)
|
||||
maxwidth= mdb->max[a]-mdb->min[a];
|
||||
for (a = 0; a < 3; a++)
|
||||
if (mdb->max[a] - mdb->min[a] > maxwidth)
|
||||
maxwidth = mdb->max[a] - mdb->min[a];
|
||||
|
||||
for (a=0; a<3; a++) {
|
||||
center[a]= (mdb->min[a]+mdb->max[a])*0.5f;
|
||||
mdb->min[a]= center[a] - maxwidth*0.5f;
|
||||
mdb->max[a]= center[a] + maxwidth*0.5f;
|
||||
for (a = 0; a < 3; a++) {
|
||||
center[a] = (mdb->min[a] + mdb->max[a]) * 0.5f;
|
||||
mdb->min[a] = center[a] - maxwidth * 0.5f;
|
||||
mdb->max[a] = center[a] + maxwidth * 0.5f;
|
||||
|
||||
mdb->width[a]= (mdb->max[a]-mdb->min[a])/(mdb->size-4);
|
||||
mdb->min[a] -= 2.1f*mdb->width[a];
|
||||
mdb->max[a] += 2.1f*mdb->width[a];
|
||||
mdb->width[a] = (mdb->max[a] - mdb->min[a]) / (mdb->size - 4);
|
||||
mdb->min[a] -= 2.1f * mdb->width[a];
|
||||
mdb->max[a] += 2.1f * mdb->width[a];
|
||||
|
||||
mdb->width[a]= (mdb->max[a]-mdb->min[a])/mdb->size;
|
||||
mdb->halfwidth[a]= mdb->width[a]*0.5f;
|
||||
mdb->width[a] = (mdb->max[a] - mdb->min[a]) / mdb->size;
|
||||
mdb->halfwidth[a] = mdb->width[a] * 0.5f;
|
||||
}
|
||||
|
||||
progress_bar(0, "Setting up mesh deform system");
|
||||
|
||||
totinside= 0;
|
||||
for (a=0; a<mdb->totvert; a++) {
|
||||
totinside = 0;
|
||||
for (a = 0; a < mdb->totvert; a++) {
|
||||
copy_v3_v3(vec, mdb->vertexcos[a]);
|
||||
mdb->inside[a]= meshdeform_inside_cage(mdb, vec);
|
||||
mdb->inside[a] = meshdeform_inside_cage(mdb, vec);
|
||||
if (mdb->inside[a])
|
||||
totinside++;
|
||||
}
|
||||
|
||||
/* free temporary MDefBoundIsects */
|
||||
BLI_memarena_free(mdb->memarena);
|
||||
mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
|
||||
mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena");
|
||||
|
||||
/* start with all cells untyped */
|
||||
for (a=0; a<mdb->size3; a++)
|
||||
mdb->tag[a]= MESHDEFORM_TAG_UNTYPED;
|
||||
for (a = 0; a < mdb->size3; a++)
|
||||
mdb->tag[a] = MESHDEFORM_TAG_UNTYPED;
|
||||
|
||||
/* detect intersections and tag boundary cells */
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_add_intersections(mdb, x, y, z);
|
||||
|
||||
/* compute exterior and interior tags */
|
||||
meshdeform_bind_floodfill(mdb);
|
||||
|
||||
for (z=0; z<mdb->size; z++)
|
||||
for (y=0; y<mdb->size; y++)
|
||||
for (x=0; x<mdb->size; x++)
|
||||
for (z = 0; z < mdb->size; z++)
|
||||
for (y = 0; y < mdb->size; y++)
|
||||
for (x = 0; x < mdb->size; x++)
|
||||
meshdeform_check_semibound(mdb, x, y, z);
|
||||
|
||||
/* solve */
|
||||
@@ -1830,45 +1831,45 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
|
||||
|
||||
/* assign results */
|
||||
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {
|
||||
mmd->totinfluence= 0;
|
||||
for (a=0; a<mdb->size3; a++)
|
||||
for (inf=mdb->dyngrid[a]; inf; inf=inf->next)
|
||||
mmd->totinfluence = 0;
|
||||
for (a = 0; a < mdb->size3; a++)
|
||||
for (inf = mdb->dyngrid[a]; inf; inf = inf->next)
|
||||
mmd->totinfluence++;
|
||||
|
||||
/* convert MDefBindInfluences to smaller MDefInfluences */
|
||||
mmd->dyngrid= MEM_callocN(sizeof(MDefCell)*mdb->size3, "MDefDynGrid");
|
||||
mmd->dyninfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefInfluence");
|
||||
offset= 0;
|
||||
for (a=0; a<mdb->size3; a++) {
|
||||
cell= &mmd->dyngrid[a];
|
||||
cell->offset= offset;
|
||||
mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid");
|
||||
mmd->dyninfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->totinfluence, "MDefInfluence");
|
||||
offset = 0;
|
||||
for (a = 0; a < mdb->size3; a++) {
|
||||
cell = &mmd->dyngrid[a];
|
||||
cell->offset = offset;
|
||||
|
||||
totweight= 0.0f;
|
||||
mdinf= mmd->dyninfluences + cell->offset;
|
||||
for (inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) {
|
||||
mdinf->weight= inf->weight;
|
||||
mdinf->vertex= inf->vertex;
|
||||
totweight = 0.0f;
|
||||
mdinf = mmd->dyninfluences + cell->offset;
|
||||
for (inf = mdb->dyngrid[a]; inf; inf = inf->next, mdinf++) {
|
||||
mdinf->weight = inf->weight;
|
||||
mdinf->vertex = inf->vertex;
|
||||
totweight += mdinf->weight;
|
||||
cell->totinfluence++;
|
||||
}
|
||||
|
||||
if (totweight > 0.0f) {
|
||||
mdinf= mmd->dyninfluences + cell->offset;
|
||||
for (b=0; b<cell->totinfluence; b++, mdinf++)
|
||||
mdinf = mmd->dyninfluences + cell->offset;
|
||||
for (b = 0; b < cell->totinfluence; b++, mdinf++)
|
||||
mdinf->weight /= totweight;
|
||||
}
|
||||
|
||||
offset += cell->totinfluence;
|
||||
}
|
||||
|
||||
mmd->dynverts= mdb->inside;
|
||||
mmd->dyngridsize= mdb->size;
|
||||
mmd->dynverts = mdb->inside;
|
||||
mmd->dyngridsize = mdb->size;
|
||||
copy_v3_v3(mmd->dyncellmin, mdb->min);
|
||||
mmd->dyncellwidth= mdb->width[0];
|
||||
mmd->dyncellwidth = mdb->width[0];
|
||||
MEM_freeN(mdb->dyngrid);
|
||||
}
|
||||
else {
|
||||
mmd->bindweights= mdb->weights;
|
||||
mmd->bindweights = mdb->weights;
|
||||
MEM_freeN(mdb->inside);
|
||||
}
|
||||
|
||||
@@ -1884,16 +1885,16 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa
|
||||
static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifierData *mmd, MeshDeformBind *mdb)
|
||||
{
|
||||
LaplacianSystem *sys;
|
||||
MFace *mface= dm->getTessFaceArray(dm), *mf;
|
||||
int totvert= dm->getNumVerts(dm);
|
||||
int totface= dm->getNumTessFaces(dm);
|
||||
MFace *mface = dm->getTessFaceArray(dm), *mf;
|
||||
int totvert = dm->getNumVerts(dm);
|
||||
int totface = dm->getNumTessFaces(dm);
|
||||
float solution, weight;
|
||||
int a, tottri, j, thrownerror = 0;
|
||||
|
||||
mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights");
|
||||
mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights");
|
||||
|
||||
/* count triangles */
|
||||
for (tottri=0, a=0, mf=mface; a<totface; a++, mf++) {
|
||||
for (tottri = 0, a = 0, mf = mface; a < totface; a++, mf++) {
|
||||
tottri++;
|
||||
if (mf->v4) tottri++;
|
||||
}
|
||||
@@ -1901,12 +1902,12 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie
|
||||
/* create laplacian */
|
||||
sys = laplacian_system_construct_begin(totvert, tottri, 1);
|
||||
|
||||
sys->heat.mface= mface;
|
||||
sys->heat.totface= totface;
|
||||
sys->heat.totvert= totvert;
|
||||
sys->heat.verts= mdb->vertexcos;
|
||||
sys->heat.mface = mface;
|
||||
sys->heat.totface = totface;
|
||||
sys->heat.totvert = totvert;
|
||||
sys->heat.verts = mdb->vertexcos;
|
||||
sys->heat.source = mdb->cagecos;
|
||||
sys->heat.numsource= mdb->totcagevert;
|
||||
sys->heat.numsource = mdb->totcagevert;
|
||||
|
||||
heat_ray_tree_create(sys);
|
||||
heat_laplacian_create(sys);
|
||||
@@ -1914,30 +1915,30 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie
|
||||
laplacian_system_construct_end(sys);
|
||||
|
||||
/* compute weights per bone */
|
||||
for (j=0; j<mdb->totcagevert; j++) {
|
||||
for (j = 0; j < mdb->totcagevert; j++) {
|
||||
/* fill right hand side */
|
||||
laplacian_begin_solve(sys, -1);
|
||||
|
||||
for (a=0; a<totvert; a++)
|
||||
for (a = 0; a < totvert; a++)
|
||||
if (heat_source_closest(sys, a, j))
|
||||
laplacian_add_right_hand_side(sys, a,
|
||||
sys->heat.H[a]*sys->heat.p[a]);
|
||||
sys->heat.H[a] * sys->heat.p[a]);
|
||||
|
||||
/* solve */
|
||||
if (laplacian_system_solve(sys)) {
|
||||
/* load solution into vertex groups */
|
||||
for (a=0; a<totvert; a++) {
|
||||
solution= laplacian_system_get_solution(a);
|
||||
for (a = 0; a < totvert; a++) {
|
||||
solution = laplacian_system_get_solution(a);
|
||||
|
||||
weight= heat_limit_weight(solution);
|
||||
weight = heat_limit_weight(solution);
|
||||
if (weight > 0.0f)
|
||||
mdb->weights[a*mdb->totcagevert + j] = weight;
|
||||
mdb->weights[a * mdb->totcagevert + j] = weight;
|
||||
}
|
||||
}
|
||||
else if (!thrownerror) {
|
||||
error("Mesh Deform Heat Weighting:"
|
||||
" failed to find solution for one or more vertices");
|
||||
thrownerror= 1;
|
||||
" failed to find solution for one or more vertices");
|
||||
thrownerror = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1946,7 +1947,7 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie
|
||||
heat_system_free(sys);
|
||||
laplacian_system_delete(sys);
|
||||
|
||||
mmd->bindweights= mdb->weights;
|
||||
mmd->bindweights = mdb->weights;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1962,19 +1963,19 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco
|
||||
memset(&mdb, 0, sizeof(MeshDeformBind));
|
||||
|
||||
/* get mesh and cage mesh */
|
||||
mdb.vertexcos= MEM_callocN(sizeof(float)*3*totvert, "MeshDeformCos");
|
||||
mdb.totvert= totvert;
|
||||
mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos");
|
||||
mdb.totvert = totvert;
|
||||
|
||||
mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH);
|
||||
mdb.totcagevert= mdb.cagedm->getNumVerts(mdb.cagedm);
|
||||
mdb.cagecos= MEM_callocN(sizeof(*mdb.cagecos)*mdb.totcagevert, "MeshDeformBindCos");
|
||||
mdb.cagedm = mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH);
|
||||
mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm);
|
||||
mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos");
|
||||
copy_m4_m4(mdb.cagemat, cagemat);
|
||||
|
||||
mvert= mdb.cagedm->getVertArray(mdb.cagedm);
|
||||
for (a=0; a<mdb.totcagevert; a++)
|
||||
mvert = mdb.cagedm->getVertArray(mdb.cagedm);
|
||||
for (a = 0; a < mdb.totcagevert; a++)
|
||||
copy_v3_v3(mdb.cagecos[a], mvert[a].co);
|
||||
for (a=0; a<mdb.totvert; a++)
|
||||
mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a*3);
|
||||
for (a = 0; a < mdb.totvert; a++)
|
||||
mul_v3_m4v3(mdb.vertexcos[a], mdb.cagemat, vertexcos + a * 3);
|
||||
|
||||
/* solve */
|
||||
#if 0
|
||||
@@ -1987,21 +1988,21 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco
|
||||
#endif
|
||||
|
||||
/* assign bind variables */
|
||||
mmd->bindcagecos= (float*)mdb.cagecos;
|
||||
mmd->totvert= mdb.totvert;
|
||||
mmd->totcagevert= mdb.totcagevert;
|
||||
mmd->bindcagecos = (float *)mdb.cagecos;
|
||||
mmd->totvert = mdb.totvert;
|
||||
mmd->totcagevert = mdb.totcagevert;
|
||||
copy_m4_m4(mmd->bindmat, mmd->object->obmat);
|
||||
|
||||
/* transform bindcagecos to world space */
|
||||
for (a=0; a<mdb.totcagevert; a++)
|
||||
mul_m4_v3(mmd->object->obmat, mmd->bindcagecos+a*3);
|
||||
for (a = 0; a < mdb.totcagevert; a++)
|
||||
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);
|
||||
modifier_mdef_compact_influences((ModifierData *)mmd);
|
||||
|
||||
end_progress_bar();
|
||||
waitcursor(0);
|
||||
|
||||
@@ -62,9 +62,9 @@ float laplacian_system_get_solution(int v);
|
||||
/* Heat Weighting */
|
||||
|
||||
void heat_bone_weighting(struct Object *ob, struct Mesh *me, float (*verts)[3],
|
||||
int numbones, struct bDeformGroup **dgrouplist,
|
||||
struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3],
|
||||
int *selected, const char **error);
|
||||
int numbones, struct bDeformGroup **dgrouplist,
|
||||
struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3],
|
||||
int *selected, const char **error);
|
||||
|
||||
#ifdef RIGID_DEFORM
|
||||
/* As-Rigid-As-Possible Deformation */
|
||||
|
||||
@@ -91,63 +91,63 @@
|
||||
|
||||
/* Temporary data shared between these operators */
|
||||
typedef struct tPoseSlideOp {
|
||||
Scene *scene; /* current scene */
|
||||
ScrArea *sa; /* area that we're operating in (needed for modal()) */
|
||||
ARegion *ar; /* region that we're operating in (needed for modal()) */
|
||||
Object *ob; /* active object that Pose Info comes from */
|
||||
bArmature *arm; /* armature for pose */
|
||||
Scene *scene; /* current scene */
|
||||
ScrArea *sa; /* area that we're operating in (needed for modal()) */
|
||||
ARegion *ar; /* region that we're operating in (needed for modal()) */
|
||||
Object *ob; /* active object that Pose Info comes from */
|
||||
bArmature *arm; /* armature for pose */
|
||||
|
||||
ListBase pfLinks; /* links between posechannels and f-curves */
|
||||
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
|
||||
|
||||
int cframe; /* current frame number */
|
||||
int prevFrame; /* frame before current frame (blend-from) */
|
||||
int nextFrame; /* frame after current frame (blend-to) */
|
||||
|
||||
ListBase pfLinks; /* links between posechannels and f-curves */
|
||||
DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */
|
||||
int mode; /* sliding mode (ePoseSlide_Modes) */
|
||||
int flag; // unused for now, but can later get used for storing runtime settings....
|
||||
|
||||
int cframe; /* current frame number */
|
||||
int prevFrame; /* frame before current frame (blend-from) */
|
||||
int nextFrame; /* frame after current frame (blend-to) */
|
||||
|
||||
int mode; /* sliding mode (ePoseSlide_Modes) */
|
||||
int flag; // unused for now, but can later get used for storing runtime settings....
|
||||
|
||||
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
|
||||
float percentage; /* 0-1 value for determining the influence of whatever is relevant */
|
||||
} tPoseSlideOp;
|
||||
|
||||
/* Pose Sliding Modes */
|
||||
typedef enum ePoseSlide_Modes {
|
||||
POSESLIDE_PUSH = 0, /* exaggerate the pose... */
|
||||
POSESLIDE_RELAX, /* soften the pose... */
|
||||
POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */
|
||||
POSESLIDE_PUSH = 0, /* exaggerate the pose... */
|
||||
POSESLIDE_RELAX, /* soften the pose... */
|
||||
POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */
|
||||
} ePoseSlide_Modes;
|
||||
|
||||
/* ------------------------------------ */
|
||||
|
||||
/* operator init */
|
||||
static int pose_slide_init (bContext *C, wmOperator *op, short mode)
|
||||
static int pose_slide_init(bContext *C, wmOperator *op, short mode)
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
bAction *act= NULL;
|
||||
bAction *act = NULL;
|
||||
|
||||
/* init slide-op data */
|
||||
pso= op->customdata= MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
|
||||
pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp");
|
||||
|
||||
/* get info from context */
|
||||
pso->scene= CTX_data_scene(C);
|
||||
pso->ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
pso->arm= (pso->ob)? pso->ob->data : NULL;
|
||||
pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */
|
||||
pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */
|
||||
pso->scene = CTX_data_scene(C);
|
||||
pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
pso->arm = (pso->ob) ? pso->ob->data : NULL;
|
||||
pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */
|
||||
pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */
|
||||
|
||||
pso->cframe= pso->scene->r.cfra;
|
||||
pso->mode= mode;
|
||||
pso->cframe = pso->scene->r.cfra;
|
||||
pso->mode = mode;
|
||||
|
||||
/* set range info from property values - these may get overridden for the invoke() */
|
||||
pso->percentage= RNA_float_get(op->ptr, "percentage");
|
||||
pso->prevFrame= RNA_int_get(op->ptr, "prev_frame");
|
||||
pso->nextFrame= RNA_int_get(op->ptr, "next_frame");
|
||||
pso->percentage = RNA_float_get(op->ptr, "percentage");
|
||||
pso->prevFrame = RNA_int_get(op->ptr, "prev_frame");
|
||||
pso->nextFrame = RNA_int_get(op->ptr, "next_frame");
|
||||
|
||||
/* check the settings from the context */
|
||||
if (ELEM4(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action))
|
||||
return 0;
|
||||
else
|
||||
act= pso->ob->adt->action;
|
||||
act = pso->ob->adt->action;
|
||||
|
||||
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
|
||||
* and set the relevant transform flags...
|
||||
@@ -155,7 +155,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
|
||||
poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act);
|
||||
|
||||
/* set depsgraph flags */
|
||||
/* make sure the lock is set OK, unlock can be accidentally saved? */
|
||||
/* make sure the lock is set OK, unlock can be accidentally saved? */
|
||||
pso->ob->pose->flag |= POSE_LOCKED;
|
||||
pso->ob->pose->flag &= ~POSE_DO_UNLOCK;
|
||||
|
||||
@@ -171,7 +171,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode)
|
||||
/* exiting the operator - free data */
|
||||
static void pose_slide_exit(wmOperator *op)
|
||||
{
|
||||
tPoseSlideOp *pso= op->customdata;
|
||||
tPoseSlideOp *pso = op->customdata;
|
||||
|
||||
/* if data exists, clear its data and exit */
|
||||
if (pso) {
|
||||
@@ -186,36 +186,36 @@ static void pose_slide_exit(wmOperator *op)
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
op->customdata= NULL;
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
/* ------------------------------------ */
|
||||
|
||||
/* helper for apply() / reset() - refresh the data */
|
||||
static void pose_slide_refresh (bContext *C, tPoseSlideOp *pso)
|
||||
static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso)
|
||||
{
|
||||
/* wrapper around the generic version, allowing us to add some custom stuff later still */
|
||||
poseAnim_mapping_refresh(C, pso->scene, pso->ob);
|
||||
}
|
||||
|
||||
/* helper for apply() - perform sliding for some value */
|
||||
static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
|
||||
static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val)
|
||||
{
|
||||
float cframe = (float)pso->cframe;
|
||||
float sVal, eVal;
|
||||
float w1, w2;
|
||||
|
||||
/* get keyframe values for endpoint poses to blend with */
|
||||
/* previous/start */
|
||||
sVal= evaluate_fcurve(fcu, (float)pso->prevFrame);
|
||||
/* next/end */
|
||||
eVal= evaluate_fcurve(fcu, (float)pso->nextFrame);
|
||||
/* previous/start */
|
||||
sVal = evaluate_fcurve(fcu, (float)pso->prevFrame);
|
||||
/* next/end */
|
||||
eVal = evaluate_fcurve(fcu, (float)pso->nextFrame);
|
||||
|
||||
/* calculate the relative weights of the endpoints */
|
||||
if (pso->mode == POSESLIDE_BREAKDOWN) {
|
||||
/* get weights from the percentage control */
|
||||
w1= pso->percentage; /* this must come second */
|
||||
w2= 1.0f - w1; /* this must come first */
|
||||
w1 = pso->percentage; /* this must come second */
|
||||
w2 = 1.0f - w1; /* this must come first */
|
||||
}
|
||||
else {
|
||||
/* - these weights are derived from the relative distance of these
|
||||
@@ -228,8 +228,8 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
|
||||
w2 = (float)pso->nextFrame - cframe;
|
||||
|
||||
wtot = w1 + w2;
|
||||
w1 = (w1/wtot);
|
||||
w2 = (w2/wtot);
|
||||
w1 = (w1 / wtot);
|
||||
w2 = (w2 / wtot);
|
||||
}
|
||||
|
||||
/* depending on the mode, calculate the new value
|
||||
@@ -243,13 +243,13 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
|
||||
* - numerator should be larger than denominator to 'expand' the result
|
||||
* - perform this weighting a number of times given by the percentage...
|
||||
*/
|
||||
int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
|
||||
while (iters-- > 0) {
|
||||
(*val)= ( -((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f;
|
||||
(*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */
|
||||
{
|
||||
@@ -257,36 +257,36 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val)
|
||||
* - numerator should be smaller than denominator to 'relax' the result
|
||||
* - perform this weighting a number of times given by the percentage...
|
||||
*/
|
||||
int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
|
||||
while (iters-- > 0) {
|
||||
(*val)= ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f;
|
||||
(*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */
|
||||
{
|
||||
/* perform simple linear interpolation - coefficient for start must come from pso->percentage... */
|
||||
// TODO: make this use some kind of spline interpolation instead?
|
||||
(*val)= ((sVal * w2) + (eVal * w1));
|
||||
(*val) = ((sVal * w2) + (eVal * w1));
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* helper for apply() - perform sliding for some 3-element vector */
|
||||
static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[])
|
||||
static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[])
|
||||
{
|
||||
LinkData *ld=NULL;
|
||||
char *path=NULL;
|
||||
LinkData *ld = NULL;
|
||||
char *path = NULL;
|
||||
|
||||
/* get the path to use... */
|
||||
path= BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
|
||||
path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName);
|
||||
|
||||
/* using this path, find each matching F-Curve for the variables we're interested in */
|
||||
while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
|
||||
FCurve *fcu= (FCurve *)ld->data;
|
||||
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
|
||||
FCurve *fcu = (FCurve *)ld->data;
|
||||
|
||||
/* just work on these channels one by one... there's no interaction between values */
|
||||
pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]);
|
||||
@@ -297,7 +297,7 @@ static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, flo
|
||||
}
|
||||
|
||||
/* helper for apply() - perform sliding for custom properties */
|
||||
static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
{
|
||||
PointerRNA ptr = {{NULL}};
|
||||
LinkData *ld;
|
||||
@@ -337,7 +337,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
pose_slide_apply_val(pso, fcu, &tval);
|
||||
RNA_property_float_set(&ptr, prop, tval);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case PROP_BOOLEAN:
|
||||
case PROP_ENUM:
|
||||
case PROP_INT:
|
||||
@@ -346,7 +346,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
pose_slide_apply_val(pso, fcu, &tval);
|
||||
RNA_property_int_set(&ptr, prop, (int)tval);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
/* cannot handle */
|
||||
//printf("Cannot Pose Slide non-numerical property\n");
|
||||
@@ -358,37 +358,37 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
}
|
||||
|
||||
/* helper for apply() - perform sliding for quaternion rotations (using quat blending) */
|
||||
static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
{
|
||||
FCurve *fcu_w=NULL, *fcu_x=NULL, *fcu_y=NULL, *fcu_z=NULL;
|
||||
bPoseChannel *pchan= pfl->pchan;
|
||||
LinkData *ld=NULL;
|
||||
char *path=NULL;
|
||||
FCurve *fcu_w = NULL, *fcu_x = NULL, *fcu_y = NULL, *fcu_z = NULL;
|
||||
bPoseChannel *pchan = pfl->pchan;
|
||||
LinkData *ld = NULL;
|
||||
char *path = NULL;
|
||||
float cframe;
|
||||
|
||||
/* get the path to use - this should be quaternion rotations only (needs care) */
|
||||
path= BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
|
||||
path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion");
|
||||
|
||||
/* get the current frame number */
|
||||
cframe= (float)pso->cframe;
|
||||
cframe = (float)pso->cframe;
|
||||
|
||||
/* using this path, find each matching F-Curve for the variables we're interested in */
|
||||
while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
|
||||
FCurve *fcu= (FCurve *)ld->data;
|
||||
while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) {
|
||||
FCurve *fcu = (FCurve *)ld->data;
|
||||
|
||||
/* assign this F-Curve to one of the relevant pointers... */
|
||||
switch (fcu->array_index) {
|
||||
case 3: /* z */
|
||||
fcu_z= fcu;
|
||||
fcu_z = fcu;
|
||||
break;
|
||||
case 2: /* y */
|
||||
fcu_y= fcu;
|
||||
fcu_y = fcu;
|
||||
break;
|
||||
case 1: /* x */
|
||||
fcu_x= fcu;
|
||||
fcu_x = fcu;
|
||||
break;
|
||||
case 0: /* w */
|
||||
fcu_w= fcu;
|
||||
fcu_w = fcu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -428,18 +428,18 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl)
|
||||
}
|
||||
else {
|
||||
float quat_interp[4], quat_orig[4];
|
||||
int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed
|
||||
|
||||
/* perform this blending several times until a satisfactory result is reached */
|
||||
while (iters-- > 0) {
|
||||
/* calculate the interpolation between the endpoints */
|
||||
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame));
|
||||
interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame));
|
||||
|
||||
/* make a copy of the original rotation */
|
||||
copy_qt_qt(quat_orig, pchan->quat);
|
||||
|
||||
/* tricky interpolations - blending between original and new */
|
||||
interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f);
|
||||
interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,13 +461,13 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
|
||||
}
|
||||
|
||||
/* for each link, handle each set of transforms */
|
||||
for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) {
|
||||
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
|
||||
/* valid transforms for each PoseChannel should have been noted already
|
||||
* - sliding the pose should be a straightforward exercise for location+rotation,
|
||||
* but rotations get more complicated since we may want to use quaternion blending
|
||||
* for quaternions instead...
|
||||
*/
|
||||
bPoseChannel *pchan= pfl->pchan;
|
||||
bPoseChannel *pchan = pfl->pchan;
|
||||
|
||||
if (pchan->flag & POSE_LOC) {
|
||||
/* calculate these for the 'location' vector, and use location curves */
|
||||
@@ -505,14 +505,14 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso)
|
||||
}
|
||||
|
||||
/* perform autokeyframing after changes were made + confirmed */
|
||||
static void pose_slide_autoKeyframe (bContext *C, tPoseSlideOp *pso)
|
||||
static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso)
|
||||
{
|
||||
/* wrapper around the generic call */
|
||||
poseAnim_mapping_autoKeyframe(C, pso->scene, pso->ob, &pso->pfLinks, (float)pso->cframe);
|
||||
}
|
||||
|
||||
/* reset changes made to current pose */
|
||||
static void pose_slide_reset (tPoseSlideOp *pso)
|
||||
static void pose_slide_reset(tPoseSlideOp *pso)
|
||||
{
|
||||
/* wrapper around the generic call, so that custom stuff can be added later */
|
||||
poseAnim_mapping_reset(&pso->pfLinks);
|
||||
@@ -521,7 +521,7 @@ static void pose_slide_reset (tPoseSlideOp *pso)
|
||||
/* ------------------------------------ */
|
||||
|
||||
/* draw percentage indicator in header */
|
||||
static void pose_slide_draw_status (tPoseSlideOp *pso)
|
||||
static void pose_slide_draw_status(tPoseSlideOp *pso)
|
||||
{
|
||||
char status_str[32];
|
||||
char mode_str[32];
|
||||
@@ -543,24 +543,24 @@ static void pose_slide_draw_status (tPoseSlideOp *pso)
|
||||
break;
|
||||
}
|
||||
|
||||
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
|
||||
BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage * 100.0f));
|
||||
ED_area_headerprint(pso->sa, status_str);
|
||||
}
|
||||
|
||||
/* common code for invoke() methods */
|
||||
static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso)
|
||||
static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
|
||||
{
|
||||
tPChanFCurveLink *pfl;
|
||||
AnimData *adt= pso->ob->adt;
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
AnimData *adt = pso->ob->adt;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
/* for each link, add all its keyframes to the search tree */
|
||||
for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) {
|
||||
for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) {
|
||||
LinkData *ld;
|
||||
|
||||
/* do this for each F-Curve */
|
||||
for (ld= pfl->fcurves.first; ld; ld= ld->next) {
|
||||
FCurve *fcu= (FCurve *)ld->data;
|
||||
for (ld = pfl->fcurves.first; ld; ld = ld->next) {
|
||||
FCurve *fcu = (FCurve *)ld->data;
|
||||
fcurve_to_keylist(adt, fcu, &pso->keys, NULL);
|
||||
}
|
||||
}
|
||||
@@ -568,34 +568,34 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *
|
||||
/* consolidate these keyframes, and figure out the nearest ones */
|
||||
BLI_dlrbTree_linkedlist_sync(&pso->keys);
|
||||
|
||||
/* cancel if no keyframes found... */
|
||||
/* cancel if no keyframes found... */
|
||||
if (pso->keys.root) {
|
||||
ActKeyColumn *ak;
|
||||
float cframe= (float)pso->cframe;
|
||||
float cframe = (float)pso->cframe;
|
||||
|
||||
/* firstly, check if the current frame is a keyframe... */
|
||||
ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
|
||||
if (ak == NULL) {
|
||||
/* current frame is not a keyframe, so search */
|
||||
ActKeyColumn *pk= (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
ActKeyColumn *nk= (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe);
|
||||
|
||||
/* new set the frames */
|
||||
/* prev frame */
|
||||
pso->prevFrame= (pk)? (pk->cfra) : (pso->cframe - 1);
|
||||
/* prev frame */
|
||||
pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1);
|
||||
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
|
||||
/* next frame */
|
||||
pso->nextFrame= (nk)? (nk->cfra) : (pso->cframe + 1);
|
||||
/* next frame */
|
||||
pso->nextFrame = (nk) ? (nk->cfra) : (pso->cframe + 1);
|
||||
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
|
||||
}
|
||||
else {
|
||||
/* current frame itself is a keyframe, so just take keyframes on either side */
|
||||
/* prev frame */
|
||||
pso->prevFrame= (ak->prev)? (ak->prev->cfra) : (pso->cframe - 1);
|
||||
/* prev frame */
|
||||
pso->prevFrame = (ak->prev) ? (ak->prev->cfra) : (pso->cframe - 1);
|
||||
RNA_int_set(op->ptr, "prev_frame", pso->prevFrame);
|
||||
/* next frame */
|
||||
pso->nextFrame= (ak->next)? (ak->next->cfra) : (pso->cframe + 1);
|
||||
/* next frame */
|
||||
pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1);
|
||||
RNA_int_set(op->ptr, "next_frame", pso->nextFrame);
|
||||
}
|
||||
}
|
||||
@@ -624,13 +624,13 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *
|
||||
}
|
||||
|
||||
/* common code for modal() */
|
||||
static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int pose_slide_modal(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
tPoseSlideOp *pso= op->customdata;
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
tPoseSlideOp *pso = op->customdata;
|
||||
wmWindow *win = CTX_wm_window(C);
|
||||
|
||||
switch (evt->type) {
|
||||
case LEFTMOUSE: /* confirm */
|
||||
case LEFTMOUSE: /* confirm */
|
||||
{
|
||||
/* return to normal cursor and header status */
|
||||
ED_area_headerprint(pso->sa, NULL);
|
||||
@@ -644,7 +644,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
case ESCKEY: /* cancel */
|
||||
case ESCKEY: /* cancel */
|
||||
case RIGHTMOUSE:
|
||||
{
|
||||
/* return to normal cursor and header status */
|
||||
@@ -669,7 +669,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
/* calculate percentage based on position of mouse (we only use x-axis for now.
|
||||
* since this is more convenient for users to do), and store new percentage value
|
||||
*/
|
||||
pso->percentage= (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx);
|
||||
pso->percentage = (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx);
|
||||
RNA_float_set(op->ptr, "percentage", pso->percentage);
|
||||
|
||||
/* update percentage indicator in header */
|
||||
@@ -681,11 +681,11 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
/* apply... */
|
||||
pose_slide_apply(C, pso);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default: /* unhandled event (maybe it was some view manip? */
|
||||
/* allow to pass through */
|
||||
return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH;
|
||||
return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
/* still running... */
|
||||
@@ -693,7 +693,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
}
|
||||
|
||||
/* common code for cancel() */
|
||||
static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op)
|
||||
static int pose_slide_cancel(bContext *UNUSED(C), wmOperator *op)
|
||||
{
|
||||
/* cleanup and done */
|
||||
pose_slide_exit(op);
|
||||
@@ -701,7 +701,7 @@ static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op)
|
||||
}
|
||||
|
||||
/* common code for exec() methods */
|
||||
static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *pso)
|
||||
static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso)
|
||||
{
|
||||
/* settings should have been set up ok for applying, so just apply! */
|
||||
pose_slide_apply(C, pso);
|
||||
@@ -716,7 +716,7 @@ static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *ps
|
||||
}
|
||||
|
||||
/* common code for defining RNA properties */
|
||||
static void pose_slide_opdef_properties (wmOperatorType *ot)
|
||||
static void pose_slide_opdef_properties(wmOperatorType *ot)
|
||||
{
|
||||
RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50);
|
||||
RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50);
|
||||
@@ -726,7 +726,7 @@ static void pose_slide_opdef_properties (wmOperatorType *ot)
|
||||
/* ------------------------------------ */
|
||||
|
||||
/* invoke() - for 'push' mode */
|
||||
static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
static int pose_slide_push_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -736,14 +736,14 @@ static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common setup work */
|
||||
return pose_slide_invoke_common(C, op, pso);
|
||||
}
|
||||
|
||||
/* exec() - for push */
|
||||
static int pose_slide_push_exec (bContext *C, wmOperator *op)
|
||||
static int pose_slide_push_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -753,7 +753,7 @@ static int pose_slide_push_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common exec work */
|
||||
return pose_slide_exec_common(C, op, pso);
|
||||
@@ -774,7 +774,7 @@ void POSE_OT_push(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* Properties */
|
||||
pose_slide_opdef_properties(ot);
|
||||
@@ -783,7 +783,7 @@ void POSE_OT_push(wmOperatorType *ot)
|
||||
/* ........................ */
|
||||
|
||||
/* invoke() - for 'relax' mode */
|
||||
static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
static int pose_slide_relax_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -793,14 +793,14 @@ static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common setup work */
|
||||
return pose_slide_invoke_common(C, op, pso);
|
||||
}
|
||||
|
||||
/* exec() - for relax */
|
||||
static int pose_slide_relax_exec (bContext *C, wmOperator *op)
|
||||
static int pose_slide_relax_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -810,7 +810,7 @@ static int pose_slide_relax_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common exec work */
|
||||
return pose_slide_exec_common(C, op, pso);
|
||||
@@ -831,7 +831,7 @@ void POSE_OT_relax(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* Properties */
|
||||
pose_slide_opdef_properties(ot);
|
||||
@@ -840,7 +840,7 @@ void POSE_OT_relax(wmOperatorType *ot)
|
||||
/* ........................ */
|
||||
|
||||
/* invoke() - for 'breakdown' mode */
|
||||
static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -850,14 +850,14 @@ static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UN
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common setup work */
|
||||
return pose_slide_invoke_common(C, op, pso);
|
||||
}
|
||||
|
||||
/* exec() - for breakdown */
|
||||
static int pose_slide_breakdown_exec (bContext *C, wmOperator *op)
|
||||
static int pose_slide_breakdown_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseSlideOp *pso;
|
||||
|
||||
@@ -867,7 +867,7 @@ static int pose_slide_breakdown_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else
|
||||
pso= op->customdata;
|
||||
pso = op->customdata;
|
||||
|
||||
/* do common exec work */
|
||||
return pose_slide_exec_common(C, op, pso);
|
||||
@@ -888,7 +888,7 @@ void POSE_OT_breakdown(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* Properties */
|
||||
pose_slide_opdef_properties(ot);
|
||||
@@ -899,18 +899,18 @@ void POSE_OT_breakdown(wmOperatorType *ot)
|
||||
|
||||
/* "termination conditions" - i.e. when we stop */
|
||||
typedef enum ePosePropagate_Termination {
|
||||
/* stop after the current hold ends */
|
||||
/* stop after the current hold ends */
|
||||
POSE_PROPAGATE_SMART_HOLDS = 0,
|
||||
/* only do on the last keyframe */
|
||||
/* only do on the last keyframe */
|
||||
POSE_PROPAGATE_LAST_KEY,
|
||||
/* stop after the next keyframe */
|
||||
/* stop after the next keyframe */
|
||||
POSE_PROPAGATE_NEXT_KEY,
|
||||
/* stop after the specified frame */
|
||||
/* stop after the specified frame */
|
||||
POSE_PROPAGATE_BEFORE_FRAME,
|
||||
/* stop when we run out of keyframes */
|
||||
/* stop when we run out of keyframes */
|
||||
POSE_PROPAGATE_BEFORE_END,
|
||||
|
||||
/* only do on the frames where markers are selected */
|
||||
/* only do on the frames where markers are selected */
|
||||
POSE_PROPAGATE_SELECTED_MARKERS
|
||||
} ePosePropagate_Termination;
|
||||
|
||||
@@ -927,15 +927,15 @@ typedef union tPosePropagate_ModeData {
|
||||
|
||||
/* get frame on which the "hold" for the bone ends
|
||||
* XXX: this may not really work that well if a bone moves on some channels and not others
|
||||
* if this happens to be a major issue, scrap this, and just make this happen
|
||||
* if this happens to be a major issue, scrap this, and just make this happen
|
||||
* independently per F-Curve
|
||||
*/
|
||||
static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *pfl, float startFrame)
|
||||
static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *pfl, float startFrame)
|
||||
{
|
||||
DLRBT_Tree keys, blocks;
|
||||
ActKeyBlock *ab;
|
||||
|
||||
AnimData *adt= ob->adt;
|
||||
AnimData *adt = ob->adt;
|
||||
LinkData *ld;
|
||||
float endFrame = startFrame;
|
||||
|
||||
@@ -958,8 +958,8 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *
|
||||
|
||||
if (actkeyblock_is_valid(ab, &keys) == 0) {
|
||||
/* There are only two cases for no-exact match:
|
||||
* 1) the current frame is just before another key but not on a key itself
|
||||
* 2) the current frame is on a key, but that key doesn't link to the next
|
||||
* 1) the current frame is just before another key but not on a key itself
|
||||
* 2) the current frame is on a key, but that key doesn't link to the next
|
||||
*
|
||||
* If we've got the first case, then we can search for another block,
|
||||
* otherwise forget it, as we'd be overwriting some valid data.
|
||||
@@ -1025,11 +1025,11 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *
|
||||
}
|
||||
|
||||
/* get reference value from F-Curve using RNA */
|
||||
static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value)
|
||||
static short pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value)
|
||||
{
|
||||
PointerRNA id_ptr, ptr;
|
||||
PropertyRNA *prop;
|
||||
short found= FALSE;
|
||||
short found = FALSE;
|
||||
|
||||
/* base pointer is always the object -> id_ptr */
|
||||
RNA_id_pointer_create(&ob->id, &id_ptr);
|
||||
@@ -1039,41 +1039,41 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value)
|
||||
if (RNA_property_array_check(prop)) {
|
||||
/* array */
|
||||
if (fcu->array_index < RNA_property_array_length(&ptr, prop)) {
|
||||
found= TRUE;
|
||||
found = TRUE;
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
*value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index);
|
||||
*value = (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index);
|
||||
break;
|
||||
case PROP_INT:
|
||||
*value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index);
|
||||
*value = (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
*value= RNA_property_float_get_index(&ptr, prop, fcu->array_index);
|
||||
*value = RNA_property_float_get_index(&ptr, prop, fcu->array_index);
|
||||
break;
|
||||
default:
|
||||
found= FALSE;
|
||||
found = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* not an array */
|
||||
found= TRUE;
|
||||
found = TRUE;
|
||||
switch (RNA_property_type(prop)) {
|
||||
case PROP_BOOLEAN:
|
||||
*value= (float)RNA_property_boolean_get(&ptr, prop);
|
||||
*value = (float)RNA_property_boolean_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_INT:
|
||||
*value= (float)RNA_property_int_get(&ptr, prop);
|
||||
*value = (float)RNA_property_int_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_ENUM:
|
||||
*value= (float)RNA_property_enum_get(&ptr, prop);
|
||||
*value = (float)RNA_property_enum_get(&ptr, prop);
|
||||
break;
|
||||
case PROP_FLOAT:
|
||||
*value= RNA_property_float_get(&ptr, prop);
|
||||
*value = RNA_property_float_get(&ptr, prop);
|
||||
break;
|
||||
default:
|
||||
found= FALSE;
|
||||
found = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1083,8 +1083,8 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value)
|
||||
}
|
||||
|
||||
/* propagate just works along each F-Curve in turn */
|
||||
static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
|
||||
float startFrame, tPosePropagate_ModeData modeData)
|
||||
static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu,
|
||||
float startFrame, tPosePropagate_ModeData modeData)
|
||||
{
|
||||
const int mode = RNA_enum_get(op->ptr, "mode");
|
||||
|
||||
@@ -1092,7 +1092,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
|
||||
float refVal = 0.0f;
|
||||
short keyExists;
|
||||
int i, match;
|
||||
short first=1;
|
||||
short first = 1;
|
||||
|
||||
/* skip if no keyframes to edit */
|
||||
if ((fcu->bezt == NULL) || (fcu->totvert < 2))
|
||||
@@ -1102,13 +1102,13 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
|
||||
* doesn't need to firstly keyframe the pose (though this doesn't mean that
|
||||
* they can't either)
|
||||
*/
|
||||
if ( !pose_propagate_get_refVal(ob, fcu, &refVal))
|
||||
if (!pose_propagate_get_refVal(ob, fcu, &refVal))
|
||||
return;
|
||||
|
||||
/* find the first keyframe to start propagating from
|
||||
* - if there's a keyframe on the current frame, we probably want to save this value there too
|
||||
* since it may be as of yet unkeyed
|
||||
* - if starting before the starting frame, don't touch the key, as it may have had some valid
|
||||
* - if starting before the starting frame, don't touch the key, as it may have had some valid
|
||||
* values
|
||||
*/
|
||||
match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists);
|
||||
@@ -1132,7 +1132,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
|
||||
}
|
||||
else if (mode == POSE_PROPAGATE_LAST_KEY) {
|
||||
/* only affect this frame if it will be the last one */
|
||||
if (i != (fcu->totvert-1))
|
||||
if (i != (fcu->totvert - 1))
|
||||
continue;
|
||||
}
|
||||
else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) {
|
||||
@@ -1162,11 +1162,11 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu,
|
||||
|
||||
/* --------------------------------- */
|
||||
|
||||
static int pose_propagate_exec (bContext *C, wmOperator *op)
|
||||
static int pose_propagate_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bAction *act= (ob && ob->adt)? ob->adt->action : NULL;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bAction *act = (ob && ob->adt) ? ob->adt->action : NULL;
|
||||
|
||||
ListBase pflinks = {NULL, NULL};
|
||||
tPChanFCurveLink *pfl;
|
||||
@@ -1210,7 +1210,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* go through propagating pose to keyframes, curve by curve */
|
||||
for (ld = pfl->fcurves.first; ld; ld= ld->next)
|
||||
for (ld = pfl->fcurves.first; ld; ld = ld->next)
|
||||
pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData);
|
||||
}
|
||||
|
||||
@@ -1230,7 +1230,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op)
|
||||
|
||||
void POSE_OT_propagate(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem terminate_items[]= {
|
||||
static EnumPropertyItem terminate_items[] = {
|
||||
{POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held", "Propagate pose to all keyframes after current frame that don't change (Default behavior)"},
|
||||
{POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe", "Propagate pose to first keyframe following the current frame only"},
|
||||
{POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "To Last Keyframe", "Propagate pose to the last keyframe only (i.e. making action cyclic)"},
|
||||
@@ -1249,7 +1249,7 @@ void POSE_OT_propagate(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode; // XXX: needs selected bones!
|
||||
|
||||
/* flag */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
// TODO: add "fade out" control for tapering off amount of propagation as time goes by?
|
||||
|
||||
@@ -79,25 +79,25 @@
|
||||
/* FCurves <-> PoseChannels Links */
|
||||
|
||||
/* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */
|
||||
static void fcurves_to_pchan_links_get (ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan)
|
||||
static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan)
|
||||
{
|
||||
ListBase curves = {NULL, NULL};
|
||||
int transFlags = action_get_item_transforms(act, ob, pchan, &curves);
|
||||
|
||||
pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
|
||||
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE);
|
||||
|
||||
/* check if any transforms found... */
|
||||
if (transFlags) {
|
||||
/* make new linkage data */
|
||||
tPChanFCurveLink *pfl= MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink");
|
||||
tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink");
|
||||
PointerRNA ptr;
|
||||
|
||||
pfl->fcurves= curves;
|
||||
pfl->pchan= pchan;
|
||||
pfl->fcurves = curves;
|
||||
pfl->pchan = pchan;
|
||||
|
||||
/* get the RNA path to this pchan - this needs to be freed! */
|
||||
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
|
||||
pfl->pchan_path= RNA_path_from_ID_to_struct(&ptr);
|
||||
pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr);
|
||||
|
||||
/* add linkage data to operator data */
|
||||
BLI_addtail(pfLinks, pfl);
|
||||
@@ -131,7 +131,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
|
||||
/* for each Pose-Channel which gets affected, get the F-Curves for that channel
|
||||
* and set the relevant transform flags...
|
||||
*/
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
|
||||
* i.e. if nothing selected, do whole pose
|
||||
*/
|
||||
if (pfLinks->first == NULL) {
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
|
||||
}
|
||||
@@ -152,11 +152,11 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
|
||||
/* free F-Curve <-> PoseChannel links */
|
||||
void poseAnim_mapping_free(ListBase *pfLinks)
|
||||
{
|
||||
tPChanFCurveLink *pfl, *pfln=NULL;
|
||||
tPChanFCurveLink *pfl, *pfln = NULL;
|
||||
|
||||
/* free the temp pchan links and their data */
|
||||
for (pfl= pfLinks->first; pfl; pfl= pfln) {
|
||||
pfln= pfl->next;
|
||||
for (pfl = pfLinks->first; pfl; pfl = pfln) {
|
||||
pfln = pfl->next;
|
||||
|
||||
/* free custom properties */
|
||||
if (pfl->oldprops) {
|
||||
@@ -180,19 +180,19 @@ void poseAnim_mapping_free(ListBase *pfLinks)
|
||||
/* helper for apply() / reset() - refresh the data */
|
||||
void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob)
|
||||
{
|
||||
bArmature *arm= (bArmature *)ob->data;
|
||||
bArmature *arm = (bArmature *)ob->data;
|
||||
|
||||
/* old optimize trick... this enforces to bypass the depgraph
|
||||
* - note: code copied from transform_generics.c -> recalcData()
|
||||
*/
|
||||
// FIXME: shouldn't this use the builtin stuff?
|
||||
if ((arm->flag & ARM_DELAYDEFORM)==0)
|
||||
if ((arm->flag & ARM_DELAYDEFORM) == 0)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
|
||||
else
|
||||
BKE_pose_where_is(scene, ob);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
}
|
||||
|
||||
/* reset changes made to current pose */
|
||||
@@ -201,8 +201,8 @@ void poseAnim_mapping_reset(ListBase *pfLinks)
|
||||
tPChanFCurveLink *pfl;
|
||||
|
||||
/* iterate over each pose-channel affected, restoring all channels to their original values */
|
||||
for (pfl= pfLinks->first; pfl; pfl= pfl->next) {
|
||||
bPoseChannel *pchan= pfl->pchan;
|
||||
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
|
||||
bPoseChannel *pchan = pfl->pchan;
|
||||
|
||||
/* just copy all the values over regardless of whether they changed or not */
|
||||
copy_v3_v3(pchan->loc, pfl->oldloc);
|
||||
@@ -231,8 +231,8 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
|
||||
/* XXX: here we already have the information about what transforms exist, though
|
||||
* it might be easier to just overwrite all using normal mechanisms
|
||||
*/
|
||||
for (pfl= pfLinks->first; pfl; pfl= pfl->next) {
|
||||
bPoseChannel *pchan= pfl->pchan;
|
||||
for (pfl = pfLinks->first; pfl; pfl = pfl->next) {
|
||||
bPoseChannel *pchan = pfl->pchan;
|
||||
|
||||
/* add datasource override for the PoseChannel, to be used later */
|
||||
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
|
||||
@@ -262,14 +262,14 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa
|
||||
/* find the next F-Curve for a PoseChannel with matching path...
|
||||
* - path is not just the pfl rna_path, since that path doesn't have property info yet
|
||||
*/
|
||||
LinkData *poseAnim_mapping_getNextFCurve (ListBase *fcuLinks, LinkData *prev, const char *path)
|
||||
LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path)
|
||||
{
|
||||
LinkData *first= (prev)? prev->next : (fcuLinks)? fcuLinks->first : NULL;
|
||||
LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL;
|
||||
LinkData *ld;
|
||||
|
||||
/* check each link to see if the linked F-Curve has a matching path */
|
||||
for (ld= first; ld; ld= ld->next) {
|
||||
FCurve *fcu= (FCurve *)ld->data;
|
||||
for (ld = first; ld; ld = ld->next) {
|
||||
FCurve *fcu = (FCurve *)ld->data;
|
||||
|
||||
/* check if paths match */
|
||||
if (strcmp(path, fcu->rna_path) == 0)
|
||||
|
||||
@@ -89,9 +89,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
|
||||
/* == POSE-LIBRARY TOOL FOR BLENDER ==
|
||||
*
|
||||
* Overview:
|
||||
* This tool allows animators to store a set of frequently used poses to dump into
|
||||
* the active action to help in "budget" productions to quickly block out new actions.
|
||||
* It acts as a kind of "glorified clipboard for poses", allowing for naming of poses.
|
||||
* This tool allows animators to store a set of frequently used poses to dump into
|
||||
* the active action to help in "budget" productions to quickly block out new actions.
|
||||
* It acts as a kind of "glorified clipboard for poses", allowing for naming of poses.
|
||||
*
|
||||
* Features:
|
||||
* - PoseLibs are simply normal Actions
|
||||
@@ -108,10 +108,10 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS
|
||||
/* gets the first available frame in poselib to store a pose on
|
||||
* - frames start from 1, and a pose should occur on every frame... 0 is error!
|
||||
*/
|
||||
static int poselib_get_free_index (bAction *act)
|
||||
static int poselib_get_free_index(bAction *act)
|
||||
{
|
||||
TimeMarker *marker;
|
||||
int low=0, high=0;
|
||||
int low = 0, high = 0;
|
||||
short changed = 0;
|
||||
|
||||
/* sanity checks */
|
||||
@@ -124,7 +124,7 @@ static int poselib_get_free_index (bAction *act)
|
||||
do {
|
||||
changed = 0;
|
||||
|
||||
for (marker= act->markers.first; marker; marker= marker->next) {
|
||||
for (marker = act->markers.first; marker; marker = marker->next) {
|
||||
/* only increase low if value is 1 greater than low, to find "gaps" where
|
||||
* poses were removed from the poselib
|
||||
*/
|
||||
@@ -135,7 +135,7 @@ static int poselib_get_free_index (bAction *act)
|
||||
|
||||
/* value replaces high if it is the highest value encountered yet */
|
||||
if (marker->frame > high) {
|
||||
high= marker->frame;
|
||||
high = marker->frame;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
@@ -151,17 +151,17 @@ static int poselib_get_free_index (bAction *act)
|
||||
}
|
||||
|
||||
/* returns the active pose for a poselib */
|
||||
static TimeMarker *poselib_get_active_pose (bAction *act)
|
||||
static TimeMarker *poselib_get_active_pose(bAction *act)
|
||||
{
|
||||
if ((act) && (act->active_marker))
|
||||
return BLI_findlink(&act->markers, act->active_marker-1);
|
||||
return BLI_findlink(&act->markers, act->active_marker - 1);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Get object that Pose Lib should be found on */
|
||||
/* XXX C can be zero */
|
||||
static Object *get_poselib_object (bContext *C)
|
||||
/* XXX C can be zero */
|
||||
static Object *get_poselib_object(bContext *C)
|
||||
{
|
||||
ScrArea *sa;
|
||||
|
||||
@@ -178,7 +178,7 @@ static Object *get_poselib_object (bContext *C)
|
||||
}
|
||||
|
||||
/* Poll callback for operators that require existing PoseLib data (with poses) to work */
|
||||
static int has_poselib_pose_data_poll (bContext *C)
|
||||
static int has_poselib_pose_data_poll(bContext *C)
|
||||
{
|
||||
Object *ob = get_poselib_object(C);
|
||||
return (ob && ob->poselib);
|
||||
@@ -187,7 +187,7 @@ static int has_poselib_pose_data_poll (bContext *C)
|
||||
/* ----------------------------------- */
|
||||
|
||||
/* Initialize a new poselib (whether it is needed or not) */
|
||||
static bAction *poselib_init_new (Object *ob)
|
||||
static bAction *poselib_init_new(Object *ob)
|
||||
{
|
||||
/* sanity checks - only for armatures */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
@@ -196,13 +196,13 @@ static bAction *poselib_init_new (Object *ob)
|
||||
/* init object's poselib action (unlink old one if there) */
|
||||
if (ob->poselib)
|
||||
id_us_min(&ob->poselib->id);
|
||||
ob->poselib= add_empty_action("PoseLib");
|
||||
ob->poselib = add_empty_action("PoseLib");
|
||||
|
||||
return ob->poselib;
|
||||
}
|
||||
|
||||
/* Initialize a new poselib (checks if that needs to happen) */
|
||||
static bAction *poselib_validate (Object *ob)
|
||||
static bAction *poselib_validate(Object *ob)
|
||||
{
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return NULL;
|
||||
@@ -215,7 +215,7 @@ static bAction *poselib_validate (Object *ob)
|
||||
/* ************************************************************* */
|
||||
/* Pose Lib UI Operators */
|
||||
|
||||
static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = get_poselib_object(C);
|
||||
|
||||
@@ -227,7 +227,7 @@ static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
poselib_init_new(ob);
|
||||
|
||||
/* notifier here might evolve? */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -244,12 +244,12 @@ void POSELIB_OT_new(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ */
|
||||
|
||||
static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = get_poselib_object(C);
|
||||
|
||||
@@ -262,7 +262,7 @@ static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
ob->poselib = NULL;
|
||||
|
||||
/* notifier here might evolve? */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -279,7 +279,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************************************************* */
|
||||
@@ -288,10 +288,10 @@ void POSELIB_OT_unlink(wmOperatorType *ot)
|
||||
/* This tool automagically generates/validates poselib data so that it corresponds to the data
|
||||
* in the action. This is for use in making existing actions usable as poselibs.
|
||||
*/
|
||||
static int poselib_sanitise_exec (bContext *C, wmOperator *op)
|
||||
static int poselib_sanitise_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = (ob)? ob->poselib : NULL;
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
DLRBT_Tree keys;
|
||||
ActKeyColumn *ak;
|
||||
TimeMarker *marker, *markern;
|
||||
@@ -304,14 +304,14 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* determine which frames have keys */
|
||||
BLI_dlrbTree_init(&keys);
|
||||
action_to_keylist(NULL, act, &keys, NULL);
|
||||
action_to_keylist(NULL, act, &keys, NULL);
|
||||
BLI_dlrbTree_linkedlist_sync(&keys);
|
||||
|
||||
/* for each key, make sure there is a corresponding pose */
|
||||
for (ak= keys.first; ak; ak= ak->next) {
|
||||
for (ak = keys.first; ak; ak = ak->next) {
|
||||
/* check if any pose matches this */
|
||||
// TODO: don't go looking through the list like this every time...
|
||||
for (marker= act->markers.first; marker; marker= marker->next) {
|
||||
for (marker = act->markers.first; marker; marker = marker->next) {
|
||||
if (IS_EQ(marker->frame, (double)ak->cfra)) {
|
||||
marker->flag = -1;
|
||||
break;
|
||||
@@ -321,20 +321,20 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op)
|
||||
/* add new if none found */
|
||||
if (marker == NULL) {
|
||||
/* add pose to poselib */
|
||||
marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker");
|
||||
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
|
||||
|
||||
BLI_strncpy(marker->name, "Pose", sizeof(marker->name));
|
||||
|
||||
marker->frame= (int)ak->cfra;
|
||||
marker->flag= -1;
|
||||
marker->frame = (int)ak->cfra;
|
||||
marker->flag = -1;
|
||||
|
||||
BLI_addtail(&act->markers, marker);
|
||||
}
|
||||
}
|
||||
|
||||
/* remove all untagged poses (unused), and remove all tags */
|
||||
for (marker= act->markers.first; marker; marker= markern) {
|
||||
markern= marker->next;
|
||||
for (marker = act->markers.first; marker; marker = markern) {
|
||||
markern = marker->next;
|
||||
|
||||
if (marker->flag != -1)
|
||||
BLI_freelinkN(&act->markers, marker);
|
||||
@@ -348,7 +348,7 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op)
|
||||
/* send notifiers for this - using keyframe editing notifiers, since action
|
||||
* may be being shown in anim editors as active action
|
||||
*/
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -365,15 +365,15 @@ void POSELIB_OT_action_sanitise(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ------------------------------------------ */
|
||||
|
||||
static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *UNUSED(arg))
|
||||
static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg))
|
||||
{
|
||||
Object *ob= get_poselib_object(C);
|
||||
bAction *act= ob->poselib; /* never NULL */
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = ob->poselib; /* never NULL */
|
||||
TimeMarker *marker;
|
||||
|
||||
wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1);
|
||||
@@ -384,7 +384,7 @@ 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) {
|
||||
for (marker = act->markers.first; marker; marker = marker->next) {
|
||||
PointerRNA props_ptr;
|
||||
|
||||
props_ptr = uiItemFullO_ptr(layout, ot,
|
||||
@@ -396,11 +396,11 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout,
|
||||
}
|
||||
}
|
||||
|
||||
static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
static int poselib_add_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= get_poselib_object(C);
|
||||
bPose *pose= (ob) ? ob->pose : NULL;
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = get_poselib_object(C);
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
|
||||
@@ -409,8 +409,8 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* start building */
|
||||
pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout= uiPupMenuLayout(pup);
|
||||
pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout = uiPupMenuLayout(pup);
|
||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
|
||||
|
||||
/* add new (adds to the first unoccupied frame) */
|
||||
@@ -432,14 +432,14 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
}
|
||||
|
||||
|
||||
static int poselib_add_exec (bContext *C, wmOperator *op)
|
||||
static int poselib_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= get_poselib_object(C);
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = poselib_validate(ob);
|
||||
bPose *pose= (ob) ? ob->pose : NULL;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
TimeMarker *marker;
|
||||
KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/
|
||||
int frame= RNA_int_get(op->ptr, "frame");
|
||||
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/
|
||||
int frame = RNA_int_get(op->ptr, "frame");
|
||||
char name[64];
|
||||
|
||||
/* sanity check (invoke should have checked this anyway) */
|
||||
@@ -453,17 +453,17 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
|
||||
* - for the 'replace' option, this should end up finding the appropriate marker,
|
||||
* so no new one will be added
|
||||
*/
|
||||
for (marker= act->markers.first; marker; marker= marker->next) {
|
||||
for (marker = act->markers.first; marker; marker = marker->next) {
|
||||
if (marker->frame == frame) {
|
||||
BLI_strncpy(marker->name, name, sizeof(marker->name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (marker == NULL) {
|
||||
marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker");
|
||||
marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker");
|
||||
|
||||
BLI_strncpy(marker->name, name, sizeof(marker->name));
|
||||
marker->frame= frame;
|
||||
marker->frame = frame;
|
||||
|
||||
BLI_addtail(&act->markers, marker);
|
||||
}
|
||||
@@ -477,7 +477,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op)
|
||||
ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame);
|
||||
|
||||
/* store new 'active' pose number */
|
||||
act->active_marker= BLI_countlist(&act->markers);
|
||||
act->active_marker = BLI_countlist(&act->markers);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -496,7 +496,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX);
|
||||
@@ -511,9 +511,9 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
TimeMarker *marker;
|
||||
EnumPropertyItem *item= NULL, item_tmp= {0};
|
||||
int totitem= 0;
|
||||
int i= 0;
|
||||
EnumPropertyItem *item = NULL, item_tmp = {0};
|
||||
int totitem = 0;
|
||||
int i = 0;
|
||||
|
||||
if (C == NULL) {
|
||||
return DummyRNA_NULL_items;
|
||||
@@ -522,24 +522,24 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS
|
||||
/* check that the action exists */
|
||||
if (act) {
|
||||
/* add each marker to the list */
|
||||
for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) {
|
||||
item_tmp.identifier= item_tmp.name= marker->name;
|
||||
item_tmp.icon= ICON_ARMATURE_DATA;
|
||||
item_tmp.value= i;
|
||||
for (marker = act->markers.first, i = 0; marker; marker = marker->next, i++) {
|
||||
item_tmp.identifier = item_tmp.name = marker->name;
|
||||
item_tmp.icon = ICON_ARMATURE_DATA;
|
||||
item_tmp.value = i;
|
||||
RNA_enum_item_add(&item, &totitem, &item_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
RNA_enum_item_end(&item, &totitem);
|
||||
*free= 1;
|
||||
*free = 1;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
static int poselib_remove_exec (bContext *C, wmOperator *op)
|
||||
static int poselib_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= get_poselib_object(C);
|
||||
bAction *act= (ob) ? ob->poselib : NULL;
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
TimeMarker *marker;
|
||||
int marker_index;
|
||||
FCurve *fcu;
|
||||
@@ -567,12 +567,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* remove relevant keyframes */
|
||||
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
|
||||
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
||||
BezTriple *bezt;
|
||||
unsigned int i;
|
||||
|
||||
if (fcu->bezt) {
|
||||
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) {
|
||||
/* check if remove */
|
||||
if (IS_EQ(bezt->vec[1][0], marker->frame)) {
|
||||
delete_fcurve_key(fcu, i, 1);
|
||||
@@ -586,12 +586,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op)
|
||||
BLI_freelinkN(&act->markers, marker);
|
||||
|
||||
/* fix active pose number */
|
||||
act->active_marker= 0;
|
||||
act->active_marker = 0;
|
||||
|
||||
/* send notifiers for this - using keyframe editing notifiers, since action
|
||||
* may be being shown in anim editors as active action
|
||||
*/
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -612,7 +612,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove");
|
||||
@@ -620,10 +620,10 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot)
|
||||
ot->prop = prop;
|
||||
}
|
||||
|
||||
static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int poselib_rename_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
Object *ob= get_poselib_object(C);
|
||||
bAction *act= (ob) ? ob->poselib : NULL;
|
||||
Object *ob = get_poselib_object(C);
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
TimeMarker *marker;
|
||||
|
||||
/* check if valid poselib */
|
||||
@@ -633,14 +633,14 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
}
|
||||
|
||||
/* get index (and pointer) of pose to remove */
|
||||
marker= BLI_findlink(&act->markers, act->active_marker-1);
|
||||
marker = BLI_findlink(&act->markers, act->active_marker - 1);
|
||||
if (marker == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else {
|
||||
/* use the existing name of the marker as the name, and use the active marker as the one to rename */
|
||||
RNA_enum_set(op->ptr, "pose", act->active_marker-1);
|
||||
RNA_enum_set(op->ptr, "pose", act->active_marker - 1);
|
||||
RNA_string_set(op->ptr, "name", marker->name);
|
||||
}
|
||||
|
||||
@@ -648,10 +648,10 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
return WM_operator_props_popup(C, op, evt);
|
||||
}
|
||||
|
||||
static int poselib_rename_exec (bContext *C, wmOperator *op)
|
||||
static int poselib_rename_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bAction *act= (ob) ? ob->poselib : NULL;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bAction *act = (ob) ? ob->poselib : NULL;
|
||||
TimeMarker *marker;
|
||||
char newname[64];
|
||||
|
||||
@@ -662,7 +662,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* get index (and pointer) of pose to remove */
|
||||
marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
|
||||
marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose"));
|
||||
if (marker == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose");
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -678,7 +678,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op)
|
||||
/* send notifiers for this - using keyframe editing notifiers, since action
|
||||
* may be being shown in anim editors as active action
|
||||
*/
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -702,13 +702,13 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
|
||||
/* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */
|
||||
ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose");
|
||||
prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
|
||||
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
|
||||
prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename");
|
||||
RNA_def_enum_funcs(prop, poselib_stored_pose_itemf);
|
||||
}
|
||||
|
||||
/* ************************************************************* */
|
||||
@@ -716,31 +716,31 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot)
|
||||
|
||||
/* Simple struct for storing settings/data for use during PoseLib preview */
|
||||
typedef struct tPoseLib_PreviewData {
|
||||
ListBase backups; /* tPoseLib_Backup structs for restoring poses */
|
||||
ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */
|
||||
ListBase backups; /* tPoseLib_Backup structs for restoring poses */
|
||||
ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */
|
||||
|
||||
Scene *scene; /* active scene */
|
||||
ScrArea *sa; /* active area */
|
||||
Scene *scene; /* active scene */
|
||||
ScrArea *sa; /* active area */
|
||||
|
||||
PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */
|
||||
Object *ob; /* object to work on */
|
||||
bArmature *arm; /* object's armature data */
|
||||
bPose *pose; /* object's pose */
|
||||
bAction *act; /* poselib to use */
|
||||
TimeMarker *marker; /* 'active' pose */
|
||||
PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */
|
||||
Object *ob; /* object to work on */
|
||||
bArmature *arm; /* object's armature data */
|
||||
bPose *pose; /* object's pose */
|
||||
bAction *act; /* poselib to use */
|
||||
TimeMarker *marker; /* 'active' pose */
|
||||
|
||||
int selcount; /* number of selected elements to work on */
|
||||
int totcount; /* total number of elements to work on */
|
||||
|
||||
short state; /* state of main loop */
|
||||
short redraw; /* redraw/update settings during main loop */
|
||||
short flag; /* flags for various settings */
|
||||
|
||||
short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */
|
||||
char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */
|
||||
char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */
|
||||
|
||||
int selcount; /* number of selected elements to work on */
|
||||
int totcount; /* total number of elements to work on */
|
||||
|
||||
short state; /* state of main loop */
|
||||
short redraw; /* redraw/update settings during main loop */
|
||||
short flag; /* flags for various settings */
|
||||
|
||||
short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */
|
||||
char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */
|
||||
char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */
|
||||
|
||||
char headerstr[200]; /* Info-text to print in header */
|
||||
char headerstr[200]; /* Info-text to print in header */
|
||||
} tPoseLib_PreviewData;
|
||||
|
||||
/* defines for tPoseLib_PreviewData->state values */
|
||||
@@ -761,8 +761,8 @@ enum {
|
||||
|
||||
/* defines for tPoseLib_PreviewData->flag values */
|
||||
enum {
|
||||
PL_PREVIEW_FIRSTTIME = (1<<0),
|
||||
PL_PREVIEW_SHOWORIGINAL = (1<<1)
|
||||
PL_PREVIEW_FIRSTTIME = (1 << 0),
|
||||
PL_PREVIEW_SHOWORIGINAL = (1 << 1)
|
||||
};
|
||||
|
||||
/* ---------------------------- */
|
||||
@@ -771,35 +771,35 @@ enum {
|
||||
typedef struct tPoseLib_Backup {
|
||||
struct tPoseLib_Backup *next, *prev;
|
||||
|
||||
bPoseChannel *pchan; /* pose channel backups are for */
|
||||
bPoseChannel *pchan; /* pose channel backups are for */
|
||||
|
||||
bPoseChannel olddata; /* copy of pose channel's old data (at start) */
|
||||
IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */
|
||||
bPoseChannel olddata; /* copy of pose channel's old data (at start) */
|
||||
IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */
|
||||
} tPoseLib_Backup;
|
||||
|
||||
/* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */
|
||||
static void poselib_backup_posecopy (tPoseLib_PreviewData *pld)
|
||||
static void poselib_backup_posecopy(tPoseLib_PreviewData *pld)
|
||||
{
|
||||
bActionGroup *agrp;
|
||||
bPoseChannel *pchan;
|
||||
|
||||
/* for each posechannel that has an actionchannel in */
|
||||
for (agrp= pld->act->groups.first; agrp; agrp= agrp->next) {
|
||||
for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) {
|
||||
/* try to find posechannel */
|
||||
pchan= BKE_pose_channel_find_name(pld->pose, agrp->name);
|
||||
pchan = BKE_pose_channel_find_name(pld->pose, agrp->name);
|
||||
|
||||
/* backup data if available */
|
||||
if (pchan) {
|
||||
tPoseLib_Backup *plb;
|
||||
|
||||
/* store backup */
|
||||
plb= MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup");
|
||||
plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup");
|
||||
|
||||
plb->pchan= pchan;
|
||||
plb->pchan = pchan;
|
||||
memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel));
|
||||
|
||||
if (pchan->prop)
|
||||
plb->oldprops= IDP_CopyProperty(pchan->prop);
|
||||
plb->oldprops = IDP_CopyProperty(pchan->prop);
|
||||
|
||||
BLI_addtail(&pld->backups, plb);
|
||||
|
||||
@@ -812,11 +812,11 @@ static void poselib_backup_posecopy (tPoseLib_PreviewData *pld)
|
||||
}
|
||||
|
||||
/* Restores original pose */
|
||||
static void poselib_backup_restore (tPoseLib_PreviewData *pld)
|
||||
static void poselib_backup_restore(tPoseLib_PreviewData *pld)
|
||||
{
|
||||
tPoseLib_Backup *plb;
|
||||
|
||||
for (plb= pld->backups.first; plb; plb= plb->next) {
|
||||
for (plb = pld->backups.first; plb; plb = plb->next) {
|
||||
/* copy most of data straight back */
|
||||
memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel));
|
||||
|
||||
@@ -829,12 +829,12 @@ static void poselib_backup_restore (tPoseLib_PreviewData *pld)
|
||||
}
|
||||
|
||||
/* Free list of backups, including any side data it may use */
|
||||
static void poselib_backup_free_data (tPoseLib_PreviewData *pld)
|
||||
static void poselib_backup_free_data(tPoseLib_PreviewData *pld)
|
||||
{
|
||||
tPoseLib_Backup *plb, *plbn;
|
||||
|
||||
for (plb= pld->backups.first; plb; plb= plbn) {
|
||||
plbn= plb->next;
|
||||
for (plb = pld->backups.first; plb; plb = plbn) {
|
||||
plbn = plb->next;
|
||||
|
||||
/* free custom data */
|
||||
if (plb->oldprops) {
|
||||
@@ -852,48 +852,48 @@ static void poselib_backup_free_data (tPoseLib_PreviewData *pld)
|
||||
/* Applies the appropriate stored pose from the pose-library to the current pose
|
||||
* - assumes that a valid object, with a poselib has been supplied
|
||||
* - gets the string to print in the header
|
||||
* - this code is based on the code for extract_pose_from_action in blenkernel/action.c
|
||||
* - this code is based on the code for extract_pose_from_action in blenkernel/action.c
|
||||
*/
|
||||
static void poselib_apply_pose (tPoseLib_PreviewData *pld)
|
||||
static void poselib_apply_pose(tPoseLib_PreviewData *pld)
|
||||
{
|
||||
PointerRNA *ptr= &pld->rna_ptr;
|
||||
bArmature *arm= pld->arm;
|
||||
bPose *pose= pld->pose;
|
||||
PointerRNA *ptr = &pld->rna_ptr;
|
||||
bArmature *arm = pld->arm;
|
||||
bPose *pose = pld->pose;
|
||||
bPoseChannel *pchan;
|
||||
bAction *act= pld->act;
|
||||
bAction *act = pld->act;
|
||||
bActionGroup *agrp;
|
||||
|
||||
KeyframeEditData ked= {{NULL}};
|
||||
KeyframeEditData ked = {{NULL}};
|
||||
KeyframeEditFunc group_ok_cb;
|
||||
int frame= 1;
|
||||
int frame = 1;
|
||||
|
||||
/* get the frame */
|
||||
if (pld->marker)
|
||||
frame= pld->marker->frame;
|
||||
frame = pld->marker->frame;
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
/* init settings for testing groups for keyframes */
|
||||
group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
ked.f1= ((float)frame) - 0.5f;
|
||||
ked.f2= ((float)frame) + 0.5f;
|
||||
group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
ked.f1 = ((float)frame) - 0.5f;
|
||||
ked.f2 = ((float)frame) + 0.5f;
|
||||
|
||||
|
||||
/* start applying - only those channels which have a key at this point in time! */
|
||||
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
|
||||
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
||||
/* check if group has any keyframes */
|
||||
if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) {
|
||||
/* has keyframe on this frame, so try to get a PoseChannel with this name */
|
||||
pchan= BKE_pose_channel_find_name(pose, agrp->name);
|
||||
pchan = BKE_pose_channel_find_name(pose, agrp->name);
|
||||
|
||||
if (pchan) {
|
||||
short ok= 0;
|
||||
short ok = 0;
|
||||
|
||||
/* check if this bone should get any animation applied */
|
||||
if (pld->selcount == 0) {
|
||||
/* if no bones are selected, then any bone is ok */
|
||||
ok= 1;
|
||||
ok = 1;
|
||||
}
|
||||
else if (pchan->bone) {
|
||||
/* only ok if bone is visible and selected */
|
||||
@@ -913,11 +913,11 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
|
||||
}
|
||||
|
||||
/* Auto-keys/tags bones affected by the pose used from the poselib */
|
||||
static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData *pld)
|
||||
static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData *pld)
|
||||
{
|
||||
bPose *pose= pld->pose;
|
||||
bPose *pose = pld->pose;
|
||||
bPoseChannel *pchan;
|
||||
bAction *act= pld->act;
|
||||
bAction *act = pld->act;
|
||||
bActionGroup *agrp;
|
||||
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID);
|
||||
@@ -925,9 +925,9 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
|
||||
short autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id);
|
||||
|
||||
/* start tagging/keying */
|
||||
for (agrp= act->groups.first; agrp; agrp= agrp->next) {
|
||||
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
||||
/* only for selected bones unless there aren't any selected, in which case all are included */
|
||||
pchan= BKE_pose_channel_find_name(pose, agrp->name);
|
||||
pchan = BKE_pose_channel_find_name(pose, agrp->name);
|
||||
|
||||
if (pchan) {
|
||||
if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) {
|
||||
@@ -956,35 +956,35 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData
|
||||
}
|
||||
|
||||
/* send notifiers for this */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
|
||||
/* Apply the relevant changes to the pose */
|
||||
static void poselib_preview_apply (bContext *C, wmOperator *op)
|
||||
static void poselib_preview_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata;
|
||||
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
|
||||
|
||||
/* only recalc pose (and its dependencies) if pose has changed */
|
||||
if (pld->redraw == PL_PREVIEW_REDRAWALL) {
|
||||
/* don't clear pose if firsttime */
|
||||
if ((pld->flag & PL_PREVIEW_FIRSTTIME)==0)
|
||||
if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0)
|
||||
poselib_backup_restore(pld);
|
||||
else
|
||||
pld->flag &= ~PL_PREVIEW_FIRSTTIME;
|
||||
|
||||
/* pose should be the right one to draw (unless we're temporarily not showing it) */
|
||||
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL)==0) {
|
||||
if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) {
|
||||
RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker));
|
||||
poselib_apply_pose(pld);
|
||||
}
|
||||
else
|
||||
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
|
||||
RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */
|
||||
|
||||
/* old optimize trick... this enforces to bypass the depgraph
|
||||
* - note: code copied from transform_generics.c -> recalcData()
|
||||
*/
|
||||
// FIXME: shouldn't this use the builtin stuff?
|
||||
if ((pld->arm->flag & ARM_DELAYDEFORM)==0)
|
||||
if ((pld->arm->flag & ARM_DELAYDEFORM) == 0)
|
||||
DAG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */
|
||||
else
|
||||
BKE_pose_where_is(pld->scene, pld->ob);
|
||||
@@ -1004,12 +1004,12 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
|
||||
short index;
|
||||
|
||||
/* get search-string */
|
||||
index= pld->search_cursor;
|
||||
index = pld->search_cursor;
|
||||
|
||||
if (index >= 0 && index <= sizeof(tempstr) - 1) {
|
||||
memcpy(&tempstr[0], &pld->searchstr[0], index);
|
||||
tempstr[index]= '|';
|
||||
memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index);
|
||||
tempstr[index] = '|';
|
||||
memcpy(&tempstr[index + 1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
|
||||
@@ -1035,8 +1035,8 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* request drawing of view + clear redraw flag */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pld->ob);
|
||||
pld->redraw= PL_PREVIEW_NOREDRAW;
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob);
|
||||
pld->redraw = PL_PREVIEW_NOREDRAW;
|
||||
}
|
||||
|
||||
/* ---------------------------- */
|
||||
@@ -1044,7 +1044,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
|
||||
/* This helper function is called during poselib_preview_poses to find the
|
||||
* pose to preview next (after a change event)
|
||||
*/
|
||||
static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step)
|
||||
static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
|
||||
{
|
||||
/* stop if not going anywhere, as we assume that there is a direction to move in */
|
||||
if (step == 0)
|
||||
@@ -1061,91 +1061,91 @@ static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step)
|
||||
BLI_freelistN(&pld->searchp);
|
||||
|
||||
/* generate a new list of search matches */
|
||||
for (marker= pld->act->markers.first; marker; marker= marker->next) {
|
||||
for (marker = pld->act->markers.first; marker; marker = marker->next) {
|
||||
/* does the name partially match?
|
||||
* - don't worry about case, to make it easier for users to quickly input a name (or
|
||||
* - don't worry about case, to make it easier for users to quickly input a name (or
|
||||
* part of one), which is the whole point of this feature
|
||||
*/
|
||||
if (BLI_strcasestr(marker->name, pld->searchstr)) {
|
||||
/* make link-data to store reference to it */
|
||||
ld= MEM_callocN(sizeof(LinkData), "PoseMatch");
|
||||
ld->data= marker;
|
||||
ld = MEM_callocN(sizeof(LinkData), "PoseMatch");
|
||||
ld->data = marker;
|
||||
BLI_addtail(&pld->searchp, ld);
|
||||
}
|
||||
}
|
||||
|
||||
/* set current marker to NULL (so that we start from first) */
|
||||
pld->marker= NULL;
|
||||
pld->marker = NULL;
|
||||
}
|
||||
|
||||
/* check if any matches */
|
||||
if (pld->searchp.first == NULL) {
|
||||
pld->marker= NULL;
|
||||
pld->marker = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
/* find first match */
|
||||
for (ldc= pld->searchp.first; ldc; ldc= ldc->next) {
|
||||
for (ldc = pld->searchp.first; ldc; ldc = ldc->next) {
|
||||
if (ldc->data == pld->marker)
|
||||
break;
|
||||
}
|
||||
if (ldc == NULL)
|
||||
ldc= pld->searchp.first;
|
||||
ldc = pld->searchp.first;
|
||||
|
||||
/* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate
|
||||
* until step == 0. At this point, marker should be the correct marker.
|
||||
*/
|
||||
if (step > 0) {
|
||||
for (ld=ldc; ld && step; ld=ldn, step--)
|
||||
ldn= (ld->next) ? ld->next : pld->searchp.first;
|
||||
for (ld = ldc; ld && step; ld = ldn, step--)
|
||||
ldn = (ld->next) ? ld->next : pld->searchp.first;
|
||||
}
|
||||
else {
|
||||
for (ld=ldc; ld && step; ld=ldn, step++)
|
||||
ldn= (ld->prev) ? ld->prev : pld->searchp.last;
|
||||
for (ld = ldc; ld && step; ld = ldn, step++)
|
||||
ldn = (ld->prev) ? ld->prev : pld->searchp.last;
|
||||
}
|
||||
|
||||
/* set marker */
|
||||
if (ld)
|
||||
pld->marker= ld->data;
|
||||
pld->marker = ld->data;
|
||||
}
|
||||
else {
|
||||
TimeMarker *marker, *next;
|
||||
|
||||
/* if no marker, because we just ended searching, then set that to the start of the list */
|
||||
if (pld->marker == NULL)
|
||||
pld->marker= pld->act->markers.first;
|
||||
pld->marker = pld->act->markers.first;
|
||||
|
||||
/* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate
|
||||
* until step == 0. At this point, marker should be the correct marker.
|
||||
*/
|
||||
if (step > 0) {
|
||||
for (marker=pld->marker; marker && step; marker=next, step--)
|
||||
next= (marker->next) ? marker->next : pld->act->markers.first;
|
||||
for (marker = pld->marker; marker && step; marker = next, step--)
|
||||
next = (marker->next) ? marker->next : pld->act->markers.first;
|
||||
}
|
||||
else {
|
||||
for (marker=pld->marker; marker && step; marker=next, step++)
|
||||
next= (marker->prev) ? marker->prev : pld->act->markers.last;
|
||||
for (marker = pld->marker; marker && step; marker = next, step++)
|
||||
next = (marker->prev) ? marker->prev : pld->act->markers.last;
|
||||
}
|
||||
|
||||
/* it should be fairly impossible for marker to be NULL */
|
||||
if (marker)
|
||||
pld->marker= marker;
|
||||
pld->marker = marker;
|
||||
}
|
||||
}
|
||||
|
||||
/* specially handle events for searching */
|
||||
static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned short event, char ascii)
|
||||
static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned short event, char ascii)
|
||||
{
|
||||
/* try doing some form of string manipulation first */
|
||||
switch (event) {
|
||||
case BACKSPACEKEY:
|
||||
if (pld->searchstr[0] && pld->search_cursor) {
|
||||
short len= strlen(pld->searchstr);
|
||||
short index= pld->search_cursor;
|
||||
short len = strlen(pld->searchstr);
|
||||
short index = pld->search_cursor;
|
||||
short i;
|
||||
|
||||
for (i = index; i <= len; i++)
|
||||
pld->searchstr[i-1] = pld->searchstr[i];
|
||||
pld->searchstr[i - 1] = pld->searchstr[i];
|
||||
|
||||
pld->search_cursor--;
|
||||
|
||||
@@ -1157,13 +1157,13 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s
|
||||
|
||||
case DELKEY:
|
||||
if (pld->searchstr[0] && pld->searchstr[1]) {
|
||||
short len= strlen(pld->searchstr);
|
||||
short index= pld->search_cursor;
|
||||
short len = strlen(pld->searchstr);
|
||||
short index = pld->search_cursor;
|
||||
int i;
|
||||
|
||||
if (index < len) {
|
||||
for (i = index; i < len; i++)
|
||||
pld->searchstr[i] = pld->searchstr[i+1];
|
||||
pld->searchstr[i] = pld->searchstr[i + 1];
|
||||
|
||||
poselib_preview_get_next(pld, 1);
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
@@ -1175,18 +1175,18 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s
|
||||
|
||||
if (ascii) {
|
||||
/* character to add to the string */
|
||||
short index= pld->search_cursor;
|
||||
short len= (pld->searchstr[0]) ? strlen(pld->searchstr) : 0;
|
||||
short index = pld->search_cursor;
|
||||
short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0;
|
||||
short i;
|
||||
|
||||
if (len) {
|
||||
for (i = len; i > index; i--)
|
||||
pld->searchstr[i]= pld->searchstr[i-1];
|
||||
pld->searchstr[i] = pld->searchstr[i - 1];
|
||||
}
|
||||
else
|
||||
pld->searchstr[1]= 0;
|
||||
pld->searchstr[1] = 0;
|
||||
|
||||
pld->searchstr[index]= ascii;
|
||||
pld->searchstr[index] = ascii;
|
||||
pld->search_cursor++;
|
||||
|
||||
poselib_preview_get_next(pld, 1);
|
||||
@@ -1195,9 +1195,9 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s
|
||||
}
|
||||
|
||||
/* handle events for poselib_preview_poses */
|
||||
static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wmEvent *event)
|
||||
static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, wmEvent *event)
|
||||
{
|
||||
tPoseLib_PreviewData *pld= op->customdata;
|
||||
tPoseLib_PreviewData *pld = op->customdata;
|
||||
int ret = OPERATOR_RUNNING_MODAL;
|
||||
|
||||
/* only accept 'press' event, and ignore 'release', so that we don't get double actions */
|
||||
@@ -1217,7 +1217,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* exit - cancel */
|
||||
case ESCKEY:
|
||||
case RIGHTMOUSE:
|
||||
pld->state= PL_PREVIEW_CANCEL;
|
||||
pld->state = PL_PREVIEW_CANCEL;
|
||||
break;
|
||||
|
||||
/* exit - confirm */
|
||||
@@ -1225,7 +1225,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
case RETKEY:
|
||||
case PADENTER:
|
||||
case SPACEKEY:
|
||||
pld->state= PL_PREVIEW_CONFIRM;
|
||||
pld->state = PL_PREVIEW_CONFIRM;
|
||||
break;
|
||||
|
||||
/* view manipulation */
|
||||
@@ -1243,7 +1243,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* quicky compare to original */
|
||||
case TABKEY:
|
||||
pld->flag &= ~PL_PREVIEW_SHOWORIGINAL;
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1257,7 +1257,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* exit - cancel */
|
||||
case ESCKEY:
|
||||
case RIGHTMOUSE:
|
||||
pld->state= PL_PREVIEW_CANCEL;
|
||||
pld->state = PL_PREVIEW_CANCEL;
|
||||
break;
|
||||
|
||||
/* exit - confirm */
|
||||
@@ -1265,39 +1265,39 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
case RETKEY:
|
||||
case PADENTER:
|
||||
case SPACEKEY:
|
||||
pld->state= PL_PREVIEW_CONFIRM;
|
||||
pld->state = PL_PREVIEW_CONFIRM;
|
||||
break;
|
||||
|
||||
/* toggle between original pose and poselib pose*/
|
||||
case TABKEY:
|
||||
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
|
||||
/* change to previous pose (cyclic) */
|
||||
case PAGEUPKEY:
|
||||
case WHEELUPMOUSE:
|
||||
poselib_preview_get_next(pld, -1);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
|
||||
/* change to next pose (cyclic) */
|
||||
case PAGEDOWNKEY:
|
||||
case WHEELDOWNMOUSE:
|
||||
poselib_preview_get_next(pld, 1);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
|
||||
/* jump 5 poses (cyclic, back) */
|
||||
case DOWNARROWKEY:
|
||||
poselib_preview_get_next(pld, -5);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
|
||||
/* jump 5 poses (cyclic, forward) */
|
||||
case UPARROWKEY:
|
||||
poselib_preview_get_next(pld, 5);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
break;
|
||||
|
||||
/* change to next pose or searching cursor control */
|
||||
@@ -1306,12 +1306,12 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* move text-cursor to the right */
|
||||
if (pld->search_cursor < strlen(pld->searchstr))
|
||||
pld->search_cursor++;
|
||||
pld->redraw= PL_PREVIEW_REDRAWHEADER;
|
||||
pld->redraw = PL_PREVIEW_REDRAWHEADER;
|
||||
}
|
||||
else {
|
||||
/* change to next pose (cyclic) */
|
||||
poselib_preview_get_next(pld, 1);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1321,42 +1321,42 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* move text-cursor to the left */
|
||||
if (pld->search_cursor)
|
||||
pld->search_cursor--;
|
||||
pld->redraw= PL_PREVIEW_REDRAWHEADER;
|
||||
pld->redraw = PL_PREVIEW_REDRAWHEADER;
|
||||
}
|
||||
else {
|
||||
/* change to previous pose (cyclic) */
|
||||
poselib_preview_get_next(pld, -1);
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
}
|
||||
break;
|
||||
|
||||
/* change to first pose or start of searching string */
|
||||
case HOMEKEY:
|
||||
if (pld->searchstr[0]) {
|
||||
pld->search_cursor= 0;
|
||||
pld->redraw= PL_PREVIEW_REDRAWHEADER;
|
||||
pld->search_cursor = 0;
|
||||
pld->redraw = PL_PREVIEW_REDRAWHEADER;
|
||||
}
|
||||
else {
|
||||
/* change to first pose */
|
||||
pld->marker= pld->act->markers.first;
|
||||
pld->act->active_marker= 1;
|
||||
pld->marker = pld->act->markers.first;
|
||||
pld->act->active_marker = 1;
|
||||
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
}
|
||||
break;
|
||||
|
||||
/* change to last pose or start of searching string */
|
||||
case ENDKEY:
|
||||
if (pld->searchstr[0]) {
|
||||
pld->search_cursor= strlen(pld->searchstr);
|
||||
pld->redraw= PL_PREVIEW_REDRAWHEADER;
|
||||
pld->search_cursor = strlen(pld->searchstr);
|
||||
pld->redraw = PL_PREVIEW_REDRAWHEADER;
|
||||
}
|
||||
else {
|
||||
/* change to last pose */
|
||||
pld->marker= pld->act->markers.last;
|
||||
pld->act->active_marker= BLI_countlist(&pld->act->markers);
|
||||
pld->marker = pld->act->markers.last;
|
||||
pld->act->active_marker = BLI_countlist(&pld->act->markers);
|
||||
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1396,53 +1396,53 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm
|
||||
/* ---------------------------- */
|
||||
|
||||
/* Init PoseLib Previewing data */
|
||||
static void poselib_preview_init_data (bContext *C, wmOperator *op)
|
||||
static void poselib_preview_init_data(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseLib_PreviewData *pld;
|
||||
Object *ob= get_poselib_object(C);
|
||||
Object *ob = get_poselib_object(C);
|
||||
int pose_index = RNA_int_get(op->ptr, "pose_index");
|
||||
|
||||
/* set up preview state info */
|
||||
op->customdata= pld= MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data");
|
||||
op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data");
|
||||
|
||||
/* get basic data */
|
||||
pld->ob= ob;
|
||||
pld->arm= (ob) ? (ob->data) : NULL;
|
||||
pld->pose= (ob) ? (ob->pose) : NULL;
|
||||
pld->act= (ob) ? (ob->poselib) : NULL;
|
||||
pld->ob = ob;
|
||||
pld->arm = (ob) ? (ob->data) : NULL;
|
||||
pld->pose = (ob) ? (ob->pose) : NULL;
|
||||
pld->act = (ob) ? (ob->poselib) : NULL;
|
||||
|
||||
pld->scene= CTX_data_scene(C);
|
||||
pld->sa= CTX_wm_area(C);
|
||||
pld->scene = CTX_data_scene(C);
|
||||
pld->sa = CTX_wm_area(C);
|
||||
|
||||
/* get starting pose based on RNA-props for this operator */
|
||||
if (pose_index == -1)
|
||||
pld->marker= poselib_get_active_pose(pld->act);
|
||||
pld->marker = poselib_get_active_pose(pld->act);
|
||||
else if (pose_index == -2)
|
||||
pld->flag |= PL_PREVIEW_SHOWORIGINAL;
|
||||
else
|
||||
pld->marker= (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
|
||||
pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL;
|
||||
|
||||
/* check if valid poselib */
|
||||
if (ELEM3(NULL, pld->ob, pld->pose, pld->arm)) {
|
||||
BKE_report(op->reports, RPT_ERROR, "PoseLib is only for Armatures in PoseMode");
|
||||
pld->state= PL_PREVIEW_ERROR;
|
||||
pld->state = PL_PREVIEW_ERROR;
|
||||
return;
|
||||
}
|
||||
if (pld->act == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Object doesn't have a valid PoseLib");
|
||||
pld->state= PL_PREVIEW_ERROR;
|
||||
pld->state = PL_PREVIEW_ERROR;
|
||||
return;
|
||||
}
|
||||
if (pld->marker == NULL) {
|
||||
if (pld->act->markers.first) {
|
||||
/* just use first one then... */
|
||||
pld->marker= pld->act->markers.first;
|
||||
pld->marker = pld->act->markers.first;
|
||||
if (pose_index > -2)
|
||||
BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose");
|
||||
}
|
||||
else {
|
||||
BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply");
|
||||
pld->state= PL_PREVIEW_ERROR;
|
||||
pld->state = PL_PREVIEW_ERROR;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1454,30 +1454,30 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op)
|
||||
poselib_backup_posecopy(pld);
|
||||
|
||||
/* set flags for running */
|
||||
pld->state= PL_PREVIEW_RUNNING;
|
||||
pld->redraw= PL_PREVIEW_REDRAWALL;
|
||||
pld->state = PL_PREVIEW_RUNNING;
|
||||
pld->redraw = PL_PREVIEW_REDRAWALL;
|
||||
pld->flag |= PL_PREVIEW_FIRSTTIME;
|
||||
|
||||
/* set depsgraph flags */
|
||||
/* make sure the lock is set OK, unlock can be accidentally saved? */
|
||||
/* make sure the lock is set OK, unlock can be accidentally saved? */
|
||||
pld->pose->flag |= POSE_LOCKED;
|
||||
pld->pose->flag &= ~POSE_DO_UNLOCK;
|
||||
|
||||
/* clear strings + search */
|
||||
pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0';
|
||||
pld->search_cursor= 0;
|
||||
pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0';
|
||||
pld->search_cursor = 0;
|
||||
}
|
||||
|
||||
/* After previewing poses */
|
||||
static void poselib_preview_cleanup (bContext *C, wmOperator *op)
|
||||
static void poselib_preview_cleanup(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata;
|
||||
Scene *scene= pld->scene;
|
||||
Object *ob= pld->ob;
|
||||
bPose *pose= pld->pose;
|
||||
bArmature *arm= pld->arm;
|
||||
bAction *act= pld->act;
|
||||
TimeMarker *marker= pld->marker;
|
||||
tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata;
|
||||
Scene *scene = pld->scene;
|
||||
Object *ob = pld->ob;
|
||||
bPose *pose = pld->pose;
|
||||
bArmature *arm = pld->arm;
|
||||
bAction *act = pld->act;
|
||||
TimeMarker *marker = pld->marker;
|
||||
|
||||
/* redraw the header so that it doesn't show any of our stuff anymore */
|
||||
ED_area_headerprint(pld->sa, NULL);
|
||||
@@ -1492,7 +1492,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op)
|
||||
/* old optimize trick... this enforces to bypass the depgraph
|
||||
* - note: code copied from transform_generics.c -> recalcData()
|
||||
*/
|
||||
if ((arm->flag & ARM_DELAYDEFORM)==0)
|
||||
if ((arm->flag & ARM_DELAYDEFORM) == 0)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */
|
||||
else
|
||||
BKE_pose_where_is(scene, ob);
|
||||
@@ -1503,7 +1503,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op)
|
||||
poselib_keytag_pose(C, scene, pld);
|
||||
|
||||
/* change active pose setting */
|
||||
act->active_marker= BLI_findindex(&act->markers, marker) + 1;
|
||||
act->active_marker = BLI_findindex(&act->markers, marker) + 1;
|
||||
action_set_activemarker(act, marker, NULL);
|
||||
|
||||
/* Update event for pose and deformation children */
|
||||
@@ -1523,13 +1523,13 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op)
|
||||
|
||||
/* free temp data for operator */
|
||||
MEM_freeN(pld);
|
||||
op->customdata= NULL;
|
||||
op->customdata = NULL;
|
||||
}
|
||||
|
||||
/* End previewing operation */
|
||||
static int poselib_preview_exit (bContext *C, wmOperator *op)
|
||||
static int poselib_preview_exit(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseLib_PreviewData *pld= op->customdata;
|
||||
tPoseLib_PreviewData *pld = op->customdata;
|
||||
int exit_state = pld->state;
|
||||
|
||||
/* finish up */
|
||||
@@ -1542,16 +1542,16 @@ static int poselib_preview_exit (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Cancel previewing operation (called when exiting Blender) */
|
||||
static int poselib_preview_cancel (bContext *C, wmOperator *op)
|
||||
static int poselib_preview_cancel(bContext *C, wmOperator *op)
|
||||
{
|
||||
poselib_preview_exit(C, op);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
/* main modal status check */
|
||||
static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event)
|
||||
static int poselib_preview_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
tPoseLib_PreviewData *pld= op->customdata;
|
||||
tPoseLib_PreviewData *pld = op->customdata;
|
||||
int ret;
|
||||
|
||||
/* 1) check state to see if we're still running */
|
||||
@@ -1559,7 +1559,7 @@ static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event)
|
||||
return poselib_preview_exit(C, op);
|
||||
|
||||
/* 2) handle events */
|
||||
ret= poselib_preview_handle_event(C, op, event);
|
||||
ret = poselib_preview_handle_event(C, op, event);
|
||||
|
||||
/* 3) apply changes and redraw, otherwise, confirming goes wrong */
|
||||
if (pld->redraw)
|
||||
@@ -1575,7 +1575,7 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
|
||||
|
||||
/* check if everything is ok, and init settings for modal operator */
|
||||
poselib_preview_init_data(C, op);
|
||||
pld= (tPoseLib_PreviewData *)op->customdata;
|
||||
pld = (tPoseLib_PreviewData *)op->customdata;
|
||||
|
||||
if (pld->state == PL_PREVIEW_ERROR) {
|
||||
/* an error occurred, so free temp mem used */
|
||||
@@ -1593,13 +1593,13 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e
|
||||
}
|
||||
|
||||
/* Repeat operator */
|
||||
static int poselib_preview_exec (bContext *C, wmOperator *op)
|
||||
static int poselib_preview_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
tPoseLib_PreviewData *pld;
|
||||
|
||||
/* check if everything is ok, and init settings for modal operator */
|
||||
poselib_preview_init_data(C, op);
|
||||
pld= (tPoseLib_PreviewData *)op->customdata;
|
||||
pld = (tPoseLib_PreviewData *)op->customdata;
|
||||
|
||||
if (pld->state == PL_PREVIEW_ERROR) {
|
||||
/* an error occurred, so free temp mem used */
|
||||
@@ -1637,10 +1637,10 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* properties */
|
||||
// TODO: make the pose_index into a proper enum instead of a cryptic int...
|
||||
// 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?
|
||||
@@ -1660,9 +1660,9 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot)
|
||||
ot->poll = has_poselib_pose_data_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
// TODO: make the pose_index into a proper enum instead of a cryptic int...
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@
|
||||
/* This function is used to process the necessary updates for */
|
||||
void ED_armature_enter_posemode(bContext *C, Base *base)
|
||||
{
|
||||
ReportList *reports= CTX_wm_reports(C);
|
||||
Object *ob= base->object;
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
Object *ob = base->object;
|
||||
|
||||
if (ob->id.lib) {
|
||||
BKE_report(reports, RPT_WARNING, "Can't pose libdata");
|
||||
@@ -96,7 +96,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
|
||||
ob->restore_mode = ob->mode;
|
||||
ob->mode |= OB_MODE_POSE;
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL);
|
||||
|
||||
break;
|
||||
default:
|
||||
@@ -110,12 +110,12 @@ void ED_armature_enter_posemode(bContext *C, Base *base)
|
||||
void ED_armature_exit_posemode(bContext *C, Base *base)
|
||||
{
|
||||
if (base) {
|
||||
Object *ob= base->object;
|
||||
Object *ob = base->object;
|
||||
|
||||
ob->restore_mode = ob->mode;
|
||||
ob->mode &= ~OB_MODE_POSE;
|
||||
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,13 +127,13 @@ static short pose_has_protected_selected(Object *ob, short warn)
|
||||
/* check protection */
|
||||
if (ob->proxy) {
|
||||
bPoseChannel *pchan;
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->bone && (pchan->bone->layer & arm->layer)) {
|
||||
if (pchan->bone->layer & arm->layer_protected) {
|
||||
if (pchan->bone->flag & BONE_SELECTED)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,17 +154,17 @@ static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
|
||||
|
||||
/* No need to check if constraint is active (has influence),
|
||||
* since all constraints with CONSTRAINT_IK_AUTO are active */
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
|
||||
bKinematicConstraint *data= con->data;
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
|
||||
bKinematicConstraint *data = con->data;
|
||||
if (data->rootbone == 0 || data->rootbone > level) {
|
||||
if ((data->flag & CONSTRAINT_IK_AUTO)==0)
|
||||
if ((data->flag & CONSTRAINT_IK_AUTO) == 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (bone= pchan->bone->childbase.first; bone; bone= bone->next) {
|
||||
pchan= BKE_pose_channel_find_name(ob->pose, bone->name);
|
||||
for (bone = pchan->bone->childbase.first; bone; bone = bone->next) {
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
|
||||
if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1))
|
||||
return 1;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNU
|
||||
static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -247,7 +247,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* set up path data for bones being calculated */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
/* verify makes sure that the selected bone has a bone with the appropriate settings */
|
||||
animviz_verify_motionpaths(op->reports, scene, ob, pchan);
|
||||
@@ -277,17 +277,17 @@ void POSE_OT_paths_calculate(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start",
|
||||
"First frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0);
|
||||
"First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
|
||||
RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End",
|
||||
"Last frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0);
|
||||
"Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0);
|
||||
|
||||
RNA_def_enum(ot->srna, "bake_location", motionpath_bake_location_items, 0,
|
||||
"Bake Location",
|
||||
"Which point on the bones is used when calculating paths");
|
||||
"Which point on the bones is used when calculating paths");
|
||||
}
|
||||
|
||||
/* --------- */
|
||||
@@ -322,7 +322,7 @@ void POSE_OT_paths_update(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* --------- */
|
||||
@@ -337,11 +337,11 @@ static void ED_pose_clear_paths(Object *ob)
|
||||
return;
|
||||
|
||||
/* free the motionpath blocks, but also take note of whether we skipped some... */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->mpath) {
|
||||
if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) {
|
||||
animviz_free_motionpath(pchan->mpath);
|
||||
pchan->mpath= NULL;
|
||||
pchan->mpath = NULL;
|
||||
}
|
||||
else
|
||||
skipped = 1;
|
||||
@@ -354,7 +354,7 @@ static void ED_pose_clear_paths(Object *ob)
|
||||
}
|
||||
|
||||
/* operator callback for this */
|
||||
static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_clear_paths_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
@@ -383,34 +383,34 @@ void POSE_OT_paths_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************* Select Constraint Target Operator ************* */
|
||||
|
||||
static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bConstraint *con;
|
||||
int found= 0;
|
||||
int found = 0;
|
||||
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
if (pchan->bone->flag & BONE_SELECTED) {
|
||||
for (con= pchan->constraints.first; con; con= con->next) {
|
||||
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
|
||||
for (con = pchan->constraints.first; con; con = con->next) {
|
||||
bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
|
||||
ListBase targets = {NULL, NULL};
|
||||
bConstraintTarget *ct;
|
||||
|
||||
if (cti && cti->get_constraint_targets) {
|
||||
cti->get_constraint_targets(con, &targets);
|
||||
|
||||
for (ct= targets.first; ct; ct= ct->next) {
|
||||
for (ct = targets.first; ct; ct = ct->next) {
|
||||
if ((ct->tar == ob) && (ct->subtarget[0])) {
|
||||
bPoseChannel *pchanc= BKE_pose_channel_find_name(ob->pose, ct->subtarget);
|
||||
bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget);
|
||||
if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) {
|
||||
pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
|
||||
found= 1;
|
||||
pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -426,7 +426,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op
|
||||
if (!found)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -443,36 +443,36 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************* select hierarchy operator ************* */
|
||||
|
||||
static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm= ob->data;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = ob->data;
|
||||
Bone *curbone, *pabone, *chbone;
|
||||
int direction = RNA_enum_get(op->ptr, "direction");
|
||||
int add_to_sel = RNA_boolean_get(op->ptr, "extend");
|
||||
int found= 0;
|
||||
int found = 0;
|
||||
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
curbone= pchan->bone;
|
||||
curbone = pchan->bone;
|
||||
|
||||
if ((curbone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if ((curbone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if (curbone == arm->act_bone) {
|
||||
if (direction == BONE_SELECT_PARENT) {
|
||||
if (pchan->parent == NULL) continue;
|
||||
else pabone= pchan->parent->bone;
|
||||
else pabone = pchan->parent->bone;
|
||||
|
||||
if (PBONE_VISIBLE(arm, pabone)) {
|
||||
if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
|
||||
pabone->flag |= BONE_SELECTED;
|
||||
arm->act_bone= pabone;
|
||||
arm->act_bone = pabone;
|
||||
|
||||
found= 1;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -505,9 +505,9 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
if (PBONE_VISIBLE(arm, chbone)) {
|
||||
if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
|
||||
chbone->flag |= BONE_SELECTED;
|
||||
arm->act_bone= chbone;
|
||||
arm->act_bone = chbone;
|
||||
|
||||
found= 1;
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -519,14 +519,14 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
|
||||
if (found == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_select_hierarchy(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem direction_items[]= {
|
||||
static EnumPropertyItem direction_items[] = {
|
||||
{BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
|
||||
{BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
@@ -542,7 +542,7 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
|
||||
@@ -552,39 +552,39 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot)
|
||||
|
||||
/* ******************* select grouped operator ************* */
|
||||
|
||||
static short pose_select_same_group (bContext *C, Object *ob, short extend)
|
||||
static short pose_select_same_group(bContext *C, Object *ob, short extend)
|
||||
{
|
||||
bArmature *arm= (ob)? ob->data : NULL;
|
||||
bPose *pose= (ob)? ob->pose : NULL;
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
char *group_flags;
|
||||
int numGroups = 0;
|
||||
short changed=0, tagged=0;
|
||||
short changed = 0, tagged = 0;
|
||||
|
||||
/* sanity checks */
|
||||
if (ELEM3(NULL, ob, pose, arm))
|
||||
return 0;
|
||||
|
||||
/* count the number of groups */
|
||||
numGroups= BLI_countlist(&pose->agroups);
|
||||
numGroups = BLI_countlist(&pose->agroups);
|
||||
if (numGroups == 0)
|
||||
return 0;
|
||||
|
||||
/* alloc a small array to keep track of the groups to use
|
||||
* - each cell stores on/off state for whether group should be used
|
||||
* - each cell stores on/off state for whether group should be used
|
||||
* - size is numGroups + 1, since index=0 is used for no-group
|
||||
*/
|
||||
group_flags= MEM_callocN(numGroups+1, "pose_select_same_group");
|
||||
group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group");
|
||||
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
/* keep track of group as group to use later? */
|
||||
if (pchan->bone->flag & BONE_SELECTED) {
|
||||
group_flags[pchan->agrp_index] = 1;
|
||||
tagged= 1;
|
||||
tagged = 1;
|
||||
}
|
||||
|
||||
/* deselect all bones before selecting new ones? */
|
||||
if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
|
||||
if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
|
||||
pchan->bone->flag &= ~BONE_SELECTED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -594,11 +594,11 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend)
|
||||
/* only if group matches (and is not selected or current bone) */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
/* check if the group used by this bone is counted */
|
||||
if (group_flags[pchan->agrp_index]) {
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
changed= 1;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -611,12 +611,12 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend)
|
||||
return changed;
|
||||
}
|
||||
|
||||
static short pose_select_same_layer (bContext *C, Object *ob, short extend)
|
||||
static short pose_select_same_layer(bContext *C, Object *ob, short extend)
|
||||
{
|
||||
bPose *pose= (ob)? ob->pose : NULL;
|
||||
bArmature *arm= (ob)? ob->data : NULL;
|
||||
short changed= 0;
|
||||
int layers= 0;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
short changed = 0;
|
||||
int layers = 0;
|
||||
|
||||
if (ELEM3(NULL, ob, pose, arm))
|
||||
return 0;
|
||||
@@ -629,7 +629,7 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend)
|
||||
layers |= pchan->bone->layer;
|
||||
|
||||
/* deselect all bones before selecting new ones? */
|
||||
if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0)
|
||||
if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0)
|
||||
pchan->bone->flag &= ~BONE_SELECTED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -640,9 +640,9 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
/* if bone is on a suitable layer, and the bone can have its selection changed, select it */
|
||||
if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
changed= 1;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -655,9 +655,9 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
|
||||
KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C));
|
||||
KS_Path *ksp;
|
||||
|
||||
bArmature *arm = (ob)? ob->data : NULL;
|
||||
bPose *pose= (ob)? ob->pose : NULL;
|
||||
short changed= 0;
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
short changed = 0;
|
||||
|
||||
/* sanity checks: validate Keying Set and object */
|
||||
if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0))
|
||||
@@ -670,7 +670,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
|
||||
if (extend == 0) {
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE)==0)
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)
|
||||
pchan->bone->flag &= ~BONE_SELECTED;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -691,7 +691,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
|
||||
if (pchan) {
|
||||
/* select if bone is visible and can be affected */
|
||||
if ((PBONE_VISIBLE(arm, pchan->bone)) &&
|
||||
(pchan->bone->flag & BONE_UNSELECTABLE)==0)
|
||||
(pchan->bone->flag & BONE_UNSELECTABLE) == 0)
|
||||
{
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
changed = 1;
|
||||
@@ -708,10 +708,10 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend)
|
||||
return changed;
|
||||
}
|
||||
|
||||
static int pose_select_grouped_exec (bContext *C, wmOperator *op)
|
||||
static int pose_select_grouped_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
short extend= RNA_boolean_get(op->ptr, "extend");
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
short extend = RNA_boolean_get(op->ptr, "extend");
|
||||
short changed = 0;
|
||||
|
||||
/* sanity check */
|
||||
@@ -723,18 +723,18 @@ static int pose_select_grouped_exec (bContext *C, wmOperator *op)
|
||||
*/
|
||||
switch (RNA_enum_get(op->ptr, "type")) {
|
||||
case 1: /* group */
|
||||
changed= pose_select_same_group(C, ob, extend);
|
||||
changed = pose_select_same_group(C, ob, extend);
|
||||
break;
|
||||
case 2: /* Keying Set */
|
||||
changed= pose_select_same_keyingset(C, ob, extend);
|
||||
changed = pose_select_same_keyingset(C, ob, extend);
|
||||
break;
|
||||
default: /* layer */
|
||||
changed= pose_select_same_layer(C, ob, extend);
|
||||
changed = pose_select_same_layer(C, ob, extend);
|
||||
break;
|
||||
}
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
/* report done status */
|
||||
if (changed)
|
||||
@@ -763,7 +763,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
|
||||
@@ -774,25 +774,25 @@ void POSE_OT_select_grouped(wmOperatorType *ot)
|
||||
/* ********************************************** */
|
||||
|
||||
/* context active object, or weightpainted object with armature in posemode */
|
||||
static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob_act= CTX_data_active_object(C);
|
||||
Object *ob= BKE_object_pose_armature_get(ob_act);
|
||||
Object *ob_act = CTX_data_active_object(C);
|
||||
Object *ob = BKE_object_pose_armature_get(ob_act);
|
||||
|
||||
if (ob && (ob->mode & OB_MODE_POSE)) {
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
|
||||
if (arm->act_bone) {
|
||||
bPoseChannel *pchanf;
|
||||
char name[MAXBONENAME];
|
||||
flip_side_name(name, arm->act_bone->name, TRUE);
|
||||
|
||||
pchanf= BKE_pose_channel_find_name(ob->pose, name);
|
||||
pchanf = BKE_pose_channel_find_name(ob->pose, name);
|
||||
if (pchanf && pchanf->bone != arm->act_bone) {
|
||||
arm->act_bone->flag &= ~BONE_SELECTED;
|
||||
pchanf->bone->flag |= BONE_SELECTED;
|
||||
|
||||
arm->act_bone= pchanf->bone;
|
||||
arm->act_bone = pchanf->bone;
|
||||
|
||||
/* in weightpaint we select the associated vertex group too */
|
||||
if (ob_act->mode & OB_MODE_WEIGHT_PAINT) {
|
||||
@@ -800,7 +800,7 @@ static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA);
|
||||
}
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -822,7 +822,7 @@ void POSE_OT_select_flip_active(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -830,49 +830,49 @@ void POSE_OT_select_flip_active(wmOperatorType *ot)
|
||||
#if 0 /* UNUSED 2.5 */
|
||||
static void pose_copy_menu(Scene *scene)
|
||||
{
|
||||
Object *obedit= scene->obedit; // XXX context
|
||||
Object *ob= OBACT;
|
||||
Object *obedit = scene->obedit; // XXX context
|
||||
Object *ob = OBACT;
|
||||
bArmature *arm;
|
||||
bPoseChannel *pchan, *pchanact;
|
||||
short nr=0;
|
||||
int i=0;
|
||||
short nr = 0;
|
||||
int i = 0;
|
||||
|
||||
/* paranoia checks */
|
||||
if (ELEM(NULL, ob, ob->pose)) return;
|
||||
if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return;
|
||||
if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return;
|
||||
|
||||
pchan= BKE_pose_channel_active(ob);
|
||||
pchan = BKE_pose_channel_active(ob);
|
||||
|
||||
if (pchan==NULL) return;
|
||||
pchanact= pchan;
|
||||
arm= ob->data;
|
||||
if (pchan == NULL) return;
|
||||
pchanact = pchan;
|
||||
arm = ob->data;
|
||||
|
||||
/* if proxy-protected bones selected, some things (such as locks + displays) shouldn't be changeable,
|
||||
* but for constraints (just add local constraints)
|
||||
*/
|
||||
if (pose_has_protected_selected(ob, 0)) {
|
||||
i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
|
||||
i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
|
||||
if (i < 25)
|
||||
nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5");
|
||||
nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5");
|
||||
else
|
||||
nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4");
|
||||
nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4");
|
||||
}
|
||||
else {
|
||||
i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
|
||||
i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
|
||||
if (i < 25)
|
||||
nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8");
|
||||
nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8");
|
||||
else
|
||||
nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8");
|
||||
nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8");
|
||||
}
|
||||
|
||||
if (nr <= 0)
|
||||
return;
|
||||
|
||||
if (nr != 5) {
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if ((arm->layer & pchan->bone->layer) &&
|
||||
(pchan->bone->flag & BONE_SELECTED) &&
|
||||
(pchan != pchanact) )
|
||||
(pchan->bone->flag & BONE_SELECTED) &&
|
||||
(pchan != pchanact) )
|
||||
{
|
||||
switch (nr) {
|
||||
case 1: /* Local Location */
|
||||
@@ -897,7 +897,7 @@ static void pose_copy_menu(Scene *scene)
|
||||
bConstraint *con;
|
||||
|
||||
/* add proxy-local tags */
|
||||
for (con= tmp_constraints.first; con; con= con->next)
|
||||
for (con = tmp_constraints.first; con; con = con->next)
|
||||
con->flag |= CONSTRAINT_PROXY_LOCAL;
|
||||
}
|
||||
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
|
||||
@@ -908,7 +908,7 @@ static void pose_copy_menu(Scene *scene)
|
||||
if (ob->pose)
|
||||
ob->pose->flag |= POSE_RECALC;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 6: /* Transform Locks */
|
||||
pchan->protectflag = pchanact->protectflag;
|
||||
break;
|
||||
@@ -918,11 +918,11 @@ static void pose_copy_menu(Scene *scene)
|
||||
copy_v3_v3(pchan->limitmin, pchanact->limitmin);
|
||||
copy_v3_v3(pchan->limitmax, pchanact->limitmax);
|
||||
copy_v3_v3(pchan->stiffness, pchanact->stiffness);
|
||||
pchan->ikstretch= pchanact->ikstretch;
|
||||
pchan->ikrotweight= pchanact->ikrotweight;
|
||||
pchan->iklinweight= pchanact->iklinweight;
|
||||
pchan->ikstretch = pchanact->ikstretch;
|
||||
pchan->ikrotweight = pchanact->ikrotweight;
|
||||
pchan->iklinweight = pchanact->iklinweight;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 8: /* Custom Bone Shape */
|
||||
pchan->custom = pchanact->custom;
|
||||
break;
|
||||
@@ -947,7 +947,7 @@ static void pose_copy_menu(Scene *scene)
|
||||
else
|
||||
mat4_to_eulO(pchan->eul, pchan->rotmode, delta_mat);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case 11: /* Visual Size */
|
||||
{
|
||||
float delta_mat[4][4], size[4];
|
||||
@@ -962,14 +962,14 @@ static void pose_copy_menu(Scene *scene)
|
||||
}
|
||||
else { /* constraints, optional (note: max we can have is 24 constraints) */
|
||||
bConstraint *con, *con_back;
|
||||
int const_toggle[24]= {0}; /* XXX, initialize as 0 to quiet errors */
|
||||
int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */
|
||||
ListBase const_copy = {NULL, NULL};
|
||||
|
||||
BLI_duplicatelist(&const_copy, &(pchanact->constraints));
|
||||
|
||||
/* build the puplist of constraints */
|
||||
for (con = pchanact->constraints.first, i=0; con; con=con->next, i++) {
|
||||
const_toggle[i]= 1;
|
||||
for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) {
|
||||
const_toggle[i] = 1;
|
||||
// add_numbut(i, TOG|INT, con->name, 0, 0, &(const_toggle[i]), "");
|
||||
}
|
||||
|
||||
@@ -979,22 +979,22 @@ static void pose_copy_menu(Scene *scene)
|
||||
// }
|
||||
|
||||
/* now build a new listbase from the options selected */
|
||||
for (i=0, con=const_copy.first; con; i++) {
|
||||
for (i = 0, con = const_copy.first; con; i++) {
|
||||
/* if not selected, free/remove it from the list */
|
||||
if (!const_toggle[i]) {
|
||||
con_back= con->next;
|
||||
con_back = con->next;
|
||||
BLI_freelinkN(&const_copy, con);
|
||||
con= con_back;
|
||||
con = con_back;
|
||||
}
|
||||
else
|
||||
con= con->next;
|
||||
con = con->next;
|
||||
}
|
||||
|
||||
/* Copy the temo listbase to the selected posebones */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if ((arm->layer & pchan->bone->layer) &&
|
||||
(pchan->bone->flag & BONE_SELECTED) &&
|
||||
(pchan!=pchanact) )
|
||||
(pchan->bone->flag & BONE_SELECTED) &&
|
||||
(pchan != pchanact) )
|
||||
{
|
||||
ListBase tmp_constraints = {NULL, NULL};
|
||||
|
||||
@@ -1004,7 +1004,7 @@ static void pose_copy_menu(Scene *scene)
|
||||
copy_constraints(&tmp_constraints, &const_copy, TRUE);
|
||||
if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) {
|
||||
/* add proxy-local tags */
|
||||
for (con= tmp_constraints.first; con; con= con->next)
|
||||
for (con = tmp_constraints.first; con; con = con->next)
|
||||
con->flag |= CONSTRAINT_PROXY_LOCAL;
|
||||
}
|
||||
BLI_movelisttolist(&pchan->constraints, &tmp_constraints);
|
||||
@@ -1020,7 +1020,7 @@ static void pose_copy_menu(Scene *scene)
|
||||
ob->pose->flag |= POSE_RECALC;
|
||||
}
|
||||
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations
|
||||
|
||||
BIF_undo_push("Copy Pose Attributes");
|
||||
|
||||
@@ -1037,7 +1037,7 @@ void free_posebuf(void)
|
||||
if (g_posebuf) {
|
||||
bPoseChannel *pchan;
|
||||
|
||||
for (pchan= g_posebuf->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = g_posebuf->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->prop) {
|
||||
IDP_FreeProperty(pchan->prop);
|
||||
MEM_freeN(pchan->prop);
|
||||
@@ -1049,20 +1049,20 @@ void free_posebuf(void)
|
||||
MEM_freeN(g_posebuf);
|
||||
}
|
||||
|
||||
g_posebuf=NULL;
|
||||
g_posebuf = NULL;
|
||||
}
|
||||
|
||||
/* This function is used to indicate that a bone is selected
|
||||
* and needs to be included in copy buffer (used to be for inserting keys)
|
||||
*/
|
||||
static void set_pose_keys (Object *ob)
|
||||
static void set_pose_keys(Object *ob)
|
||||
{
|
||||
bArmature *arm= ob->data;
|
||||
bArmature *arm = ob->data;
|
||||
bPoseChannel *chan;
|
||||
|
||||
if (ob->pose) {
|
||||
for (chan=ob->pose->chanbase.first; chan; chan=chan->next) {
|
||||
Bone *bone= chan->bone;
|
||||
for (chan = ob->pose->chanbase.first; chan; chan = chan->next) {
|
||||
Bone *bone = chan->bone;
|
||||
if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer))
|
||||
chan->flag |= POSE_KEY;
|
||||
else
|
||||
@@ -1079,7 +1079,7 @@ static void set_pose_keys (Object *ob)
|
||||
*
|
||||
* > returns: whether the bone that we pasted to if we succeeded
|
||||
*/
|
||||
static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip)
|
||||
static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short selOnly, short flip)
|
||||
{
|
||||
bPoseChannel *pchan;
|
||||
char name[MAXBONENAME];
|
||||
@@ -1087,20 +1087,20 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
|
||||
/* get the name - if flipping, we must flip this first */
|
||||
if (flip)
|
||||
flip_side_name(name, chan->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:
|
||||
* 1) channel exists - poses are not meant to add random channels to anymore
|
||||
* 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
|
||||
* 1) channel exists - poses are not meant to add random channels to anymore
|
||||
* 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical
|
||||
*/
|
||||
pchan= BKE_pose_channel_find_name(ob->pose, name);
|
||||
pchan = BKE_pose_channel_find_name(ob->pose, name);
|
||||
|
||||
if (selOnly)
|
||||
paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED));
|
||||
paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED));
|
||||
else
|
||||
paste_ok= ((pchan != NULL));
|
||||
paste_ok = ((pchan != NULL));
|
||||
|
||||
/* continue? */
|
||||
if (paste_ok) {
|
||||
@@ -1109,7 +1109,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
*/
|
||||
copy_v3_v3(pchan->loc, chan->loc);
|
||||
copy_v3_v3(pchan->size, chan->size);
|
||||
pchan->flag= chan->flag;
|
||||
pchan->flag = chan->flag;
|
||||
|
||||
/* check if rotation modes are compatible (i.e. do they need any conversions) */
|
||||
if (pchan->rotmode == chan->rotmode) {
|
||||
@@ -1149,7 +1149,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
|
||||
/* paste flipped pose? */
|
||||
if (flip) {
|
||||
pchan->loc[0]*= -1;
|
||||
pchan->loc[0] *= -1;
|
||||
|
||||
/* has to be done as eulers... */
|
||||
if (pchan->rotmode > 0) {
|
||||
@@ -1160,8 +1160,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
float eul[3];
|
||||
|
||||
axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle);
|
||||
eul[1]*= -1;
|
||||
eul[2]*= -1;
|
||||
eul[1] *= -1;
|
||||
eul[2] *= -1;
|
||||
eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT);
|
||||
}
|
||||
else {
|
||||
@@ -1169,8 +1169,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
|
||||
normalize_qt(pchan->quat);
|
||||
quat_to_eul(eul, pchan->quat);
|
||||
eul[1]*= -1;
|
||||
eul[2]*= -1;
|
||||
eul[1] *= -1;
|
||||
eul[2] *= -1;
|
||||
eul_to_quat(pchan->quat, eul);
|
||||
}
|
||||
}
|
||||
@@ -1186,7 +1186,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
}
|
||||
else {
|
||||
/* no existing properties, so assume that we want copies too? */
|
||||
pchan->prop= IDP_CopyProperty(chan->prop);
|
||||
pchan->prop = IDP_CopyProperty(chan->prop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1197,9 +1197,9 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s
|
||||
|
||||
/* ---- */
|
||||
|
||||
static int pose_copy_exec (bContext *C, wmOperator *op)
|
||||
static int pose_copy_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
/* sanity checking */
|
||||
if (ELEM(NULL, ob, ob->pose)) {
|
||||
@@ -1235,13 +1235,13 @@ void POSE_OT_copy(wmOperatorType *ot)
|
||||
|
||||
/* ---- */
|
||||
|
||||
static int pose_paste_exec (bContext *C, wmOperator *op)
|
||||
static int pose_paste_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
bPoseChannel *chan;
|
||||
int flip= RNA_boolean_get(op->ptr, "flipped");
|
||||
int selOnly= RNA_boolean_get(op->ptr, "selected_mask");
|
||||
int flip = RNA_boolean_get(op->ptr, "flipped");
|
||||
int selOnly = RNA_boolean_get(op->ptr, "selected_mask");
|
||||
|
||||
/* get KeyingSet to use */
|
||||
KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOC_ROT_SCALE_ID);
|
||||
@@ -1264,7 +1264,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Safely merge all of the channels in the buffer pose into any existing pose */
|
||||
for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) {
|
||||
for (chan = g_posebuf->chanbase.first; chan; chan = chan->next) {
|
||||
if (chan->flag & POSE_KEY) {
|
||||
/* try to perform paste on this bone */
|
||||
bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip);
|
||||
@@ -1280,7 +1280,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ void POSE_OT_paste(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flag */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
prop = RNA_def_boolean(ot->srna, "flipped", FALSE, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose");
|
||||
@@ -1311,16 +1311,16 @@ void POSE_OT_paste(wmOperatorType *ot)
|
||||
/* ********************************************** */
|
||||
/* Bone Groups */
|
||||
|
||||
static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
/* only continue if there's an object */
|
||||
if (ob == NULL)
|
||||
@@ -1330,7 +1330,7 @@ static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
BKE_pose_add_group(ob);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1347,20 +1347,20 @@ void POSE_OT_group_add(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
/* only continue if there's an object */
|
||||
if (ob == NULL)
|
||||
@@ -1370,7 +1370,7 @@ static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
BKE_pose_remove_group(ob);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1387,15 +1387,15 @@ void POSE_OT_group_remove(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ------------ */
|
||||
|
||||
/* invoke callback which presents a list of bone-groups for the user to choose from */
|
||||
static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Object *ob;
|
||||
bPose *pose;
|
||||
|
||||
@@ -1406,20 +1406,20 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
|
||||
/* 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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(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= ob->pose;
|
||||
pose = ob->pose;
|
||||
|
||||
/* if there's no active group (or active is invalid), create a new menu to find it */
|
||||
if (pose->active_group <= 0) {
|
||||
/* create a new menu, and start populating it with group names */
|
||||
pup= uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout= uiPupMenuLayout(pup);
|
||||
pup = uiPupMenuBegin(C, op->type->name, ICON_NONE);
|
||||
layout = uiPupMenuLayout(pup);
|
||||
|
||||
/* special entry - allow to create new group, then use that
|
||||
* (not to be used for removing though)
|
||||
@@ -1430,7 +1430,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
}
|
||||
|
||||
/* add entries for each group */
|
||||
for (grp= pose->agroups.first, i=1; grp; grp=grp->next, i++)
|
||||
for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++)
|
||||
uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i);
|
||||
|
||||
/* finish building the menu, and process it (should result in calling self again) */
|
||||
@@ -1446,42 +1446,42 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED
|
||||
}
|
||||
|
||||
/* Assign selected pchans to the bone group that the user selects */
|
||||
static int pose_group_assign_exec (bContext *C, wmOperator *op)
|
||||
static int pose_group_assign_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Object *ob;
|
||||
bPose *pose;
|
||||
short done= 0;
|
||||
short done = 0;
|
||||
|
||||
/* 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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(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= ob->pose;
|
||||
pose = ob->pose;
|
||||
|
||||
/* set the active group number to the one from operator props
|
||||
* - if 0 after this, make a new group...
|
||||
* - if 0 after this, make a new group...
|
||||
*/
|
||||
pose->active_group= RNA_int_get(op->ptr, "type");
|
||||
pose->active_group = RNA_int_get(op->ptr, "type");
|
||||
if (pose->active_group == 0)
|
||||
BKE_pose_add_group(ob);
|
||||
|
||||
/* add selected bones to group then */
|
||||
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;
|
||||
pchan->agrp_index = pose->active_group;
|
||||
done = 1;
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
/* report done status */
|
||||
if (done)
|
||||
@@ -1503,41 +1503,41 @@ void POSE_OT_group_assign(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_int(ot->srna, "type", 0, 0, 10, "Bone Group Index", "", 0, INT_MAX);
|
||||
}
|
||||
|
||||
|
||||
static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Object *ob;
|
||||
short done= 0;
|
||||
short done = 0;
|
||||
|
||||
/* 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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(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;
|
||||
|
||||
/* find selected bones to remove from all bone groups */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
if (pchan->agrp_index) {
|
||||
pchan->agrp_index= 0;
|
||||
done= 1;
|
||||
pchan->agrp_index = 0;
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
/* report done status */
|
||||
if (done)
|
||||
@@ -1558,16 +1558,16 @@ void POSE_OT_group_unassign(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int group_move_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
bPose *pose= (ob) ? ob->pose : NULL;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
bPoseChannel *pchan;
|
||||
bActionGroup *grp;
|
||||
int dir= RNA_enum_get(op->ptr, "direction");
|
||||
int dir = RNA_enum_get(op->ptr, "direction");
|
||||
int grpIndexA, grpIndexB;
|
||||
|
||||
if (ELEM(NULL, ob, pose))
|
||||
@@ -1576,7 +1576,7 @@ static int group_move_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get group to move */
|
||||
grp= BLI_findlink(&pose->agroups, pose->active_group-1);
|
||||
grp = BLI_findlink(&pose->agroups, pose->active_group - 1);
|
||||
if (grp == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
@@ -1608,15 +1608,15 @@ static int group_move_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* fix changed bone group indices in bones (swap grpIndexA with grpIndexB) */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->agrp_index == grpIndexB)
|
||||
pchan->agrp_index= grpIndexA;
|
||||
pchan->agrp_index = grpIndexA;
|
||||
else if (pchan->agrp_index == grpIndexA)
|
||||
pchan->agrp_index= grpIndexB;
|
||||
pchan->agrp_index = grpIndexB;
|
||||
}
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1639,7 +1639,7 @@ void POSE_OT_group_move(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "direction", group_slot_move, 0, "Direction", "Direction to move, UP or DOWN");
|
||||
}
|
||||
@@ -1647,14 +1647,14 @@ void POSE_OT_group_move(wmOperatorType *ot)
|
||||
/* bone group sort element */
|
||||
typedef struct tSortActionGroup {
|
||||
bActionGroup *agrp;
|
||||
int index;
|
||||
int index;
|
||||
} tSortActionGroup;
|
||||
|
||||
/* compare bone groups by name */
|
||||
static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr)
|
||||
{
|
||||
tSortActionGroup *sgrp_a= (tSortActionGroup *)sgrp_a_ptr;
|
||||
tSortActionGroup *sgrp_b= (tSortActionGroup *)sgrp_b_ptr;
|
||||
tSortActionGroup *sgrp_a = (tSortActionGroup *)sgrp_a_ptr;
|
||||
tSortActionGroup *sgrp_b = (tSortActionGroup *)sgrp_b_ptr;
|
||||
|
||||
return strcmp(sgrp_a->agrp->name, sgrp_b->agrp->name);
|
||||
}
|
||||
@@ -1662,7 +1662,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr)
|
||||
static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob = ED_object_context(C);
|
||||
bPose *pose= (ob) ? ob->pose : NULL;
|
||||
bPose *pose = (ob) ? ob->pose : NULL;
|
||||
bPoseChannel *pchan;
|
||||
tSortActionGroup *agrp_array;
|
||||
bActionGroup *agrp;
|
||||
@@ -1677,26 +1677,26 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* create temporary array with bone groups and indices */
|
||||
agrp_count = BLI_countlist(&pose->agroups);
|
||||
agrp_array = MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups");
|
||||
for (agrp= pose->agroups.first, i= 0; agrp; agrp= agrp->next, i++) {
|
||||
for (agrp = pose->agroups.first, i = 0; agrp; agrp = agrp->next, i++) {
|
||||
BLI_assert(i < agrp_count);
|
||||
agrp_array[i].agrp = agrp;
|
||||
agrp_array[i].index = i+1;
|
||||
agrp_array[i].index = i + 1;
|
||||
}
|
||||
|
||||
/* sort bone groups by name */
|
||||
qsort(agrp_array, agrp_count, sizeof(tSortActionGroup), compare_agroup);
|
||||
|
||||
/* create sorted bone group list from sorted array */
|
||||
pose->agroups.first= pose->agroups.last= NULL;
|
||||
for (i= 0; i < agrp_count; i++) {
|
||||
pose->agroups.first = pose->agroups.last = NULL;
|
||||
for (i = 0; i < agrp_count; i++) {
|
||||
BLI_addtail(&pose->agroups, agrp_array[i].agrp);
|
||||
}
|
||||
|
||||
/* fix changed bone group indizes in bones */
|
||||
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (i= 0; i < agrp_count; i++) {
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
for (i = 0; i < agrp_count; i++) {
|
||||
if (pchan->agrp_index == agrp_array[i].index) {
|
||||
pchan->agrp_index= i+1;
|
||||
pchan->agrp_index = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1706,7 +1706,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
MEM_freeN(agrp_array);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1723,16 +1723,16 @@ void POSE_OT_group_sort(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static void pose_group_select(bContext *C, Object *ob, int select)
|
||||
{
|
||||
bPose *pose= ob->pose;
|
||||
bPose *pose = ob->pose;
|
||||
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
|
||||
{
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
|
||||
if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
|
||||
if (select) {
|
||||
if (pchan->agrp_index == pose->active_group)
|
||||
pchan->bone->flag |= BONE_SELECTED;
|
||||
@@ -1746,16 +1746,16 @@ static void pose_group_select(bContext *C, Object *ob, int select)
|
||||
CTX_DATA_END;
|
||||
}
|
||||
|
||||
static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
/* only continue if there's an object, and a pose there too */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
@@ -1764,7 +1764,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
pose_group_select(C, ob, 1);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1781,19 +1781,19 @@ void POSE_OT_group_select(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
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= ED_object_context(C);
|
||||
ob = ED_object_context(C);
|
||||
else
|
||||
ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
|
||||
/* only continue if there's an object, and a pose there too */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
@@ -1802,7 +1802,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
pose_group_select(C, ob, 0);
|
||||
|
||||
/* notifiers for updates */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1819,23 +1819,23 @@ void POSE_OT_group_deselect(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ********************************************** */
|
||||
|
||||
static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm;
|
||||
|
||||
/* paranoia checks */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return OPERATOR_CANCELLED;
|
||||
arm= ob->data;
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
char newname[MAXBONENAME];
|
||||
flip_side_name(newname, pchan->name, TRUE);
|
||||
@@ -1847,7 +1847,7 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1864,25 +1864,25 @@ void POSE_OT_flip_names(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ------------------ */
|
||||
|
||||
static int pose_autoside_names_exec (bContext *C, wmOperator *op)
|
||||
static int pose_autoside_names_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm;
|
||||
char newname[MAXBONENAME];
|
||||
short axis= RNA_enum_get(op->ptr, "axis");
|
||||
short axis = RNA_enum_get(op->ptr, "axis");
|
||||
|
||||
/* paranoia checks */
|
||||
if (ELEM(NULL, ob, ob->pose))
|
||||
return OPERATOR_CANCELLED;
|
||||
arm= ob->data;
|
||||
arm = ob->data;
|
||||
|
||||
/* loop through selected bones, auto-naming them */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
BLI_strncpy(newname, pchan->name, sizeof(newname));
|
||||
if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis]))
|
||||
@@ -1894,18 +1894,19 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op)
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void POSE_OT_autoside_names(wmOperatorType *ot)
|
||||
{
|
||||
static EnumPropertyItem axis_items[]= {
|
||||
static EnumPropertyItem axis_items[] = {
|
||||
{0, "XAXIS", 0, "X-Axis", "Left/Right"},
|
||||
{1, "YAXIS", 0, "Y-Axis", "Front/Back"},
|
||||
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
{0, NULL, 0, NULL, NULL}
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "AutoName by Axis";
|
||||
@@ -1918,7 +1919,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* settings */
|
||||
ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with");
|
||||
@@ -1926,7 +1927,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot)
|
||||
|
||||
/* ********************************************** */
|
||||
|
||||
static int pose_bone_rotmode_exec (bContext *C, wmOperator *op)
|
||||
static int pose_bone_rotmode_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
int mode = RNA_enum_get(op->ptr, "type");
|
||||
@@ -1940,7 +1941,7 @@ static int pose_bone_rotmode_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* notifiers and updates */
|
||||
DAG_id_tag_update((ID *)ob, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1958,7 +1959,7 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", posebone_rotmode_items, 0, "Rotation Mode", "");
|
||||
@@ -1967,18 +1968,18 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot)
|
||||
/* ********************************************** */
|
||||
|
||||
/* Show all armature layers */
|
||||
static int pose_armature_layers_showall_poll (bContext *C)
|
||||
static int pose_armature_layers_showall_poll(bContext *C)
|
||||
{
|
||||
/* this single operator can be used in posemode OR editmode for armatures */
|
||||
return ED_operator_posemode(C) || ED_operator_editarmature(C);
|
||||
}
|
||||
|
||||
static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op)
|
||||
static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = (ob)? ob->data : NULL;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
PointerRNA ptr;
|
||||
int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16;
|
||||
int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16;
|
||||
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
int i;
|
||||
|
||||
@@ -1987,7 +1988,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* use RNA to set the layers
|
||||
* although it would be faster to just set directly using bitflags, we still
|
||||
* although it would be faster to just set directly using bitflags, we still
|
||||
* need to setup a RNA pointer so that we get the "update" callbacks for free...
|
||||
*/
|
||||
RNA_id_pointer_create(&arm->id, &ptr);
|
||||
@@ -1998,7 +1999,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op)
|
||||
RNA_boolean_set_array(&ptr, "layers", layers);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -2016,7 +2017,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
|
||||
ot->poll = pose_armature_layers_showall_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)");
|
||||
@@ -2025,10 +2026,10 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
|
||||
/* ------------------- */
|
||||
|
||||
/* Present a popup to get the layers that should be used */
|
||||
static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int pose_armature_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm= (ob)? ob->data : NULL;
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
PointerRNA ptr;
|
||||
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
@@ -2046,9 +2047,9 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
|
||||
}
|
||||
|
||||
/* Set the visible layers for the active armature (edit and pose modes) */
|
||||
static int pose_armature_layers_exec (bContext *C, wmOperator *op)
|
||||
static int pose_armature_layers_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
PointerRNA ptr;
|
||||
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
@@ -2064,7 +2065,7 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op)
|
||||
RNA_boolean_set_array(&ptr, "layers", layers);
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2083,7 +2084,7 @@ void POSE_OT_armature_layers(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
|
||||
@@ -2102,7 +2103,7 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible");
|
||||
@@ -2111,9 +2112,9 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot)
|
||||
/* ------------------- */
|
||||
|
||||
/* Present a popup to get the layers that should be used */
|
||||
static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int pose_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
/* get layers that are active already */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
@@ -2121,9 +2122,9 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
short bit;
|
||||
|
||||
/* loop over the bits for this pchan's layers, adding layers where they're needed */
|
||||
for (bit= 0; bit < 32; bit++) {
|
||||
if (pchan->bone->layer & (1<<bit))
|
||||
layers[bit]= 1;
|
||||
for (bit = 0; bit < 32; bit++) {
|
||||
if (pchan->bone->layer & (1 << bit))
|
||||
layers[bit] = 1;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -2131,18 +2132,18 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
/* copy layers to operator */
|
||||
RNA_boolean_set_array(op->ptr, "layers", layers);
|
||||
|
||||
/* part to sync with other similar operators... */
|
||||
/* part to sync with other similar operators... */
|
||||
return WM_operator_props_popup(C, op, evt);
|
||||
}
|
||||
|
||||
/* Set the visible layers for the active armature (edit and pose modes) */
|
||||
static int pose_bone_layers_exec (bContext *C, wmOperator *op)
|
||||
static int pose_bone_layers_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
PointerRNA ptr;
|
||||
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
if (ob==NULL || ob->data==NULL) {
|
||||
if (ob == NULL || ob->data == NULL) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
@@ -2159,7 +2160,7 @@ static int pose_bone_layers_exec (bContext *C, wmOperator *op)
|
||||
CTX_DATA_END;
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2177,7 +2178,7 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
|
||||
@@ -2186,9 +2187,9 @@ void POSE_OT_bone_layers(wmOperatorType *ot)
|
||||
/* ------------------- */
|
||||
|
||||
/* Present a popup to get the layers that should be used */
|
||||
static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int armature_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
/* get layers that are active already */
|
||||
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
|
||||
@@ -2196,9 +2197,9 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
|
||||
short bit;
|
||||
|
||||
/* loop over the bits for this pchan's layers, adding layers where they're needed */
|
||||
for (bit= 0; bit < 32; bit++) {
|
||||
if (ebone->layer & (1<<bit))
|
||||
layers[bit]= 1;
|
||||
for (bit = 0; bit < 32; bit++) {
|
||||
if (ebone->layer & (1 << bit))
|
||||
layers[bit] = 1;
|
||||
}
|
||||
}
|
||||
CTX_DATA_END;
|
||||
@@ -2206,15 +2207,15 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev
|
||||
/* copy layers to operator */
|
||||
RNA_boolean_set_array(op->ptr, "layers", layers);
|
||||
|
||||
/* part to sync with other similar operators... */
|
||||
/* part to sync with other similar operators... */
|
||||
return WM_operator_props_popup(C, op, evt);
|
||||
}
|
||||
|
||||
/* Set the visible layers for the active armature (edit and pose modes) */
|
||||
static int armature_bone_layers_exec (bContext *C, wmOperator *op)
|
||||
static int armature_bone_layers_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *ob= CTX_data_edit_object(C);
|
||||
bArmature *arm= (ob)? ob->data : NULL;
|
||||
Object *ob = CTX_data_edit_object(C);
|
||||
bArmature *arm = (ob) ? ob->data : NULL;
|
||||
PointerRNA ptr;
|
||||
int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
|
||||
|
||||
@@ -2231,7 +2232,7 @@ static int armature_bone_layers_exec (bContext *C, wmOperator *op)
|
||||
CTX_DATA_END;
|
||||
|
||||
/* note, notifier might evolve */
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2249,7 +2250,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_editarmature;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to");
|
||||
@@ -2258,14 +2259,14 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot)
|
||||
/* ********************************************** */
|
||||
/* Flip Quats */
|
||||
|
||||
static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Object *ob= BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
|
||||
KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID);
|
||||
|
||||
/* loop through all selected pchans, flipping and keying (as needed) */
|
||||
CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
|
||||
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
|
||||
{
|
||||
/* only if bone is using quaternion rotation */
|
||||
if (pchan->rotmode == ROT_MODE_QUAT) {
|
||||
@@ -2279,7 +2280,7 @@ static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* notifiers and updates */
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2296,13 +2297,13 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ********************************************** */
|
||||
/* Clear User Transforms */
|
||||
|
||||
static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op)
|
||||
static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
@@ -2335,7 +2336,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* free temp data - free manually as was copied without constraints */
|
||||
if (dummyPose) {
|
||||
for (pchan= dummyPose->chanbase.first; pchan; pchan= pchan->next) {
|
||||
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
if (pchan->prop) {
|
||||
IDP_FreeProperty(pchan->prop);
|
||||
MEM_freeN(pchan->prop);
|
||||
@@ -2356,7 +2357,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* notifiers and updates */
|
||||
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2373,7 +2374,7 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_posemode;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_boolean(ot->srna, "only_selected", TRUE, "Only Selected", "Only visible/selected bones");
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef struct VertexData {
|
||||
|
||||
typedef struct EdgeIndex {
|
||||
EditEdge **edges;
|
||||
int *offset;
|
||||
int *offset;
|
||||
} EdgeIndex;
|
||||
|
||||
typedef enum {
|
||||
@@ -110,12 +110,12 @@ typedef enum {
|
||||
int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
|
||||
void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction);
|
||||
int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1);
|
||||
EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index);
|
||||
EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index);
|
||||
void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc);
|
||||
void addFacetoArc(ReebArc *arc, EditFace *efa);
|
||||
|
||||
void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count);
|
||||
void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2);
|
||||
void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count);
|
||||
void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2);
|
||||
|
||||
void flipArcBuckets(ReebArc *arc);
|
||||
|
||||
@@ -145,34 +145,34 @@ static VertexData *allocVertexData(EditMesh *em)
|
||||
|
||||
static int indexData(EditVert *eve)
|
||||
{
|
||||
return ((VertexData*)eve->tmp.p)->i;
|
||||
return ((VertexData *)eve->tmp.p)->i;
|
||||
}
|
||||
|
||||
static float weightData(EditVert *eve)
|
||||
{
|
||||
return ((VertexData*)eve->tmp.p)->w;
|
||||
return ((VertexData *)eve->tmp.p)->w;
|
||||
}
|
||||
|
||||
static void weightSetData(EditVert *eve, float w)
|
||||
{
|
||||
((VertexData*)eve->tmp.p)->w = w;
|
||||
((VertexData *)eve->tmp.p)->w = w;
|
||||
}
|
||||
|
||||
static ReebNode* nodeData(EditVert *eve)
|
||||
static ReebNode *nodeData(EditVert *eve)
|
||||
{
|
||||
return ((VertexData*)eve->tmp.p)->n;
|
||||
return ((VertexData *)eve->tmp.p)->n;
|
||||
}
|
||||
|
||||
static void nodeSetData(EditVert *eve, ReebNode *n)
|
||||
{
|
||||
((VertexData*)eve->tmp.p)->n = n;
|
||||
((VertexData *)eve->tmp.p)->n = n;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void REEB_freeArc(BArc *barc)
|
||||
{
|
||||
ReebArc *arc = (ReebArc*)barc;
|
||||
ReebArc *arc = (ReebArc *)barc;
|
||||
BLI_freelistN(&arc->edges);
|
||||
|
||||
if (arc->buckets)
|
||||
@@ -191,7 +191,7 @@ void REEB_freeGraph(ReebGraph *rg)
|
||||
|
||||
// free nodes
|
||||
for (node = rg->nodes.first; node; node = node->next) {
|
||||
BLI_freeNode((BGraph*)rg, (BNode*)node);
|
||||
BLI_freeNode((BGraph *)rg, (BNode *)node);
|
||||
}
|
||||
BLI_freelistN(&rg->nodes);
|
||||
|
||||
@@ -199,7 +199,7 @@ void REEB_freeGraph(ReebGraph *rg)
|
||||
arc = rg->arcs.first;
|
||||
while (arc) {
|
||||
ReebArc *next = arc->next;
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
arc = next;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ void REEB_freeGraph(ReebGraph *rg)
|
||||
MEM_freeN(rg);
|
||||
}
|
||||
|
||||
ReebGraph * newReebGraph(void)
|
||||
ReebGraph *newReebGraph(void)
|
||||
{
|
||||
ReebGraph *rg;
|
||||
rg = MEM_callocN(sizeof(ReebGraph), "reeb graph");
|
||||
@@ -233,13 +233,13 @@ ReebGraph * newReebGraph(void)
|
||||
|
||||
void BIF_flagMultiArcs(ReebGraph *rg, int flag)
|
||||
{
|
||||
for ( ; rg; rg = rg->link_up) {
|
||||
BLI_flagArcs((BGraph*)rg, flag);
|
||||
for (; rg; rg = rg->link_up) {
|
||||
BLI_flagArcs((BGraph *)rg, flag);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
static ReebNode * addNode(ReebGraph *rg, EditVert *eve)
|
||||
static ReebNode *addNode(ReebGraph *rg, EditVert *eve)
|
||||
{
|
||||
float weight;
|
||||
ReebNode *node = NULL;
|
||||
@@ -264,7 +264,7 @@ static ReebNode * addNode(ReebGraph *rg, EditVert *eve)
|
||||
return node;
|
||||
}
|
||||
|
||||
static ReebNode * copyNode(ReebGraph *rg, ReebNode *node)
|
||||
static ReebNode *copyNode(ReebGraph *rg, ReebNode *node)
|
||||
{
|
||||
ReebNode *cp_node = NULL;
|
||||
|
||||
@@ -329,7 +329,7 @@ ReebNode *BIF_lowestLevelNode(ReebNode *node)
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc)
|
||||
static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
|
||||
{
|
||||
ReebArc *cp_arc;
|
||||
ReebNode *node;
|
||||
@@ -375,7 +375,7 @@ static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc)
|
||||
return cp_arc;
|
||||
}
|
||||
|
||||
static ReebGraph * copyReebGraph(ReebGraph *rg, int level)
|
||||
static ReebGraph *copyReebGraph(ReebGraph *rg, int level)
|
||||
{
|
||||
ReebNode *node;
|
||||
ReebArc *arc;
|
||||
@@ -399,7 +399,7 @@ static ReebGraph * copyReebGraph(ReebGraph *rg, int level)
|
||||
copyArc(cp_rg, arc);
|
||||
}
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)cp_rg);
|
||||
BLI_buildAdjacencyList((BGraph *)cp_rg);
|
||||
|
||||
return cp_rg;
|
||||
}
|
||||
@@ -417,7 +417,7 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node)
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
static ReebEdge * copyEdge(ReebEdge *edge)
|
||||
static ReebEdge *copyEdge(ReebEdge *edge)
|
||||
{
|
||||
ReebEdge *newEdge = NULL;
|
||||
|
||||
@@ -433,11 +433,11 @@ static ReebEdge * copyEdge(ReebEdge *edge)
|
||||
static void printArc(ReebArc *arc)
|
||||
{
|
||||
ReebEdge *edge;
|
||||
ReebNode *head = (ReebNode*)arc->head;
|
||||
ReebNode *tail = (ReebNode*)arc->tail;
|
||||
ReebNode *head = (ReebNode *)arc->head;
|
||||
ReebNode *tail = (ReebNode *)arc->tail;
|
||||
printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight);
|
||||
|
||||
for (edge = arc->edges.first; edge ; edge = edge->next)
|
||||
for (edge = arc->edges.first; edge; edge = edge->next)
|
||||
{
|
||||
printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index);
|
||||
}
|
||||
@@ -475,8 +475,8 @@ static void NodeDegreeIncrement(ReebGraph *UNUSED(rg), ReebNode *node)
|
||||
}
|
||||
|
||||
#else
|
||||
#define NodeDegreeDecrement(rg, node) {node->degree--;}
|
||||
#define NodeDegreeIncrement(rg, node) {node->degree++;}
|
||||
#define NodeDegreeDecrement(rg, node) {node->degree--; }
|
||||
#define NodeDegreeIncrement(rg, node) {node->degree++; }
|
||||
#endif
|
||||
|
||||
void repositionNodes(ReebGraph *rg)
|
||||
@@ -490,14 +490,14 @@ void repositionNodes(ReebGraph *rg)
|
||||
}
|
||||
|
||||
for (arc = rg->arcs.first; arc; arc = arc->next) {
|
||||
if (((ReebArc*)arc)->bcount > 0) {
|
||||
if (((ReebArc *)arc)->bcount > 0) {
|
||||
float p[3];
|
||||
|
||||
copy_v3_v3(p, ((ReebArc*)arc)->buckets[0].p);
|
||||
copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p);
|
||||
mul_v3_fl(p, 1.0f / arc->head->degree);
|
||||
add_v3_v3(arc->head->p, p);
|
||||
|
||||
copy_v3_v3(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p);
|
||||
copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p);
|
||||
mul_v3_fl(p, 1.0f / arc->tail->degree);
|
||||
add_v3_v3(arc->tail->p, p);
|
||||
}
|
||||
@@ -529,15 +529,15 @@ void verifyNodeDegree(ReebGraph *rg)
|
||||
|
||||
static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc)
|
||||
{
|
||||
ReebNode *head = (ReebNode*)arc->head;
|
||||
ReebNode *tail = (ReebNode*)arc->tail;
|
||||
ReebNode *head = (ReebNode *)arc->head;
|
||||
ReebNode *tail = (ReebNode *)arc->tail;
|
||||
|
||||
if (arc->bcount > 0) {
|
||||
int i;
|
||||
for (i = 0; i < arc->bcount; i++) {
|
||||
if (arc->buckets[i].nv == 0) {
|
||||
printArc(arc);
|
||||
printf("count error in bucket %i/%i\n", i+1, arc->bcount);
|
||||
printf("count error in bucket %i/%i\n", i + 1, arc->bcount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,12 +653,12 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end
|
||||
indexSrc++;
|
||||
}
|
||||
|
||||
for ( ; indexDst < aDst->bcount &&
|
||||
indexSrc < aSrc->bcount &&
|
||||
aDst->buckets[indexDst].val <= end &&
|
||||
aSrc->buckets[indexSrc].val <= end
|
||||
for (; indexDst < aDst->bcount &&
|
||||
indexSrc < aSrc->bcount &&
|
||||
aDst->buckets[indexDst].val <= end &&
|
||||
aSrc->buckets[indexSrc].val <= end
|
||||
|
||||
; indexDst++, indexSrc++)
|
||||
; indexDst++, indexSrc++)
|
||||
{
|
||||
mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc);
|
||||
}
|
||||
@@ -809,7 +809,7 @@ static void fillArcEmptyBuckets(ReebArc *arc)
|
||||
static void ExtendArcBuckets(ReebArc *arc)
|
||||
{
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
EmbedBucket *last_bucket, *first_bucket;
|
||||
float *previous = NULL;
|
||||
float average_length = 0, length;
|
||||
@@ -823,10 +823,10 @@ static void ExtendArcBuckets(ReebArc *arc)
|
||||
IT_next(iter);
|
||||
previous = iter->p;
|
||||
|
||||
for ( IT_next(iter);
|
||||
IT_stopped(iter) == 0;
|
||||
previous = iter->p, IT_next(iter)
|
||||
)
|
||||
for (IT_next(iter);
|
||||
IT_stopped(iter) == 0;
|
||||
previous = iter->p, IT_next(iter)
|
||||
)
|
||||
{
|
||||
average_length += len_v3v3(previous, iter->p);
|
||||
}
|
||||
@@ -880,7 +880,7 @@ static void extendGraphBuckets(ReebGraph *rg)
|
||||
static void calculateArcLength(ReebArc *arc)
|
||||
{
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
float *vec0, *vec1;
|
||||
|
||||
arc->length = 0;
|
||||
@@ -913,9 +913,9 @@ static void calculateGraphLength(ReebGraph *rg)
|
||||
|
||||
/**************************************** SYMMETRY HANDLING ******************************************/
|
||||
|
||||
void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count)
|
||||
{
|
||||
ReebNode *node = (ReebNode*)root_node;
|
||||
ReebNode *node = (ReebNode *)root_node;
|
||||
float axis[3];
|
||||
int i;
|
||||
|
||||
@@ -932,11 +932,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
add_v3_v3v3(tangent, ring[i].n, ring[j].n);
|
||||
cross_v3_v3v3(normal, tangent, axis);
|
||||
|
||||
node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node);
|
||||
node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node);
|
||||
node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
|
||||
node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
|
||||
|
||||
arc1 = (ReebArc*)ring[i].arc;
|
||||
arc2 = (ReebArc*)ring[j].arc;
|
||||
arc1 = (ReebArc *)ring[i].arc;
|
||||
arc2 = (ReebArc *)ring[j].arc;
|
||||
|
||||
/* mirror first node and mix with the second */
|
||||
BLI_mirrorAlongAxis(node1->p, root_node->p, normal);
|
||||
@@ -947,12 +947,12 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
* */
|
||||
if (arc1->bcount > 0 && arc2->bcount > 0) {
|
||||
ReebArcIterator arc_iter1, arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
|
||||
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
|
||||
|
||||
initArcIterator(iter1, arc1, (ReebNode*)root_node);
|
||||
initArcIterator(iter2, arc2, (ReebNode*)root_node);
|
||||
initArcIterator(iter1, arc1, (ReebNode *)root_node);
|
||||
initArcIterator(iter2, arc2, (ReebNode *)root_node);
|
||||
|
||||
bucket1 = IT_next(iter1);
|
||||
bucket2 = IT_next(iter2);
|
||||
@@ -967,7 +967,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
}
|
||||
|
||||
|
||||
for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
bucket2->nv += bucket1->nv; /* add counts */
|
||||
|
||||
/* mirror on axis */
|
||||
@@ -989,11 +989,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
add_v3_v3v3(tangent, ring[i].n, ring[j].n);
|
||||
cross_v3_v3v3(normal, tangent, axis);
|
||||
|
||||
node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node);
|
||||
node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node);
|
||||
node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node);
|
||||
node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node);
|
||||
|
||||
arc1 = (ReebArc*)ring[i].arc;
|
||||
arc2 = (ReebArc*)ring[j].arc;
|
||||
arc1 = (ReebArc *)ring[i].arc;
|
||||
arc2 = (ReebArc *)ring[j].arc;
|
||||
|
||||
/* copy first node than mirror */
|
||||
copy_v3_v3(node2->p, node1->p);
|
||||
@@ -1004,8 +1004,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
* */
|
||||
if (arc1->bcount > 0 && arc2->bcount > 0) {
|
||||
ReebArcIterator arc_iter1, arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
|
||||
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
|
||||
|
||||
initArcIterator(iter1, arc1, node);
|
||||
@@ -1024,7 +1024,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
}
|
||||
|
||||
|
||||
for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
/* copy and mirror back to bucket2 */
|
||||
bucket2->nv = bucket1->nv;
|
||||
copy_v3_v3(bucket2->p, bucket1->p);
|
||||
@@ -1034,13 +1034,13 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
|
||||
}
|
||||
}
|
||||
|
||||
void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2)
|
||||
void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2)
|
||||
{
|
||||
ReebArc *arc1, *arc2;
|
||||
float nor[3], p[3];
|
||||
|
||||
arc1 = (ReebArc*)barc1;
|
||||
arc2 = (ReebArc*)barc2;
|
||||
arc1 = (ReebArc *)barc1;
|
||||
arc2 = (ReebArc *)barc2;
|
||||
|
||||
copy_v3_v3(nor, root_node->symmetry_axis);
|
||||
|
||||
@@ -1061,12 +1061,12 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr
|
||||
* */
|
||||
if (arc1->bcount > 0 && arc2->bcount > 0) {
|
||||
ReebArcIterator arc_iter1, arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
|
||||
BArcIterator *iter1 = (BArcIterator *)&arc_iter1;
|
||||
BArcIterator *iter2 = (BArcIterator *)&arc_iter2;
|
||||
EmbedBucket *bucket1 = NULL, *bucket2 = NULL;
|
||||
|
||||
initArcIterator(iter1, arc1, (ReebNode*)root_node);
|
||||
initArcIterator(iter2, arc2, (ReebNode*)root_node);
|
||||
initArcIterator(iter1, arc1, (ReebNode *)root_node);
|
||||
initArcIterator(iter2, arc2, (ReebNode *)root_node);
|
||||
|
||||
bucket1 = IT_next(iter1);
|
||||
bucket2 = IT_next(iter2);
|
||||
@@ -1081,7 +1081,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr
|
||||
}
|
||||
|
||||
|
||||
for ( ; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) {
|
||||
bucket1->nv += bucket2->nv; /* add counts */
|
||||
|
||||
/* mirror on axis */
|
||||
@@ -1110,21 +1110,21 @@ void postprocessGraph(ReebGraph *rg, char mode)
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case SKGEN_AVERAGE:
|
||||
fac1 = fac2 = fac3 = 1.0f / 3.0f;
|
||||
break;
|
||||
case SKGEN_SMOOTH:
|
||||
fac1 = fac3 = 0.25f;
|
||||
fac2 = 0.5f;
|
||||
break;
|
||||
case SKGEN_SHARPEN:
|
||||
fac1 = fac3 = -0.25f;
|
||||
fac2 = 1.5f;
|
||||
break;
|
||||
default:
|
||||
case SKGEN_AVERAGE:
|
||||
fac1 = fac2 = fac3 = 1.0f / 3.0f;
|
||||
break;
|
||||
case SKGEN_SMOOTH:
|
||||
fac1 = fac3 = 0.25f;
|
||||
fac2 = 0.5f;
|
||||
break;
|
||||
case SKGEN_SHARPEN:
|
||||
fac1 = fac3 = -0.25f;
|
||||
fac2 = 1.5f;
|
||||
break;
|
||||
default:
|
||||
// XXX
|
||||
// error("Unknown post processing mode");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
for (arc = rg->arcs.first; arc; arc = arc->next)
|
||||
@@ -1145,8 +1145,8 @@ void postprocessGraph(ReebGraph *rg, char mode)
|
||||
|
||||
static int compareNodesWeight(void *vnode1, void *vnode2)
|
||||
{
|
||||
ReebNode *node1 = (ReebNode*)vnode1;
|
||||
ReebNode *node2 = (ReebNode*)vnode2;
|
||||
ReebNode *node1 = (ReebNode *)vnode1;
|
||||
ReebNode *node2 = (ReebNode *)vnode2;
|
||||
|
||||
if (node1->weight < node2->weight)
|
||||
{
|
||||
@@ -1156,8 +1156,7 @@ static int compareNodesWeight(void *vnode1, void *vnode2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1169,10 +1168,10 @@ void sortNodes(ReebGraph *rg)
|
||||
|
||||
static int compareArcsWeight(void *varc1, void *varc2)
|
||||
{
|
||||
ReebArc *arc1 = (ReebArc*)varc1;
|
||||
ReebArc *arc2 = (ReebArc*)varc2;
|
||||
ReebNode *node1 = (ReebNode*)arc1->head;
|
||||
ReebNode *node2 = (ReebNode*)arc2->head;
|
||||
ReebArc *arc1 = (ReebArc *)varc1;
|
||||
ReebArc *arc2 = (ReebArc *)varc2;
|
||||
ReebNode *node1 = (ReebNode *)arc1->head;
|
||||
ReebNode *node2 = (ReebNode *)arc2->head;
|
||||
|
||||
if (node1->weight < node2->weight)
|
||||
{
|
||||
@@ -1182,8 +1181,7 @@ static int compareArcsWeight(void *varc1, void *varc2)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -1201,7 +1199,7 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float
|
||||
float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight);
|
||||
int i;
|
||||
|
||||
node = (ReebNode*)BLI_otherNode((BArc*)arc, (BNode*)start_node);
|
||||
node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node);
|
||||
|
||||
/* prevent backtracking */
|
||||
if (node->flag == 1)
|
||||
@@ -1243,7 +1241,7 @@ static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_we
|
||||
{
|
||||
int i;
|
||||
|
||||
BLI_flagNodes((BGraph*)rg, 0);
|
||||
BLI_flagNodes((BGraph *)rg, 0);
|
||||
|
||||
for (i = 0; i < start_node->degree; i++)
|
||||
{
|
||||
@@ -1317,15 +1315,15 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs)
|
||||
|
||||
if (merging)
|
||||
{
|
||||
BLI_ReflagSubgraph((BGraph*)rg, end_node->flag, subgraph);
|
||||
BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph);
|
||||
|
||||
resizeArcBuckets(start_arc);
|
||||
fillArcEmptyBuckets(start_arc);
|
||||
|
||||
NodeDegreeIncrement(rg, end_node);
|
||||
BLI_rebuildAdjacencyListForNode((BGraph*)rg, (BNode*)end_node);
|
||||
BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)start_node);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)start_node);
|
||||
}
|
||||
|
||||
joined = 1;
|
||||
@@ -1368,10 +1366,9 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
|
||||
int nb_subgraphs;
|
||||
int joined = 0;
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
if (BLI_isGraphCyclic((BGraph*)rg))
|
||||
{
|
||||
if (BLI_isGraphCyclic((BGraph *)rg)) {
|
||||
/* don't deal with cyclic graphs YET */
|
||||
return 0;
|
||||
}
|
||||
@@ -1379,13 +1376,13 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
|
||||
/* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */
|
||||
sortNodes(rg);
|
||||
|
||||
nb_subgraphs = BLI_FlagSubgraphs((BGraph*)rg);
|
||||
nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg);
|
||||
|
||||
/* Harmonic function can create flipped arcs, take the occasion to fix them */
|
||||
// XXX
|
||||
// if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC)
|
||||
// {
|
||||
fixSubgraphsOrientation(rg, nb_subgraphs);
|
||||
fixSubgraphsOrientation(rg, nb_subgraphs);
|
||||
// }
|
||||
|
||||
if (nb_subgraphs > 1)
|
||||
@@ -1395,7 +1392,7 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
|
||||
if (joined)
|
||||
{
|
||||
removeNormalNodes(rg);
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1407,8 +1404,8 @@ static int joinSubgraphs(ReebGraph *rg, float threshold)
|
||||
static float lengthArc(ReebArc *arc)
|
||||
{
|
||||
#if 0
|
||||
ReebNode *head = (ReebNode*)arc->head;
|
||||
ReebNode *tail = (ReebNode*)arc->tail;
|
||||
ReebNode *head = (ReebNode *)arc->head;
|
||||
ReebNode *tail = (ReebNode *)arc->tail;
|
||||
|
||||
return tail->weight - head->weight;
|
||||
#else
|
||||
@@ -1418,8 +1415,8 @@ static float lengthArc(ReebArc *arc)
|
||||
|
||||
static int compareArcs(void *varc1, void *varc2)
|
||||
{
|
||||
ReebArc *arc1 = (ReebArc*)varc1;
|
||||
ReebArc *arc2 = (ReebArc*)varc2;
|
||||
ReebArc *arc1 = (ReebArc *)varc1;
|
||||
ReebArc *arc2 = (ReebArc *)varc2;
|
||||
float len1 = lengthArc(arc1);
|
||||
float len2 = lengthArc(arc2);
|
||||
|
||||
@@ -1434,7 +1431,7 @@ static int compareArcs(void *varc1, void *varc2)
|
||||
}
|
||||
}
|
||||
|
||||
static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc * srcArc, int merging)
|
||||
static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc *srcArc, int merging)
|
||||
{
|
||||
ReebArc *arc = NULL, *nextArc = NULL;
|
||||
|
||||
@@ -1470,7 +1467,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
|
||||
// If it's srcArc, it'll be removed later, so keep it for now
|
||||
if (arc != srcArc) {
|
||||
BLI_remlink(&rg->arcs, arc);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1509,8 +1506,8 @@ void filterNullReebGraph(ReebGraph *rg)
|
||||
nextArc = arc->next;
|
||||
// Only collapse arcs too short to have any embed bucket
|
||||
if (arc->bcount == 0) {
|
||||
ReebNode *newNode = (ReebNode*)arc->head;
|
||||
ReebNode *removedNode = (ReebNode*)arc->tail;
|
||||
ReebNode *newNode = (ReebNode *)arc->head;
|
||||
ReebNode *removedNode = (ReebNode *)arc->tail;
|
||||
float blend;
|
||||
|
||||
blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors
|
||||
@@ -1523,9 +1520,9 @@ void filterNullReebGraph(ReebGraph *rg)
|
||||
nextArc = arc->next;
|
||||
|
||||
BLI_remlink(&rg->arcs, arc);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)removedNode);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
|
||||
}
|
||||
|
||||
arc = nextArc;
|
||||
@@ -1561,9 +1558,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
|
||||
nextArc = arc->next;
|
||||
|
||||
BLI_remlink(&rg->arcs, arc);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)removedNode);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
|
||||
value = 1;
|
||||
}
|
||||
|
||||
@@ -1613,9 +1610,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
|
||||
nextArc = arc->next;
|
||||
|
||||
BLI_remlink(&rg->arcs, arc);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)removedNode);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
|
||||
value = 1;
|
||||
}
|
||||
}
|
||||
@@ -1641,7 +1638,7 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold)
|
||||
NodeDegreeDecrement(rg, arc1->tail);
|
||||
|
||||
BLI_remlink(&rg->arcs, arc2);
|
||||
REEB_freeArc((BArc*)arc2);
|
||||
REEB_freeArc((BArc *)arc2);
|
||||
|
||||
filtered = 1;
|
||||
}
|
||||
@@ -1662,7 +1659,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
|
||||
#ifdef DEBUG_REEB
|
||||
{
|
||||
EditFace *efa;
|
||||
for (efa=G.editMesh->faces.first; efa; efa=efa->next) {
|
||||
for (efa = G.editMesh->faces.first; efa; efa = efa->next) {
|
||||
efa->tmp.fp = -1;
|
||||
}
|
||||
}
|
||||
@@ -1686,14 +1683,14 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
|
||||
float avg_vec[3] = {0, 0, 0};
|
||||
|
||||
for (BLI_ghashIterator_init(&ghi, arc->faces);
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
{
|
||||
EditFace *efa = BLI_ghashIterator_getValue(&ghi);
|
||||
|
||||
#if 0
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
EmbedBucket *bucket = NULL;
|
||||
EmbedBucket *previous = NULL;
|
||||
float min_distance = -1;
|
||||
@@ -1716,8 +1713,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
|
||||
vec0 = arc->head->p;
|
||||
}
|
||||
/* Previous is a valid bucket */
|
||||
else
|
||||
{
|
||||
else {
|
||||
vec0 = previous->p;
|
||||
}
|
||||
|
||||
@@ -1805,7 +1801,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
|
||||
nextArc = arc->next;
|
||||
|
||||
BLI_remlink(&rg->arcs, arc);
|
||||
REEB_freeArc((BArc*)arc);
|
||||
REEB_freeArc((BArc *)arc);
|
||||
|
||||
BLI_freelinkN(&rg->nodes, removedNode);
|
||||
value = 1;
|
||||
@@ -1858,7 +1854,7 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method)
|
||||
{
|
||||
int i;
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
sortNodes(rg);
|
||||
|
||||
@@ -1873,10 +1869,10 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method)
|
||||
|
||||
/************************************** WEIGHT SPREADING ***********************************************/
|
||||
|
||||
static int compareVerts(const void* a, const void* b)
|
||||
static int compareVerts(const void *a, const void *b)
|
||||
{
|
||||
EditVert *va = *(EditVert**)a;
|
||||
EditVert *vb = *(EditVert**)b;
|
||||
EditVert *va = *(EditVert **)a;
|
||||
EditVert *vb = *(EditVert **)b;
|
||||
int value = 0;
|
||||
|
||||
if (weightData(va) < weightData(vb)) {
|
||||
@@ -1897,7 +1893,7 @@ static void spreadWeight(EditMesh *em)
|
||||
int i;
|
||||
int work_needed = 1;
|
||||
|
||||
verts = MEM_callocN(sizeof(EditVert*) * totvert, "verts array");
|
||||
verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array");
|
||||
|
||||
for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) {
|
||||
verts[i] = eve;
|
||||
@@ -1905,7 +1901,7 @@ static void spreadWeight(EditMesh *em)
|
||||
|
||||
while (work_needed == 1) {
|
||||
work_needed = 0;
|
||||
qsort(verts, totvert, sizeof(EditVert*), compareVerts);
|
||||
qsort(verts, totvert, sizeof(EditVert *), compareVerts);
|
||||
|
||||
for (i = 0; i < totvert; i++) {
|
||||
eve = verts[i];
|
||||
@@ -1976,7 +1972,7 @@ static void removeZeroNodes(ReebGraph *rg)
|
||||
next_node = node->next;
|
||||
|
||||
if (node->degree == 0) {
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)node);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1992,7 +1988,7 @@ void removeNormalNodes(ReebGraph *rg)
|
||||
while (arc->head->degree == 2 || arc->tail->degree == 2) {
|
||||
// merge at v1
|
||||
if (arc->head->degree == 2) {
|
||||
ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->head);
|
||||
ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->head);
|
||||
|
||||
/* If arcs are one after the other */
|
||||
if (arc->head == connectedArc->tail) {
|
||||
@@ -2015,7 +2011,7 @@ void removeNormalNodes(ReebGraph *rg)
|
||||
|
||||
/* merge at v2 */
|
||||
if (arc->tail->degree == 2) {
|
||||
ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->tail);
|
||||
ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail);
|
||||
|
||||
/* If arcs are one after the other */
|
||||
if (arc->tail == connectedArc->head) {
|
||||
@@ -2073,8 +2069,8 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc)
|
||||
GHashIterator ghi;
|
||||
|
||||
for (BLI_ghashIterator_init(&ghi, aSrc->faces);
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
!BLI_ghashIterator_isDone(&ghi);
|
||||
BLI_ghashIterator_step(&ghi))
|
||||
{
|
||||
EditFace *efa = BLI_ghashIterator_getValue(&ghi);
|
||||
BLI_ghash_insert(aDst->faces, efa, efa);
|
||||
@@ -2107,11 +2103,11 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
|
||||
|
||||
// if edge was the first in the list, point the edit edge to the new reeb edge instead.
|
||||
if (*p == e) {
|
||||
*p = (void*)newEdge;
|
||||
*p = (void *)newEdge;
|
||||
}
|
||||
// otherwise, advance in the list until the predecessor is found then insert it there
|
||||
else {
|
||||
ReebEdge *previous = (ReebEdge*)*p;
|
||||
ReebEdge *previous = (ReebEdge *)*p;
|
||||
|
||||
while (previous->nextEdge != e) {
|
||||
previous = previous->nextEdge;
|
||||
@@ -2155,9 +2151,9 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
|
||||
|
||||
// remove a1 from graph
|
||||
BLI_remlink(&rg->arcs, a1);
|
||||
REEB_freeArc((BArc*)a1);
|
||||
REEB_freeArc((BArc *)a1);
|
||||
|
||||
BLI_removeNode((BGraph*)rg, (BNode*)removedNode);
|
||||
BLI_removeNode((BGraph *)rg, (BNode *)removedNode);
|
||||
result = 1;
|
||||
|
||||
return result;
|
||||
@@ -2183,7 +2179,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
|
||||
// remove a1 from graph
|
||||
BLI_remlink(&rg->arcs, a1);
|
||||
|
||||
REEB_freeArc((BArc*)a1);
|
||||
REEB_freeArc((BArc *)a1);
|
||||
result = 1;
|
||||
}
|
||||
else if (a0->tail->weight > a1->tail->weight) { /* a1->tail->weight is in the middle */
|
||||
@@ -2266,9 +2262,9 @@ static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e
|
||||
else {
|
||||
a1 = nextArcMappedToEdge(a1, e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2)
|
||||
{
|
||||
@@ -2281,7 +2277,7 @@ static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2)
|
||||
glueByMergeSort(rg, a0, a2, e0, e2);
|
||||
}
|
||||
|
||||
static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
|
||||
static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
|
||||
{
|
||||
ReebEdge *edge;
|
||||
|
||||
@@ -2359,7 +2355,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
|
||||
return edge;
|
||||
}
|
||||
|
||||
static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, ReebNode * n3, EditFace *efa)
|
||||
static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNode *n3, EditFace *efa)
|
||||
{
|
||||
ReebEdge *re1, *re2, *re3;
|
||||
ReebEdge *e1, *e2, *e3;
|
||||
@@ -2408,7 +2404,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, Reeb
|
||||
mergePaths(rg, e1, e2, e3);
|
||||
}
|
||||
|
||||
ReebGraph * generateReebGraph(EditMesh *em, int subdivisions)
|
||||
ReebGraph *generateReebGraph(EditMesh *em, int subdivisions)
|
||||
{
|
||||
ReebGraph *rg;
|
||||
EditVert *eve;
|
||||
@@ -2536,13 +2532,13 @@ static float cotan_weight(float *v1, float *v2, float *v3)
|
||||
if (clen == 0.0f)
|
||||
return 0.0f;
|
||||
|
||||
return dot_v3v3(a, b)/clen;
|
||||
return dot_v3v3(a, b) / clen;
|
||||
}
|
||||
|
||||
static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3)
|
||||
{
|
||||
/* Angle opposite e1 */
|
||||
float t1= cotan_weight(v1->co, v2->co, v3->co) / e2;
|
||||
float t1 = cotan_weight(v1->co, v2->co, v3->co) / e2;
|
||||
|
||||
/* Angle opposite e2 */
|
||||
float t2 = cotan_weight(v2->co, v3->co, v1->co) / e3;
|
||||
@@ -2554,9 +2550,9 @@ static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2
|
||||
int i2 = indexData(v2);
|
||||
int i3 = indexData(v3);
|
||||
|
||||
nlMatrixAdd(i1, i1, t2+t3);
|
||||
nlMatrixAdd(i2, i2, t1+t3);
|
||||
nlMatrixAdd(i3, i3, t1+t2);
|
||||
nlMatrixAdd(i1, i1, t2 + t3);
|
||||
nlMatrixAdd(i2, i2, t1 + t3);
|
||||
nlMatrixAdd(i3, i3, t1 + t2);
|
||||
|
||||
nlMatrixAdd(i1, i2, -t3);
|
||||
nlMatrixAdd(i2, i1, -t3);
|
||||
@@ -2688,7 +2684,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
|
||||
}
|
||||
|
||||
|
||||
EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index)
|
||||
EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index)
|
||||
{
|
||||
static int offset = -1;
|
||||
|
||||
@@ -2712,7 +2708,7 @@ EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index)
|
||||
|
||||
static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeIndex *indexed_edges)
|
||||
{
|
||||
Heap *edge_heap;
|
||||
Heap *edge_heap;
|
||||
EditVert *current_eve = NULL;
|
||||
EditEdge *eed = NULL;
|
||||
EditEdge *select_eed = NULL;
|
||||
@@ -2725,7 +2721,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
|
||||
BLI_heap_insert(edge_heap, FLT_MAX, NULL);
|
||||
|
||||
/* Initialize edge flag */
|
||||
for (eed= em->edges.first; eed; eed= eed->next) {
|
||||
for (eed = em->edges.first; eed; eed = eed->next) {
|
||||
eed->f1 = 0;
|
||||
}
|
||||
|
||||
@@ -2744,8 +2740,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
|
||||
}
|
||||
|
||||
/* Find next shortest edge with unselected verts */
|
||||
do
|
||||
{
|
||||
do {
|
||||
current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap));
|
||||
select_eed = BLI_heap_popmin(edge_heap);
|
||||
} while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1);
|
||||
@@ -2795,7 +2790,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
|
||||
|
||||
tot_indexed += totvert;
|
||||
|
||||
indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge*), "EdgeIndex edges");
|
||||
indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges");
|
||||
|
||||
/* setting vert offsets */
|
||||
for (eve = em->verts.first; eve; eve = eve->next) {
|
||||
@@ -2807,7 +2802,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
|
||||
}
|
||||
|
||||
/* adding edges in array */
|
||||
for (eed = em->edges.first; eed; eed= eed->next) {
|
||||
for (eed = em->edges.first; eed; eed = eed->next) {
|
||||
if (eed->v1->h == 0 && eed->v2->h == 0) {
|
||||
int i;
|
||||
for (i = indexed_edges->offset[indexData(eed->v1)]; i < tot_indexed; i++) {
|
||||
@@ -2862,7 +2857,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
|
||||
int allDone = 0;
|
||||
|
||||
/* Calculate edge weight */
|
||||
for (eed = em->edges.first; eed; eed= eed->next) {
|
||||
for (eed = em->edges.first; eed; eed = eed->next) {
|
||||
if (eed->v1->h == 0 && eed->v2->h == 0) {
|
||||
eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co);
|
||||
}
|
||||
@@ -2925,12 +2920,12 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
|
||||
|
||||
/****************************************** BUCKET ITERATOR **************************************************/
|
||||
|
||||
static void* headNode(void *arg);
|
||||
static void* tailNode(void *arg);
|
||||
static void* nextBucket(void *arg);
|
||||
static void* nextNBucket(void *arg, int n);
|
||||
static void* peekBucket(void *arg, int n);
|
||||
static void* previousBucket(void *arg);
|
||||
static void *headNode(void *arg);
|
||||
static void *tailNode(void *arg);
|
||||
static void *nextBucket(void *arg);
|
||||
static void *nextNBucket(void *arg, int n);
|
||||
static void *peekBucket(void *arg, int n);
|
||||
static void *previousBucket(void *arg);
|
||||
static int iteratorStopped(void *arg);
|
||||
|
||||
static void initIteratorFct(ReebArcIterator *iter)
|
||||
@@ -2959,7 +2954,7 @@ static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket)
|
||||
|
||||
void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
|
||||
initIteratorFct(iter);
|
||||
iter->arc = arc;
|
||||
@@ -2982,7 +2977,7 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
|
||||
|
||||
void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNode *head, int start)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
|
||||
initIteratorFct(iter);
|
||||
iter->arc = arc;
|
||||
@@ -3009,7 +3004,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod
|
||||
|
||||
void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
|
||||
initIteratorFct(iter);
|
||||
iter->arc = arc;
|
||||
@@ -3029,9 +3024,9 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end)
|
||||
iter->length = abs(iter->end - iter->start) + 1;
|
||||
}
|
||||
|
||||
static void* headNode(void *arg)
|
||||
static void *headNode(void *arg)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
ReebNode *node;
|
||||
|
||||
if (iter->start < iter->end) {
|
||||
@@ -3048,9 +3043,9 @@ static void* headNode(void *arg)
|
||||
return node;
|
||||
}
|
||||
|
||||
static void* tailNode(void *arg)
|
||||
static void *tailNode(void *arg)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
ReebNode *node;
|
||||
|
||||
if (iter->start < iter->end) {
|
||||
@@ -3067,9 +3062,9 @@ static void* tailNode(void *arg)
|
||||
return node;
|
||||
}
|
||||
|
||||
static void* nextBucket(void *arg)
|
||||
static void *nextBucket(void *arg)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
EmbedBucket *result = NULL;
|
||||
|
||||
iter->index++;
|
||||
@@ -3082,9 +3077,9 @@ static void* nextBucket(void *arg)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* nextNBucket(void *arg, int n)
|
||||
static void *nextNBucket(void *arg, int n)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
EmbedBucket *result = NULL;
|
||||
|
||||
iter->index += n;
|
||||
@@ -3098,9 +3093,9 @@ static void* nextNBucket(void *arg, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* peekBucket(void *arg, int n)
|
||||
static void *peekBucket(void *arg, int n)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
EmbedBucket *result = NULL;
|
||||
int index = iter->index + n;
|
||||
|
||||
@@ -3113,9 +3108,9 @@ static void* peekBucket(void *arg, int n)
|
||||
return result;
|
||||
}
|
||||
|
||||
static void* previousBucket(void *arg)
|
||||
static void *previousBucket(void *arg)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
EmbedBucket *result = NULL;
|
||||
|
||||
if (iter->index > 0) {
|
||||
@@ -3129,7 +3124,7 @@ static void* previousBucket(void *arg)
|
||||
|
||||
static int iteratorStopped(void *arg)
|
||||
{
|
||||
ReebArcIterator *iter = (ReebArcIterator*)arg;
|
||||
ReebArcIterator *iter = (ReebArcIterator *)arg;
|
||||
|
||||
if (iter->index >= iter->length) {
|
||||
return 1;
|
||||
@@ -3148,7 +3143,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
|
||||
#if 0
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
EditMesh *em = BKE_mesh_get_editmesh(((Mesh*)obedit->data));
|
||||
EditMesh *em = BKE_mesh_get_editmesh(((Mesh *)obedit->data));
|
||||
EdgeIndex indexed_edges;
|
||||
VertexData *data;
|
||||
ReebGraph *rg = NULL;
|
||||
@@ -3193,10 +3188,10 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
|
||||
|
||||
joinSubgraphs(rg, 1.0);
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
/* calc length before copy, so we have same length on all levels */
|
||||
BLI_calcGraphLength((BGraph*)rg);
|
||||
BLI_calcGraphLength((BGraph *)rg);
|
||||
|
||||
previous = NULL;
|
||||
for (i = 0; i <= nb_levels; i++)
|
||||
@@ -3214,8 +3209,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
|
||||
{
|
||||
internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels);
|
||||
}
|
||||
|
||||
@@ -3231,7 +3225,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C)
|
||||
|
||||
finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro);
|
||||
|
||||
BLI_markdownSymmetry((BGraph*)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit);
|
||||
BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit);
|
||||
|
||||
if (previous != NULL)
|
||||
{
|
||||
@@ -3306,10 +3300,10 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void)
|
||||
|
||||
joinSubgraphs(rg, 1.0);
|
||||
|
||||
BLI_buildAdjacencyList((BGraph*)rg);
|
||||
BLI_buildAdjacencyList((BGraph *)rg);
|
||||
|
||||
/* calc length before copy, so we have same length on all levels */
|
||||
BLI_calcGraphLength((BGraph*)rg);
|
||||
BLI_calcGraphLength((BGraph *)rg);
|
||||
|
||||
filterGraph(rg, G.scene->toolsettings->skgen_options, G.scene->toolsettings->skgen_threshold_internal, G.scene->toolsettings->skgen_threshold_external);
|
||||
|
||||
@@ -3323,7 +3317,7 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void)
|
||||
#endif
|
||||
|
||||
printf("DONE\n");
|
||||
printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph*)rg));
|
||||
printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph *)rg));
|
||||
|
||||
MEM_freeN(data);
|
||||
|
||||
@@ -3363,13 +3357,12 @@ void REEB_draw()
|
||||
|
||||
if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG)
|
||||
{
|
||||
for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up);
|
||||
for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
i = G.scene->toolsettings->skgen_multi_level;
|
||||
|
||||
for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up);
|
||||
for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ;
|
||||
}
|
||||
|
||||
glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE));
|
||||
@@ -3378,7 +3371,7 @@ void REEB_draw()
|
||||
for (arc = rg->arcs.first; arc; arc = arc->next, i++)
|
||||
{
|
||||
ReebArcIterator arc_iter;
|
||||
BArcIterator *iter = (BArcIterator*)&arc_iter;
|
||||
BArcIterator *iter = (BArcIterator *)&arc_iter;
|
||||
float vec[3];
|
||||
char text[128];
|
||||
char *s = text;
|
||||
@@ -3386,18 +3379,18 @@ void REEB_draw()
|
||||
glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2);
|
||||
glColor3f(0, 0, 0);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(arc->head->p);
|
||||
glVertex3fv(arc->head->p);
|
||||
|
||||
if (arc->bcount)
|
||||
if (arc->bcount)
|
||||
{
|
||||
initArcIterator(iter, arc, arc->head);
|
||||
for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter))
|
||||
{
|
||||
initArcIterator(iter, arc, arc->head);
|
||||
for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter))
|
||||
{
|
||||
glVertex3fv(iter->p);
|
||||
}
|
||||
glVertex3fv(iter->p);
|
||||
}
|
||||
}
|
||||
|
||||
glVertex3fv(arc->tail->p);
|
||||
glVertex3fv(arc->tail->p);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE));
|
||||
@@ -3414,13 +3407,33 @@ void REEB_draw()
|
||||
{
|
||||
glColor3f(0.5f, 1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
glColor3f(1, 1, 0);
|
||||
}
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex3fv(arc->head->p);
|
||||
glVertex3fv(arc->head->p);
|
||||
|
||||
if (arc->bcount)
|
||||
{
|
||||
initArcIterator(iter, arc, arc->head);
|
||||
for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
|
||||
{
|
||||
glVertex3fv(iter->p);
|
||||
}
|
||||
}
|
||||
|
||||
glVertex3fv(arc->tail->p);
|
||||
glEnd();
|
||||
|
||||
|
||||
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED)
|
||||
{
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3fv(arc->head->p);
|
||||
glVertex3fv(arc->tail->p);
|
||||
|
||||
glColor3f(0.5f, 0.5f, 1);
|
||||
if (arc->bcount)
|
||||
{
|
||||
initArcIterator(iter, arc, arc->head);
|
||||
@@ -3429,27 +3442,6 @@ void REEB_draw()
|
||||
glVertex3fv(iter->p);
|
||||
}
|
||||
}
|
||||
|
||||
glVertex3fv(arc->tail->p);
|
||||
glEnd();
|
||||
|
||||
|
||||
if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED)
|
||||
{
|
||||
glColor3f(1, 1, 1);
|
||||
glBegin(GL_POINTS);
|
||||
glVertex3fv(arc->head->p);
|
||||
glVertex3fv(arc->tail->p);
|
||||
|
||||
glColor3f(0.5f, 0.5f, 1);
|
||||
if (arc->bcount)
|
||||
{
|
||||
initArcIterator(iter, arc, arc->head);
|
||||
for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
|
||||
{
|
||||
glVertex3fv(iter->p);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,15 +41,15 @@ struct ReebEdge;
|
||||
struct ReebNode;
|
||||
|
||||
typedef struct ReebGraph {
|
||||
ListBase arcs;
|
||||
ListBase nodes;
|
||||
ListBase arcs;
|
||||
ListBase nodes;
|
||||
|
||||
float length;
|
||||
|
||||
FreeArc free_arc;
|
||||
FreeNode free_node;
|
||||
RadialSymmetry radial_symmetry;
|
||||
AxialSymmetry axial_symmetry;
|
||||
FreeArc free_arc;
|
||||
FreeNode free_node;
|
||||
RadialSymmetry radial_symmetry;
|
||||
AxialSymmetry axial_symmetry;
|
||||
/*********************************/
|
||||
|
||||
int resolution;
|
||||
@@ -61,7 +61,7 @@ typedef struct ReebGraph {
|
||||
|
||||
typedef struct EmbedBucket {
|
||||
float val;
|
||||
int nv;
|
||||
int nv;
|
||||
float p[3];
|
||||
float no[3]; /* if non-null, normal of the bucket */
|
||||
} EmbedBucket;
|
||||
@@ -85,7 +85,7 @@ typedef struct ReebNode {
|
||||
|
||||
int index;
|
||||
float weight;
|
||||
int multi_level;
|
||||
int multi_level;
|
||||
struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */
|
||||
struct ReebNode *link_up;
|
||||
} ReebNode;
|
||||
@@ -120,13 +120,13 @@ typedef struct ReebArc {
|
||||
} ReebArc;
|
||||
|
||||
typedef struct ReebArcIterator {
|
||||
HeadFct head;
|
||||
TailFct tail;
|
||||
PeekFct peek;
|
||||
NextFct next;
|
||||
NextNFct nextN;
|
||||
PreviousFct previous;
|
||||
StoppedFct stopped;
|
||||
HeadFct head;
|
||||
TailFct tail;
|
||||
PeekFct peek;
|
||||
NextFct next;
|
||||
NextNFct nextN;
|
||||
PreviousFct previous;
|
||||
StoppedFct stopped;
|
||||
|
||||
float *p, *no;
|
||||
float size;
|
||||
@@ -134,7 +134,7 @@ typedef struct ReebArcIterator {
|
||||
int length;
|
||||
int index;
|
||||
/*********************************/
|
||||
struct ReebArc *arc;
|
||||
struct ReebArc *arc;
|
||||
int start;
|
||||
int end;
|
||||
int stride;
|
||||
@@ -151,8 +151,8 @@ void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
|
||||
void angleToVCol(struct EditMesh *em, int index);
|
||||
void renormalizeWeight(struct EditMesh *em, float newmax);
|
||||
|
||||
ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
|
||||
ReebGraph * newReebGraph(void);
|
||||
ReebGraph *generateReebGraph(struct EditMesh *me, int subdivisions);
|
||||
ReebGraph *newReebGraph(void);
|
||||
|
||||
void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
|
||||
void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end);
|
||||
@@ -178,7 +178,7 @@ void verifyNodeDegree(ReebGraph *rg);
|
||||
|
||||
/*********************** PUBLIC *********************************/
|
||||
|
||||
#define REEB_MAX_MULTI_LEVEL 10
|
||||
#define REEB_MAX_MULTI_LEVEL 10
|
||||
|
||||
struct bContext;
|
||||
|
||||
|
||||
@@ -67,12 +67,12 @@
|
||||
#include "UI_interface.h"
|
||||
#include "UI_resources.h"
|
||||
|
||||
#include "graph_intern.h" // own include
|
||||
#include "graph_intern.h" // own include
|
||||
|
||||
/* XXX */
|
||||
|
||||
/* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */
|
||||
#define UI_FLT_MAX 10000.0f
|
||||
#define UI_FLT_MAX 10000.0f
|
||||
|
||||
|
||||
/* ******************* graph editor space & buttons ************** */
|
||||
@@ -98,7 +98,7 @@ static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int
|
||||
static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu)
|
||||
{
|
||||
bAnimContext ac;
|
||||
bAnimListElem *elem= NULL;
|
||||
bAnimListElem *elem = NULL;
|
||||
|
||||
/* for now, only draw if we could init the anim-context info (necessary for all animation-related tools)
|
||||
* to work correctly is able to be correctly retrieved. There's no point showing empty panels?
|
||||
@@ -107,14 +107,14 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **
|
||||
return 0;
|
||||
|
||||
/* try to find 'active' F-Curve */
|
||||
elem= get_active_fcurve_channel(&ac);
|
||||
elem = get_active_fcurve_channel(&ac);
|
||||
if (elem == NULL)
|
||||
return 0;
|
||||
|
||||
if (fcu)
|
||||
*fcu= (FCurve*)elem->data;
|
||||
*fcu = (FCurve *)elem->data;
|
||||
if (ale)
|
||||
*ale= elem;
|
||||
*ale = elem;
|
||||
else
|
||||
MEM_freeN(elem);
|
||||
|
||||
@@ -131,9 +131,9 @@ static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||
/* Graph Editor View Settings */
|
||||
static void graph_panel_view(const bContext *C, Panel *pa)
|
||||
{
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
bScreen *sc = CTX_wm_screen(C);
|
||||
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
PointerRNA spaceptr, sceneptr;
|
||||
uiLayout *col, *sub, *row;
|
||||
|
||||
@@ -142,21 +142,21 @@ static void graph_panel_view(const bContext *C, Panel *pa)
|
||||
RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr);
|
||||
|
||||
/* 2D-Cursor */
|
||||
col= uiLayoutColumn(pa->layout, 0);
|
||||
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
|
||||
col = uiLayoutColumn(pa->layout, 0);
|
||||
uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE);
|
||||
|
||||
sub= uiLayoutColumn(col, 1);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
||||
uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
|
||||
|
||||
sub= uiLayoutColumn(col, 1);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
||||
row= uiLayoutSplit(sub, 0.7, 1);
|
||||
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
|
||||
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
|
||||
row= uiLayoutSplit(sub, 0.7, 1);
|
||||
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
|
||||
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
|
||||
sub = uiLayoutColumn(col, 1);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
||||
uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump");
|
||||
|
||||
sub = uiLayoutColumn(col, 1);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor"));
|
||||
row = uiLayoutSplit(sub, 0.7, 1);
|
||||
uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE);
|
||||
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA);
|
||||
row = uiLayoutSplit(sub, 0.7, 1);
|
||||
uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE);
|
||||
uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE);
|
||||
}
|
||||
|
||||
/* ******************* active F-Curve ************** */
|
||||
@@ -175,7 +175,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
|
||||
if (!graph_panel_context(C, &ale, &fcu))
|
||||
return;
|
||||
|
||||
block= uiLayoutGetBlock(layout);
|
||||
block = uiLayoutGetBlock(layout);
|
||||
uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL);
|
||||
|
||||
/* F-Curve pointer */
|
||||
@@ -183,26 +183,26 @@ static void graph_panel_properties(const bContext *C, Panel *pa)
|
||||
|
||||
/* user-friendly 'name' for F-Curve */
|
||||
/* TODO: only show the path if this is invalid? */
|
||||
col= uiLayoutColumn(layout, 0);
|
||||
icon= getname_anim_fcurve(name, ale->id, fcu);
|
||||
uiItemL(col, name, icon);
|
||||
col = uiLayoutColumn(layout, 0);
|
||||
icon = getname_anim_fcurve(name, ale->id, fcu);
|
||||
uiItemL(col, name, icon);
|
||||
|
||||
/* RNA-Path Editing - only really should be enabled when things aren't working */
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)!=0);
|
||||
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
|
||||
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0);
|
||||
uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA);
|
||||
uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE);
|
||||
|
||||
/* color settings */
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiItemL(col, IFACE_("Display Color:"), ICON_NONE);
|
||||
|
||||
row= uiLayoutRow(col, 1);
|
||||
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
|
||||
row = uiLayoutRow(col, 1);
|
||||
uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE);
|
||||
|
||||
sub= uiLayoutRow(row, 1);
|
||||
uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM));
|
||||
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
|
||||
sub = uiLayoutRow(row, 1);
|
||||
uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM));
|
||||
uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE);
|
||||
|
||||
MEM_freeN(ale);
|
||||
}
|
||||
@@ -226,13 +226,13 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
|
||||
* - this is a reasonable assumption, given that whenever anyone
|
||||
* wants to edit numerically, there is likely to only be 1 vert selected
|
||||
*/
|
||||
for (i=0, b=fcu->bezt; i < fcu->totvert; i++, b++) {
|
||||
for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) {
|
||||
if (BEZSELECTED(b)) {
|
||||
/* found
|
||||
* - 'previous' is either the one before, of the keyframe itself (which is still fine)
|
||||
* XXX: we can just make this null instead if needed
|
||||
*/
|
||||
*prevbezt = (i > 0) ? b-1 : b;
|
||||
*prevbezt = (i > 0) ? b - 1 : b;
|
||||
*bezt = b;
|
||||
|
||||
return 1;
|
||||
@@ -246,7 +246,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT
|
||||
/* update callback for active keyframe properties - base updates stuff */
|
||||
static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr))
|
||||
{
|
||||
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
||||
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
||||
const short use_handle = !(sipo->flag & SIPO_NOHANDLES);
|
||||
FCurve *fcu = (FCurve *)fcu_ptr;
|
||||
|
||||
@@ -265,8 +265,8 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez
|
||||
*/
|
||||
if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) {
|
||||
/* by changing to aligned handles, these can now be moved... */
|
||||
bezt->h1= HD_ALIGN;
|
||||
bezt->h2= HD_ALIGN;
|
||||
bezt->h1 = HD_ALIGN;
|
||||
bezt->h2 = HD_ALIGN;
|
||||
}
|
||||
|
||||
/* now call standard updates */
|
||||
@@ -307,56 +307,56 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
|
||||
}
|
||||
|
||||
/* interpolation */
|
||||
col= uiLayoutColumn(layout, 0);
|
||||
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
|
||||
col = uiLayoutColumn(layout, 0);
|
||||
uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE);
|
||||
|
||||
/* numerical coordinate editing
|
||||
* - we use the button-versions of the calls so that we can attach special update handlers
|
||||
* and unit conversion magic that cannot be achieved using a purely RNA-approach
|
||||
* - we use the button-versions of the calls so that we can attach special update handlers
|
||||
* and unit conversion magic that cannot be achieved using a purely RNA-approach
|
||||
*/
|
||||
// XXX:
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
/* keyframe itself */
|
||||
{
|
||||
uiItemL(col, IFACE_("Key:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
|
||||
/* previous handle - only if previous was Bezier interpolation */
|
||||
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
|
||||
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
|
||||
/* next handle - only if current is Bezier interpolation */
|
||||
if (bezt->ipo == BEZT_IPO_BEZ) {
|
||||
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
/* keyframe itself */
|
||||
{
|
||||
uiItemL(col, IFACE_("Key:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "co", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "co", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
|
||||
/* previous handle - only if previous was Bezier interpolation */
|
||||
if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) {
|
||||
uiItemL(col, IFACE_("Left Handle:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
|
||||
/* next handle - only if current is Bezier interpolation */
|
||||
if (bezt->ipo == BEZT_IPO_BEZ) {
|
||||
uiItemL(col, IFACE_("Right Handle:"), ICON_NONE);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
|
||||
but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
&bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL);
|
||||
uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt);
|
||||
uiButSetUnitType(but, unit);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((fcu->bezt == NULL) && (fcu->modifiers.first)) {
|
||||
@@ -378,12 +378,12 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
|
||||
|
||||
/* ******************* drivers ******************************** */
|
||||
|
||||
#define B_IPO_DEPCHANGE 10
|
||||
#define B_IPO_DEPCHANGE 10
|
||||
|
||||
static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
switch (event) {
|
||||
case B_IPO_DEPCHANGE:
|
||||
@@ -394,19 +394,19 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e
|
||||
/* force an update of depsgraph */
|
||||
DAG_ids_flush_update(bmain, 0);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* default for now */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); // XXX could use better notifier
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier
|
||||
}
|
||||
|
||||
/* callback to remove the active driver */
|
||||
static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg))
|
||||
static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg))
|
||||
{
|
||||
bAnimListElem *ale= (bAnimListElem *)ale_v;
|
||||
ID *id= ale->id;
|
||||
FCurve *fcu= ale->data;
|
||||
bAnimListElem *ale = (bAnimListElem *)ale_v;
|
||||
ID *id = ale->id;
|
||||
FCurve *fcu = ale->data;
|
||||
ReportList *reports = CTX_wm_reports(C);
|
||||
|
||||
/* try to get F-Curve that driver lives on, and ID block which has this AnimData */
|
||||
@@ -418,29 +418,29 @@ static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg))
|
||||
}
|
||||
|
||||
/* callback to add a target variable to the active driver */
|
||||
static void driver_add_var_cb (bContext *UNUSED(C), void *driver_v, void *UNUSED(arg))
|
||||
static void driver_add_var_cb(bContext *UNUSED(C), void *driver_v, void *UNUSED(arg))
|
||||
{
|
||||
ChannelDriver *driver= (ChannelDriver *)driver_v;
|
||||
ChannelDriver *driver = (ChannelDriver *)driver_v;
|
||||
|
||||
/* add a new variable */
|
||||
driver_add_new_variable(driver);
|
||||
}
|
||||
|
||||
/* callback to remove target variable from active driver */
|
||||
static void driver_delete_var_cb (bContext *UNUSED(C), void *driver_v, void *dvar_v)
|
||||
static void driver_delete_var_cb(bContext *UNUSED(C), void *driver_v, void *dvar_v)
|
||||
{
|
||||
ChannelDriver *driver= (ChannelDriver *)driver_v;
|
||||
DriverVar *dvar= (DriverVar *)dvar_v;
|
||||
ChannelDriver *driver = (ChannelDriver *)driver_v;
|
||||
DriverVar *dvar = (DriverVar *)dvar_v;
|
||||
|
||||
/* remove the active variable */
|
||||
driver_free_variable(driver, dvar);
|
||||
}
|
||||
|
||||
/* callback to reset the driver's flags */
|
||||
static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg))
|
||||
static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg))
|
||||
{
|
||||
FCurve *fcu= (FCurve *)fcu_v;
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
FCurve *fcu = (FCurve *)fcu_v;
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
/* clear invalid flags */
|
||||
fcu->flag &= ~FCURVE_DISABLED; // XXX?
|
||||
@@ -450,7 +450,7 @@ static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUS
|
||||
/* drivers panel poll */
|
||||
static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||
{
|
||||
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
||||
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
||||
|
||||
if (sipo->mode != SIPO_MODE_DRIVERS)
|
||||
return 0;
|
||||
@@ -461,7 +461,7 @@ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt))
|
||||
/* settings for 'single property' driver variable type */
|
||||
static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar)
|
||||
{
|
||||
DriverTarget *dtar= &dvar->targets[0];
|
||||
DriverTarget *dtar = &dvar->targets[0];
|
||||
PointerRNA dtar_ptr;
|
||||
uiLayout *row, *col;
|
||||
|
||||
@@ -469,8 +469,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
|
||||
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
||||
|
||||
/* Target ID */
|
||||
row= uiLayoutRow(layout, 0);
|
||||
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
|
||||
row = uiLayoutRow(layout, 0);
|
||||
uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:"));
|
||||
|
||||
/* Target Property */
|
||||
// TODO: make this less technical...
|
||||
@@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
|
||||
/* get pointer for resolving the property selected */
|
||||
RNA_id_pointer_create(dtar->id, &root_ptr);
|
||||
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
/* rna path */
|
||||
uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path"));
|
||||
}
|
||||
@@ -489,8 +489,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa
|
||||
/* settings for 'rotation difference' driver variable type */
|
||||
static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *dvar)
|
||||
{
|
||||
DriverTarget *dtar= &dvar->targets[0];
|
||||
DriverTarget *dtar2= &dvar->targets[1];
|
||||
DriverTarget *dtar = &dvar->targets[0];
|
||||
DriverTarget *dtar2 = &dvar->targets[1];
|
||||
Object *ob1 = (Object *)dtar->id;
|
||||
Object *ob2 = (Object *)dtar2->id;
|
||||
PointerRNA dtar_ptr, dtar2_ptr;
|
||||
@@ -501,32 +501,32 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *
|
||||
RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
|
||||
|
||||
/* Bone 1 */
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:"));
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:"));
|
||||
|
||||
if (dtar->id && ob1->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
if (dtar->id && ob1->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:"));
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:"));
|
||||
|
||||
if (dtar2->id && ob2->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
if (dtar2->id && ob2->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
|
||||
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
/* settings for 'location difference' driver variable type */
|
||||
static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *dvar)
|
||||
{
|
||||
DriverTarget *dtar= &dvar->targets[0];
|
||||
DriverTarget *dtar2= &dvar->targets[1];
|
||||
DriverTarget *dtar = &dvar->targets[0];
|
||||
DriverTarget *dtar2 = &dvar->targets[1];
|
||||
Object *ob1 = (Object *)dtar->id;
|
||||
Object *ob2 = (Object *)dtar2->id;
|
||||
PointerRNA dtar_ptr, dtar2_ptr;
|
||||
@@ -537,35 +537,35 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *
|
||||
RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr);
|
||||
|
||||
/* Bone 1 */
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:"));
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:"));
|
||||
|
||||
if (dtar->id && ob1->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
if (dtar->id && ob1->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
|
||||
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE);
|
||||
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:"));
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:"));
|
||||
|
||||
if (dtar2->id && ob2->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
if (dtar2->id && ob2->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
|
||||
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
|
||||
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE);
|
||||
}
|
||||
|
||||
/* settings for 'transform channel' driver variable type */
|
||||
static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar)
|
||||
{
|
||||
DriverTarget *dtar= &dvar->targets[0];
|
||||
DriverTarget *dtar = &dvar->targets[0];
|
||||
Object *ob = (Object *)dtar->id;
|
||||
PointerRNA dtar_ptr;
|
||||
uiLayout *col, *sub;
|
||||
@@ -574,19 +574,19 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar
|
||||
RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr);
|
||||
|
||||
/* properties */
|
||||
col= uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:"));
|
||||
col = uiLayoutColumn(layout, 1);
|
||||
uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:"));
|
||||
|
||||
if (dtar->id && ob->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
if (dtar->id && ob->pose) {
|
||||
PointerRNA tar_ptr;
|
||||
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr);
|
||||
uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA);
|
||||
}
|
||||
|
||||
sub= uiLayoutColumn(layout, 1);
|
||||
uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
|
||||
sub = uiLayoutColumn(layout, 1);
|
||||
uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE);
|
||||
}
|
||||
|
||||
/* driver settings for active F-Curve (only for 'Drivers' mode) */
|
||||
@@ -605,125 +605,125 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
||||
/* Get settings from context */
|
||||
if (!graph_panel_context(C, &ale, &fcu))
|
||||
return;
|
||||
driver= fcu->driver;
|
||||
driver = fcu->driver;
|
||||
|
||||
/* set event handler for panel */
|
||||
block= uiLayoutGetBlock(pa->layout); // xxx?
|
||||
block = uiLayoutGetBlock(pa->layout); // xxx?
|
||||
uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL);
|
||||
|
||||
/* general actions - management */
|
||||
col= uiLayoutColumn(pa->layout, 0);
|
||||
block= uiLayoutGetBlock(col);
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10*UI_UNIT_X, 22,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
|
||||
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
|
||||
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10*UI_UNIT_X, 18,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
|
||||
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
||||
col = uiLayoutColumn(pa->layout, 0);
|
||||
block = uiLayoutGetBlock(col);
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies"));
|
||||
uiButSetFunc(but, driver_update_flags_cb, fcu, NULL);
|
||||
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver"));
|
||||
uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL);
|
||||
|
||||
/* driver-level settings - type, expressions, and errors */
|
||||
RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr);
|
||||
|
||||
col= uiLayoutColumn(pa->layout, 1);
|
||||
block= uiLayoutGetBlock(col);
|
||||
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
|
||||
col = uiLayoutColumn(pa->layout, 1);
|
||||
block = uiLayoutGetBlock(col);
|
||||
uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE);
|
||||
|
||||
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
||||
if (driver->type == DRIVER_TYPE_PYTHON) {
|
||||
/* expression */
|
||||
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
|
||||
|
||||
/* errors? */
|
||||
if (driver->flag & DRIVER_FLAG_INVALID)
|
||||
uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
|
||||
}
|
||||
else {
|
||||
/* errors? */
|
||||
if (driver->flag & DRIVER_FLAG_INVALID)
|
||||
uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
|
||||
}
|
||||
|
||||
/* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */
|
||||
if (driver->type == DRIVER_TYPE_PYTHON) {
|
||||
/* expression */
|
||||
uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE);
|
||||
|
||||
/* errors? */
|
||||
if (driver->flag & DRIVER_FLAG_INVALID)
|
||||
uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR);
|
||||
}
|
||||
else {
|
||||
/* errors? */
|
||||
if (driver->flag & DRIVER_FLAG_INVALID)
|
||||
uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR);
|
||||
}
|
||||
col = uiLayoutColumn(pa->layout, 1);
|
||||
/* debug setting */
|
||||
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
|
||||
|
||||
col= uiLayoutColumn(pa->layout, 1);
|
||||
/* debug setting */
|
||||
uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE);
|
||||
|
||||
/* value of driver */
|
||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
||||
uiLayout *row= uiLayoutRow(col, 1);
|
||||
char valBuf[32];
|
||||
/* value of driver */
|
||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
||||
uiLayout *row = uiLayoutRow(col, 1);
|
||||
char valBuf[32];
|
||||
|
||||
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
|
||||
uiItemL(row, IFACE_("Driver Value:"), ICON_NONE);
|
||||
|
||||
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
|
||||
uiItemL(row, valBuf, ICON_NONE);
|
||||
}
|
||||
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
|
||||
uiItemL(row, valBuf, ICON_NONE);
|
||||
}
|
||||
|
||||
/* add driver variables */
|
||||
col= uiLayoutColumn(pa->layout, 0);
|
||||
block= uiLayoutGetBlock(col);
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10*UI_UNIT_X, UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
|
||||
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
|
||||
col = uiLayoutColumn(pa->layout, 0);
|
||||
block = uiLayoutGetBlock(col);
|
||||
but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver"));
|
||||
uiButSetFunc(but, driver_add_var_cb, driver, NULL);
|
||||
|
||||
/* loop over targets, drawing them */
|
||||
for (dvar= driver->variables.first; dvar; dvar= dvar->next) {
|
||||
for (dvar = driver->variables.first; dvar; dvar = dvar->next) {
|
||||
PointerRNA dvar_ptr;
|
||||
uiLayout *box, *row;
|
||||
|
||||
/* sub-layout column for this variable's settings */
|
||||
col= uiLayoutColumn(pa->layout, 1);
|
||||
col = uiLayoutColumn(pa->layout, 1);
|
||||
|
||||
/* header panel */
|
||||
box= uiLayoutBox(col);
|
||||
/* first row context info for driver */
|
||||
RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
|
||||
|
||||
row= uiLayoutRow(box, 0);
|
||||
block= uiLayoutGetBlock(row);
|
||||
/* variable name */
|
||||
uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
|
||||
|
||||
/* remove button */
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
|
||||
uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
/* variable type */
|
||||
row= uiLayoutRow(box, 0);
|
||||
uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
|
||||
box = uiLayoutBox(col);
|
||||
/* first row context info for driver */
|
||||
RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr);
|
||||
|
||||
row = uiLayoutRow(box, 0);
|
||||
block = uiLayoutGetBlock(row);
|
||||
/* variable name */
|
||||
uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE);
|
||||
|
||||
/* remove button */
|
||||
uiBlockSetEmboss(block, UI_EMBOSSN);
|
||||
but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y,
|
||||
NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable"));
|
||||
uiButSetFunc(but, driver_delete_var_cb, driver, dvar);
|
||||
uiBlockSetEmboss(block, UI_EMBOSS);
|
||||
|
||||
/* variable type */
|
||||
row = uiLayoutRow(box, 0);
|
||||
uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE);
|
||||
|
||||
/* variable type settings */
|
||||
box= uiLayoutBox(col);
|
||||
/* controls to draw depends on the type of variable */
|
||||
switch (dvar->type) {
|
||||
case DVAR_TYPE_SINGLE_PROP: /* single property */
|
||||
graph_panel_driverVar__singleProp(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_ROT_DIFF: /* rotational difference */
|
||||
graph_panel_driverVar__rotDiff(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_LOC_DIFF: /* location difference */
|
||||
graph_panel_driverVar__locDiff(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
|
||||
graph_panel_driverVar__transChan(box, ale->id, dvar);
|
||||
break;
|
||||
}
|
||||
box = uiLayoutBox(col);
|
||||
/* controls to draw depends on the type of variable */
|
||||
switch (dvar->type) {
|
||||
case DVAR_TYPE_SINGLE_PROP: /* single property */
|
||||
graph_panel_driverVar__singleProp(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_ROT_DIFF: /* rotational difference */
|
||||
graph_panel_driverVar__rotDiff(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_LOC_DIFF: /* location difference */
|
||||
graph_panel_driverVar__locDiff(box, ale->id, dvar);
|
||||
break;
|
||||
case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */
|
||||
graph_panel_driverVar__transChan(box, ale->id, dvar);
|
||||
break;
|
||||
}
|
||||
|
||||
/* value of variable */
|
||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
||||
char valBuf[32];
|
||||
/* value of variable */
|
||||
if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
|
||||
char valBuf[32];
|
||||
|
||||
box= uiLayoutBox(col);
|
||||
row= uiLayoutRow(box, 1);
|
||||
uiItemL(row, IFACE_("Value:"), ICON_NONE);
|
||||
|
||||
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
|
||||
uiItemL(row, valBuf, ICON_NONE);
|
||||
}
|
||||
box = uiLayoutBox(col);
|
||||
row = uiLayoutRow(box, 1);
|
||||
uiItemL(row, IFACE_("Value:"), ICON_NONE);
|
||||
|
||||
BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
|
||||
uiItemL(row, valBuf, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
@@ -733,7 +733,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
|
||||
/* ******************* f-modifiers ******************************** */
|
||||
/* all the drawing code is in editors/animation/fmodifier_ui.c */
|
||||
|
||||
#define B_FMODIFIER_REDRAW 20
|
||||
#define B_FMODIFIER_REDRAW 20
|
||||
|
||||
static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event)
|
||||
{
|
||||
@@ -755,27 +755,27 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa)
|
||||
if (!graph_panel_context(C, &ale, &fcu))
|
||||
return;
|
||||
|
||||
block= uiLayoutGetBlock(pa->layout);
|
||||
block = uiLayoutGetBlock(pa->layout);
|
||||
uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL);
|
||||
|
||||
/* 'add modifier' button at top of panel */
|
||||
{
|
||||
row= uiLayoutRow(pa->layout, 0);
|
||||
block= uiLayoutGetBlock(row);
|
||||
row = uiLayoutRow(pa->layout, 0);
|
||||
block = uiLayoutGetBlock(row);
|
||||
|
||||
// XXX for now, this will be a operator button which calls a 'add modifier' operator
|
||||
uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"),
|
||||
10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve"));
|
||||
|
||||
/* copy/paste (as sub-row)*/
|
||||
row= uiLayoutRow(row, 1);
|
||||
uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy");
|
||||
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste");
|
||||
row = uiLayoutRow(row, 1);
|
||||
uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy");
|
||||
uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste");
|
||||
}
|
||||
|
||||
/* draw each modifier */
|
||||
for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) {
|
||||
col= uiLayoutColumn(pa->layout, 1);
|
||||
for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) {
|
||||
col = uiLayoutColumn(pa->layout, 1);
|
||||
|
||||
ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm);
|
||||
}
|
||||
@@ -789,47 +789,47 @@ void graph_buttons_register(ARegionType *art)
|
||||
{
|
||||
PanelType *pt;
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view");
|
||||
strcpy(pt->idname, "GRAPH_PT_view");
|
||||
strcpy(pt->label, N_("View Properties"));
|
||||
pt->draw= graph_panel_view;
|
||||
pt->draw = graph_panel_view;
|
||||
pt->flag |= PNL_DEFAULT_CLOSED;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
||||
strcpy(pt->idname, "GRAPH_PT_properties");
|
||||
strcpy(pt->label, N_("Active F-Curve"));
|
||||
pt->draw= graph_panel_properties;
|
||||
pt->poll= graph_panel_poll;
|
||||
pt->draw = graph_panel_properties;
|
||||
pt->poll = graph_panel_poll;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties");
|
||||
strcpy(pt->idname, "GRAPH_PT_key_properties");
|
||||
strcpy(pt->label, N_("Active Keyframe"));
|
||||
pt->draw= graph_panel_key_properties;
|
||||
pt->poll= graph_panel_poll;
|
||||
pt->draw = graph_panel_key_properties;
|
||||
pt->poll = graph_panel_poll;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers");
|
||||
strcpy(pt->idname, "GRAPH_PT_drivers");
|
||||
strcpy(pt->label, N_("Drivers"));
|
||||
pt->draw= graph_panel_drivers;
|
||||
pt->poll= graph_panel_drivers_poll;
|
||||
pt->draw = graph_panel_drivers;
|
||||
pt->poll = graph_panel_drivers_poll;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
|
||||
pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
|
||||
pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers");
|
||||
strcpy(pt->idname, "GRAPH_PT_modifiers");
|
||||
strcpy(pt->label, N_("Modifiers"));
|
||||
pt->draw= graph_panel_modifiers;
|
||||
pt->poll= graph_panel_poll;
|
||||
pt->draw = graph_panel_modifiers;
|
||||
pt->poll = graph_panel_poll;
|
||||
BLI_addtail(&art->paneltypes, pt);
|
||||
}
|
||||
|
||||
static int graph_properties(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ARegion *ar= graph_has_buttons_region(sa);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = graph_has_buttons_region(sa);
|
||||
|
||||
if (ar)
|
||||
ED_region_toggle_hidden(C, ar);
|
||||
|
||||
@@ -84,11 +84,11 @@ static float fcurve_display_alpha(FCurve *fcu)
|
||||
/* Envelope -------------- */
|
||||
|
||||
// TODO: draw a shaded poly showing the region of influence too!!!
|
||||
static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d)
|
||||
static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d)
|
||||
{
|
||||
FMod_Envelope *env= (FMod_Envelope *)fcm->data;
|
||||
FMod_Envelope *env = (FMod_Envelope *)fcm->data;
|
||||
FCM_EnvelopeData *fed;
|
||||
const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
int i;
|
||||
|
||||
/* draw two black lines showing the standard reference levels */
|
||||
@@ -96,11 +96,11 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d)
|
||||
setlinestyle(5);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(v2d->cur.xmin, env->midval+env->min);
|
||||
glVertex2f(v2d->cur.xmax, env->midval+env->min);
|
||||
glVertex2f(v2d->cur.xmin, env->midval + env->min);
|
||||
glVertex2f(v2d->cur.xmax, env->midval + env->min);
|
||||
|
||||
glVertex2f(v2d->cur.xmin, env->midval+env->max);
|
||||
glVertex2f(v2d->cur.xmax, env->midval+env->max);
|
||||
glVertex2f(v2d->cur.xmin, env->midval + env->max);
|
||||
glVertex2f(v2d->cur.xmax, env->midval + env->max);
|
||||
glEnd(); // GL_LINES
|
||||
setlinestyle(0);
|
||||
|
||||
@@ -114,7 +114,7 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d)
|
||||
* drawing bugs that some drivers have (probably legacy ones only though)
|
||||
*/
|
||||
bglBegin(GL_POINTS);
|
||||
for (i=0, fed=env->data; i < env->totvert; i++, fed++) {
|
||||
for (i = 0, fed = env->data; i < env->totvert; i++, fed++) {
|
||||
/* only draw if visible
|
||||
* - min/max here are fixed, not relative
|
||||
*/
|
||||
@@ -134,10 +134,10 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d)
|
||||
/* Points ---------------- */
|
||||
|
||||
/* helper func - draw keyframe vertices only for an F-Curve */
|
||||
static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
|
||||
static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel)
|
||||
{
|
||||
BezTriple *bezt= fcu->bezt;
|
||||
const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
BezTriple *bezt = fcu->bezt;
|
||||
const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
int i;
|
||||
|
||||
/* we use bgl points not standard gl points, to workaround vertex
|
||||
@@ -174,18 +174,18 @@ static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo),
|
||||
* NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
|
||||
* have a consistent appearance (due to off-pixel alignments)...
|
||||
*/
|
||||
static void draw_fcurve_handle_control (float x, float y, float xscale, float yscale, float hsize)
|
||||
static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize)
|
||||
{
|
||||
static GLuint displist=0;
|
||||
static GLuint displist = 0;
|
||||
|
||||
/* initialize round circle shape */
|
||||
if (displist == 0) {
|
||||
GLUquadricObj *qobj;
|
||||
|
||||
displist= glGenLists(1);
|
||||
displist = glGenLists(1);
|
||||
glNewList(displist, GL_COMPILE);
|
||||
|
||||
qobj = gluNewQuadric();
|
||||
qobj = gluNewQuadric();
|
||||
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
|
||||
gluDisk(qobj, 0, 0.7, 8, 1);
|
||||
gluDeleteQuadric(qobj);
|
||||
@@ -195,26 +195,26 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys
|
||||
|
||||
/* adjust view transform before starting */
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
|
||||
glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
|
||||
|
||||
/* draw! */
|
||||
glCallList(displist);
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale/hsize, yscale/hsize, 1.0);
|
||||
glScalef(xscale / hsize, yscale / hsize, 1.0);
|
||||
glTranslatef(-x, -y, 0.0f);
|
||||
}
|
||||
|
||||
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
|
||||
static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only)
|
||||
static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only)
|
||||
{
|
||||
BezTriple *bezt= fcu->bezt;
|
||||
BezTriple *bezt = fcu->bezt;
|
||||
BezTriple *prevbezt = NULL;
|
||||
float hsize, xscale, yscale;
|
||||
int i;
|
||||
|
||||
/* get view settings */
|
||||
hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
|
||||
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
|
||||
/* set handle color */
|
||||
@@ -222,10 +222,10 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v
|
||||
else UI_ThemeColor(TH_HANDLE_VERTEX);
|
||||
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
|
||||
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) {
|
||||
/* Draw the editmode handles for a bezier curve (others don't have handles)
|
||||
* if their selection status matches the selection status we're drawing for
|
||||
* - first handle only if previous beztriple was bezier-mode
|
||||
@@ -234,31 +234,31 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v
|
||||
* Also, need to take into account whether the keyframe was selected
|
||||
* if a Graph Editor option to only show handles of selected keys is on.
|
||||
*/
|
||||
if ( !sel_handle_only || BEZSELECTED(bezt) ) {
|
||||
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
|
||||
if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
|
||||
if (!sel_handle_only || BEZSELECTED(bezt) ) {
|
||||
if ( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) {
|
||||
if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
|
||||
}
|
||||
|
||||
if (bezt->ipo==BEZT_IPO_BEZ) {
|
||||
if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
|
||||
if (bezt->ipo == BEZT_IPO_BEZ) {
|
||||
if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* helper func - set color to draw F-Curve data with */
|
||||
static void set_fcurve_vertex_color (FCurve *fcu, short sel)
|
||||
static void set_fcurve_vertex_color(FCurve *fcu, short sel)
|
||||
{
|
||||
/* Fade the 'intensity' of the vertices based on the selection of the curves too */
|
||||
int alphaOffset= (int)((fcurve_display_alpha(fcu) - 1.0f) * 255);
|
||||
int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255);
|
||||
|
||||
/* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */
|
||||
if ((fcu->flag & FCURVE_PROTECTED)==0) {
|
||||
if ((fcu->flag & FCURVE_PROTECTED) == 0) {
|
||||
/* Curve's points ARE BEING edited */
|
||||
if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset);
|
||||
else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset);
|
||||
@@ -271,14 +271,14 @@ static void set_fcurve_vertex_color (FCurve *fcu, short sel)
|
||||
}
|
||||
|
||||
|
||||
static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
|
||||
static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only)
|
||||
{
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
|
||||
/* only draw points if curve is visible
|
||||
* - draw unselected points before selected points as separate passes to minimise color-changing overhead
|
||||
* - draw unselected points before selected points as separate passes to minimise color-changing overhead
|
||||
* (XXX dunno if this is faster than drawing all in one pass though)
|
||||
* and also to make sure in the case of overlapping points that the selected is always visible
|
||||
* and also to make sure in the case of overlapping points that the selected is always visible
|
||||
* - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users)
|
||||
*/
|
||||
|
||||
@@ -308,14 +308,14 @@ static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, shor
|
||||
static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
|
||||
{
|
||||
/* don't draw handle lines if handles are not to be shown */
|
||||
if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */
|
||||
(fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */
|
||||
#if 0 /* handles can still be selected and handle types set, better draw - campbell */
|
||||
(fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */
|
||||
if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */
|
||||
(fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */
|
||||
#if 0 /* handles can still be selected and handle types set, better draw - campbell */
|
||||
(fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */
|
||||
#endif
|
||||
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */
|
||||
(fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */
|
||||
)
|
||||
((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */
|
||||
(fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */
|
||||
)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -326,7 +326,7 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
|
||||
|
||||
/* draw lines for F-Curve handles only (this is only done in EditMode)
|
||||
* note: draw_fcurve_handles_check must be checked before running this. */
|
||||
static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu)
|
||||
static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu)
|
||||
{
|
||||
int sel, b;
|
||||
|
||||
@@ -339,13 +339,13 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu)
|
||||
/* slightly hacky, but we want to draw unselected points before selected ones
|
||||
* so that selected points are clearly visible
|
||||
*/
|
||||
for (sel= 0; sel < 2; sel++) {
|
||||
BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
|
||||
int basecol= (sel)? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
|
||||
for (sel = 0; sel < 2; sel++) {
|
||||
BezTriple *bezt = fcu->bezt, *prevbezt = NULL;
|
||||
int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
|
||||
float *fp;
|
||||
unsigned char col[4];
|
||||
|
||||
for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) {
|
||||
for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) {
|
||||
/* if only selected keyframes can get their handles shown,
|
||||
* check that keyframe is selected
|
||||
*/
|
||||
@@ -355,50 +355,50 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu)
|
||||
}
|
||||
|
||||
/* draw handle with appropriate set of colors if selection is ok */
|
||||
if ((bezt->f2 & SELECT)==sel) {
|
||||
fp= bezt->vec[0];
|
||||
if ((bezt->f2 & SELECT) == sel) {
|
||||
fp = bezt->vec[0];
|
||||
|
||||
/* only draw first handle if previous segment had handles */
|
||||
if ((!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) {
|
||||
if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
||||
col[3]= fcurve_display_alpha(fcu) * 255;
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
glColor4ubv((GLubyte *)col);
|
||||
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glVertex2fv(fp); glVertex2fv(fp + 3);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier */
|
||||
if (bezt->ipo == BEZT_IPO_BEZ) {
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
||||
col[3]= fcurve_display_alpha(fcu) * 255;
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
glColor4ubv((GLubyte *)col);
|
||||
|
||||
glVertex2fv(fp+3); glVertex2fv(fp+6);
|
||||
glVertex2fv(fp + 3); glVertex2fv(fp + 6);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* only draw first handle if previous segment was had handles, and selection is ok */
|
||||
if ( ((bezt->f1 & SELECT)==sel) &&
|
||||
( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) )
|
||||
if ( ((bezt->f1 & SELECT) == sel) &&
|
||||
( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) )
|
||||
{
|
||||
fp= bezt->vec[0];
|
||||
fp = bezt->vec[0];
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
|
||||
col[3]= fcurve_display_alpha(fcu) * 255;
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
glColor4ubv((GLubyte *)col);
|
||||
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glVertex2fv(fp); glVertex2fv(fp + 3);
|
||||
}
|
||||
|
||||
/* only draw second handle if this segment is bezier, and selection is ok */
|
||||
if ( ((bezt->f3 & SELECT)==sel) &&
|
||||
(bezt->ipo == BEZT_IPO_BEZ) )
|
||||
if ( ((bezt->f3 & SELECT) == sel) &&
|
||||
(bezt->ipo == BEZT_IPO_BEZ) )
|
||||
{
|
||||
fp= bezt->vec[1];
|
||||
fp = bezt->vec[1];
|
||||
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
|
||||
col[3]= fcurve_display_alpha(fcu) * 255;
|
||||
col[3] = fcurve_display_alpha(fcu) * 255;
|
||||
glColor4ubv((GLubyte *)col);
|
||||
|
||||
glVertex2fv(fp); glVertex2fv(fp+3);
|
||||
glVertex2fv(fp); glVertex2fv(fp + 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -413,21 +413,21 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu)
|
||||
* NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
|
||||
* have a consistent appearance (due to off-pixel alignments)...
|
||||
*/
|
||||
static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize)
|
||||
static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize)
|
||||
{
|
||||
static GLuint displist=0;
|
||||
static GLuint displist = 0;
|
||||
|
||||
/* initialize X shape */
|
||||
if (displist == 0) {
|
||||
displist= glGenLists(1);
|
||||
displist = glGenLists(1);
|
||||
glNewList(displist, GL_COMPILE);
|
||||
|
||||
glBegin(GL_LINES);
|
||||
glVertex2f(-0.7f, -0.7f);
|
||||
glVertex2f(+0.7f, +0.7f);
|
||||
glVertex2f(-0.7f, -0.7f);
|
||||
glVertex2f(+0.7f, +0.7f);
|
||||
|
||||
glVertex2f(-0.7f, +0.7f);
|
||||
glVertex2f(+0.7f, -0.7f);
|
||||
glVertex2f(-0.7f, +0.7f);
|
||||
glVertex2f(+0.7f, -0.7f);
|
||||
glEnd(); // GL_LINES
|
||||
|
||||
glEndList();
|
||||
@@ -435,52 +435,52 @@ static void draw_fcurve_sample_control (float x, float y, float xscale, float ys
|
||||
|
||||
/* adjust view transform before starting */
|
||||
glTranslatef(x, y, 0.0f);
|
||||
glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f);
|
||||
glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
|
||||
|
||||
/* draw! */
|
||||
glCallList(displist);
|
||||
|
||||
/* restore view transform */
|
||||
glScalef(xscale/hsize, yscale/hsize, 1.0);
|
||||
glScalef(xscale / hsize, yscale / hsize, 1.0);
|
||||
glTranslatef(-x, -y, 0.0f);
|
||||
}
|
||||
|
||||
/* helper func - draw keyframe vertices only for an F-Curve */
|
||||
static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
{
|
||||
FPoint *first, *last;
|
||||
float hsize, xscale, yscale;
|
||||
|
||||
/* get view settings */
|
||||
hsize= UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
|
||||
|
||||
/* set vertex color */
|
||||
if (fcu->flag & (FCURVE_ACTIVE|FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
|
||||
if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
|
||||
else UI_ThemeColor(TH_TEXT);
|
||||
|
||||
/* get verts */
|
||||
first= fcu->fpt;
|
||||
last= (first) ? (first + (fcu->totvert-1)) : (NULL);
|
||||
first = fcu->fpt;
|
||||
last = (first) ? (first + (fcu->totvert - 1)) : (NULL);
|
||||
|
||||
/* draw */
|
||||
if (first && last) {
|
||||
/* anti-aliased lines for more consistent appearance */
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize);
|
||||
draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
|
||||
}
|
||||
}
|
||||
|
||||
/* Curve ---------------- */
|
||||
|
||||
/* helper func - just draw the F-Curve by sampling the visible region (for drawing curves with modifiers) */
|
||||
static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid)
|
||||
static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid)
|
||||
{
|
||||
ChannelDriver *driver;
|
||||
float samplefreq, ctime;
|
||||
@@ -496,33 +496,33 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2
|
||||
|
||||
|
||||
/* disable any drivers temporarily */
|
||||
driver= fcu->driver;
|
||||
fcu->driver= NULL;
|
||||
driver = fcu->driver;
|
||||
fcu->driver = NULL;
|
||||
|
||||
/* compute unit correction factor */
|
||||
unitFac= ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0);
|
||||
unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0);
|
||||
|
||||
/* Note about sampling frequency:
|
||||
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
|
||||
* Ideally, this is chosen such that we have 1-2 pixels = 1 segment
|
||||
* which means that our curves can be as smooth as possible. However,
|
||||
* this does mean that curves may not be fully accurate (i.e. if they have
|
||||
* sudden spikes which happen at the sampling point, we may have problems).
|
||||
* Also, this may introduce lower performance on less densely detailed curves,'
|
||||
* this does mean that curves may not be fully accurate (i.e. if they have
|
||||
* sudden spikes which happen at the sampling point, we may have problems).
|
||||
* Also, this may introduce lower performance on less densely detailed curves,'
|
||||
* though it is impossible to predict this from the modifiers!
|
||||
*
|
||||
* If the automatically determined sampling frequency is likely to cause an infinite
|
||||
* loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
|
||||
* chosen here is just the coarsest value which still looks reasonable...
|
||||
* chosen here is just the coarsest value which still looks reasonable...
|
||||
*/
|
||||
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
|
||||
// TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted?
|
||||
samplefreq= dx / U.v2d_min_gridsize;
|
||||
if (samplefreq < 0.00001f) samplefreq= 0.00001f;
|
||||
/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
|
||||
// TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted?
|
||||
samplefreq = dx / U.v2d_min_gridsize;
|
||||
if (samplefreq < 0.00001f) samplefreq = 0.00001f;
|
||||
|
||||
|
||||
/* the start/end times are simply the horizontal extents of the 'cur' rect */
|
||||
stime= v2d->cur.xmin;
|
||||
etime= v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
|
||||
stime = v2d->cur.xmin;
|
||||
etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */
|
||||
|
||||
|
||||
/* at each sampling interval, add a new vertex
|
||||
@@ -531,22 +531,22 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2
|
||||
*/
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
for (ctime= stime; ctime <= etime; ctime += samplefreq)
|
||||
for (ctime = stime; ctime <= etime; ctime += samplefreq)
|
||||
glVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac);
|
||||
|
||||
glEnd();
|
||||
|
||||
/* restore driver */
|
||||
fcu->driver= driver;
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
||||
/* helper func - draw a samples-based F-Curve */
|
||||
static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d)
|
||||
static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d)
|
||||
{
|
||||
FPoint *prevfpt= fcu->fpt;
|
||||
FPoint *fpt= prevfpt + 1;
|
||||
FPoint *prevfpt = fcu->fpt;
|
||||
FPoint *fpt = prevfpt + 1;
|
||||
float fac, v[2];
|
||||
int b= fcu->totvert-1;
|
||||
int b = fcu->totvert - 1;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
|
||||
@@ -555,18 +555,18 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi
|
||||
|
||||
/* extrapolate to left? - left-side of view comes before first keyframe? */
|
||||
if (prevfpt->vec[0] > v2d->cur.xmin) {
|
||||
v[0]= v2d->cur.xmin;
|
||||
v[0] = v2d->cur.xmin;
|
||||
|
||||
/* y-value depends on the interpolation */
|
||||
if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) {
|
||||
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
|
||||
/* just extend across the first keyframe's value */
|
||||
v[1]= prevfpt->vec[1];
|
||||
v[1] = prevfpt->vec[1];
|
||||
}
|
||||
else {
|
||||
/* extrapolate linear dosnt use the handle, use the next points center instead */
|
||||
fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]);
|
||||
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
|
||||
}
|
||||
|
||||
glVertex2fv(v);
|
||||
@@ -583,7 +583,7 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi
|
||||
glVertex2fv(prevfpt->vec);
|
||||
|
||||
/* get next pointers */
|
||||
prevfpt= fpt;
|
||||
prevfpt = fpt;
|
||||
fpt++;
|
||||
|
||||
/* last point? */
|
||||
@@ -593,19 +593,19 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi
|
||||
|
||||
/* extrapolate to right? (see code for left-extrapolation above too) */
|
||||
if (prevfpt->vec[0] < v2d->cur.xmax) {
|
||||
v[0]= v2d->cur.xmax;
|
||||
v[0] = v2d->cur.xmax;
|
||||
|
||||
/* y-value depends on the interpolation */
|
||||
if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) {
|
||||
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) {
|
||||
/* based on last keyframe's value */
|
||||
v[1]= prevfpt->vec[1];
|
||||
v[1] = prevfpt->vec[1];
|
||||
}
|
||||
else {
|
||||
/* extrapolate linear dosnt use the handle, use the previous points center instead */
|
||||
fpt = prevfpt-1;
|
||||
fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]);
|
||||
fpt = prevfpt - 1;
|
||||
fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]);
|
||||
}
|
||||
|
||||
glVertex2fv(v);
|
||||
@@ -618,14 +618,14 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi
|
||||
}
|
||||
|
||||
/* helper func - draw one repeat of an F-Curve */
|
||||
static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d)
|
||||
static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d)
|
||||
{
|
||||
BezTriple *prevbezt= fcu->bezt;
|
||||
BezTriple *bezt= prevbezt+1;
|
||||
BezTriple *prevbezt = fcu->bezt;
|
||||
BezTriple *bezt = prevbezt + 1;
|
||||
float v1[2], v2[2], v3[2], v4[2];
|
||||
float *fp, data[120];
|
||||
float fac= 0.0f;
|
||||
int b= fcu->totvert-1;
|
||||
float fac = 0.0f;
|
||||
int b = fcu->totvert - 1;
|
||||
int resol;
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -636,24 +636,24 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View
|
||||
/* extrapolate to left? */
|
||||
if (prevbezt->vec[1][0] > v2d->cur.xmin) {
|
||||
/* left-side of view comes before first keyframe, so need to extend as not cyclic */
|
||||
v1[0]= v2d->cur.xmin;
|
||||
v1[0] = v2d->cur.xmin;
|
||||
|
||||
/* y-value depends on the interpolation */
|
||||
if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) {
|
||||
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
|
||||
/* just extend across the first keyframe's value */
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
}
|
||||
else if (prevbezt->ipo==BEZT_IPO_LIN) {
|
||||
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* extrapolate linear dosnt use the handle, use the next points center instead */
|
||||
fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]);
|
||||
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
|
||||
}
|
||||
else {
|
||||
/* based on angle of handle 1 (relative to keyframe) */
|
||||
fac= (prevbezt->vec[0][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[0][1]-prevbezt->vec[1][1]);
|
||||
fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]);
|
||||
}
|
||||
|
||||
glVertex2fv(v1);
|
||||
@@ -661,28 +661,28 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View
|
||||
|
||||
/* if only one keyframe, add it now */
|
||||
if (fcu->totvert == 1) {
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
}
|
||||
|
||||
/* draw curve between first and last keyframe (if there are enough to do so) */
|
||||
// TODO: optimize this to not have to calc stuff out of view too?
|
||||
while (b--) {
|
||||
if (prevbezt->ipo==BEZT_IPO_CONST) {
|
||||
if (prevbezt->ipo == BEZT_IPO_CONST) {
|
||||
/* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
|
||||
v1[0]= bezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = bezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
}
|
||||
else if (prevbezt->ipo==BEZT_IPO_LIN) {
|
||||
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* Linear interpolation: just add one point (which should add a new line segment) */
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
}
|
||||
else {
|
||||
@@ -693,74 +693,74 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View
|
||||
/* resol depends on distance between points (not just horizontal) OR is a fixed high res */
|
||||
// TODO: view scale should factor into this someday too...
|
||||
if (fcu->driver)
|
||||
resol= 32;
|
||||
resol = 32;
|
||||
else
|
||||
resol= (int)(5.0f*len_v2v2(bezt->vec[1], prevbezt->vec[1]));
|
||||
resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1]));
|
||||
|
||||
if (resol < 2) {
|
||||
/* only draw one */
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
}
|
||||
else {
|
||||
/* clamp resolution to max of 32 */
|
||||
// NOTE: higher values will crash
|
||||
if (resol > 32) resol= 32;
|
||||
if (resol > 32) resol = 32;
|
||||
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v2[0]= prevbezt->vec[2][0];
|
||||
v2[1]= prevbezt->vec[2][1];
|
||||
|
||||
v3[0]= bezt->vec[0][0];
|
||||
v3[1]= bezt->vec[0][1];
|
||||
v4[0]= bezt->vec[1][0];
|
||||
v4[1]= bezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
v2[0] = prevbezt->vec[2][0];
|
||||
v2[1] = prevbezt->vec[2][1];
|
||||
|
||||
v3[0] = bezt->vec[0][0];
|
||||
v3[1] = bezt->vec[0][1];
|
||||
v4[0] = bezt->vec[1][0];
|
||||
v4[1] = bezt->vec[1][1];
|
||||
|
||||
correct_bezpart(v1, v2, v3, v4);
|
||||
|
||||
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float)*3);
|
||||
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data+1, resol, sizeof(float)*3);
|
||||
BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
|
||||
BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
|
||||
|
||||
for (fp= data; resol; resol--, fp+= 3)
|
||||
for (fp = data; resol; resol--, fp += 3)
|
||||
glVertex2fv(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* get next pointers */
|
||||
prevbezt= bezt;
|
||||
prevbezt = bezt;
|
||||
bezt++;
|
||||
|
||||
/* last point? */
|
||||
if (b == 0) {
|
||||
v1[0]= prevbezt->vec[1][0];
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[0] = prevbezt->vec[1][0];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
glVertex2fv(v1);
|
||||
}
|
||||
}
|
||||
|
||||
/* extrapolate to right? (see code for left-extrapolation above too) */
|
||||
if (prevbezt->vec[1][0] < v2d->cur.xmax) {
|
||||
v1[0]= v2d->cur.xmax;
|
||||
v1[0] = v2d->cur.xmax;
|
||||
|
||||
/* y-value depends on the interpolation */
|
||||
if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) {
|
||||
if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) {
|
||||
/* based on last keyframe's value */
|
||||
v1[1]= prevbezt->vec[1][1];
|
||||
v1[1] = prevbezt->vec[1][1];
|
||||
}
|
||||
else if (prevbezt->ipo==BEZT_IPO_LIN) {
|
||||
else if (prevbezt->ipo == BEZT_IPO_LIN) {
|
||||
/* extrapolate linear dosnt use the handle, use the previous points center instead */
|
||||
bezt = prevbezt-1;
|
||||
fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]);
|
||||
bezt = prevbezt - 1;
|
||||
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]);
|
||||
}
|
||||
else {
|
||||
/* based on angle of handle 1 (relative to keyframe) */
|
||||
fac= (prevbezt->vec[2][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]);
|
||||
if (fac) fac= 1.0f/fac;
|
||||
v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[2][1]-prevbezt->vec[1][1]);
|
||||
fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
|
||||
if (fac) fac = 1.0f / fac;
|
||||
v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]);
|
||||
}
|
||||
|
||||
glVertex2fv(v1);
|
||||
@@ -786,13 +786,13 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
glLineWidth(3.0f);
|
||||
|
||||
/* anti-aliased lines for less jagged appearance */
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */
|
||||
for (fcu= sipo->ghostCurves.first; fcu; fcu= fcu->next) {
|
||||
for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) {
|
||||
/* set whatever color the curve has set
|
||||
* - this is set by the function which creates these
|
||||
* - this is set by the function which creates these
|
||||
* - draw with a fixed opacity of 2
|
||||
*/
|
||||
glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f);
|
||||
@@ -805,7 +805,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar)
|
||||
setlinestyle(0);
|
||||
glLineWidth(1.0f);
|
||||
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -819,18 +819,18 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
|
||||
int filter;
|
||||
|
||||
/* build list of curves to draw */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_CURVE_VISIBLE);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
|
||||
filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL));
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* for each curve:
|
||||
* draw curve, then handle-lines, and finally vertices in this order so that
|
||||
* the data will be layered correctly
|
||||
* the data will be layered correctly
|
||||
*/
|
||||
for (ale=anim_data.first; ale; ale=ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
FModifier *fcm= find_active_fmodifier(&fcu->modifiers);
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
FModifier *fcm = find_active_fmodifier(&fcu->modifiers);
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* map keyframes for drawing if scaled F-Curve */
|
||||
if (adt)
|
||||
@@ -868,7 +868,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
|
||||
}
|
||||
|
||||
/* anti-aliased lines for less jagged appearance */
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* draw F-Curve */
|
||||
@@ -890,7 +890,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid
|
||||
setlinestyle(0);
|
||||
glLineWidth(1.0);
|
||||
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH);
|
||||
if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
@@ -953,35 +953,35 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
View2D *v2d= &ar->v2d;
|
||||
float y= 0.0f, height;
|
||||
View2D *v2d = &ar->v2d;
|
||||
float y = 0.0f, height;
|
||||
size_t items;
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
/* build list of channels to draw */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
||||
items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS);
|
||||
items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* Update max-extent of channels here (taking into account scrollers):
|
||||
* - this is done to allow the channel list to be scrollable, but must be done here
|
||||
* to avoid regenerating the list again and/or also because channels list is drawn first
|
||||
* - this is done to allow the channel list to be scrollable, but must be done here
|
||||
* to avoid regenerating the list again and/or also because channels list is drawn first
|
||||
* - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for
|
||||
* start of list offset, and the second is as a correction for the scrollers.
|
||||
*/
|
||||
height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2));
|
||||
height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2));
|
||||
UI_view2d_totRect_set(v2d, ar->winx, height);
|
||||
|
||||
/* loop through channels, and set up drawing depending on their type */
|
||||
{ /* first pass: just the standard GL-drawing for backdrop + text */
|
||||
y= (float)ACHANNEL_FIRST;
|
||||
{ /* first pass: just the standard GL-drawing for backdrop + text */
|
||||
y = (float)ACHANNEL_FIRST;
|
||||
|
||||
for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) {
|
||||
const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
|
||||
const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF);
|
||||
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
|
||||
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF);
|
||||
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF);
|
||||
|
||||
/* check if visible */
|
||||
if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
|
||||
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
|
||||
{
|
||||
/* draw all channels using standard channel-drawing API */
|
||||
ANIM_channel_draw(ac, ale, yminc, ymaxc);
|
||||
@@ -991,23 +991,23 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar)
|
||||
y -= ACHANNEL_STEP;
|
||||
}
|
||||
}
|
||||
{ /* second pass: widgets */
|
||||
uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
|
||||
{ /* second pass: widgets */
|
||||
uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
|
||||
size_t channel_index = 0;
|
||||
|
||||
y= (float)ACHANNEL_FIRST;
|
||||
y = (float)ACHANNEL_FIRST;
|
||||
|
||||
/* set blending again, as may not be set in previous step */
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) {
|
||||
const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF);
|
||||
const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF);
|
||||
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
|
||||
const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF);
|
||||
const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF);
|
||||
|
||||
/* check if visible */
|
||||
if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
|
||||
if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
|
||||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
|
||||
{
|
||||
/* draw all channels using standard channel-drawing API */
|
||||
ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index);
|
||||
|
||||
@@ -90,21 +90,21 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
|
||||
int filter;
|
||||
|
||||
/* get data to filter, from Dopesheet */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* set large values to try to override */
|
||||
if (xmin) *xmin= 999999999.0f;
|
||||
if (xmax) *xmax= -999999999.0f;
|
||||
if (ymin) *ymin= 999999999.0f;
|
||||
if (ymax) *ymax= -999999999.0f;
|
||||
if (xmin) *xmin = 999999999.0f;
|
||||
if (xmax) *xmax = -999999999.0f;
|
||||
if (ymin) *ymin = 999999999.0f;
|
||||
if (ymax) *ymax = -999999999.0f;
|
||||
|
||||
/* check if any channels to set range with */
|
||||
if (anim_data.first) {
|
||||
/* go through channels, finding max extents */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
float txmin, txmax, tymin, tymax;
|
||||
float unitFac;
|
||||
|
||||
@@ -113,20 +113,20 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
|
||||
|
||||
/* apply NLA scaling */
|
||||
if (adt) {
|
||||
txmin= BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP);
|
||||
txmax= BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP);
|
||||
txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP);
|
||||
txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP);
|
||||
}
|
||||
|
||||
/* apply unit corrections */
|
||||
unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
|
||||
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
|
||||
tymin *= unitFac;
|
||||
tymax *= unitFac;
|
||||
|
||||
/* try to set cur using these values, if they're more extreme than previously set values */
|
||||
if ((xmin) && (txmin < *xmin)) *xmin= txmin;
|
||||
if ((xmax) && (txmax > *xmax)) *xmax= txmax;
|
||||
if ((ymin) && (tymin < *ymin)) *ymin= tymin;
|
||||
if ((ymax) && (tymax > *ymax)) *ymax= tymax;
|
||||
if ((xmin) && (txmin < *xmin)) *xmin = txmin;
|
||||
if ((xmax) && (txmax > *xmax)) *xmax = txmax;
|
||||
if ((ymin) && (tymin < *ymin)) *ymin = tymin;
|
||||
if ((ymax) && (tymax > *ymax)) *ymax = tymax;
|
||||
}
|
||||
|
||||
/* ensure that the extents are not too extreme that view implodes...*/
|
||||
@@ -139,16 +139,16 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa
|
||||
else {
|
||||
/* set default range */
|
||||
if (ac->scene) {
|
||||
if (xmin) *xmin= (float)ac->scene->r.sfra;
|
||||
if (xmax) *xmax= (float)ac->scene->r.efra;
|
||||
if (xmin) *xmin = (float)ac->scene->r.sfra;
|
||||
if (xmax) *xmax = (float)ac->scene->r.efra;
|
||||
}
|
||||
else {
|
||||
if (xmin) *xmin= -5;
|
||||
if (xmax) *xmax= 100;
|
||||
if (xmin) *xmin = -5;
|
||||
if (xmax) *xmax = 100;
|
||||
}
|
||||
|
||||
if (ymin) *ymin= -5;
|
||||
if (ymax) *ymax= 5;
|
||||
if (ymin) *ymin = -5;
|
||||
if (ymax) *ymax = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,17 +166,17 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
if (ac.scene == NULL)
|
||||
return OPERATOR_CANCELLED;
|
||||
else
|
||||
scene= ac.scene;
|
||||
scene = ac.scene;
|
||||
|
||||
/* set the range directly */
|
||||
get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE);
|
||||
scene->r.flag |= SCER_PRV_RANGE;
|
||||
scene->r.psfra= (int)floor(min + 0.5f);
|
||||
scene->r.pefra= (int)floor(max + 0.5f);
|
||||
scene->r.psfra = (int)floor(min + 0.5f);
|
||||
scene->r.pefra = (int)floor(max + 0.5f);
|
||||
|
||||
/* set notifier that things have changed */
|
||||
// XXX err... there's nothing for frame ranges yet, but this should do fine too
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ****************** View-All Operator ****************** */
|
||||
@@ -207,16 +207,16 @@ static int graphkeys_viewall(bContext *C, const short selOnly)
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
v2d= &ac.ar->v2d;
|
||||
v2d = &ac.ar->v2d;
|
||||
|
||||
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
|
||||
get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, selOnly);
|
||||
|
||||
extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
|
||||
v2d->cur.xmin -= extra;
|
||||
v2d->cur.xmax += extra;
|
||||
|
||||
extra= 0.1f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
extra = 0.1f * (v2d->cur.ymax - v2d->cur.ymin);
|
||||
v2d->cur.ymin -= extra;
|
||||
v2d->cur.ymax += extra;
|
||||
|
||||
@@ -255,7 +255,7 @@ void GRAPH_OT_view_all(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void GRAPH_OT_view_selected(wmOperatorType *ot)
|
||||
@@ -270,7 +270,7 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier...
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************** Create Ghost-Curves Operator *********************** */
|
||||
@@ -279,9 +279,9 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
|
||||
*/
|
||||
|
||||
/* Bake each F-Curve into a set of samples, and store as a ghost curve */
|
||||
static void create_ghost_curves (bAnimContext *ac, int start, int end)
|
||||
static void create_ghost_curves(bAnimContext *ac, int start, int end)
|
||||
{
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
@@ -296,51 +296,51 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end)
|
||||
}
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and add keys between selected keyframes on every frame */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
FCurve *gcu= MEM_callocN(sizeof(FCurve), "Ghost FCurve");
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
FCurve *gcu = MEM_callocN(sizeof(FCurve), "Ghost FCurve");
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
FPoint *fpt;
|
||||
float unitFac;
|
||||
int cfra;
|
||||
|
||||
/* disable driver so that it don't muck up the sampling process */
|
||||
fcu->driver= NULL;
|
||||
fcu->driver = NULL;
|
||||
|
||||
/* calculate unit-mapping factor */
|
||||
unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
|
||||
unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0);
|
||||
|
||||
/* create samples, but store them in a new curve
|
||||
* - we cannot use fcurve_store_samples() as that will only overwrite the original curve
|
||||
*/
|
||||
gcu->fpt= fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "Ghost FPoint Samples");
|
||||
gcu->totvert= end - start + 1;
|
||||
gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples");
|
||||
gcu->totvert = end - start + 1;
|
||||
|
||||
/* use the sampling callback at 1-frame intervals from start to end frames */
|
||||
for (cfra= start; cfra <= end; cfra++, fpt++) {
|
||||
float cfrae= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
|
||||
for (cfra = start; cfra <= end; cfra++, fpt++) {
|
||||
float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
|
||||
|
||||
fpt->vec[0]= cfrae;
|
||||
fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac;
|
||||
fpt->vec[0] = cfrae;
|
||||
fpt->vec[1] = fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac;
|
||||
}
|
||||
|
||||
/* set color of ghost curve
|
||||
* - make the color slightly darker
|
||||
*/
|
||||
gcu->color[0]= fcu->color[0] - 0.07f;
|
||||
gcu->color[1]= fcu->color[1] - 0.07f;
|
||||
gcu->color[2]= fcu->color[2] - 0.07f;
|
||||
gcu->color[0] = fcu->color[0] - 0.07f;
|
||||
gcu->color[1] = fcu->color[1] - 0.07f;
|
||||
gcu->color[2] = fcu->color[2] - 0.07f;
|
||||
|
||||
/* store new ghost curve */
|
||||
BLI_addtail(&sipo->ghostCurves, gcu);
|
||||
|
||||
/* restore driver */
|
||||
fcu->driver= driver;
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
||||
/* admin and redraws */
|
||||
@@ -360,9 +360,9 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */
|
||||
v2d= &ac.ar->v2d;
|
||||
start= (int)v2d->cur.xmin;
|
||||
end= (int)v2d->cur.xmax;
|
||||
v2d = &ac.ar->v2d;
|
||||
start = (int)v2d->cur.xmin;
|
||||
end = (int)v2d->cur.xmax;
|
||||
|
||||
/* bake selected curves into a ghost curve */
|
||||
create_ghost_curves(&ac, start, end);
|
||||
@@ -385,7 +385,7 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
// todo: add props for start/end frames
|
||||
}
|
||||
@@ -401,7 +401,7 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
sipo= (SpaceIpo *)ac.sl;
|
||||
sipo = (SpaceIpo *)ac.sl;
|
||||
|
||||
/* if no ghost curves, don't do anything */
|
||||
if (sipo->ghostCurves.first == NULL)
|
||||
@@ -428,7 +428,7 @@ void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_graphedit_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
@@ -451,11 +451,11 @@ static void insert_graph_keys(bAnimContext *ac, short mode)
|
||||
int filter;
|
||||
|
||||
ReportList *reports = ac->reports;
|
||||
Scene *scene= ac->scene;
|
||||
Scene *scene = ac->scene;
|
||||
short flag = 0;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
if (mode == 2) filter |= ANIMFILTER_SEL;
|
||||
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
@@ -464,20 +464,20 @@ static void insert_graph_keys(bAnimContext *ac, short mode)
|
||||
flag = ANIM_get_keyframing_flags(scene, 1);
|
||||
|
||||
/* insert keyframes */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
float cfra;
|
||||
|
||||
/* adjust current frame for NLA-mapping */
|
||||
if (adt)
|
||||
cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
|
||||
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
|
||||
else
|
||||
cfra= (float)CFRA;
|
||||
cfra = (float)CFRA;
|
||||
|
||||
/* if there's an id */
|
||||
if (ale->id)
|
||||
insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag);
|
||||
else
|
||||
insert_vert_fcurve(fcu, cfra, fcu->curval, 0);
|
||||
}
|
||||
@@ -497,7 +497,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* which channels to affect? */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* insert keyframes */
|
||||
insert_graph_keys(&ac, mode);
|
||||
@@ -506,7 +506,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -524,7 +524,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", "");
|
||||
@@ -532,7 +532,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot)
|
||||
|
||||
/* ******************** Click-Insert Keyframes Operator ************************* */
|
||||
|
||||
static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
|
||||
static int graphkeys_click_insert_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
bAnimListElem *ale;
|
||||
@@ -545,7 +545,7 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get active F-Curve 'anim-list-element' */
|
||||
ale= get_active_fcurve_channel(&ac);
|
||||
ale = get_active_fcurve_channel(&ac);
|
||||
if (ELEM(NULL, ale, ale->data)) {
|
||||
if (ale) MEM_freeN(ale);
|
||||
return OPERATOR_CANCELLED;
|
||||
@@ -557,12 +557,12 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
|
||||
*/
|
||||
if (fcurve_is_keyframable(fcu)) {
|
||||
/* get frame and value from props */
|
||||
frame= RNA_float_get(op->ptr, "frame");
|
||||
val= RNA_float_get(op->ptr, "value");
|
||||
frame = RNA_float_get(op->ptr, "frame");
|
||||
val = RNA_float_get(op->ptr, "value");
|
||||
|
||||
/* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
|
||||
adt= ANIM_nla_mapping_get(&ac, ale);
|
||||
frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
|
||||
adt = ANIM_nla_mapping_get(&ac, ale);
|
||||
frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP);
|
||||
|
||||
/* apply inverse unit-mapping to value to get correct value for F-Curves */
|
||||
val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1);
|
||||
@@ -584,13 +584,13 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
|
||||
MEM_freeN(ale);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
/* done */
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent *evt)
|
||||
static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, wmEvent *evt)
|
||||
{
|
||||
bAnimContext ac;
|
||||
ARegion *ar;
|
||||
@@ -603,11 +603,11 @@ static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent *
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* store mouse coordinates in View2D space, into the operator's properties */
|
||||
ar= ac.ar;
|
||||
v2d= &ar->v2d;
|
||||
ar = ac.ar;
|
||||
v2d = &ar->v2d;
|
||||
|
||||
mval[0]= (evt->x - ar->winrct.xmin);
|
||||
mval[1]= (evt->y - ar->winrct.ymin);
|
||||
mval[0] = (evt->x - ar->winrct.xmin);
|
||||
mval[1] = (evt->y - ar->winrct.ymin);
|
||||
|
||||
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
|
||||
|
||||
@@ -631,7 +631,7 @@ void GRAPH_OT_click_insert(wmOperatorType *ot)
|
||||
ot->poll = graphop_active_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100);
|
||||
@@ -641,20 +641,20 @@ void GRAPH_OT_click_insert(wmOperatorType *ot)
|
||||
/* ******************** Copy/Paste Keyframes Operator ************************* */
|
||||
/* NOTE: the backend code for this is shared with the dopesheet editor */
|
||||
|
||||
static short copy_graph_keys (bAnimContext *ac)
|
||||
static short copy_graph_keys(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
int filter, ok=0;
|
||||
int filter, ok = 0;
|
||||
|
||||
/* clear buffer first */
|
||||
free_anim_copybuf();
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* copy keyframes */
|
||||
ok= copy_animedit_keys(ac, &anim_data);
|
||||
ok = copy_animedit_keys(ac, &anim_data);
|
||||
|
||||
/* clean up */
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -662,18 +662,18 @@ static short copy_graph_keys (bAnimContext *ac)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static short paste_graph_keys (bAnimContext *ac,
|
||||
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode)
|
||||
static short paste_graph_keys(bAnimContext *ac,
|
||||
const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
int filter, ok=0;
|
||||
int filter, ok = 0;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* paste keyframes */
|
||||
ok= paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode);
|
||||
ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode);
|
||||
|
||||
/* clean up */
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -713,7 +713,7 @@ void GRAPH_OT_copy(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -722,15 +722,15 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
const eKeyPasteOffset offset_mode= RNA_enum_get(op->ptr, "offset");
|
||||
const eKeyMergeMode merge_mode= RNA_enum_get(op->ptr, "merge");
|
||||
const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset");
|
||||
const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge");
|
||||
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* ac.reports by default will be the global reports list, which won't show warnings */
|
||||
ac.reports= op->reports;
|
||||
ac.reports = op->reports;
|
||||
|
||||
/* paste keyframes - non-zero return means an error occurred while trying to paste */
|
||||
if (paste_graph_keys(&ac, offset_mode, merge_mode)) {
|
||||
@@ -741,7 +741,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -759,7 +759,7 @@ void GRAPH_OT_paste(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys");
|
||||
RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing");
|
||||
@@ -767,18 +767,18 @@ void GRAPH_OT_paste(wmOperatorType *ot)
|
||||
|
||||
/* ******************** Duplicate Keyframes Operator ************************* */
|
||||
|
||||
static void duplicate_graph_keys (bAnimContext *ac)
|
||||
static void duplicate_graph_keys(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and delete selected keys */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
duplicate_fcurve_keys((FCurve *)ale->key_data);
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -828,7 +828,7 @@ void GRAPH_OT_duplicate(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* to give to transform */
|
||||
RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
|
||||
@@ -836,20 +836,20 @@ void GRAPH_OT_duplicate(wmOperatorType *ot)
|
||||
|
||||
/* ******************** Delete Keyframes Operator ************************* */
|
||||
|
||||
static void delete_graph_keys (bAnimContext *ac)
|
||||
static void delete_graph_keys(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and delete selected keys */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
AnimData *adt= ale->adt;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
AnimData *adt = ale->adt;
|
||||
|
||||
/* delete selected keyframes only */
|
||||
delete_fcurve_keys(fcu);
|
||||
@@ -880,7 +880,7 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -898,23 +898,23 @@ void GRAPH_OT_delete(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************** Clean Keyframes Operator ************************* */
|
||||
|
||||
static void clean_graph_keys (bAnimContext *ac, float thresh)
|
||||
static void clean_graph_keys(bAnimContext *ac, float thresh)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and clean curves */
|
||||
for (ale= anim_data.first; ale; ale= ale->next)
|
||||
for (ale = anim_data.first; ale; ale = ale->next)
|
||||
clean_fcurve((FCurve *)ale->key_data, thresh);
|
||||
|
||||
/* free temp data */
|
||||
@@ -933,7 +933,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get cleaning threshold */
|
||||
thresh= RNA_float_get(op->ptr, "threshold");
|
||||
thresh = RNA_float_get(op->ptr, "threshold");
|
||||
|
||||
/* clean keyframes */
|
||||
clean_graph_keys(&ac, thresh);
|
||||
@@ -942,7 +942,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -960,7 +960,7 @@ void GRAPH_OT_clean(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f);
|
||||
@@ -970,29 +970,29 @@ void GRAPH_OT_clean(wmOperatorType *ot)
|
||||
/* This operator bakes the data of the selected F-Curves to F-Points */
|
||||
|
||||
/* Bake each F-Curve into a set of samples */
|
||||
static void bake_graph_curves (bAnimContext *ac, int start, int end)
|
||||
static void bake_graph_curves(bAnimContext *ac, int start, int end)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and add keys between selected keyframes on every frame */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
ChannelDriver *driver= fcu->driver;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
ChannelDriver *driver = fcu->driver;
|
||||
|
||||
/* disable driver so that it don't muck up the sampling process */
|
||||
fcu->driver= NULL;
|
||||
fcu->driver = NULL;
|
||||
|
||||
/* create samples */
|
||||
fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve);
|
||||
|
||||
/* restore driver */
|
||||
fcu->driver= driver;
|
||||
fcu->driver = driver;
|
||||
}
|
||||
|
||||
/* admin and redraws */
|
||||
@@ -1004,7 +1004,7 @@ static void bake_graph_curves (bAnimContext *ac, int start, int end)
|
||||
static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bAnimContext ac;
|
||||
Scene *scene= NULL;
|
||||
Scene *scene = NULL;
|
||||
int start, end;
|
||||
|
||||
/* get editor data */
|
||||
@@ -1013,9 +1013,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* for now, init start/end from preview-range extents */
|
||||
// TODO: add properties for this
|
||||
scene= ac.scene;
|
||||
start= PSFRA;
|
||||
end= PEFRA;
|
||||
scene = ac.scene;
|
||||
start = PSFRA;
|
||||
end = PEFRA;
|
||||
|
||||
/* bake keyframes */
|
||||
bake_graph_curves(&ac, start, end);
|
||||
@@ -1025,7 +1025,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
// NOTE: some distinction between order/number of keyframes and type should be made?
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1043,7 +1043,7 @@ void GRAPH_OT_bake(wmOperatorType *ot)
|
||||
ot->poll = graphop_selected_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
// todo: add props for start/end frames
|
||||
}
|
||||
@@ -1069,9 +1069,9 @@ typedef struct tSoundBakeInfo {
|
||||
/* Sampling callback used to determine the value from the sound to
|
||||
* save in the F-Curve at the specified frame
|
||||
*/
|
||||
static float fcurve_samplingcb_sound (FCurve *UNUSED(fcu), void *data, float evaltime)
|
||||
static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float evaltime)
|
||||
{
|
||||
tSoundBakeInfo *sbi= (tSoundBakeInfo *)data;
|
||||
tSoundBakeInfo *sbi = (tSoundBakeInfo *)data;
|
||||
|
||||
int position = evaltime - sbi->cfra;
|
||||
if ((position < 0) || (position >= sbi->length))
|
||||
@@ -1090,7 +1090,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
|
||||
int filter;
|
||||
|
||||
tSoundBakeInfo sbi;
|
||||
Scene *scene= NULL;
|
||||
Scene *scene = NULL;
|
||||
int start, end;
|
||||
|
||||
char path[FILE_MAX];
|
||||
@@ -1101,20 +1101,20 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
|
||||
|
||||
RNA_string_get(op->ptr, "filepath", path);
|
||||
|
||||
scene= ac.scene; /* current scene */
|
||||
scene = ac.scene; /* current scene */
|
||||
|
||||
/* store necessary data for the baking steps */
|
||||
sbi.samples = AUD_readSoundBuffer(path,
|
||||
RNA_float_get(op->ptr, "low"),
|
||||
RNA_float_get(op->ptr, "high"),
|
||||
RNA_float_get(op->ptr, "attack"),
|
||||
RNA_float_get(op->ptr, "release"),
|
||||
RNA_float_get(op->ptr, "threshold"),
|
||||
RNA_boolean_get(op->ptr, "accumulate"),
|
||||
RNA_boolean_get(op->ptr, "use_additive"),
|
||||
RNA_boolean_get(op->ptr, "square"),
|
||||
RNA_float_get(op->ptr, "sthreshold"),
|
||||
FPS, &sbi.length);
|
||||
RNA_float_get(op->ptr, "low"),
|
||||
RNA_float_get(op->ptr, "high"),
|
||||
RNA_float_get(op->ptr, "attack"),
|
||||
RNA_float_get(op->ptr, "release"),
|
||||
RNA_float_get(op->ptr, "threshold"),
|
||||
RNA_boolean_get(op->ptr, "accumulate"),
|
||||
RNA_boolean_get(op->ptr, "use_additive"),
|
||||
RNA_boolean_get(op->ptr, "square"),
|
||||
RNA_float_get(op->ptr, "sthreshold"),
|
||||
FPS, &sbi.length);
|
||||
|
||||
if (sbi.samples == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Unsupported audio format");
|
||||
@@ -1126,12 +1126,12 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
|
||||
end = CFRA + sbi.length - 1;
|
||||
|
||||
/* filter anim channels */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* loop through all selected F-Curves, replacing its data with the sound samples */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* sample the sound */
|
||||
fcurve_store_samples(fcu, &sbi, start, end, fcurve_samplingcb_sound);
|
||||
@@ -1147,7 +1147,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that 'keyframes' have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op)
|
||||
|
||||
#endif //WITH_AUDASPACE
|
||||
|
||||
static int graphkeys_sound_bake_invoke (bContext *C, wmOperator *op, wmEvent *event)
|
||||
static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
@@ -1187,10 +1187,10 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
|
||||
ot->poll = graphop_selected_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* properties */
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
|
||||
WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
|
||||
RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00);
|
||||
RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00);
|
||||
RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1);
|
||||
@@ -1208,18 +1208,18 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot)
|
||||
*/
|
||||
|
||||
/* Evaluates the curves between each selected keyframe on each frame, and keys the value */
|
||||
static void sample_graph_keys (bAnimContext *ac)
|
||||
static void sample_graph_keys(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through filtered data and add keys between selected keyframes on every frame */
|
||||
for (ale= anim_data.first; ale; ale= ale->next)
|
||||
for (ale = anim_data.first; ale; ale = ale->next)
|
||||
sample_fcurve((FCurve *)ale->key_data);
|
||||
|
||||
/* admin and redraws */
|
||||
@@ -1243,7 +1243,7 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1260,7 +1260,7 @@ void GRAPH_OT_sample(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
|
||||
@@ -1270,8 +1270,8 @@ void GRAPH_OT_sample(wmOperatorType *ot)
|
||||
/* ******************** Set Extrapolation-Type Operator *********************** */
|
||||
|
||||
/* defines for make/clear cyclic extrapolation tools */
|
||||
#define MAKE_CYCLIC_EXPO -1
|
||||
#define CLEAR_CYCLIC_EXPO -2
|
||||
#define MAKE_CYCLIC_EXPO -1
|
||||
#define CLEAR_CYCLIC_EXPO -2
|
||||
|
||||
/* defines for set extrapolation-type for selected keyframes tool */
|
||||
static EnumPropertyItem prop_graphkeys_expo_types[] = {
|
||||
@@ -1291,16 +1291,16 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
|
||||
int filter;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through setting mode per F-Curve */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
if (mode >= 0) {
|
||||
/* just set mode setting */
|
||||
fcu->extend= mode;
|
||||
fcu->extend = mode;
|
||||
}
|
||||
else {
|
||||
/* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
|
||||
@@ -1315,7 +1315,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
|
||||
}
|
||||
else if (mode == CLEAR_CYCLIC_EXPO) {
|
||||
/* remove all the modifiers fitting this description */
|
||||
FModifier *fcm, *fcn=NULL;
|
||||
FModifier *fcm, *fcn = NULL;
|
||||
|
||||
for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
|
||||
fcn = fcm->next;
|
||||
@@ -1343,7 +1343,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get handle setting mode */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* set handle type */
|
||||
setexpo_graph_keys(&ac, mode);
|
||||
@@ -1352,7 +1352,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframe properties have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1370,7 +1370,7 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", "");
|
||||
@@ -1384,16 +1384,16 @@ static void setipo_graph_keys(bAnimContext *ac, short mode)
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode);
|
||||
KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode);
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through setting BezTriple interpolation
|
||||
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
|
||||
*/
|
||||
for (ale= anim_data.first; ale; ale= ale->next)
|
||||
for (ale = anim_data.first; ale; ale = ale->next)
|
||||
ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve);
|
||||
|
||||
/* cleanup */
|
||||
@@ -1412,7 +1412,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get handle setting mode */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* set handle type */
|
||||
setipo_graph_keys(&ac, mode);
|
||||
@@ -1421,7 +1421,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframe properties have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1439,7 +1439,7 @@ void GRAPH_OT_interpolation_type(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", "");
|
||||
@@ -1454,18 +1454,18 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode)
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode);
|
||||
KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
|
||||
KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode);
|
||||
KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* loop through setting flags for handles
|
||||
* Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here...
|
||||
*/
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* any selected keyframes for editing? */
|
||||
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) {
|
||||
@@ -1489,7 +1489,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get handle setting mode */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* set handle type */
|
||||
sethandles_graph_keys(&ac, mode);
|
||||
@@ -1498,12 +1498,12 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframe properties have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GRAPH_OT_handle_type (wmOperatorType *ot)
|
||||
void GRAPH_OT_handle_type(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Set Keyframe Handle Type";
|
||||
@@ -1516,7 +1516,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", "");
|
||||
@@ -1536,39 +1536,39 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op)
|
||||
typedef struct tEulerFilter {
|
||||
struct tEulerFilter *next, *prev;
|
||||
|
||||
ID *id; /* ID-block which owns the channels */
|
||||
FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */
|
||||
char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */
|
||||
ID *id; /* ID-block which owns the channels */
|
||||
FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */
|
||||
char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */
|
||||
} tEulerFilter;
|
||||
|
||||
static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
ListBase eulers = {NULL, NULL};
|
||||
tEulerFilter *euf= NULL;
|
||||
int groups=0, failed=0;
|
||||
tEulerFilter *euf = NULL;
|
||||
int groups = 0, failed = 0;
|
||||
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* The process is done in two passes:
|
||||
* 1) Sets of three related rotation curves are identified from the selected channels,
|
||||
* 1) Sets of three related rotation curves are identified from the selected channels,
|
||||
* and are stored as a single 'operation unit' for the next step
|
||||
* 2) Each set of three F-Curves is processed for each keyframe, with the values being
|
||||
* processed as necessary
|
||||
* processed as necessary
|
||||
*/
|
||||
|
||||
/* step 1: extract only the rotation f-curves */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
/* check if this is an appropriate F-Curve
|
||||
@@ -1579,8 +1579,8 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
continue;
|
||||
else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) {
|
||||
BKE_reportf(op->reports, RPT_WARNING,
|
||||
"Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)",
|
||||
(ale->id)? ale->id->name:"<No ID>", fcu->rna_path, fcu->array_index);
|
||||
"Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)",
|
||||
(ale->id) ? ale->id->name : "<No ID>", fcu->rna_path, fcu->array_index);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1588,19 +1588,19 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
* so if the paths or the ID's don't match up, then a curve needs to be added
|
||||
* to a new group
|
||||
*/
|
||||
if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path)==0)) {
|
||||
if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path) == 0)) {
|
||||
/* this should be fine to add to the existing group then */
|
||||
euf->fcurves[fcu->array_index]= fcu;
|
||||
euf->fcurves[fcu->array_index] = fcu;
|
||||
}
|
||||
else {
|
||||
/* just add to a new block */
|
||||
euf= MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
|
||||
euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter");
|
||||
BLI_addtail(&eulers, euf);
|
||||
groups++;
|
||||
|
||||
euf->id= ale->id;
|
||||
euf->id = ale->id;
|
||||
euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */
|
||||
euf->fcurves[fcu->array_index]= fcu;
|
||||
euf->fcurves[fcu->array_index] = fcu;
|
||||
}
|
||||
}
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -1613,7 +1613,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
/* step 2: go through each set of curves, processing the values at each keyframe
|
||||
* - it is assumed that there must be a full set of keyframes at each keyframe position
|
||||
*/
|
||||
for (euf= eulers.first; euf; euf= euf->next) {
|
||||
for (euf = eulers.first; euf; euf = euf->next) {
|
||||
int f;
|
||||
|
||||
/* sanity check: ensure that there are enough F-Curves to work on in this group */
|
||||
@@ -1621,11 +1621,11 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) {
|
||||
/* report which components are missing */
|
||||
BKE_reportf(op->reports, RPT_WARNING,
|
||||
"Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'",
|
||||
(euf->fcurves[0]==NULL)? "X":"",
|
||||
(euf->fcurves[1]==NULL)? "Y":"",
|
||||
(euf->fcurves[2]==NULL)? "Z":"",
|
||||
euf->id->name, euf->rna_path);
|
||||
"Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'",
|
||||
(euf->fcurves[0] == NULL) ? "X" : "",
|
||||
(euf->fcurves[1] == NULL) ? "Y" : "",
|
||||
(euf->fcurves[2] == NULL) ? "Z" : "",
|
||||
euf->id->name, euf->rna_path);
|
||||
|
||||
/* keep track of number of failed sets, and carry on to next group */
|
||||
failed++;
|
||||
@@ -1636,7 +1636,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
// FIXME: there are more complicated methods that will be needed to fix more cases than just some
|
||||
for (f = 0; f < 3; f++) {
|
||||
FCurve *fcu = euf->fcurves[f];
|
||||
BezTriple *bezt, *prev=NULL;
|
||||
BezTriple *bezt, *prev = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* skip if not enough vets to do a decent analysis of... */
|
||||
@@ -1644,7 +1644,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
continue;
|
||||
|
||||
/* prev follows bezt, bezt = "current" point to be fixed */
|
||||
for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, prev=bezt, bezt++) {
|
||||
for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, prev = bezt, bezt++) {
|
||||
/* our method depends on determining a "difference" from the previous vert */
|
||||
if (prev == NULL)
|
||||
continue;
|
||||
@@ -1661,7 +1661,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
bezt->vec[2][1] += fac;
|
||||
}
|
||||
}
|
||||
else /* if (prev->vec[1][1] < bezt->vec[1][1]) */ {
|
||||
else { /* if (prev->vec[1][1] < bezt->vec[1][1]) */
|
||||
while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) {
|
||||
bezt->vec[0][1] -= fac;
|
||||
bezt->vec[1][1] -= fac;
|
||||
@@ -1677,20 +1677,20 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op)
|
||||
/* updates + finishing warnings */
|
||||
if (failed == groups) {
|
||||
BKE_report(op->reports, RPT_ERROR,
|
||||
"No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
|
||||
"No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else {
|
||||
if (failed) {
|
||||
BKE_report(op->reports, RPT_ERROR,
|
||||
"Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
|
||||
"Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected");
|
||||
}
|
||||
|
||||
/* validate keyframes after editing */
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
/* done at last */
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -1709,7 +1709,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ***************** Jump to Selected Frames Operator *********************** */
|
||||
@@ -1718,7 +1718,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot)
|
||||
static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bAnimContext ac;
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
KeyframeEditData ked;
|
||||
@@ -1731,11 +1731,11 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
|
||||
/* loop over action data, averaging values */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(&ac, ale);
|
||||
|
||||
/* apply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
|
||||
@@ -1749,24 +1749,24 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL);
|
||||
|
||||
/* unapply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|ANIM_UNITCONV_ONLYKEYS);
|
||||
ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS);
|
||||
}
|
||||
|
||||
BLI_freelistN(&anim_data);
|
||||
|
||||
/* set the new current frame and cursor values, based on the average time and value */
|
||||
if (ked.i1) {
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac.sl;
|
||||
Scene *scene= ac.scene;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac.sl;
|
||||
Scene *scene = ac.scene;
|
||||
|
||||
/* take the average values, rounding to the nearest int for the current frame */
|
||||
CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f);
|
||||
SUBFRA= 0.f;
|
||||
sipo->cursorVal= ked.f2 / (float)ked.i1;
|
||||
CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f);
|
||||
SUBFRA = 0.f;
|
||||
sipo->cursorVal = ked.f2 / (float)ked.i1;
|
||||
}
|
||||
|
||||
/* set notifier that things have changed */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1783,7 +1783,7 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ******************** Snap Keyframes Operator *********************** */
|
||||
@@ -1810,26 +1810,26 @@ static void snap_graph_keys(bAnimContext *ac, short mode)
|
||||
KeyframeEditFunc edit_cb;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* get beztriple editing callbacks */
|
||||
edit_cb= ANIM_editkeyframes_snap(mode);
|
||||
edit_cb = ANIM_editkeyframes_snap(mode);
|
||||
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
ked.scene= ac->scene;
|
||||
ked.scene = ac->scene;
|
||||
if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) {
|
||||
ked.list.first= (ac->markers) ? ac->markers->first : NULL;
|
||||
ked.list.last= (ac->markers) ? ac->markers->last : NULL;
|
||||
ked.list.first = (ac->markers) ? ac->markers->first : NULL;
|
||||
ked.list.last = (ac->markers) ? ac->markers->last : NULL;
|
||||
}
|
||||
else if (mode == GRAPHKEYS_SNAP_VALUE) {
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
ked.f1= (sipo) ? sipo->cursorVal : 0.0f;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
|
||||
}
|
||||
|
||||
/* snap keyframes */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* apply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
|
||||
@@ -1861,7 +1861,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get snapping mode */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* snap keyframes */
|
||||
snap_graph_keys(&ac, mode);
|
||||
@@ -1870,7 +1870,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -1888,7 +1888,7 @@ void GRAPH_OT_snap(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", "");
|
||||
@@ -1917,37 +1917,37 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
|
||||
KeyframeEditFunc edit_cb;
|
||||
|
||||
/* get beztriple editing callbacks */
|
||||
edit_cb= ANIM_editkeyframes_mirror(mode);
|
||||
edit_cb = ANIM_editkeyframes_mirror(mode);
|
||||
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
ked.scene= ac->scene;
|
||||
ked.scene = ac->scene;
|
||||
|
||||
/* for 'first selected marker' mode, need to find first selected marker first! */
|
||||
// XXX should this be made into a helper func in the API?
|
||||
if (mode == GRAPHKEYS_MIRROR_MARKER) {
|
||||
TimeMarker *marker= NULL;
|
||||
TimeMarker *marker = NULL;
|
||||
|
||||
/* find first selected marker */
|
||||
marker= ED_markers_get_first_selected(ac->markers);
|
||||
marker = ED_markers_get_first_selected(ac->markers);
|
||||
|
||||
/* store marker's time (if available) */
|
||||
if (marker)
|
||||
ked.f1= (float)marker->frame;
|
||||
ked.f1 = (float)marker->frame;
|
||||
else
|
||||
return;
|
||||
}
|
||||
else if (mode == GRAPHKEYS_MIRROR_VALUE) {
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
ked.f1= (sipo) ? sipo->cursorVal : 0.0f;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
ked.f1 = (sipo) ? sipo->cursorVal : 0.0f;
|
||||
}
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* mirror keyframes */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* apply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS);
|
||||
@@ -1961,7 +1961,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode)
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve);
|
||||
|
||||
/* unapply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS|ANIM_UNITCONV_RESTORE);
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE);
|
||||
}
|
||||
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -1979,7 +1979,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get mirroring mode */
|
||||
mode= RNA_enum_get(op->ptr, "type");
|
||||
mode = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* mirror keyframes */
|
||||
mirror_graph_keys(&ac, mode);
|
||||
@@ -1988,7 +1988,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2006,7 +2006,7 @@ void GRAPH_OT_mirror(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", "");
|
||||
@@ -2026,11 +2026,11 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* smooth keyframes */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
/* For now, we can only smooth by flattening handles AND smoothing curve values.
|
||||
* Perhaps the mode argument could be removed, as that functionality is offerred through
|
||||
* Snap->Flatten Handles anyway.
|
||||
@@ -2043,7 +2043,7 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2060,7 +2060,7 @@ void GRAPH_OT_smooth(wmOperatorType *ot)
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
@@ -2069,19 +2069,19 @@ void GRAPH_OT_smooth(wmOperatorType *ot)
|
||||
/* ******************** Add F-Modifier Operator *********************** */
|
||||
|
||||
/* present a special customised popup menu for this, with some filtering */
|
||||
static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
static int graph_fmodifier_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
||||
{
|
||||
wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1);
|
||||
uiPopupMenu *pup;
|
||||
uiLayout *layout;
|
||||
int i;
|
||||
|
||||
pup= uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE);
|
||||
layout= uiPupMenuLayout(pup);
|
||||
pup = uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE);
|
||||
layout = uiPupMenuLayout(pup);
|
||||
|
||||
/* start from 1 to skip the 'Invalid' modifier type */
|
||||
for (i = 1; i < FMODIFIER_NUM_TYPES; i++) {
|
||||
FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i);
|
||||
FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i);
|
||||
PointerRNA props_ptr;
|
||||
|
||||
/* check if modifier is valid for this context */
|
||||
@@ -2089,11 +2089,11 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU
|
||||
continue;
|
||||
|
||||
/* create operator menu item with relevant properties filled in */
|
||||
props_ptr= uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE,
|
||||
NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
|
||||
/* the only thing that gets set from the menu is the type of F-Modifier to add */
|
||||
props_ptr = uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE,
|
||||
NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS);
|
||||
/* the only thing that gets set from the menu is the type of F-Modifier to add */
|
||||
RNA_enum_set(&props_ptr, "type", i);
|
||||
/* the following properties are just repeats of existing ones... */
|
||||
/* the following properties are just repeats of existing ones... */
|
||||
RNA_boolean_set(&props_ptr, "only_active", RNA_boolean_get(op->ptr, "only_active"));
|
||||
}
|
||||
uiItemS(layout);
|
||||
@@ -2116,23 +2116,23 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* get type of modifier to add */
|
||||
type= RNA_enum_get(op->ptr, "type");
|
||||
type = RNA_enum_get(op->ptr, "type");
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
|
||||
if (RNA_boolean_get(op->ptr, "only_active"))
|
||||
filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled?
|
||||
filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled?
|
||||
else
|
||||
filter |= (ANIMFILTER_SEL|ANIMFILTER_CURVE_VISIBLE);
|
||||
filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* add f-modifier to each curve */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
FModifier *fcm;
|
||||
|
||||
/* add F-Modifier of specified type to active F-Curve, and make it the active one */
|
||||
fcm= add_fmodifier(&fcu->modifiers, type);
|
||||
fcm = add_fmodifier(&fcu->modifiers, type);
|
||||
if (fcm)
|
||||
set_active_fmodifier(&fcu->modifiers, fcm);
|
||||
else {
|
||||
@@ -2165,7 +2165,7 @@ void GRAPH_OT_fmodifier_add(wmOperatorType *ot)
|
||||
ot->poll = graphop_selected_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", "");
|
||||
@@ -2188,14 +2188,14 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op)
|
||||
free_fmodifiers_copybuf();
|
||||
|
||||
/* get the active F-Curve */
|
||||
ale= get_active_fcurve_channel(&ac);
|
||||
ale = get_active_fcurve_channel(&ac);
|
||||
|
||||
/* if this exists, call the copy F-Modifiers API function */
|
||||
if (ale && ale->data) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
// TODO: when 'active' vs 'all' boolean is added, change last param!
|
||||
ok= ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0);
|
||||
ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0);
|
||||
|
||||
/* free temp data now */
|
||||
MEM_freeN(ale);
|
||||
@@ -2222,7 +2222,7 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot)
|
||||
ot->poll = graphop_active_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
//ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one");
|
||||
@@ -2235,19 +2235,19 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
|
||||
bAnimContext ac;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter, ok=0;
|
||||
int filter, ok = 0;
|
||||
|
||||
/* get editor data */
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* paste modifiers */
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
// TODO: do we want to replace existing modifiers? add user pref for that!
|
||||
ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0);
|
||||
@@ -2262,7 +2262,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op)
|
||||
ANIM_editkeyframes_refresh(&ac);
|
||||
|
||||
/* set notifier that keyframes have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -2284,7 +2284,7 @@ void GRAPH_OT_fmodifier_paste(wmOperatorType *ot)
|
||||
ot->poll = graphop_active_fcurve_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -70,14 +70,14 @@ void GRAPH_OT_clickselect(struct wmOperatorType *ot);
|
||||
|
||||
/* defines for left-right select tool */
|
||||
enum {
|
||||
GRAPHKEYS_LRSEL_TEST = 0,
|
||||
GRAPHKEYS_LRSEL_TEST = 0,
|
||||
GRAPHKEYS_LRSEL_LEFT,
|
||||
GRAPHKEYS_LRSEL_RIGHT
|
||||
} eGraphKeys_LeftRightSelect_Mode;
|
||||
|
||||
/* defines for column-select mode */
|
||||
enum {
|
||||
GRAPHKEYS_COLUMNSEL_KEYS = 0,
|
||||
GRAPHKEYS_COLUMNSEL_KEYS = 0,
|
||||
GRAPHKEYS_COLUMNSEL_CFRA,
|
||||
GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN,
|
||||
GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN,
|
||||
@@ -86,7 +86,7 @@ enum {
|
||||
/* ***************************************** */
|
||||
/* graph_edit.c */
|
||||
|
||||
void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected);
|
||||
void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected);
|
||||
|
||||
void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_view_all(struct wmOperatorType *ot);
|
||||
@@ -172,4 +172,3 @@ void graphedit_operatortypes(void);
|
||||
|
||||
|
||||
#endif /* __GRAPH_INTERN_H__ */
|
||||
|
||||
|
||||
@@ -69,22 +69,22 @@
|
||||
/* Set the new frame number */
|
||||
static void graphview_cursor_apply(bContext *C, wmOperator *op)
|
||||
{
|
||||
Main *bmain= CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
||||
|
||||
/* adjust the frame
|
||||
* NOTE: sync this part of the code with ANIM_OT_change_frame
|
||||
*/
|
||||
CFRA= RNA_int_get(op->ptr, "frame");
|
||||
SUBFRA=0.f;
|
||||
CFRA = RNA_int_get(op->ptr, "frame");
|
||||
SUBFRA = 0.f;
|
||||
sound_seek_scene(bmain, scene);
|
||||
|
||||
/* set the cursor value */
|
||||
sipo->cursorVal= RNA_float_get(op->ptr, "value");
|
||||
sipo->cursorVal = RNA_float_get(op->ptr, "value");
|
||||
|
||||
/* send notifiers - notifiers for frame should force an update for both vars ok... */
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene);
|
||||
}
|
||||
|
||||
/* ... */
|
||||
@@ -101,7 +101,7 @@ static int graphview_cursor_exec(bContext *C, wmOperator *op)
|
||||
/* set the operator properties from the initial event */
|
||||
static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
ARegion *ar= CTX_wm_region(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
float viewx, viewy;
|
||||
|
||||
/* abort if not active region (should not really be possible) */
|
||||
@@ -112,8 +112,8 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *even
|
||||
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy);
|
||||
|
||||
/* store the values in the operator properties */
|
||||
/* frame is rounded to the nearest int, since frames are ints */
|
||||
RNA_int_set(op->ptr, "frame", (int)floor(viewx+0.5f));
|
||||
/* frame is rounded to the nearest int, since frames are ints */
|
||||
RNA_int_set(op->ptr, "frame", (int)floor(viewx + 0.5f));
|
||||
RNA_float_set(op->ptr, "value", viewy);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
/* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init
|
||||
* the modal op) doesn't work for some reason
|
||||
*/
|
||||
if (event->val==KM_RELEASE)
|
||||
if (event->val == KM_RELEASE)
|
||||
return OPERATOR_FINISHED;
|
||||
break;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot)
|
||||
ot->poll = ED_operator_graphedit_active;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO;
|
||||
|
||||
/* rna */
|
||||
RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME);
|
||||
@@ -198,7 +198,7 @@ void graphedit_operatortypes(void)
|
||||
WM_operatortype_append(GRAPH_OT_ghost_curves_clear);
|
||||
|
||||
/* keyframes */
|
||||
/* selection */
|
||||
/* selection */
|
||||
WM_operatortype_append(GRAPH_OT_clickselect);
|
||||
WM_operatortype_append(GRAPH_OT_select_all_toggle);
|
||||
WM_operatortype_append(GRAPH_OT_select_border);
|
||||
@@ -208,7 +208,7 @@ void graphedit_operatortypes(void)
|
||||
WM_operatortype_append(GRAPH_OT_select_less);
|
||||
WM_operatortype_append(GRAPH_OT_select_leftright);
|
||||
|
||||
/* editing */
|
||||
/* editing */
|
||||
WM_operatortype_append(GRAPH_OT_snap);
|
||||
WM_operatortype_append(GRAPH_OT_mirror);
|
||||
WM_operatortype_append(GRAPH_OT_frame_jump);
|
||||
@@ -243,7 +243,7 @@ void ED_operatormacros_graph(void)
|
||||
|
||||
ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate",
|
||||
"Make a copy of all selected keyframes and move them",
|
||||
OPTYPE_UNDO|OPTYPE_REGISTER);
|
||||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
if (ot) {
|
||||
WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate");
|
||||
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform");
|
||||
@@ -254,7 +254,7 @@ void ED_operatormacros_graph(void)
|
||||
|
||||
/* ************************** registration - keymaps **********************************/
|
||||
|
||||
static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
{
|
||||
wmKeyMapItem *kmi;
|
||||
|
||||
@@ -262,95 +262,95 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_string_set(kmi->ptr, "data_path", "space_data.show_handles");
|
||||
|
||||
/* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons
|
||||
* This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values
|
||||
*/
|
||||
/* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons
|
||||
* This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values
|
||||
*/
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0);
|
||||
|
||||
|
||||
/* graph_select.c - selection tools */
|
||||
/* click-select */
|
||||
/* click-select */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", TRUE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", TRUE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "column", TRUE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "curves", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "column", FALSE);
|
||||
|
||||
/* select left/right */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", TRUE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
|
||||
RNA_boolean_set(kmi->ptr, "extend", FALSE);
|
||||
RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT);
|
||||
|
||||
/* deselect all */
|
||||
/* deselect all */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "invert", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "invert", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_boolean_set(kmi->ptr, "invert", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "invert", TRUE);
|
||||
|
||||
/* borderselect */
|
||||
/* borderselect */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", FALSE);
|
||||
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", FALSE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "axis_range", TRUE);
|
||||
RNA_boolean_set(kmi->ptr, "include_handles", TRUE);
|
||||
|
||||
/* column select */
|
||||
/* column select */
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN);
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN);
|
||||
|
||||
/* select more/less */
|
||||
/* select more/less */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* select linked */
|
||||
/* select linked */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0);
|
||||
|
||||
|
||||
/* graph_edit.c */
|
||||
/* snap - current frame to selected keys */
|
||||
// TODO: maybe since this is called jump, we're better to have it on <something>-J?
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
/* snap - current frame to selected keys */
|
||||
// TODO: maybe since this is called jump, we're better to have it on <something>-J?
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
|
||||
/* menu + single-step transform */
|
||||
/* menu + single-step transform */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
@@ -358,7 +358,7 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* destructive */
|
||||
/* destructive */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_clean", OKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
@@ -370,27 +370,27 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
|
||||
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
/* insertkey */
|
||||
/* insertkey */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_CLICK, KM_CTRL, 0);
|
||||
|
||||
/* copy/paste */
|
||||
/* copy/paste */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
|
||||
|
||||
/* auto-set range */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
|
||||
/* auto-set range */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
|
||||
|
||||
/* F-Modifiers */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
|
||||
/* F-Modifiers */
|
||||
kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
|
||||
RNA_boolean_set(kmi->ptr, "only_active", FALSE);
|
||||
|
||||
/* animation module */
|
||||
/* channels list
|
||||
* NOTE: these operators were originally for the channels list, but are added here too for convenience...
|
||||
*/
|
||||
/* channels list
|
||||
* NOTE: these operators were originally for the channels list, but are added here too for convenience...
|
||||
*/
|
||||
WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* transform system */
|
||||
@@ -409,7 +409,7 @@ void graphedit_keymap(wmKeyConfig *keyconf)
|
||||
/* keymap for all regions */
|
||||
keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0);
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0);
|
||||
/* extrapolation works on channels, not keys */
|
||||
/* extrapolation works on channels, not keys */
|
||||
WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
/* channels */
|
||||
|
||||
@@ -76,48 +76,48 @@
|
||||
/* Deselects keyframes in the Graph Editor
|
||||
* - This is called by the deselect all operator, as well as other ones!
|
||||
*
|
||||
* - test: check if select or deselect all
|
||||
* - test: check if select or deselect all
|
||||
* - sel: how to select keyframes
|
||||
* 0 = deselect
|
||||
* 1 = select
|
||||
* 2 = invert
|
||||
* - do_channels: whether to affect selection status of channels
|
||||
*/
|
||||
static void deselect_graph_keys (bAnimContext *ac, short test, short sel, short do_channels)
|
||||
static void deselect_graph_keys(bAnimContext *ac, short test, short sel, short do_channels)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
KeyframeEditData ked= {{NULL}};
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
KeyframeEditData ked = {{NULL}};
|
||||
KeyframeEditFunc test_cb, sel_cb;
|
||||
|
||||
/* determine type-based settings */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
|
||||
/* filter data */
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* init BezTriple looping data */
|
||||
test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
|
||||
test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED);
|
||||
|
||||
/* See if we should be selecting or deselecting */
|
||||
if (test) {
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) {
|
||||
sel= SELECT_SUBTRACT;
|
||||
sel = SELECT_SUBTRACT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* convert sel to selectmode, and use that to get editor */
|
||||
sel_cb= ANIM_editkeyframes_select(sel);
|
||||
sel_cb = ANIM_editkeyframes_select(sel);
|
||||
|
||||
/* Now set the flags */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* Keyframes First */
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL);
|
||||
@@ -161,7 +161,7 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op)
|
||||
deselect_graph_keys(&ac, 1, SELECT_ADD, TRUE);
|
||||
|
||||
/* set notifier that things have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props */
|
||||
ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", "");
|
||||
@@ -186,7 +186,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
|
||||
|
||||
/* ******************** Border Select Operator **************************** */
|
||||
/* This operator currently works in one of three ways:
|
||||
* -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION)
|
||||
* -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION)
|
||||
* -> ALT-BKEY - depending on which axis of the region was larger...
|
||||
* -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE)
|
||||
* -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE)
|
||||
@@ -197,16 +197,16 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot)
|
||||
* this, and allow handles to be considered independently too.
|
||||
* Also, for convenience, handles should get same status as keyframe (if it was within bounds).
|
||||
*/
|
||||
static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles)
|
||||
static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter, mapping_flag;
|
||||
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
KeyframeEditData ked;
|
||||
KeyframeEditFunc ok_cb, select_cb;
|
||||
View2D *v2d= &ac->ar->v2d;
|
||||
View2D *v2d = &ac->ar->v2d;
|
||||
rctf rectf;
|
||||
|
||||
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
|
||||
@@ -214,29 +214,29 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
|
||||
UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* get beztriple editing/validation funcs */
|
||||
select_cb= ANIM_editkeyframes_select(selectmode);
|
||||
ok_cb= ANIM_editkeyframes_ok(mode);
|
||||
select_cb = ANIM_editkeyframes_select(selectmode);
|
||||
ok_cb = ANIM_editkeyframes_ok(mode);
|
||||
|
||||
/* init editing data */
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
ked.data= &rectf;
|
||||
ked.data = &rectf;
|
||||
|
||||
/* treat handles separately? */
|
||||
if (incl_handles) {
|
||||
ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES;
|
||||
mapping_flag= 0;
|
||||
mapping_flag = 0;
|
||||
}
|
||||
else
|
||||
mapping_flag= ANIM_UNITCONV_ONLYKEYS;
|
||||
mapping_flag = ANIM_UNITCONV_ONLYKEYS;
|
||||
|
||||
/* loop over data, doing border select */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* apply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag);
|
||||
@@ -245,19 +245,19 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
|
||||
* guess when a callback might use something different
|
||||
*/
|
||||
if (adt)
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles==0);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0);
|
||||
|
||||
/* set horizontal range (if applicable)
|
||||
* NOTE: these values are only used for x-range and y-range but not region
|
||||
* (which uses ked.data, i.e. rectf)
|
||||
* (which uses ked.data, i.e. rectf)
|
||||
*/
|
||||
if (mode != BEZT_OK_VALUERANGE) {
|
||||
ked.f1= rectf.xmin;
|
||||
ked.f2= rectf.xmax;
|
||||
ked.f1 = rectf.xmin;
|
||||
ked.f2 = rectf.xmax;
|
||||
}
|
||||
else {
|
||||
ked.f1= rectf.ymin;
|
||||
ked.f2= rectf.ymax;
|
||||
ked.f1 = rectf.ymin;
|
||||
ked.f2 = rectf.ymax;
|
||||
}
|
||||
|
||||
/* firstly, check if any keyframes will be hit by this */
|
||||
@@ -275,10 +275,10 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
|
||||
|
||||
/* un-apply NLA mapping from all the keyframes */
|
||||
if (adt)
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles==0);
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0);
|
||||
|
||||
/* unapply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|mapping_flag);
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
@@ -291,7 +291,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
rcti rect;
|
||||
short mode=0, selectmode=0;
|
||||
short mode = 0, selectmode = 0;
|
||||
short incl_handles;
|
||||
int extend;
|
||||
|
||||
@@ -300,7 +300,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* clear all selection if not extending selection */
|
||||
extend= RNA_boolean_get(op->ptr, "extend");
|
||||
extend = RNA_boolean_get(op->ptr, "extend");
|
||||
if (!extend)
|
||||
deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, TRUE);
|
||||
|
||||
@@ -308,10 +308,10 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
|
||||
* - 'gesture_mode' from the operator specifies how to select
|
||||
* - 'include_handles' from the operator specifies whether to include handles in the selection
|
||||
*/
|
||||
if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT)
|
||||
selectmode= SELECT_ADD;
|
||||
if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT)
|
||||
selectmode = SELECT_ADD;
|
||||
else
|
||||
selectmode= SELECT_SUBTRACT;
|
||||
selectmode = SELECT_SUBTRACT;
|
||||
|
||||
incl_handles = RNA_boolean_get(op->ptr, "include_handles");
|
||||
|
||||
@@ -329,18 +329,18 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op)
|
||||
* used for tweaking timing when "blocking", while channels is not that useful...
|
||||
*/
|
||||
if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin))
|
||||
mode= BEZT_OK_FRAMERANGE;
|
||||
mode = BEZT_OK_FRAMERANGE;
|
||||
else
|
||||
mode= BEZT_OK_VALUERANGE;
|
||||
mode = BEZT_OK_VALUERANGE;
|
||||
}
|
||||
else
|
||||
mode= BEZT_OK_REGION;
|
||||
mode = BEZT_OK_REGION;
|
||||
|
||||
/* apply borderselect action */
|
||||
borderselect_graphkeys(&ac, rect, mode, selectmode, incl_handles);
|
||||
|
||||
/* send notifier that keyframe selection has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
|
||||
/* rna */
|
||||
WM_operator_properties_gesture_border(ot, TRUE);
|
||||
@@ -392,14 +392,14 @@ static EnumPropertyItem prop_column_select_types[] = {
|
||||
/* Selects all visible keyframes between the specified markers */
|
||||
/* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c
|
||||
* should de-duplicate - campbell */
|
||||
static void markers_selectkeys_between (bAnimContext *ac)
|
||||
static void markers_selectkeys_between(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
KeyframeEditFunc ok_cb, select_cb;
|
||||
KeyframeEditData ked= {{NULL}};
|
||||
KeyframeEditData ked = {{NULL}};
|
||||
float min, max;
|
||||
|
||||
/* get extreme markers */
|
||||
@@ -408,19 +408,19 @@ static void markers_selectkeys_between (bAnimContext *ac)
|
||||
max += 0.5f;
|
||||
|
||||
/* get editing funcs + data */
|
||||
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
select_cb= ANIM_editkeyframes_select(SELECT_ADD);
|
||||
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
|
||||
|
||||
ked.f1= min;
|
||||
ked.f2= max;
|
||||
ked.f1 = min;
|
||||
ked.f2 = max;
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* select keys in-between */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
|
||||
@@ -438,13 +438,13 @@ static void markers_selectkeys_between (bAnimContext *ac)
|
||||
|
||||
|
||||
/* Selects all visible keyframes in the same frames as the specified elements */
|
||||
static void columnselect_graph_keys (bAnimContext *ac, short mode)
|
||||
static void columnselect_graph_keys(bAnimContext *ac, short mode)
|
||||
{
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
Scene *scene= ac->scene;
|
||||
Scene *scene = ac->scene;
|
||||
CfraElem *ce;
|
||||
KeyframeEditFunc select_cb, ok_cb;
|
||||
KeyframeEditData ked;
|
||||
@@ -455,10 +455,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode)
|
||||
/* build list of columns */
|
||||
switch (mode) {
|
||||
case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next)
|
||||
for (ale = anim_data.first; ale; ale = ale->next)
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL);
|
||||
|
||||
BLI_freelistN(&anim_data);
|
||||
@@ -466,10 +466,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode)
|
||||
|
||||
case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */
|
||||
/* make a single CfraElem for storing this */
|
||||
ce= MEM_callocN(sizeof(CfraElem), "cfraElem");
|
||||
ce = MEM_callocN(sizeof(CfraElem), "cfraElem");
|
||||
BLI_addtail(&ked.list, ce);
|
||||
|
||||
ce->cfra= (float)CFRA;
|
||||
ce->cfra = (float)CFRA;
|
||||
break;
|
||||
|
||||
case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */
|
||||
@@ -481,24 +481,24 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode)
|
||||
}
|
||||
|
||||
/* set up BezTriple edit callbacks */
|
||||
select_cb= ANIM_editkeyframes_select(SELECT_ADD);
|
||||
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME);
|
||||
select_cb = ANIM_editkeyframes_select(SELECT_ADD);
|
||||
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
|
||||
|
||||
/* loop through all of the keys and select additional keyframes
|
||||
* based on the keys found to be selected above
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* loop over cfraelems (stored in the KeyframeEditData->list)
|
||||
* - we need to do this here, as we can apply fewer NLA-mapping conversions
|
||||
*/
|
||||
for (ce= ked.list.first; ce; ce= ce->next) {
|
||||
for (ce = ked.list.first; ce; ce = ce->next) {
|
||||
/* set frame for validation callback to refer to */
|
||||
ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
|
||||
ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP);
|
||||
|
||||
/* select elements with frame number matching cfraelem */
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
|
||||
@@ -522,7 +522,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* action to take depends on the mode */
|
||||
mode= RNA_enum_get(op->ptr, "mode");
|
||||
mode = RNA_enum_get(op->ptr, "mode");
|
||||
|
||||
if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN)
|
||||
markers_selectkeys_between(&ac);
|
||||
@@ -530,7 +530,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op)
|
||||
columnselect_graph_keys(&ac, mode);
|
||||
|
||||
/* set notifier that keyframe selection has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -547,7 +547,7 @@ void GRAPH_OT_select_column(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", "");
|
||||
@@ -555,11 +555,11 @@ void GRAPH_OT_select_column(wmOperatorType *ot)
|
||||
|
||||
/* ******************** Select Linked Operator *********************** */
|
||||
|
||||
static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
@@ -571,11 +571,11 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
/* loop through all of the keys and select additional keyframes based on these */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* check if anything selected? */
|
||||
if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) {
|
||||
@@ -588,7 +588,7 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
BLI_freelistN(&anim_data);
|
||||
|
||||
/* set notifier that keyframe selection has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -605,15 +605,15 @@ void GRAPH_OT_select_linked(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
}
|
||||
|
||||
/* ******************** Select More/Less Operators *********************** */
|
||||
|
||||
/* Common code to perform selection */
|
||||
static void select_moreless_graph_keys (bAnimContext *ac, short mode)
|
||||
static void select_moreless_graph_keys(bAnimContext *ac, short mode)
|
||||
{
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
@@ -622,22 +622,22 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode)
|
||||
|
||||
|
||||
/* init selmap building data */
|
||||
build_cb= ANIM_editkeyframes_buildselmap(mode);
|
||||
build_cb = ANIM_editkeyframes_buildselmap(mode);
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
|
||||
/* loop through all of the keys and select additional keyframes based on these */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
|
||||
/* only continue if F-Curve has keyframes */
|
||||
if (fcu->bezt == NULL)
|
||||
continue;
|
||||
|
||||
/* build up map of whether F-Curve's keyframes should be selected or not */
|
||||
ked.data= MEM_callocN(fcu->totvert, "selmap graphEdit");
|
||||
ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit");
|
||||
ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL);
|
||||
|
||||
/* based on this map, adjust the selection status of the keyframes */
|
||||
@@ -645,7 +645,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode)
|
||||
|
||||
/* free the selmap used here */
|
||||
MEM_freeN(ked.data);
|
||||
ked.data= NULL;
|
||||
ked.data = NULL;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
@@ -654,7 +654,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode)
|
||||
|
||||
/* ----------------- */
|
||||
|
||||
static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
@@ -666,7 +666,7 @@ static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
select_moreless_graph_keys(&ac, SELMAP_MORE);
|
||||
|
||||
/* set notifier that keyframe selection has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -683,12 +683,12 @@ void GRAPH_OT_select_more(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
}
|
||||
|
||||
/* ----------------- */
|
||||
|
||||
static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
@@ -700,7 +700,7 @@ static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op))
|
||||
select_moreless_graph_keys(&ac, SELMAP_LESS);
|
||||
|
||||
/* set notifier that keyframe selection has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
@@ -717,7 +717,7 @@ void GRAPH_OT_select_less(wmOperatorType *ot)
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/;
|
||||
}
|
||||
|
||||
/* ******************** Select Left/Right Operator ************************* */
|
||||
@@ -733,19 +733,19 @@ static EnumPropertyItem prop_graphkeys_leftright_select_types[] = {
|
||||
|
||||
/* --------------------------------- */
|
||||
|
||||
static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode)
|
||||
static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
KeyframeEditFunc ok_cb, select_cb;
|
||||
KeyframeEditData ked= {{NULL}};
|
||||
Scene *scene= ac->scene;
|
||||
KeyframeEditData ked = {{NULL}};
|
||||
Scene *scene = ac->scene;
|
||||
|
||||
/* if select mode is replace, deselect all keyframes (and channels) first */
|
||||
if (select_mode==SELECT_REPLACE) {
|
||||
select_mode= SELECT_ADD;
|
||||
if (select_mode == SELECT_REPLACE) {
|
||||
select_mode = SELECT_ADD;
|
||||
|
||||
/* - deselect all other keyframes, so that just the newly selected remain
|
||||
* - channels aren't deselected, since we don't re-select any as a consequence
|
||||
@@ -754,8 +754,8 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short
|
||||
}
|
||||
|
||||
/* set callbacks and editing data */
|
||||
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
select_cb= ANIM_editkeyframes_select(select_mode);
|
||||
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE);
|
||||
select_cb = ANIM_editkeyframes_select(select_mode);
|
||||
|
||||
if (leftright == GRAPHKEYS_LRSEL_LEFT) {
|
||||
ked.f1 = MINAFRAMEF;
|
||||
@@ -767,12 +767,12 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short
|
||||
}
|
||||
|
||||
/* filter data */
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* select keys */
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
if (adt) {
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
|
||||
@@ -789,7 +789,7 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short
|
||||
|
||||
/* ----------------- */
|
||||
|
||||
static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op)
|
||||
static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
short leftright = RNA_enum_get(op->ptr, "mode");
|
||||
@@ -801,9 +801,9 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op)
|
||||
|
||||
/* select mode is either replace (deselect all, then add) or add/extend */
|
||||
if (RNA_boolean_get(op->ptr, "extend"))
|
||||
selectmode= SELECT_INVERT;
|
||||
selectmode = SELECT_INVERT;
|
||||
else
|
||||
selectmode= SELECT_REPLACE;
|
||||
selectmode = SELECT_REPLACE;
|
||||
|
||||
/* if "test" mode is set, we don't have any info to set this with */
|
||||
if (leftright == GRAPHKEYS_LRSEL_TEST)
|
||||
@@ -813,12 +813,12 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op)
|
||||
graphkeys_select_leftright(&ac, leftright, selectmode);
|
||||
|
||||
/* set notifier that keyframe selection (and channels too) have changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event)
|
||||
static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
bAnimContext ac;
|
||||
short leftright = RNA_enum_get(op->ptr, "mode");
|
||||
@@ -829,9 +829,9 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve
|
||||
|
||||
/* handle mode-based testing */
|
||||
if (leftright == GRAPHKEYS_LRSEL_TEST) {
|
||||
Scene *scene= ac.scene;
|
||||
ARegion *ar= ac.ar;
|
||||
View2D *v2d= &ar->v2d;
|
||||
Scene *scene = ac.scene;
|
||||
ARegion *ar = ac.ar;
|
||||
View2D *v2d = &ar->v2d;
|
||||
float x;
|
||||
|
||||
/* determine which side of the current frame mouse is on */
|
||||
@@ -854,12 +854,12 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot)
|
||||
ot->description = "Select keyframes to the left or the right of the current frame";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= graphkeys_select_leftright_invoke;
|
||||
ot->invoke = graphkeys_select_leftright_invoke;
|
||||
ot->exec = graphkeys_select_leftright_exec;
|
||||
ot->poll = graphop_visible_keyframes_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* id-props */
|
||||
ot->prop = RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", "");
|
||||
@@ -880,26 +880,26 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot)
|
||||
typedef struct tNearestVertInfo {
|
||||
struct tNearestVertInfo *next, *prev;
|
||||
|
||||
FCurve *fcu; /* F-Curve that keyframe comes from */
|
||||
FCurve *fcu; /* F-Curve that keyframe comes from */
|
||||
|
||||
BezTriple *bezt; /* keyframe to consider */
|
||||
FPoint *fpt; /* sample point to consider */
|
||||
BezTriple *bezt; /* keyframe to consider */
|
||||
FPoint *fpt; /* sample point to consider */
|
||||
|
||||
short hpoint; /* the handle index that we hit (eHandleIndex) */
|
||||
short sel; /* whether the handle is selected or not */
|
||||
int dist; /* distance from mouse to vert */
|
||||
short hpoint; /* the handle index that we hit (eHandleIndex) */
|
||||
short sel; /* whether the handle is selected or not */
|
||||
int dist; /* distance from mouse to vert */
|
||||
} tNearestVertInfo;
|
||||
|
||||
/* Tags for the type of graph vert that we have */
|
||||
typedef enum eGraphVertIndex {
|
||||
NEAREST_HANDLE_LEFT = -1,
|
||||
NEAREST_HANDLE_LEFT = -1,
|
||||
NEAREST_HANDLE_KEY,
|
||||
NEAREST_HANDLE_RIGHT
|
||||
} eGraphVertIndex;
|
||||
|
||||
/* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */
|
||||
// TODO: perhaps this should depend a bit on the size that the user set the vertices to be?
|
||||
#define GVERTSEL_TOL 10
|
||||
#define GVERTSEL_TOL 10
|
||||
|
||||
/* ....... */
|
||||
|
||||
@@ -908,13 +908,13 @@ typedef enum eGraphVertIndex {
|
||||
static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt)
|
||||
{
|
||||
if (sipo->flag & SIPO_NOHANDLES) return 0;
|
||||
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt)==0) return 0;
|
||||
if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt) == 0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* check if the given vertex is within bounds or not */
|
||||
// TODO: should we return if we hit something?
|
||||
static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2])
|
||||
static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2])
|
||||
{
|
||||
/* Keyframes or Samples? */
|
||||
if (bezt) {
|
||||
@@ -922,16 +922,16 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f
|
||||
|
||||
/* convert from data-space to screen coordinates
|
||||
* NOTE: hpoint+1 gives us 0,1,2 respectively for each handle,
|
||||
* needed to access the relevant vertex coordinates in the 3x3
|
||||
* 'vec' matrix
|
||||
* needed to access the relevant vertex coordinates in the 3x3
|
||||
* 'vec' matrix
|
||||
*/
|
||||
UI_view2d_view_to_region(v2d, bezt->vec[hpoint+1][0], bezt->vec[hpoint+1][1], &screen_co[0], &screen_co[1]);
|
||||
UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]);
|
||||
|
||||
/* check if distance from mouse cursor to vert in screen space is within tolerance */
|
||||
// XXX: inlined distance calculation, since we cannot do this on ints using the math lib...
|
||||
// XXX: inlined distance calculation, since we cannot do this on ints using the math lib...
|
||||
//dist = len_v2v2(mval, screen_co);
|
||||
dist = sqrt((mval[0] - screen_co[0])*(mval[0] - screen_co[0]) +
|
||||
(mval[1] - screen_co[1])*(mval[1] - screen_co[1]));
|
||||
dist = sqrt((mval[0] - screen_co[0]) * (mval[0] - screen_co[0]) +
|
||||
(mval[1] - screen_co[1]) * (mval[1] - screen_co[1]));
|
||||
|
||||
if (dist <= GVERTSEL_TOL) {
|
||||
tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last;
|
||||
@@ -941,7 +941,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f
|
||||
if ((nvi) && (nvi->fcu == fcu)) {
|
||||
/* replace if we are closer, or if equal and that one wasn't selected but we are... */
|
||||
if ( (nvi->dist > dist) || ((nvi->sel == 0) && BEZSELECTED(bezt)) )
|
||||
replace= 1;
|
||||
replace = 1;
|
||||
}
|
||||
/* add new if not replacing... */
|
||||
if (replace == 0)
|
||||
@@ -953,7 +953,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f
|
||||
nvi->hpoint = hpoint;
|
||||
nvi->dist = dist;
|
||||
|
||||
nvi->sel= BEZSELECTED(bezt); // XXX... should this use the individual verts instead?
|
||||
nvi->sel = BEZSELECTED(bezt); // XXX... should this use the individual verts instead?
|
||||
|
||||
/* add to list of matches if appropriate... */
|
||||
if (replace == 0)
|
||||
@@ -966,27 +966,27 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f
|
||||
}
|
||||
|
||||
/* helper for find_nearest_fcurve_vert() - build the list of nearest matches */
|
||||
static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ListBase *matches)
|
||||
static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
View2D *v2d= &ac->ar->v2d;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
View2D *v2d = &ac->ar->v2d;
|
||||
|
||||
/* get curves to search through
|
||||
* - if the option to only show keyframes that belong to selected F-Curves is enabled,
|
||||
* include the 'only selected' flag...
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code...
|
||||
filter |= ANIMFILTER_SEL;
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->key_data;
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* apply unit corrections */
|
||||
ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0);
|
||||
@@ -996,17 +996,17 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2],
|
||||
ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
|
||||
|
||||
if (fcu->bezt) {
|
||||
BezTriple *bezt1=fcu->bezt, *prevbezt=NULL;
|
||||
BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL;
|
||||
int i;
|
||||
|
||||
for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) {
|
||||
for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) {
|
||||
/* keyframe */
|
||||
nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval);
|
||||
|
||||
/* handles - only do them if they're visible */
|
||||
if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) {
|
||||
/* first handle only visible if previous segment had handles */
|
||||
if ((!prevbezt && (bezt1->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) {
|
||||
if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) {
|
||||
nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval);
|
||||
}
|
||||
|
||||
@@ -1035,7 +1035,7 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2],
|
||||
}
|
||||
|
||||
/* helper for find_nearest_fcurve_vert() - get the best match to use */
|
||||
static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches)
|
||||
static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
|
||||
{
|
||||
tNearestVertInfo *nvi = NULL;
|
||||
short found = 0;
|
||||
@@ -1047,7 +1047,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches)
|
||||
/* if list only has 1 item, remove it from the list and return */
|
||||
if (matches->first == matches->last) {
|
||||
/* need to remove from the list, otherwise it gets freed and then we can't return it */
|
||||
nvi= matches->first;
|
||||
nvi = matches->first;
|
||||
BLI_remlink(matches, nvi);
|
||||
|
||||
return nvi;
|
||||
@@ -1066,7 +1066,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches)
|
||||
else {
|
||||
/* if vert is selected, we've got what we want... */
|
||||
if (nvi->sel)
|
||||
found= 1;
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1081,7 +1081,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches)
|
||||
/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates)
|
||||
* NOTE: the match info found must still be freed
|
||||
*/
|
||||
static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int mval[2])
|
||||
static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2])
|
||||
{
|
||||
ListBase matches = {NULL, NULL};
|
||||
tNearestVertInfo *nvi;
|
||||
@@ -1090,7 +1090,7 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m
|
||||
get_nearest_fcurve_verts_list(ac, mval, &matches);
|
||||
|
||||
/* step 2: find the best vert */
|
||||
nvi= get_best_nearest_fcurve_vert(&matches);
|
||||
nvi = get_best_nearest_fcurve_vert(&matches);
|
||||
|
||||
BLI_freelistN(&matches);
|
||||
|
||||
@@ -1101,11 +1101,11 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m
|
||||
/* ------------------- */
|
||||
|
||||
/* option 1) select keyframe directly under mouse */
|
||||
static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_mode, short curves_only)
|
||||
static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_mode, short curves_only)
|
||||
{
|
||||
SpaceIpo *sipo= (SpaceIpo *)ac->sl;
|
||||
SpaceIpo *sipo = (SpaceIpo *)ac->sl;
|
||||
tNearestVertInfo *nvi;
|
||||
BezTriple *bezt= NULL;
|
||||
BezTriple *bezt = NULL;
|
||||
|
||||
/* find the beztriple that we're selecting, and the handle that was clicked on */
|
||||
nvi = find_nearest_fcurve_vert(ac, mval);
|
||||
@@ -1117,7 +1117,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_
|
||||
/* deselect all other curves? */
|
||||
if (select_mode == SELECT_REPLACE) {
|
||||
/* reset selection mode */
|
||||
select_mode= SELECT_ADD;
|
||||
select_mode = SELECT_ADD;
|
||||
|
||||
/* deselect all other keyframes (+ F-Curves too) */
|
||||
deselect_graph_keys(ac, 0, SELECT_SUBTRACT, TRUE);
|
||||
@@ -1132,10 +1132,10 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_
|
||||
|
||||
/* if points can be selected on this F-Curve */
|
||||
// TODO: what about those with no keyframes?
|
||||
if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED)==0)) {
|
||||
if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) {
|
||||
/* only if there's keyframe */
|
||||
if (nvi->bezt) {
|
||||
bezt= nvi->bezt; /* used to check bezt seletion is set */
|
||||
bezt = nvi->bezt; /* used to check bezt seletion is set */
|
||||
/* depends on selection mode */
|
||||
if (select_mode == SELECT_INVERT) {
|
||||
/* keyframe - invert select of all */
|
||||
@@ -1182,7 +1182,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
|
||||
/* set up BezTriple edit callbacks */
|
||||
select_cb= ANIM_editkeyframes_select(select_mode);
|
||||
select_cb = ANIM_editkeyframes_select(select_mode);
|
||||
|
||||
/* select all keyframes */
|
||||
ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL);
|
||||
@@ -1212,7 +1212,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_
|
||||
/* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */
|
||||
/* needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY) otherwise the active flag won't be set [#26452] */
|
||||
if (nvi->fcu->flag & FCURVE_SELECTED) {
|
||||
int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, ANIMTYPE_FCURVE);
|
||||
}
|
||||
|
||||
@@ -1224,9 +1224,9 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_
|
||||
/* (see graphkeys_select_leftright) */
|
||||
|
||||
/* Option 3) Selects all visible keyframes in the same frame as the mouse click */
|
||||
static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short select_mode)
|
||||
static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short select_mode)
|
||||
{
|
||||
ListBase anim_data= {NULL, NULL};
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
bAnimListElem *ale;
|
||||
int filter;
|
||||
|
||||
@@ -1245,14 +1245,14 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short
|
||||
/* get frame number on which elements should be selected */
|
||||
// TODO: should we restrict to integer frames only?
|
||||
if (nvi->bezt)
|
||||
selx= nvi->bezt->vec[1][0];
|
||||
selx = nvi->bezt->vec[1][0];
|
||||
else if (nvi->fpt)
|
||||
selx= nvi->fpt->vec[0];
|
||||
selx = nvi->fpt->vec[0];
|
||||
|
||||
/* if select mode is replace, deselect all keyframes first */
|
||||
if (select_mode==SELECT_REPLACE) {
|
||||
if (select_mode == SELECT_REPLACE) {
|
||||
/* reset selection mode to add to selection */
|
||||
select_mode= SELECT_ADD;
|
||||
select_mode = SELECT_ADD;
|
||||
|
||||
/* - deselect all other keyframes, so that just the newly selected remain
|
||||
* - channels aren't deselected, since we don't re-select any as a consequence
|
||||
@@ -1264,23 +1264,23 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short
|
||||
memset(&ked, 0, sizeof(KeyframeEditData));
|
||||
|
||||
/* set up BezTriple edit callbacks */
|
||||
select_cb= ANIM_editkeyframes_select(select_mode);
|
||||
ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME);
|
||||
select_cb = ANIM_editkeyframes_select(select_mode);
|
||||
ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME);
|
||||
|
||||
/* loop through all of the keys and select additional keyframes
|
||||
* based on the keys found to be selected above
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
for (ale= anim_data.first; ale; ale= ale->next) {
|
||||
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
|
||||
|
||||
/* set frame for validation callback to refer to */
|
||||
if (adt)
|
||||
ked.f1= BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
|
||||
ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP);
|
||||
else
|
||||
ked.f1= selx;
|
||||
ked.f1 = selx;
|
||||
|
||||
/* select elements with frame number matching cfra */
|
||||
ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL);
|
||||
@@ -1306,9 +1306,9 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
|
||||
|
||||
/* select mode is either replace (deselect all, then add) or add/extend */
|
||||
if (RNA_boolean_get(op->ptr, "extend"))
|
||||
selectmode= SELECT_INVERT;
|
||||
selectmode = SELECT_INVERT;
|
||||
else
|
||||
selectmode= SELECT_REPLACE;
|
||||
selectmode = SELECT_REPLACE;
|
||||
|
||||
/* figure out action to take */
|
||||
if (RNA_boolean_get(op->ptr, "column")) {
|
||||
@@ -1325,10 +1325,10 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
|
||||
}
|
||||
|
||||
/* set notifier that keyframe selection (and also channel selection in some cases) has changed */
|
||||
WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL);
|
||||
|
||||
/* for tweak grab to work */
|
||||
return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
|
||||
return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
void GRAPH_OT_clickselect(wmOperatorType *ot)
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "ED_anim_api.h"
|
||||
|
||||
|
||||
#include "graph_intern.h" // own include
|
||||
#include "graph_intern.h" // own include
|
||||
|
||||
/* ************************************************************** */
|
||||
/* Active F-Curve */
|
||||
@@ -65,17 +65,17 @@
|
||||
*
|
||||
* NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
|
||||
*/
|
||||
bAnimListElem *get_active_fcurve_channel (bAnimContext *ac)
|
||||
bAnimListElem *get_active_fcurve_channel(bAnimContext *ac)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE);
|
||||
int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE);
|
||||
size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
|
||||
|
||||
/* We take the first F-Curve only, since some other ones may have had 'active' flag set
|
||||
* if they were from linked data.
|
||||
*/
|
||||
if (items) {
|
||||
bAnimListElem *ale= (bAnimListElem *)anim_data.first;
|
||||
bAnimListElem *ale = (bAnimListElem *)anim_data.first;
|
||||
|
||||
/* remove first item from list, then free the rest of the list and return the stored one */
|
||||
BLI_remlink(&anim_data, ale);
|
||||
@@ -97,7 +97,7 @@ int graphop_visible_keyframes_poll(bContext *C)
|
||||
bAnimContext ac;
|
||||
bAnimListElem *ale;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
size_t items;
|
||||
int filter;
|
||||
short found = 0;
|
||||
@@ -114,13 +114,13 @@ int graphop_visible_keyframes_poll(bContext *C)
|
||||
/* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable
|
||||
* stopping on the first successful match
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE);
|
||||
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
if (items == 0)
|
||||
return 0;
|
||||
|
||||
for (ale = anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
/* visible curves for selection must fulfill the following criteria:
|
||||
* - it has bezier keyframes
|
||||
@@ -146,7 +146,7 @@ int graphop_editable_keyframes_poll(bContext *C)
|
||||
bAnimContext ac;
|
||||
bAnimListElem *ale;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
size_t items;
|
||||
int filter;
|
||||
short found = 0;
|
||||
@@ -163,13 +163,13 @@ int graphop_editable_keyframes_poll(bContext *C)
|
||||
/* loop over the editable F-Curves, and see if they're suitable
|
||||
* stopping on the first successful match
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
|
||||
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
if (items == 0)
|
||||
return 0;
|
||||
|
||||
for (ale = anim_data.first; ale; ale= ale->next) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
for (ale = anim_data.first; ale; ale = ale->next) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
/* editable curves must fulfill the following criteria:
|
||||
* - it has bezier keyframes
|
||||
@@ -195,8 +195,8 @@ int graphop_active_fcurve_poll(bContext *C)
|
||||
{
|
||||
bAnimContext ac;
|
||||
bAnimListElem *ale;
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
short has_fcurve= 0;
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
short has_fcurve = 0;
|
||||
|
||||
/* firstly, check if in Graph Editor */
|
||||
// TODO: also check for region?
|
||||
@@ -208,15 +208,15 @@ int graphop_active_fcurve_poll(bContext *C)
|
||||
return 0;
|
||||
|
||||
/* try to get the Active F-Curve */
|
||||
ale= get_active_fcurve_channel(&ac);
|
||||
ale = get_active_fcurve_channel(&ac);
|
||||
if (ale == NULL)
|
||||
return 0;
|
||||
|
||||
/* free temp data... */
|
||||
has_fcurve= ((ale->data) && (ale->type == ANIMTYPE_FCURVE));
|
||||
has_fcurve = ((ale->data) && (ale->type == ANIMTYPE_FCURVE));
|
||||
if (has_fcurve) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
has_fcurve= (fcu->flag & FCURVE_VISIBLE)!=0;
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0;
|
||||
}
|
||||
|
||||
MEM_freeN(ale);
|
||||
@@ -230,7 +230,7 @@ int graphop_selected_fcurve_poll(bContext *C)
|
||||
{
|
||||
bAnimContext ac;
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
ScrArea *sa= CTX_wm_area(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
size_t items;
|
||||
int filter;
|
||||
|
||||
@@ -246,7 +246,7 @@ int graphop_selected_fcurve_poll(bContext *C)
|
||||
/* get the editable + selected F-Curves, and as long as we got some, we can return
|
||||
* NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
|
||||
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
if (items == 0)
|
||||
return 0;
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
#include "UI_resources.h"
|
||||
#include "UI_view2d.h"
|
||||
|
||||
#include "graph_intern.h" // own include
|
||||
#include "graph_intern.h" // own include
|
||||
|
||||
/* ******************** manage regions ********************* */
|
||||
|
||||
@@ -69,20 +69,20 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
|
||||
{
|
||||
ARegion *ar, *arnew;
|
||||
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_UI);
|
||||
if (ar) return ar;
|
||||
|
||||
/* add subdiv level; after main */
|
||||
ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW);
|
||||
|
||||
/* is error! */
|
||||
if (ar==NULL) return NULL;
|
||||
if (ar == NULL) return NULL;
|
||||
|
||||
arnew= MEM_callocN(sizeof(ARegion), "buttons for graph");
|
||||
arnew = MEM_callocN(sizeof(ARegion), "buttons for graph");
|
||||
|
||||
BLI_insertlinkafter(&sa->regionbase, ar, arnew);
|
||||
arnew->regiontype= RGN_TYPE_UI;
|
||||
arnew->alignment= RGN_ALIGN_RIGHT;
|
||||
arnew->regiontype = RGN_TYPE_UI;
|
||||
arnew->alignment = RGN_ALIGN_RIGHT;
|
||||
|
||||
arnew->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
@@ -94,71 +94,71 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
|
||||
|
||||
static SpaceLink *graph_new(const bContext *C)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ARegion *ar;
|
||||
SpaceIpo *sipo;
|
||||
|
||||
/* Graph Editor - general stuff */
|
||||
sipo= MEM_callocN(sizeof(SpaceIpo), "init graphedit");
|
||||
sipo->spacetype= SPACE_IPO;
|
||||
sipo = MEM_callocN(sizeof(SpaceIpo), "init graphedit");
|
||||
sipo->spacetype = SPACE_IPO;
|
||||
|
||||
sipo->autosnap= SACTSNAP_FRAME;
|
||||
sipo->autosnap = SACTSNAP_FRAME;
|
||||
|
||||
/* allocate DopeSheet data for Graph Editor */
|
||||
sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
sipo->ads->source= (ID *)scene;
|
||||
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
sipo->ads->source = (ID *)scene;
|
||||
|
||||
/* settings for making it easier by default to just see what you're interested in tweaking */
|
||||
sipo->ads->filterflag |= ADS_FILTER_ONLYSEL;
|
||||
sipo->flag |= SIPO_SELVHANDLESONLY;
|
||||
|
||||
/* header */
|
||||
ar= MEM_callocN(sizeof(ARegion), "header for graphedit");
|
||||
ar = MEM_callocN(sizeof(ARegion), "header for graphedit");
|
||||
|
||||
BLI_addtail(&sipo->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_HEADER;
|
||||
ar->alignment= RGN_ALIGN_BOTTOM;
|
||||
ar->regiontype = RGN_TYPE_HEADER;
|
||||
ar->alignment = RGN_ALIGN_BOTTOM;
|
||||
|
||||
/* channels */
|
||||
ar= MEM_callocN(sizeof(ARegion), "channels area for graphedit");
|
||||
ar = MEM_callocN(sizeof(ARegion), "channels area for graphedit");
|
||||
|
||||
BLI_addtail(&sipo->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_CHANNELS;
|
||||
ar->alignment= RGN_ALIGN_LEFT;
|
||||
ar->regiontype = RGN_TYPE_CHANNELS;
|
||||
ar->alignment = RGN_ALIGN_LEFT;
|
||||
|
||||
ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM);
|
||||
ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM);
|
||||
|
||||
/* ui buttons */
|
||||
ar= MEM_callocN(sizeof(ARegion), "buttons area for graphedit");
|
||||
ar = MEM_callocN(sizeof(ARegion), "buttons area for graphedit");
|
||||
|
||||
BLI_addtail(&sipo->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_UI;
|
||||
ar->alignment= RGN_ALIGN_RIGHT;
|
||||
ar->regiontype = RGN_TYPE_UI;
|
||||
ar->alignment = RGN_ALIGN_RIGHT;
|
||||
ar->flag = RGN_FLAG_HIDDEN;
|
||||
|
||||
/* main area */
|
||||
ar= MEM_callocN(sizeof(ARegion), "main area for graphedit");
|
||||
ar = MEM_callocN(sizeof(ARegion), "main area for graphedit");
|
||||
|
||||
BLI_addtail(&sipo->regionbase, ar);
|
||||
ar->regiontype= RGN_TYPE_WINDOW;
|
||||
ar->regiontype = RGN_TYPE_WINDOW;
|
||||
|
||||
ar->v2d.tot.xmin = 0.0f;
|
||||
ar->v2d.tot.ymin = (float)scene->r.sfra - 10.0f;
|
||||
ar->v2d.tot.xmax = (float)scene->r.efra;
|
||||
ar->v2d.tot.ymax = 10.0f;
|
||||
|
||||
ar->v2d.cur= ar->v2d.tot;
|
||||
ar->v2d.cur = ar->v2d.tot;
|
||||
|
||||
ar->v2d.min[0]= FLT_MIN;
|
||||
ar->v2d.min[1]= FLT_MIN;
|
||||
ar->v2d.min[0] = FLT_MIN;
|
||||
ar->v2d.min[1] = FLT_MIN;
|
||||
|
||||
ar->v2d.max[0]= MAXFRAMEF;
|
||||
ar->v2d.max[1]= FLT_MAX;
|
||||
ar->v2d.max[0] = MAXFRAMEF;
|
||||
ar->v2d.max[1] = FLT_MAX;
|
||||
|
||||
ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL);
|
||||
ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL);
|
||||
ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL);
|
||||
|
||||
ar->v2d.keeptot= 0;
|
||||
ar->v2d.keeptot = 0;
|
||||
|
||||
return (SpaceLink *)sipo;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ static SpaceLink *graph_new(const bContext *C)
|
||||
/* not spacelink itself */
|
||||
static void graph_free(SpaceLink *sl)
|
||||
{
|
||||
SpaceIpo *si= (SpaceIpo *)sl;
|
||||
SpaceIpo *si = (SpaceIpo *)sl;
|
||||
|
||||
if (si->ads) {
|
||||
BLI_freelistN(&si->ads->chanbase);
|
||||
@@ -181,12 +181,12 @@ static void graph_free(SpaceLink *sl)
|
||||
/* spacetype; init callback */
|
||||
static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
|
||||
{
|
||||
SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first;
|
||||
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
|
||||
|
||||
/* init dopesheet data if non-existant (i.e. for old files) */
|
||||
if (sipo->ads == NULL) {
|
||||
sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
sipo->ads->source= (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now...
|
||||
sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet");
|
||||
sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now...
|
||||
}
|
||||
|
||||
ED_area_tag_refresh(sa);
|
||||
@@ -194,11 +194,11 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
|
||||
|
||||
static SpaceLink *graph_duplicate(SpaceLink *sl)
|
||||
{
|
||||
SpaceIpo *sipon= MEM_dupallocN(sl);
|
||||
SpaceIpo *sipon = MEM_dupallocN(sl);
|
||||
|
||||
/* clear or remove stuff from old */
|
||||
BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves);
|
||||
sipon->ads= MEM_dupallocN(sipon->ads);
|
||||
sipon->ads = MEM_dupallocN(sipon->ads);
|
||||
|
||||
return (SpaceLink *)sipon;
|
||||
}
|
||||
@@ -220,13 +220,13 @@ static void graph_main_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
static void graph_main_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
/* draw entirely, view changes should be handled here */
|
||||
SpaceIpo *sipo= CTX_wm_space_graph(C);
|
||||
SpaceIpo *sipo = CTX_wm_space_graph(C);
|
||||
bAnimContext ac;
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DGrid *grid;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
short unitx=0, unity=V2D_UNIT_VALUES, flag=0;
|
||||
short unitx = 0, unity = V2D_UNIT_VALUES, flag = 0;
|
||||
|
||||
/* clear and setup matrix */
|
||||
UI_GetThemeColor3fv(TH_BACK, col);
|
||||
@@ -236,8 +236,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
/* grid */
|
||||
unitx= (sipo->flag & SIPO_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
|
||||
grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
|
||||
unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE;
|
||||
grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy);
|
||||
UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
|
||||
|
||||
/* draw data */
|
||||
@@ -260,29 +260,29 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_grid_free(grid);
|
||||
|
||||
/* horizontal component of value-cursor (value line before the current frame line) */
|
||||
if ((sipo->flag & SIPO_NODRAWCURSOR)==0) {
|
||||
if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) {
|
||||
float vec[2];
|
||||
|
||||
/* Draw a green line to indicate the cursor value */
|
||||
vec[1]= sipo->cursorVal;
|
||||
vec[1] = sipo->cursorVal;
|
||||
|
||||
UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50);
|
||||
glLineWidth(2.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_LINE_STRIP);
|
||||
vec[0]= v2d->cur.xmin;
|
||||
glVertex2fv(vec);
|
||||
vec[0] = v2d->cur.xmin;
|
||||
glVertex2fv(vec);
|
||||
|
||||
vec[0]= v2d->cur.xmax;
|
||||
glVertex2fv(vec);
|
||||
vec[0] = v2d->cur.xmax;
|
||||
glVertex2fv(vec);
|
||||
glEnd(); // GL_LINE_STRIP
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
/* current frame */
|
||||
if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if ((sipo->flag & SIPO_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS;
|
||||
if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX;
|
||||
ANIM_draw_cfra(C, v2d, flag);
|
||||
|
||||
/* markers */
|
||||
@@ -297,8 +297,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
// FIXME: args for scrollers depend on the type of data being shown...
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
|
||||
// FIXME: args for scrollers depend on the type of data being shown...
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
@@ -319,7 +319,7 @@ static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar)
|
||||
static void graph_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
{
|
||||
bAnimContext ac;
|
||||
View2D *v2d= &ar->v2d;
|
||||
View2D *v2d = &ar->v2d;
|
||||
View2DScrollers *scrollers;
|
||||
float col[3];
|
||||
|
||||
@@ -332,14 +332,14 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
/* draw channels */
|
||||
if (ANIM_animdata_get_context(C, &ac)) {
|
||||
graph_draw_channel_names((bContext*)C, &ac, ar);
|
||||
graph_draw_channel_names((bContext *)C, &ac, ar);
|
||||
}
|
||||
|
||||
/* reset view matrix */
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
@@ -418,7 +418,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
|
||||
ED_region_tag_redraw(ar);
|
||||
break;
|
||||
default:
|
||||
if (wmn->data==ND_KEYS)
|
||||
if (wmn->data == ND_KEYS)
|
||||
ED_region_tag_redraw(ar);
|
||||
|
||||
}
|
||||
@@ -427,7 +427,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
|
||||
/* editor level listener */
|
||||
static void graph_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
{
|
||||
SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first;
|
||||
SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first;
|
||||
|
||||
/* context changes */
|
||||
switch (wmn->category) {
|
||||
@@ -440,7 +440,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
break;
|
||||
case NC_SCENE:
|
||||
switch (wmn->data) {
|
||||
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
||||
case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
||||
case ND_OB_SELECT:
|
||||
sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
|
||||
ED_area_tag_refresh(sa);
|
||||
@@ -453,7 +453,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
break;
|
||||
case NC_OBJECT:
|
||||
switch (wmn->data) {
|
||||
case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
||||
case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */
|
||||
case ND_BONE_ACTIVE:
|
||||
sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
|
||||
ED_area_tag_refresh(sa);
|
||||
@@ -472,16 +472,16 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn)
|
||||
sipo->flag |= SIPO_TEMP_NEEDCHANSYNC;
|
||||
ED_area_tag_refresh(sa);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case NC_SPACE:
|
||||
if (wmn->data == ND_SPACE_GRAPH)
|
||||
ED_area_tag_redraw(sa);
|
||||
break;
|
||||
|
||||
// XXX: restore the case below if not enough updates occur...
|
||||
//default:
|
||||
// if (wmn->data==ND_KEYS)
|
||||
// ED_area_tag_redraw(sa);
|
||||
// XXX: restore the case below if not enough updates occur...
|
||||
//default:
|
||||
// if (wmn->data==ND_KEYS)
|
||||
// ED_area_tag_redraw(sa);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,13 +498,13 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case SIPO_MODE_DRIVERS: /* drivers only */
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
/* region updates? */
|
||||
@@ -528,15 +528,15 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
int i;
|
||||
|
||||
/* build list of F-Curves which will be visible as channels in channel-region
|
||||
* - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a
|
||||
* mismatch between channel-colors and the drawn curves
|
||||
* - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a
|
||||
* mismatch between channel-colors and the drawn curves
|
||||
*/
|
||||
filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_NODUPLIS);
|
||||
items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS);
|
||||
items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
|
||||
|
||||
/* loop over F-Curves, assigning colors */
|
||||
for (ale=anim_data.first, i=0; ale; ale= ale->next, i++) {
|
||||
FCurve *fcu= (FCurve *)ale->data;
|
||||
for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) {
|
||||
FCurve *fcu = (FCurve *)ale->data;
|
||||
|
||||
/* set color of curve here */
|
||||
switch (fcu->color_mode) {
|
||||
@@ -551,7 +551,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
/* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors.
|
||||
* TODO: find a way to module the hue so that not all curves have same color...
|
||||
*/
|
||||
float *col= fcu->color;
|
||||
float *col = fcu->color;
|
||||
|
||||
switch (fcu->array_index) {
|
||||
case 0:
|
||||
@@ -569,7 +569,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case FCURVE_COLOR_AUTO_RAINBOW:
|
||||
default:
|
||||
@@ -579,7 +579,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
*/
|
||||
getcolor_fcurve_rainbow(i, items, fcu->color);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -591,10 +591,10 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
|
||||
/* only called once, from space/spacetypes.c */
|
||||
void ED_spacetype_ipo(void)
|
||||
{
|
||||
SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype ipo");
|
||||
SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo");
|
||||
ARegionType *art;
|
||||
|
||||
st->spaceid= SPACE_IPO;
|
||||
st->spaceid = SPACE_IPO;
|
||||
strncpy(st->name, "Graph", BKE_ST_MAXNAME);
|
||||
|
||||
st->new = graph_new;
|
||||
@@ -612,7 +612,7 @@ void ED_spacetype_ipo(void)
|
||||
art->init = graph_main_area_init;
|
||||
art->draw = graph_main_area_draw;
|
||||
art->listener = graph_region_listener;
|
||||
art->keymapflag = ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES;
|
||||
art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES;
|
||||
|
||||
BLI_addhead(&st->regiontypes, art);
|
||||
|
||||
@@ -620,7 +620,7 @@ void ED_spacetype_ipo(void)
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
|
||||
art->regionid = RGN_TYPE_HEADER;
|
||||
art->prefsizey = HEADERY;
|
||||
art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
|
||||
art->listener = graph_region_listener;
|
||||
art->init = graph_header_area_init;
|
||||
art->draw = graph_header_area_draw;
|
||||
@@ -631,7 +631,7 @@ void ED_spacetype_ipo(void)
|
||||
art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region");
|
||||
art->regionid = RGN_TYPE_CHANNELS;
|
||||
art->prefsizex = 200 + V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */
|
||||
art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES;
|
||||
art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES;
|
||||
art->listener = graph_region_listener;
|
||||
art->init = graph_channel_area_init;
|
||||
art->draw = graph_channel_area_draw;
|
||||
|
||||
Reference in New Issue
Block a user