Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-05-09 00:18:33 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-05-09 00:18:33 +0400
commitf6abd6ee401fb19a3005c0f0b604674b026eb270 (patch)
tree4212a9a9c886034e60d84681d3b9b6dc46b931a2 /source/blender/editors/armature
parentd9a70ceeb14fa7e723ce226f36eba12aea2373df (diff)
style cleanup: graph & armature
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/BIF_generate.h4
-rw-r--r--source/blender/editors/armature/BIF_retarget.h45
-rw-r--r--source/blender/editors/armature/armature_intern.h10
-rw-r--r--source/blender/editors/armature/armature_ops.c104
-rw-r--r--source/blender/editors/armature/editarmature.c1892
-rw-r--r--source/blender/editors/armature/editarmature_generate.c2
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c200
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c281
-rw-r--r--source/blender/editors/armature/meshlaplacian.c947
-rw-r--r--source/blender/editors/armature/meshlaplacian.h6
-rw-r--r--source/blender/editors/armature/poseSlide.c330
-rw-r--r--source/blender/editors/armature/poseUtils.c44
-rw-r--r--source/blender/editors/armature/poselib.c512
-rw-r--r--source/blender/editors/armature/poseobject.c601
-rw-r--r--source/blender/editors/armature/reeb.c436
-rw-r--r--source/blender/editors/armature/reeb.h38
16 files changed, 2722 insertions, 2730 deletions
diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h
index 1d8ee8e2c62..583178dd2b7 100644
--- a/source/blender/editors/armature/BIF_generate.h
+++ b/source/blender/editors/armature/BIF_generate.h
@@ -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]);
diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h
index c878b0c36df..2ea0e0ab0d7 100644
--- a/source/blender/editors/armature/BIF_retarget.h
+++ b/source/blender/editors/armature/BIF_retarget.h
@@ -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;
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 11129f34f3e..0760b384ecd 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -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;
/* ----------- */
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index ab8bfb2b98a..f3461f71391 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -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 */
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 44dfcaacbfc..f698153eb7f 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -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) ||
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
index 5b56f5fe7fe..7f966dbc884 100644
--- a/source/blender/editors/armature/editarmature_generate.c
+++ b/source/blender/editors/armature/editarmature_generate.c
@@ -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;
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index a97823ebcc8..566dbc901b8 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -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);
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 9b32c7a090e..2201bcf7224 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -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;
}
diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c
index 3828c025bcd..ccba3599318 100644
--- a/source/blender/editors/armature/meshlaplacian.c
+++ b/source/blender/editors/armature/meshlaplacian.c
@@ -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;
-
- 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;
+ 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 += 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);
diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h
index 095de4ac9a9..da512f2df12 100644
--- a/source/blender/editors/armature/meshlaplacian.h
+++ b/source/blender/editors/armature/meshlaplacian.h
@@ -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 */
diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c
index f33dce00f8d..824a39374fd 100644
--- a/source/blender/editors/armature/poseSlide.c
+++ b/source/blender/editors/armature/poseSlide.c
@@ -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 */
-
- 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) */
+ 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) */
- int mode; /* sliding mode (ePoseSlide_Modes) */
- int flag; // unused for now, but can later get used for storing runtime settings....
+ 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?
diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c
index 3b613a6d25c..4e0398168d3 100644
--- a/source/blender/editors/armature/poseUtils.c
+++ b/source/blender/editors/armature/poseUtils.c
@@ -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)
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index f180f735294..36c15c50809 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -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 */
-
- Scene *scene; /* active scene */
- ScrArea *sa; /* active area */
+ ListBase backups; /* tPoseLib_Backup structs for restoring poses */
+ ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */
- 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 */
+ Scene *scene; /* active scene */
+ ScrArea *sa; /* active area */
- 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 */
+ 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 */
- 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);
}
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 8cc0251e024..e9c960c4080 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -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");
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index efcbab78884..2564683ddd2 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -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,23 +3407,22 @@ 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)
+ if (arc->bcount)
+ {
+ initArcIterator(iter, arc, arc->head);
+ for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
{
- initArcIterator(iter, arc, arc->head);
- for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
- {
- glVertex3fv(iter->p);
- }
+ glVertex3fv(iter->p);
}
+ }
- glVertex3fv(arc->tail->p);
+ glVertex3fv(arc->tail->p);
glEnd();
@@ -3438,18 +3430,18 @@ void REEB_draw()
{
glColor3f(1, 1, 1);
glBegin(GL_POINTS);
- glVertex3fv(arc->head->p);
- glVertex3fv(arc->tail->p);
+ glVertex3fv(arc->head->p);
+ glVertex3fv(arc->tail->p);
- glColor3f(0.5f, 0.5f, 1);
- if (arc->bcount)
+ 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))
{
- initArcIterator(iter, arc, arc->head);
- for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter))
- {
- glVertex3fv(iter->p);
- }
+ glVertex3fv(iter->p);
}
+ }
glEnd();
}
diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h
index a9b32da4e5b..d71e80ca0ca 100644
--- a/source/blender/editors/armature/reeb.h
+++ b/source/blender/editors/armature/reeb.h
@@ -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;