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-04-28 10:31:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-28 10:31:57 +0400
commitb340f930ec5639f24e7e2d47fab221fb752b61dd (patch)
tree0e880a36bb528d133af6d10701fc090716b3b7f8 /source/blender/editors
parent09dc600839904a198ab4ba3fad62ce58c2d3aa07 (diff)
style cleanup: changes to brace placement / newlines - for/while/if/switch
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_filter.c3
-rw-r--r--source/blender/editors/animation/anim_markers.c2
-rw-r--r--source/blender/editors/armature/editarmature.c5
-rw-r--r--source/blender/editors/armature/editarmature_generate.c48
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c834
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c738
-rw-r--r--source/blender/editors/armature/poselib.c8
-rw-r--r--source/blender/editors/armature/reeb.c793
-rw-r--r--source/blender/editors/curve/editcurve.c2
-rw-r--r--source/blender/editors/curve/editfont.c27
-rw-r--r--source/blender/editors/interface/interface_handlers.c6
-rw-r--r--source/blender/editors/interface/interface_widgets.c3
-rw-r--r--source/blender/editors/interface/resources.c3
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c5
-rw-r--r--source/blender/editors/mesh/meshtools.c5
-rw-r--r--source/blender/editors/object/object_add.c4
-rw-r--r--source/blender/editors/object/object_bake.c2
-rw-r--r--source/blender/editors/object/object_edit.c18
-rw-r--r--source/blender/editors/object/object_hook.c2
-rw-r--r--source/blender/editors/object/object_relations.c6
-rw-r--r--source/blender/editors/object/object_shapekey.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c15
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c3
-rw-r--r--source/blender/editors/physics/particle_edit.c12
-rw-r--r--source/blender/editors/physics/physics_fluid.c3
-rw-r--r--source/blender/editors/screen/area.c18
-rw-r--r--source/blender/editors/screen/glutil.c18
-rw-r--r--source/blender/editors/screen/screen_edit.c4
-rw-r--r--source/blender/editors/screen/screen_ops.c12
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c9
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c2
-rw-r--r--source/blender/editors/sound/sound_ops.c6
-rw-r--r--source/blender/editors/space_action/space_action.c14
-rw-r--r--source/blender/editors/space_buttons/buttons_context.c2
-rw-r--r--source/blender/editors/space_buttons/buttons_header.c4
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c12
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c2
-rw-r--r--source/blender/editors/space_clip/clip_ops.c4
-rw-r--r--source/blender/editors/space_clip/space_clip.c16
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c2
-rw-r--r--source/blender/editors/space_file/file_draw.c8
-rw-r--r--source/blender/editors/space_file/file_ops.c3
-rw-r--r--source/blender/editors/space_file/filelist.c4
-rw-r--r--source/blender/editors/space_file/filesel.c3
-rw-r--r--source/blender/editors/space_file/fsmenu.c19
-rw-r--r--source/blender/editors/space_file/space_file.c8
-rw-r--r--source/blender/editors/space_graph/graph_buttons.c2
-rw-r--r--source/blender/editors/space_graph/space_graph.c10
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_logic/logic_buttons.c3
-rw-r--r--source/blender/editors/space_logic/logic_window.c72
-rw-r--r--source/blender/editors/space_logic/space_logic.c4
-rw-r--r--source/blender/editors/space_nla/nla_buttons.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c20
-rw-r--r--source/blender/editors/space_node/drawnode.c37
-rw-r--r--source/blender/editors/space_node/node_edit.c4
-rw-r--r--source/blender/editors/space_node/node_templates.c13
-rw-r--r--source/blender/editors/space_node/space_node.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c16
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c16
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c12
-rw-r--r--source/blender/editors/space_text/text_draw.c3
-rw-r--r--source/blender/editors/space_time/space_time.c8
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c9
-rw-r--r--source/blender/editors/transform/transform.c169
-rw-r--r--source/blender/editors/transform/transform_constraints.c9
-rw-r--r--source/blender/editors/transform/transform_conversions.c68
-rw-r--r--source/blender/editors/transform/transform_generics.c109
-rw-r--r--source/blender/editors/transform/transform_input.c6
-rw-r--r--source/blender/editors/transform/transform_manipulator.c12
-rw-r--r--source/blender/editors/transform/transform_ops.c53
-rw-r--r--source/blender/editors/transform/transform_orientations.c14
-rw-r--r--source/blender/editors/transform/transform_snap.c240
-rw-r--r--source/blender/editors/util/numinput.c3
78 files changed, 1339 insertions, 2314 deletions
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index e5822c76fa1..922156ebb7a 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -992,8 +992,7 @@ static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *
* 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through
* the rest of the F-Curve list without an eternal loop. Back to step 2 :)
*/
- for (fcu=first; ( (fcu = animfilter_fcurve_next(ads, fcu, grp, filter_mode, owner_id)) ); fcu=fcu->next)
- {
+ for (fcu = first; ( (fcu = animfilter_fcurve_next(ads, fcu, grp, filter_mode, owner_id)) ); fcu = fcu->next) {
ANIMCHANNEL_NEW_CHANNEL(fcu, ANIMTYPE_FCURVE, owner_id);
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 73dba91207f..94d9d426932 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -745,7 +745,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt)
float dx, fac;
char str[256];
- switch(evt->type) {
+ switch (evt->type) {
case ESCKEY:
ed_marker_move_cancel(C, op);
return OPERATOR_CANCELLED;
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index cc3d0c6e184..c529ad66d73 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -2458,8 +2458,7 @@ void preEditBoneDuplicate(ListBase *editbones)
EditBone *eBone;
/* clear temp */
- for (eBone = editbones->first; eBone; eBone = eBone->next)
- {
+ for (eBone = editbones->first; eBone; eBone = eBone->next) {
eBone->temp = NULL;
}
}
@@ -5800,7 +5799,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
/* Loop over subdivision methods */
for (i = 0; lastBone == NULL && i < SKGEN_SUB_TOTAL; i++) {
- switch(scene->toolsettings->skgen_subdivisions[i]) {
+ switch (scene->toolsettings->skgen_subdivisions[i]) {
case SKGEN_SUB_LENGTH:
lastBone = test_subdivideByLength(scene, obedit, arc, head, tail);
break;
diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c
index 37d095221c9..5b56f5fe7fe 100644
--- a/source/blender/editors/armature/editarmature_generate.c
+++ b/source/blender/editors/armature/editarmature_generate.c
@@ -52,8 +52,7 @@
void setBoneRollFromNormal(EditBone *bone, float *no, float UNUSED(invmat[][4]), float tmat[][3])
{
- if (no != NULL && !is_zero_v3(no))
- {
+ if (no != NULL && !is_zero_v3(no)) {
float normal[3];
copy_v3_v3(normal, no);
@@ -67,16 +66,14 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl
{
int len = 2 + abs(end - start);
- if (len > 2)
- {
+ if (len > 2) {
float avg_t = 0.0f;
float s_t = 0.0f;
float s_xyz = 0.0f;
int i;
/* First pass, calculate average */
- for (i = start; i <= end; i++)
- {
+ for (i = start; i <= end; i++) {
float v[3];
IT_peek(iter, i);
@@ -89,8 +86,7 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl
avg_t /= len;
/* Second pass, calculate s_xyz and s_t */
- for (i = start; i <= end; i++)
- {
+ for (i = start; i <= end; i++) {
float v[3], d[3];
float dt;
@@ -110,8 +106,7 @@ float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], fl
return 1.0f - s_xyz / s_t;
}
- else
- {
+ else {
return 1.0f;
}
}
@@ -125,15 +120,13 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta
float length_threshold;
int i;
- if (stroke_length == 0)
- {
+ if (stroke_length == 0) {
current_length = 0;
IT_peek(iter, start);
v1 = iter->p;
- for (i = start + 1; i <= end; i++)
- {
+ for (i = start + 1; i <= end; i++) {
IT_peek(iter, i);
v2 = iter->p;
@@ -154,8 +147,7 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta
v1 = iter->p;
/* < and not <= because we don't care about end, it is P_EXACT anyway */
- for (i = start + 1; i < end; i++)
- {
+ for (i = start + 1; i < end; i++) {
IT_peek(iter, i);
v2 = iter->p;
@@ -183,8 +175,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in
IT_peek(iter, start);
start_p = iter->p;
- for (i = start + 2; i <= end; i++)
- {
+ for (i = start + 2; i <= end; i++) {
/* Calculate normal */
IT_peek(iter, i);
sub_v3_v3v3(n, iter->p, head);
@@ -206,8 +197,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
int i;
i = start + 1;
- while (i <= end)
- {
+ while (i <= end) {
float *vec0;
float *vec1;
@@ -218,10 +208,8 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
vec1 = iter->p;
/* If lengthLimit hits the current segment */
- if (len_v3v3(vec1, head) > lengthLimit)
- {
- if (same == 0)
- {
+ if (len_v3v3(vec1, head) > lengthLimit) {
+ if (same == 0) {
float dv[3], off[3];
float a, b, c, f;
@@ -260,8 +248,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st
return i - 1; /* restart at lower bound */
}
- else
- {
+ else {
i++;
same = 0; // Reset same
}
@@ -286,16 +273,14 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *
parent = ED_armature_edit_bone_add(arm, "Bone");
copy_v3_v3(parent->head, iter->p);
- if (iter->size > 0)
- {
+ if (iter->size > 0) {
parent->rad_head = iter->size * size_buffer;
}
normal = iter->no;
index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail);
- while (index != -1)
- {
+ while (index != -1) {
IT_peek(iter, index);
child = ED_armature_edit_bone_add(arm, "Bone");
@@ -303,8 +288,7 @@ EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *
child->parent = parent;
child->flag |= BONE_CONNECTED;
- if (iter->size > 0)
- {
+ if (iter->size > 0) {
child->rad_head = iter->size * size_buffer;
parent->rad_tail = iter->size * size_buffer;
}
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index f554b7b1c50..7e4d76cb794 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -119,10 +119,8 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent)
EditBone *ebone;
int count = 0;
- for (ebone = list->first; ebone; ebone = ebone->next)
- {
- if (ebone->parent == parent)
- {
+ for (ebone = list->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == parent) {
count++;
}
}
@@ -134,12 +132,9 @@ static EditBone* nextEditBoneChild(ListBase *list, EditBone *parent, int n)
{
EditBone *ebone;
- for (ebone = list->first; ebone; ebone = ebone->next)
- {
- if (ebone->parent == parent)
- {
- if (n == 0)
- {
+ for (ebone = list->first; ebone; ebone = ebone->next) {
+ if (ebone->parent == parent) {
+ if (n == 0) {
return ebone;
}
n--;
@@ -175,23 +170,19 @@ static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float q
normalize_v3(x_axis);
normalize_v3(z_axis);
- if (dot_v3v3(new_up_axis, x_axis) < 0)
- {
+ if (dot_v3v3(new_up_axis, x_axis) < 0) {
negate_v3(x_axis);
}
- if (dot_v3v3(new_up_axis, z_axis) < 0)
- {
+ if (dot_v3v3(new_up_axis, z_axis) < 0) {
negate_v3(z_axis);
}
- if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis))
- {
+ if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) {
rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */
return ED_rollBoneToVector(bone, x_axis, FALSE);
}
- else
- {
+ else {
rotation_between_vecs_to_quat(qroll, new_up_axis, z_axis); /* set roll rotation quat */
return ED_rollBoneToVector(bone, z_axis, FALSE);
}
@@ -199,26 +190,21 @@ static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float q
static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4], float qroll[4], float up_axis[3])
{
- if (previous == NULL)
- {
+ if (previous == NULL) {
/* default to up_axis if no previous */
return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
}
- else
- {
+ else {
float new_up_axis[3];
float vec_first[3], vec_second[3], normal[3];
- if (previous->bone)
- {
+ if (previous->bone) {
sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head);
}
- else if (previous->prev->bone)
- {
+ else if (previous->prev->bone) {
sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail);
}
- else
- {
+ else {
/* default to up_axis if first bone in the chain is an offset */
return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis);
}
@@ -274,19 +260,16 @@ void RIG_freeRigGraph(BGraph *rg)
BLI_destroy_worker(rigg->worker);
#endif
- if (rigg->link_mesh)
- {
+ if (rigg->link_mesh) {
REEB_freeGraph(rigg->link_mesh);
}
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RIG_freeRigArc(arc);
}
BLI_freelistN(&rg->arcs);
- for (node = rg->nodes.first; node; node = node->next)
- {
+ for (node = rg->nodes.first; node; node = node->next) {
BLI_freeNode(rg, (BNode*)node);
}
BLI_freelistN(&rg->nodes);
@@ -296,8 +279,7 @@ void RIG_freeRigGraph(BGraph *rg)
BLI_ghash_free(rigg->bones_map, NULL, NULL);
BLI_ghash_free(rigg->controls_map, NULL, NULL);
- if (rigg->flag & RIG_FREE_BONELIST)
- {
+ if (rigg->flag & RIG_FREE_BONELIST) {
BLI_freelistN(rigg->editbones);
MEM_freeN(rigg->editbones);
}
@@ -409,12 +391,10 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
{
BLI_addtail(&arc->edges, edge);
- if (edge->prev == NULL)
- {
+ if (edge->prev == NULL) {
copy_v3_v3(edge->head, arc->head->p);
}
- else
- {
+ else {
RigEdge *last_edge = edge->prev;
copy_v3_v3(edge->head, last_edge->tail);
RIG_calculateEdgeAngles(last_edge, edge);
@@ -436,8 +416,7 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
copy_v3_v3(edge->tail, tail);
edge->bone = bone;
- if (bone)
- {
+ if (bone) {
getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis);
}
@@ -449,28 +428,22 @@ 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++)
- {
- if (template_name[i] == '&')
- {
- if (template_name[i+1] == 'S' || template_name[i+1] == 's')
- {
+ 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') {
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++;
}
- else
- {
+ else {
name[j] = template_name[i];
j++;
}
}
- else
- {
+ else {
name[j] = template_name[i];
j++;
}
@@ -524,8 +497,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
arc->count = src_arc->count;
- for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next)
- {
+ for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) {
RigEdge *edge;
edge = MEM_callocN(sizeof(RigEdge), "rig edge");
@@ -538,8 +510,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
edge->angle = src_edge->angle;
edge->up_angle = src_edge->up_angle;
- if (src_edge->bone != NULL)
- {
+ if (src_edge->bone != NULL) {
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);
@@ -572,8 +543,7 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
preEditBoneDuplicate(src->editbones); /* prime bones for duplication */
/* Clone nodes */
- for (node = src->nodes.first; node; node = node->next)
- {
+ for (node = src->nodes.first; node; node = node->next) {
RigNode *cloned_node = newRigNode(rg, node->p);
BLI_ghash_insert(ptr_hash, node, cloned_node);
}
@@ -581,40 +551,32 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
rg->head = BLI_ghash_lookup(ptr_hash, src->head);
/* Clone arcs */
- for (arc = src->arcs.first; arc; arc = arc->next)
- {
+ for (arc = src->arcs.first; arc; arc = arc->next) {
cloneArc(rg, src, arc, ptr_hash, side_string, num_string);
}
/* Clone controls */
- for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next)
- {
+ for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) {
cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string);
}
/* Relink bones properly */
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
- if (edge->bone != NULL)
- {
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone != NULL) {
EditBone *bone;
updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob);
- if (edge->bone->parent)
- {
+ if (edge->bone->parent) {
bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent);
- if (bone != NULL)
- {
+ if (bone != NULL) {
edge->bone->parent = bone;
}
- else
- {
+ else {
/* disconnect since parent isn't cloned
* this will only happen when cloning from selected bones
* */
@@ -625,22 +587,18 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
}
}
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next)
- {
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
EditBone *bone;
updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob);
- if (ctrl->bone->parent)
- {
+ if (ctrl->bone->parent) {
bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent);
- if (bone != NULL)
- {
+ if (bone != NULL) {
ctrl->bone->parent = bone;
}
- else
- {
+ else {
/* disconnect since parent isn't cloned
* this will only happen when cloning from selected bones
* */
@@ -672,8 +630,7 @@ static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second)
edge_first->angle = angle_normalized_v3v3(vec_first, vec_second);
- if (edge_second->bone != NULL)
- {
+ if (edge_second->bone != NULL) {
float normal[3];
cross_v3_v3v3(normal, vec_first, vec_second);
@@ -699,16 +656,14 @@ static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
static int RIG_parentControl(RigControl *ctrl, EditBone *link)
{
- if (link)
- {
+ if (link) {
float offset[3];
int flag = 0;
sub_v3_v3v3(offset, ctrl->bone->head, link->head);
/* if root matches, check for direction too */
- if (dot_v3v3(offset, offset) < 0.0001f)
- {
+ if (dot_v3v3(offset, offset) < 0.0001f) {
float vbone[3], vparent[3];
flag |= RIG_CTRL_FIT_ROOT;
@@ -717,45 +672,38 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
sub_v3_v3v3(vparent, link->tail, link->head);
/* test for opposite direction */
- if (dot_v3v3(vbone, vparent) > 0)
- {
+ if (dot_v3v3(vbone, vparent) > 0) {
float nor[3];
float len;
cross_v3_v3v3(nor, vbone, vparent);
len = dot_v3v3(nor, nor);
- if (len < 0.0001f)
- {
+ if (len < 0.0001f) {
flag |= RIG_CTRL_FIT_BONE;
}
}
}
/* Bail out if old one is automatically better */
- if (flag < ctrl->flag)
- {
+ if (flag < ctrl->flag) {
return 0;
}
/* if there's already a link
* overwrite only if new link is higher in the chain */
- if (ctrl->link && flag == ctrl->flag)
- {
+ if (ctrl->link && flag == ctrl->flag) {
EditBone *bone = NULL;
- for (bone = ctrl->link; bone; bone = bone->parent)
- {
+ for (bone = ctrl->link; bone; bone = bone->parent) {
/* if link is in the chain, break and use that one */
- if (bone == link)
- {
+ if (bone == link) {
break;
}
}
/* not in chain, don't update link */
- if (bone == NULL)
- {
+ if (bone == NULL) {
return 0;
}
}
@@ -778,43 +726,34 @@ static void RIG_reconnectControlBones(RigGraph *rg)
int change = 1;
/* first pass, link to deform bones */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next)
- {
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
bPoseChannel *pchan;
bConstraint *con;
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)
- {
+ 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;
/* constraint targets */
- if (cti && cti->get_constraint_targets)
- {
+ if (cti && cti->get_constraint_targets) {
int target_index;
cti->get_constraint_targets(con, &targets);
- 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)
- {
+ 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);
/* Making sure bone is in this armature */
- if (link != NULL)
- {
+ if (link != NULL) {
/* for pole targets, link to parent bone instead, if possible */
- if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1)
- {
- if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name))
- {
+ if (con->type == CONSTRAINT_TYPE_KINEMATIC && target_index == 1) {
+ if (link->parent && BLI_ghash_haskey(rg->bones_map, link->parent->name)) {
link = link->parent;
}
}
@@ -831,10 +770,8 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
/* if not found yet, check parent */
- if (found == 0)
- {
- if (ctrl->bone->parent)
- {
+ if (found == 0) {
+ if (ctrl->bone->parent) {
/* make sure parent is a deforming bone
* NULL if not
* */
@@ -849,24 +786,19 @@ static void RIG_reconnectControlBones(RigGraph *rg)
RigArc *best_arc = NULL;
EditBone *link = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
- if (edge->bone)
- {
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone) {
int fit = 0;
fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
- if (fit)
- {
+ if (fit) {
/* pick the bone on the arc with the lowest symmetry level
* means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level)
- {
+ if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
best_arc = arc;
link = edge->bone;
}
@@ -880,23 +812,18 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
/* if not found yet, check child */
- if (found == 0)
- {
+ if (found == 0) {
RigArc *arc;
RigArc *best_arc = NULL;
EditBone *link = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
- if (edge->bone && edge->bone->parent == ctrl->bone)
- {
+ for (edge = arc->edges.first; edge; edge = edge->next) {
+ if (edge->bone && edge->bone->parent == ctrl->bone) {
/* pick the bone on the arc with the lowest symmetry level
* means you connect control to the trunk of the skeleton */
- if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level)
- {
+ if (best_arc == NULL || arc->symmetry_level < best_arc->symmetry_level) {
best_arc = arc;
link = edge->bone;
}
@@ -911,52 +838,42 @@ static void RIG_reconnectControlBones(RigGraph *rg)
/* second pass, make chains in control bones */
- while (change)
- {
+ while (change) {
change = 0;
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next)
- {
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
/* if control is not linked yet */
- if (ctrl->link == NULL)
- {
+ if (ctrl->link == NULL) {
bPoseChannel *pchan;
bConstraint *con;
RigControl *ctrl_parent = NULL;
RigControl *ctrl_child;
int found = 0;
- if (ctrl->bone->parent)
- {
+ if (ctrl->bone->parent) {
ctrl_parent = BLI_ghash_lookup(rg->controls_map, ctrl->bone->parent->name);
}
/* 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)
- {
+ 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;
/* constraint targets */
- if (cti && cti->get_constraint_targets)
- {
+ if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next)
- {
- if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0)
- {
+ 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);
/* if owner is a control bone, link with it */
- if (link && link->link)
- {
+ if (link && link->link) {
RIG_parentControl(ctrl, link->bone);
found = 1;
break;
@@ -970,22 +887,17 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
}
- if (found == 0)
- {
+ if (found == 0) {
/* check if parent is already linked */
- if (ctrl_parent && ctrl_parent->link)
- {
+ if (ctrl_parent && ctrl_parent->link) {
RIG_parentControl(ctrl, ctrl_parent->bone);
change = 1;
}
- else
- {
+ else {
/* check childs */
- for (ctrl_child = rg->controls.first; ctrl_child; ctrl_child = ctrl_child->next)
- {
+ for (ctrl_child = rg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
/* if a child is linked, link to that one */
- if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone)
- {
+ if (ctrl_child->link && ctrl_child->bone->parent == ctrl->bone) {
RIG_parentControl(ctrl, ctrl_child->bone);
change = 1;
break;
@@ -998,31 +910,25 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
/* third pass, link control tails */
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next)
- {
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
/* fit bone already means full match, so skip those */
- if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0)
- {
+ if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) {
GHashIterator ghi;
/* look on deform bones first */
BLI_ghashIterator_init(&ghi, rg->bones_map);
- for ( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&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)
- {
- if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f)
- {
+ if (bone->parent != ctrl->bone) {
+ if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) {
ctrl->tail_mode = TL_HEAD;
ctrl->link_tail = bone;
break;
}
- else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f)
- {
+ else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f) {
ctrl->tail_mode = TL_TAIL;
ctrl->link_tail = bone;
break;
@@ -1031,8 +937,7 @@ static void RIG_reconnectControlBones(RigGraph *rg)
}
/* if we haven't found one yet, look in control bones */
- if (ctrl->tail_mode == TL_NONE)
- {
+ if (ctrl->tail_mode == TL_NONE) {
}
}
}
@@ -1046,21 +951,18 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr
RigEdge *edge, *next_edge;
/* ignore cases where joint is at start or end */
- if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail)
- {
+ if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) {
return;
}
/* swap arcs to make sure arc1 is before arc2 */
- if (joined_arc1->head == joined_arc2->tail)
- {
+ if (joined_arc1->head == joined_arc2->tail) {
RigArc *tmp = joined_arc1;
joined_arc1 = joined_arc2;
joined_arc2 = tmp;
}
- for (edge = joined_arc2->edges.first; edge; edge = next_edge)
- {
+ for (edge = joined_arc2->edges.first; edge; edge = next_edge) {
next_edge = edge->next;
RIG_appendEdgeToArc(joined_arc1, edge);
@@ -1079,24 +981,18 @@ static void RIG_removeNormalNodes(RigGraph *rg)
{
RigNode *node, *next_node;
- for (node = rg->nodes.first; node; node = next_node)
- {
+ for (node = rg->nodes.first; node; node = next_node) {
next_node = node->next;
- if (node->degree == 2)
- {
+ if (node->degree == 2) {
RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (arc->head == node || arc->tail == node)
- {
- if (joined_arc1 == NULL)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (arc->head == node || arc->tail == node) {
+ if (joined_arc1 == NULL) {
joined_arc1 = arc;
}
- else
- {
+ else {
joined_arc2 = arc;
break;
}
@@ -1112,36 +1008,29 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
{
RigArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RigEdge *first_edge, *last_edge;
first_edge = arc->edges.first;
last_edge = arc->edges.last;
- if (first_edge->bone == NULL)
- {
- if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f)
- {
+ if (first_edge->bone == NULL) {
+ if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
}
- else if (arc->head->degree == 1)
- {
+ else if (arc->head->degree == 1) {
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001f);
- if (new_node)
- {
+ 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);
}
- else
- {
+ else {
RigEdge *next_edge = first_edge->next;
- if (next_edge)
- {
+ if (next_edge) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
@@ -1149,57 +1038,44 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
}
}
- else
- {
+ else {
/* check if all arc connected start with a null edge */
RigArc *other_arc;
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next)
- {
- if (other_arc != arc)
- {
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
RigEdge *test_edge;
- if (other_arc->head == arc->head)
- {
+ if (other_arc->head == arc->head) {
test_edge = other_arc->edges.first;
- if (test_edge->bone != NULL)
- {
+ if (test_edge->bone != NULL) {
break;
}
}
- else if (other_arc->tail == arc->head)
- {
+ else if (other_arc->tail == arc->head) {
test_edge = other_arc->edges.last;
- if (test_edge->bone != NULL)
- {
+ if (test_edge->bone != NULL) {
break;
}
}
}
}
- if (other_arc == NULL)
- {
+ if (other_arc == NULL) {
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001);
- if (new_node)
- {
+ if (new_node) {
/* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next)
- {
- if (other_arc != arc)
- {
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
RigEdge *test_edge;
- if (other_arc->head == arc->head)
- {
+ if (other_arc->head == 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)
- {
+ else if (other_arc->tail == arc->head) {
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);
@@ -1212,31 +1088,25 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
MEM_freeN(first_edge);
BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head);
}
- else
- {
+ else {
RigEdge *next_edge = first_edge->next;
- if (next_edge)
- {
+ if (next_edge) {
BLI_remlink(&arc->edges, first_edge);
MEM_freeN(first_edge);
copy_v3_v3(arc->head->p, next_edge->head);
/* remove null edge in other arcs too */
- for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next)
- {
- if (other_arc != arc)
- {
+ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) {
+ if (other_arc != arc) {
RigEdge *test_edge;
- if (other_arc->head == arc->head)
- {
+ if (other_arc->head == 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)
- {
+ else if (other_arc->tail == arc->head) {
test_edge = other_arc->edges.last;
BLI_remlink(&other_arc->edges, test_edge);
MEM_freeN(test_edge);
@@ -1249,19 +1119,15 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
}
}
- if (last_edge->bone == NULL)
- {
- if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f)
- {
+ if (last_edge->bone == NULL) {
+ if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) {
BLI_remlink(&arc->edges, last_edge);
MEM_freeN(last_edge);
}
- else if (arc->tail->degree == 1)
- {
+ else if (arc->tail->degree == 1) {
RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001f);
- if (new_node)
- {
+ if (new_node) {
RigEdge *previous_edge = last_edge->prev;
BLI_remlink(&arc->edges, last_edge);
@@ -1269,17 +1135,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
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)
- {
+ if (previous_edge) {
previous_edge->angle = 0;
}
}
- else
- {
+ else {
RigEdge *previous_edge = last_edge->prev;
- if (previous_edge)
- {
+ if (previous_edge) {
BLI_remlink(&arc->edges, last_edge);
MEM_freeN(last_edge);
@@ -1298,32 +1161,25 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
RigArc *arc = NULL;
int contain_head = 0;
- for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0))
- {
+ for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) {
int nb_children;
- if (selected == 0 || (bone->flag & BONE_SELECTED))
- {
- if ((bone->flag & BONE_NO_DEFORM) == 0)
- {
+ if (selected == 0 || (bone->flag & BONE_SELECTED)) {
+ if ((bone->flag & BONE_NO_DEFORM) == 0) {
BLI_ghash_insert(rg->bones_map, bone->name, bone);
- if (arc == NULL)
- {
+ if (arc == NULL) {
arc = newRigArc(rg);
- if (starting_node == NULL)
- {
+ if (starting_node == NULL) {
starting_node = newRigNodeHead(rg, arc, root_bone->head);
}
- else
- {
+ else {
addRigNodeHead(rg, arc, starting_node);
}
}
- if (bone->parent && (bone->flag & BONE_CONNECTED) == 0)
- {
+ if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) {
RIG_addEdgeToArc(arc, bone->head, NULL);
}
@@ -1331,34 +1187,28 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
last_bone = bone;
- if (strcmp(bone->name, "head") == 0)
- {
+ if (strcmp(bone->name, "head") == 0) {
contain_head = 1;
}
}
- else if ((bone->flag & BONE_EDITMODE_LOCKED) == 0) /* ignore locked bones */
- {
+ else if ((bone->flag & BONE_EDITMODE_LOCKED) == 0) { /* ignore locked bones */
RIG_addControlBone(rg, bone);
}
}
nb_children = countEditBoneChildren(list, bone);
- if (nb_children > 1)
- {
+ if (nb_children > 1) {
RigNode *end_node = NULL;
int i;
- if (arc != NULL)
- {
+ if (arc != NULL) {
end_node = newRigNodeTail(rg, arc, bone->tail);
}
- else
- {
+ else {
end_node = newRigNode(rg, bone->tail);
}
- for (i = 0; i < nb_children; i++)
- {
+ for (i = 0; i < nb_children; i++) {
root_bone = nextEditBoneChild(list, bone, i);
RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected);
}
@@ -1369,13 +1219,11 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
}
/* If the loop exited without forking */
- if (arc != NULL && bone == NULL)
- {
+ if (arc != NULL && bone == NULL) {
newRigNodeTail(rg, arc, last_bone->tail);
}
- if (contain_head)
- {
+ if (contain_head) {
rg->head = arc->tail;
}
}
@@ -1383,32 +1231,26 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo
/*******************************************************************************************************/
static void RIG_findHead(RigGraph *rg)
{
- if (rg->head == NULL)
- {
- if (BLI_countlist(&rg->arcs) == 1)
- {
+ if (rg->head == NULL) {
+ if (BLI_countlist(&rg->arcs) == 1) {
RigArc *arc = rg->arcs.first;
rg->head = (RigNode*)arc->head;
}
- else
- {
+ else {
RigArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ 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;
}
}
}
- if (rg->head == NULL)
- {
+ if (rg->head == NULL) {
rg->head = rg->nodes.first;
}
}
@@ -1420,8 +1262,7 @@ static void RIG_printNode(RigNode *node, const char name[])
{
printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]);
- if (node->symmetry_flag & SYM_TOPOLOGICAL)
- {
+ if (node->symmetry_flag & SYM_TOPOLOGICAL) {
if (node->symmetry_flag & SYM_AXIAL)
printf("Symmetry AXIAL\n");
else if (node->symmetry_flag & SYM_RADIAL)
@@ -1435,8 +1276,7 @@ void RIG_printArcBones(RigArc *arc)
{
RigEdge *edge;
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
+ for (edge = arc->edges.first; edge; edge = edge->next) {
if (edge->bone)
printf("%s ", edge->bone->name);
else
@@ -1465,17 +1305,14 @@ static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs)
char *s = indent;
int i;
- for (i = 0; i < tabs; i++)
- {
+ for (i = 0; i < tabs; i++) {
s[0] = '\t';
s++;
}
s[0] = 0;
- for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next)
- {
- if (ctrl->link == bone)
- {
+ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) {
+ if (ctrl->link == bone) {
RIG_printCtrl(ctrl, indent);
RIG_printLinkedCtrl(rg, ctrl->bone, tabs + 1);
}
@@ -1488,13 +1325,11 @@ void RIG_printArc(RigGraph *rg, RigArc *arc)
RIG_printNode((RigNode*)arc->head, "head");
- for (edge = arc->edges.first; edge; edge = edge->next)
- {
+ 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]);
printf("\t\tlength %f\n", edge->length);
printf("\t\tangle %f\n", edge->angle * 180 / M_PI);
- if (edge->bone)
- {
+ if (edge->bone) {
printf("\t\t%s\n", edge->bone->name);
RIG_printLinkedCtrl(rg, edge->bone, 3);
}
@@ -1509,18 +1344,15 @@ void RIG_printGraph(RigGraph *rg)
RigArc *arc;
printf("---- ARCS ----\n");
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
RIG_printArc(rg, arc);
printf("\n");
}
- if (rg->head)
- {
+ if (rg->head) {
RIG_printNode(rg->head, "HEAD NODE:");
}
- else
- {
+ else {
printf("HEAD NODE: NONE\n");
}
}
@@ -1536,12 +1368,10 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
rg = newRigGraph();
- if (obedit == ob)
- {
+ if (obedit == ob) {
rg->editbones = ((bArmature *)obedit->data)->edbo;
}
- else
- {
+ else {
rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
rg->flag |= RIG_FREE_BONELIST;
@@ -1551,8 +1381,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
/* Do the rotations */
for (ebone = rg->editbones->first; ebone; ebone=ebone->next) {
- if (ebone->parent == NULL)
- {
+ if (ebone->parent == NULL) {
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0);
}
}
@@ -1571,8 +1400,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm)
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");
}
@@ -1588,12 +1416,10 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
rg = newRigGraph();
- if (obedit == ob)
- {
+ if (obedit == ob) {
rg->editbones = arm->edbo;
}
- else
- {
+ else {
rg->editbones = MEM_callocN(sizeof(ListBase), "EditBones");
make_boneList(rg->editbones, &arm->bonebase, NULL, NULL);
rg->flag |= RIG_FREE_BONELIST;
@@ -1603,8 +1429,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
/* Do the rotations */
for (ebone = rg->editbones->first; ebone; ebone=ebone->next) {
- if (ebone->parent == NULL)
- {
+ if (ebone->parent == NULL) {
RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1);
}
}
@@ -1623,8 +1448,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm
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");
}
@@ -1721,8 +1545,7 @@ static void repositionTailControl(RigGraph *rigg, RigControl *ctrl);
static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
{
- if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE)
- {
+ if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) {
RigControl *ctrl_child;
#if 0
@@ -1737,17 +1560,14 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
#endif
/* if there was a tail link: apply link, recalc resize factor and qrot */
- if (ctrl->tail_mode != TL_NONE)
- {
+ if (ctrl->tail_mode != TL_NONE) {
float *tail_vec = NULL;
float v1[3], v2[3], qtail[4];
- if (ctrl->tail_mode == TL_TAIL)
- {
+ if (ctrl->tail_mode == TL_TAIL) {
tail_vec = ctrl->link_tail->tail;
}
- else if (ctrl->tail_mode == TL_HEAD)
- {
+ else if (ctrl->tail_mode == TL_HEAD) {
tail_vec = ctrl->link_tail->head;
}
@@ -1765,14 +1585,11 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot);
/* Cascade to connected control bones */
- for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next)
- {
- if (ctrl_child->link == ctrl->bone)
- {
+ for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) {
+ if (ctrl_child->link == ctrl->bone) {
repositionControl(rigg, ctrl_child, ctrl->bone->head, ctrl->bone->tail, ctrl->qrot, resize);
}
- if (ctrl_child->link_tail == ctrl->bone)
- {
+ if (ctrl_child->link_tail == ctrl->bone) {
repositionTailControl(rigg, ctrl_child);
}
}
@@ -1800,8 +1617,7 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f
copy_qt_qt(ctrl->qrot, qrot);
- if (ctrl->tail_mode == TL_NONE)
- {
+ if (ctrl->tail_mode == TL_NONE) {
sub_v3_v3v3(tail_offset, ctrl->tail, ctrl->head);
mul_v3_fl(tail_offset, resize);
mul_qt_v3(qrot, tail_offset);
@@ -1838,38 +1654,30 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec
copy_v3_v3(bone->head, vec0);
copy_v3_v3(bone->tail, vec1);
- if (!is_zero_v3(up_axis))
- {
+ if (!is_zero_v3(up_axis)) {
float qroll[4];
- if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_VIEW)
- {
+ if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_VIEW) {
bone->roll = rollBoneByQuatAligned(bone, edge->up_axis, qrot, qroll, up_axis);
}
- else if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT)
- {
+ else if (scene->toolsettings->skgen_retarget_roll == SK_RETARGET_ROLL_JOINT) {
bone->roll = rollBoneByQuatJoint(edge, edge->prev, qrot, qroll, up_axis);
}
- else
- {
+ else {
unit_qt(qroll);
}
mul_qt_qtqt(qrot, qroll, qrot);
}
- else
- {
+ else {
bone->roll = rollBoneByQuat(bone, edge->up_axis, qrot);
}
- for (ctrl = rigg->controls.first; ctrl; ctrl = ctrl->next)
- {
- if (ctrl->link == bone)
- {
+ for (ctrl = rigg->controls.first; ctrl; ctrl = ctrl->next) {
+ if (ctrl->link == bone) {
repositionControl(rigg, ctrl, vec0, vec1, qrot, resize);
}
- if (ctrl->link_tail == bone)
- {
+ if (ctrl->link_tail == bone) {
repositionTailControl(rigg, ctrl);
}
}
@@ -1890,8 +1698,7 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
int nb_edges = 0;
- for (edge = iarc->edges.first; edge; edge = edge->next)
- {
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
avg_angle += edge->angle;
nb_edges++;
}
@@ -1901,29 +1708,23 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
/* avg_length = iarc->length / nb_edges; */ /* UNUSED */
- if (nb_edges > 2)
- {
- for (edge = iarc->edges.first; edge; edge = edge->next)
- {
- if (fabs(edge->angle - avg_angle) > M_PI / 6)
- {
+ if (nb_edges > 2) {
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
+ if (fabs(edge->angle - avg_angle) > M_PI / 6) {
large_angle = 1;
}
}
}
- else if (nb_edges == 2 && avg_angle > 0)
- {
+ else if (nb_edges == 2 && avg_angle > 0) {
large_angle = 1;
}
- if (large_angle == 0)
- {
+ if (large_angle == 0) {
mode = RETARGET_LENGTH;
}
- if (earc->bcount <= (iarc->count - 1))
- {
+ if (earc->bcount <= (iarc->count - 1)) {
mode = RETARGET_LENGTH;
}
@@ -1936,8 +1737,7 @@ static void printMovesNeeded(int *positions, int nb_positions)
int moves = 0;
int i;
- for (i = 0; i < nb_positions; i++)
- {
+ for (i = 0; i < nb_positions; i++) {
moves += positions[i] - (i + 1);
}
@@ -1948,8 +1748,7 @@ static void printPositions(int *positions, int nb_positions)
{
int i;
- for (i = 0; i < nb_positions; i++)
- {
+ for (i = 0; i < nb_positions; i++) {
printf("%i ", positions[i]);
}
printf("\n");
@@ -1965,17 +1764,14 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0,
float v1[3], v2[3], c[3];
float v1_inpf;
- if (distance_weight > 0)
- {
+ if (distance_weight > 0) {
sub_v3_v3v3(v1, vec0, vec1);
v1_inpf = dot_v3v3(v1, v1);
- if (v1_inpf > 0)
- {
+ if (v1_inpf > 0) {
int j;
- for (j = i0 + 1; j < i1 - 1; j++)
- {
+ for (j = i0 + 1; j < i1 - 1; j++) {
float dist;
bucket = IT_peek(iter, j);
@@ -1991,48 +1787,40 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0,
return distance_weight * max_dist;
}
- else
- {
+ else {
return MAX_COST;
}
}
- else
- {
+ else {
return 0;
}
}
static float costAngle(float original_angle, float vec_first[3], float vec_second[3], float angle_weight)
{
- if (angle_weight > 0)
- {
+ if (angle_weight > 0) {
float current_angle;
- if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second))
- {
+ if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) {
current_angle = saacos(dot_v3v3(vec_first, vec_second));
return angle_weight * fabsf(current_angle - original_angle);
}
- else
- {
+ else {
return angle_weight * (float)M_PI;
}
}
- else
- {
+ else {
return 0;
}
}
static float costLength(float original_length, float current_length, float length_weight)
{
- if (current_length == 0)
- {
+ if (current_length == 0) {
return MAX_COST;
}
- else
- {
+ else {
float length_ratio = fabs((current_length - original_length) / original_length);
return length_weight * length_ratio * length_ratio;
}
@@ -2062,8 +1850,7 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_
/* Angle cost */
- if (edge->prev)
- {
+ if (edge->prev) {
sub_v3_v3v3(vec_first, vec1, vec0);
normalize_v3(vec_first);
@@ -2089,8 +1876,7 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions,
int previous = 0, current = 0;
int i = 0;
- for (i = 0; joints_left > 0; joints_left--, i++)
- {
+ for (i = 0; joints_left > 0; joints_left--, i++) {
MemoNode *node;
node = table + indexMemoNode(nb_positions, previous, current, joints_left);
@@ -2108,12 +1894,10 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
node = table + index;
- if (node->weight != 0)
- {
+ if (node->weight != 0) {
return node;
}
- else if (joints_left == 0)
- {
+ else if (joints_left == 0) {
float *vec0 = vec_cache[previous];
float *vec1 = vec_cache[current];
float *vec2 = vec_cache[nb_positions + 1];
@@ -2122,8 +1906,7 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
return node;
}
- else
- {
+ else {
MemoNode *min_node = NULL;
float *vec0 = vec_cache[previous];
float *vec1 = vec_cache[current];
@@ -2131,8 +1914,7 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
int min_next= 0;
int next;
- for (next = current + 1; next <= nb_positions - (joints_left - 1); next++)
- {
+ for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) {
MemoNode *next_node;
float *vec2 = vec_cache[next];
float weight = 0.0f;
@@ -2140,8 +1922,7 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
/* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */
weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight);
- if (weight >= MAX_COST)
- {
+ if (weight >= MAX_COST) {
continue;
}
@@ -2149,22 +1930,19 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c
next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight);
weight += next_node->weight;
- if (min_node == NULL || weight < min_weight)
- {
+ if (min_node == NULL || weight < min_weight) {
min_weight = weight;
min_node = next_node;
min_next = next;
}
}
- if (min_node)
- {
+ if (min_node) {
node->weight = min_weight;
node->next = min_next;
return node;
}
- else
- {
+ else {
node->weight = MAX_COST;
return node;
}
@@ -2178,12 +1956,12 @@ static int testFlipArc(RigArc *iarc, RigNode *inode_start)
ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh);
/* no flip needed if both nodes are the same */
- if ((enode_start == earc->head && inode_start == iarc->head) || (enode_start == earc->tail && inode_start == iarc->tail))
+ if ((enode_start == earc->head && inode_start == iarc->head) ||
+ (enode_start == earc->tail && inode_start == iarc->tail))
{
return 0;
}
- else
- {
+ else {
return 1;
}
}
@@ -2209,38 +1987,32 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
RetargetMethod method = METHOD_MEMOIZE;
int i;
- if (nb_joints > earc->bcount)
- {
+ if (nb_joints > earc->bcount) {
printf("NOT ENOUGH BUCKETS!\n");
return;
}
best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions");
- if (testFlipArc(iarc, inode_start))
- {
+ if (testFlipArc(iarc, inode_start)) {
node_start = earc->tail;
node_end = earc->head;
}
- else
- {
+ else {
node_start = earc->head;
node_end = earc->tail;
}
/* equal number of joints and potential position, just fill them in */
- if (nb_joints == earc->bcount)
- {
+ if (nb_joints == earc->bcount) {
int i;
/* init with first values */
- for (i = 0; i < nb_joints; i++)
- {
+ for (i = 0; i < nb_joints; i++) {
best_positions[i] = i + 1;
}
}
- if (method == METHOD_MEMOIZE)
- {
+ if (method == METHOD_MEMOIZE) {
int nb_positions = earc->bcount;
int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
@@ -2255,8 +2027,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
initArcIterator(iter, earc, node_start);
- for (i = 1; i <= nb_positions; i++)
- {
+ for (i = 1; i <= nb_positions; i++) {
EmbedBucket *bucket = IT_peek(iter, i);
positions_cache[i] = bucket->p;
}
@@ -2290,20 +2061,17 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
edge = edge->next, i++)
{
float *no = NULL;
- if (i < nb_joints)
- {
+ if (i < nb_joints) {
bucket = IT_peek(iter, best_positions[i]);
vec1 = bucket->p;
no = bucket->no;
}
- else
- {
+ else {
vec1 = node_end->p;
no = node_end->no;
}
- if (edge->bone)
- {
+ if (edge->bone) {
repositionBone(C, rigg, edge, vec0, vec1, no);
}
@@ -2327,13 +2095,11 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
float *previous_vec = NULL;
- if (testFlipArc(iarc, inode_start))
- {
+ if (testFlipArc(iarc, inode_start)) {
node_start = (ReebNode*)earc->tail;
node_end = (ReebNode*)earc->head;
}
- else
- {
+ else {
node_start = (ReebNode*)earc->head;
node_end = (ReebNode*)earc->tail;
}
@@ -2344,8 +2110,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
vec0 = node_start->p;
- while (bucket != NULL)
- {
+ while (bucket != NULL) {
vec1 = bucket->p;
embedding_length += len_v3v3(vec0, vec1);
@@ -2365,14 +2130,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
previous_vec = vec0;
vec1 = bucket->p;
- for (edge = iarc->edges.first; edge; edge = edge->next)
- {
+ for (edge = iarc->edges.first; edge; edge = edge->next) {
float new_bone_length = edge->length / iarc->length * embedding_length;
float *no = NULL;
float length = 0;
- while (bucket && new_bone_length > length)
- {
+ while (bucket && new_bone_length > length) {
length += len_v3v3(previous_vec, vec1);
bucket = IT_next(iter);
previous_vec = vec1;
@@ -2380,15 +2143,13 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri
no = bucket->no;
}
- if (bucket == NULL)
- {
+ if (bucket == NULL) {
vec1 = node_end->p;
no = node_end->no;
}
/* no need to move virtual edges (space between unconnected bones) */
- if (edge->bone)
- {
+ if (edge->bone) {
repositionBone(C, rigg, edge, vec0, vec1, no);
}
@@ -2429,29 +2190,23 @@ void *exec_retargetArctoArc(void *param)
RigNode *inode_start = p->inode_start;
ReebArc *earc = iarc->link_mesh;
- if (BLI_countlist(&iarc->edges) == 1)
- {
+ if (BLI_countlist(&iarc->edges) == 1) {
RigEdge *edge = iarc->edges.first;
- if (testFlipArc(iarc, inode_start))
- {
+ if (testFlipArc(iarc, inode_start)) {
repositionBone(C, rigg, edge, earc->tail->p, earc->head->p, earc->head->no);
}
- else
- {
+ else {
repositionBone(C, rigg, edge, earc->head->p, earc->tail->p, earc->tail->no);
}
}
- else
- {
+ else {
RetargetMode mode = detectArcRetargetMode(iarc);
- if (mode == RETARGET_AGGRESSIVE)
- {
+ if (mode == RETARGET_AGGRESSIVE) {
retargetArctoArcAggresive(C, rigg, iarc, inode_start);
}
- else
- {
+ else {
retargetArctoArcLength(C, rigg, iarc, inode_start);
}
}
@@ -2474,8 +2229,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t
inode->link_mesh = enode;
- while (ishape == eshape && enode->link_down)
- {
+ while (ishape == eshape && enode->link_down) {
inode->link_mesh = enode;
enode = enode->link_down;
@@ -2488,16 +2242,13 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
{
int i;
- for (i = 0; i < enode->degree; i++)
- {
+ for (i = 0; i < enode->degree; i++) {
ReebArc *earc = (ReebArc*)enode->arcs[i];
- if (earc->flag == ARC_FREE)
- {
+ if (earc->flag == ARC_FREE) {
earc->flag = ARC_TAKEN;
- if (earc->tail->degree > 1 && earc->tail != end_enode)
- {
+ if (earc->tail->degree > 1 && earc->tail != end_enode) {
markMultiResolutionChildArc(end_enode, earc->tail);
}
break;
@@ -2507,15 +2258,12 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode)
static void markMultiResolutionArc(ReebArc *start_earc)
{
- if (start_earc->link_up)
- {
+ 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)
- {
+ if (earc->tail->index != start_earc->tail->index) {
markMultiResolutionChildArc(earc->tail, earc->tail);
}
}
@@ -2531,8 +2279,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc
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)
- {
+ while (ishape != eshape && next_earc->link_up) {
next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels
next_earc = next_earc->link_up;
@@ -2563,8 +2310,7 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R
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)
- {
+ while (ishape != eshape && reebg->link_up) {
reebg = reebg->link_up;
enode = reebg->nodes.first;
@@ -2593,8 +2339,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
// RIG_printArcBones(next_iarc);
// }
- for (i = 0; i < enode->degree; i++)
- {
+ for (i = 0; i < enode->degree; i++) {
next_earc = (ReebArc*)enode->arcs[i];
// if (next_earc->flag == ARC_FREE)
@@ -2619,20 +2364,17 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
}
/* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */
- if (next_iarc->link_mesh == NULL)
- {
+ if (next_iarc->link_mesh == NULL) {
// printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n");
- if (enode->link_up)
- {
+ if (enode->link_up) {
start_node->link_mesh = enode->link_up;
findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0);
}
}
/* still not found, print debug info */
- if (root && next_iarc->link_mesh == NULL)
- {
+ if (root && next_iarc->link_mesh == NULL) {
start_node->link_mesh = enode; /* linking back with root node */
// printf("NO CORRESPONDING ARC FOUND\n");
@@ -2651,12 +2393,10 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta
// }
/* Emergency matching */
- for (i = 0; i < enode->degree; i++)
- {
+ for (i = 0; i < enode->degree; i++) {
next_earc = (ReebArc*)enode->arcs[i];
- if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level)
- {
+ if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) {
// printf("USING:\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);
matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc);
@@ -2673,8 +2413,7 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig
int i;
/* no start arc on first node */
- if (start_arc)
- {
+ if (start_arc) {
ReebNode *enode = start_node->link_mesh;
ReebArc *earc = start_arc->link_mesh;
@@ -2687,16 +2426,13 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig
matchMultiResolutionNode(rigg, inode, enode);
}
- for (i = 0; i < inode->degree; i++)
- {
+ for (i = 0; i < inode->degree; i++) {
RigArc *next_iarc = (RigArc*)inode->arcs[i];
/* no back tracking */
- if (next_iarc != start_arc)
- {
+ if (next_iarc != start_arc) {
findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1);
- if (next_iarc->link_mesh)
- {
+ if (next_iarc->link_mesh) {
retargetSubgraph(C, rigg, next_iarc, inode);
}
}
@@ -2715,10 +2451,8 @@ static void adjustGraphs(bContext *C, RigGraph *rigg)
bArmature *arm= rigg->ob->data;
RigArc *arc;
- for (arc = rigg->arcs.first; arc; arc = arc->next)
- {
- if (arc->link_mesh)
- {
+ for (arc = rigg->arcs.first; arc; arc = arc->next) {
+ if (arc->link_mesh) {
retargetArctoArc(C, rigg, arc, arc->head);
}
}
@@ -2762,25 +2496,21 @@ const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index)
RigArc *arc = BLI_findlink(&rg->arcs, arc_index);
RigEdge *iedge;
- if (arc == NULL)
- {
+ if (arc == NULL) {
return "None";
}
- if (bone_index == BLI_countlist(&arc->edges))
- {
+ if (bone_index == BLI_countlist(&arc->edges)) {
return "Last joint";
}
iedge = BLI_findlink(&arc->edges, bone_index);
- if (iedge == NULL)
- {
+ if (iedge == NULL) {
return "Done";
}
- if (iedge->bone == NULL)
- {
+ if (iedge->bone == NULL) {
return "Bone offset";
}
@@ -2794,8 +2524,7 @@ int RIG_nbJoints(RigGraph *rg)
total += BLI_countlist(&rg->nodes);
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
total += BLI_countlist(&arc->edges) - 1; /* -1 because end nodes are already counted */
}
@@ -2804,8 +2533,7 @@ int RIG_nbJoints(RigGraph *rg)
static void BIF_freeRetarget(void)
{
- if (GLOBAL_RIGG)
- {
+ if (GLOBAL_RIGG) {
RIG_freeRigGraph((BGraph*)GLOBAL_RIGG);
GLOBAL_RIGG = NULL;
}
@@ -2830,8 +2558,7 @@ void BIF_retargetArmature(bContext *C)
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;
@@ -2910,8 +2637,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
template_rigg = armatureSelectedToGraph(C, ob, ob->data);
}
- if (template_rigg->arcs.first == NULL)
- {
+ if (template_rigg->arcs.first == NULL) {
// XXX
// error("No Template and no deforming bones selected");
return;
@@ -2930,8 +2656,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
finishRetarget(rigg);
/* free template if it comes from the edit armature */
- if (free_template)
- {
+ if (free_template) {
RIG_freeRigGraph((BGraph*)template_rigg);
}
RIG_freeRigGraph((BGraph*)rigg);
@@ -2944,8 +2669,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
void BIF_adjustRetarget(bContext *C)
{
- if (GLOBAL_RIGG)
- {
+ if (GLOBAL_RIGG) {
adjustGraphs(C, GLOBAL_RIGG);
}
}
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index 81b020a4cf9..4c7ab833e69 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -162,25 +162,21 @@ void BIF_makeListTemplates(const bContext *C)
Base *base;
int index = 0;
- if (TEMPLATES_HASH != NULL)
- {
+ if (TEMPLATES_HASH != NULL) {
BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
}
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)
- {
+ if (ob != obedit && ob->type == OB_ARMATURE) {
index++;
BLI_ghash_insert(TEMPLATES_HASH, SET_INT_IN_POINTER(index), ob);
- if (ob == ts->skgen_template)
- {
+ if (ob == ts->skgen_template) {
TEMPLATES_CURRENT = index;
}
}
@@ -193,8 +189,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C))
char menu_header[] = "Template%t|None%x0|";
char *p;
- if (TEMPLATES_MENU != NULL)
- {
+ if (TEMPLATES_MENU != NULL) {
MEM_freeN(TEMPLATES_MENU);
}
@@ -206,8 +201,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C))
BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
- while (!BLI_ghashIterator_isDone(&ghi))
- {
+ while (!BLI_ghashIterator_isDone(&ghi)) {
Object *ob = BLI_ghashIterator_getValue(&ghi);
int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
@@ -223,18 +217,15 @@ int BIF_currentTemplate(const bContext *C)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- if (TEMPLATES_CURRENT == 0 && ts->skgen_template != NULL)
- {
+ if (TEMPLATES_CURRENT == 0 && ts->skgen_template != NULL) {
GHashIterator ghi;
BLI_ghashIterator_init(&ghi, TEMPLATES_HASH);
- while (!BLI_ghashIterator_isDone(&ghi))
- {
+ while (!BLI_ghashIterator_isDone(&ghi)) {
Object *ob = BLI_ghashIterator_getValue(&ghi);
int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi));
- if (ob == ts->skgen_template)
- {
+ if (ob == ts->skgen_template) {
TEMPLATES_CURRENT = key;
break;
}
@@ -249,21 +240,17 @@ int BIF_currentTemplate(const bContext *C)
static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob)
{
Object *obedit = CTX_data_edit_object(C);
- if (ob == obedit)
- {
+ if (ob == obedit) {
return NULL;
}
- if (ob != NULL)
- {
- if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob)
- {
+ if (ob != NULL) {
+ if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) {
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
TEMPLATE_RIGG = NULL;
}
- if (TEMPLATE_RIGG == NULL)
- {
+ if (TEMPLATE_RIGG == NULL) {
bArmature *arm;
arm = ob->data;
@@ -280,12 +267,10 @@ int BIF_nbJointsTemplate(const bContext *C)
ToolSettings *ts = CTX_data_tool_settings(C);
RigGraph *rg = sk_makeTemplateGraph(C, ts->skgen_template);
- if (rg)
- {
+ if (rg) {
return RIG_nbJoints(rg);
}
- else
- {
+ else {
return -1;
}
}
@@ -297,15 +282,13 @@ const char * BIF_nameBoneTemplate(const bContext *C)
RigGraph *rg;
int index = 0;
- if (stk && stk->active_stroke != NULL)
- {
+ if (stk && stk->active_stroke != NULL) {
index = stk->active_stroke->nb_points;
}
rg = sk_makeTemplateGraph(C, ts->skgen_template);
- if (rg == NULL)
- {
+ if (rg == NULL) {
return "";
}
@@ -314,20 +297,17 @@ const char * BIF_nameBoneTemplate(const bContext *C)
void BIF_freeTemplates(bContext *UNUSED(C))
{
- if (TEMPLATES_MENU != NULL)
- {
+ if (TEMPLATES_MENU != NULL) {
MEM_freeN(TEMPLATES_MENU);
TEMPLATES_MENU = NULL;
}
- if (TEMPLATES_HASH != NULL)
- {
+ if (TEMPLATES_HASH != NULL) {
BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
TEMPLATES_HASH = NULL;
}
- if (TEMPLATE_RIGG != NULL)
- {
+ if (TEMPLATE_RIGG != NULL) {
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
TEMPLATE_RIGG = NULL;
}
@@ -336,16 +316,13 @@ void BIF_freeTemplates(bContext *UNUSED(C))
void BIF_setTemplate(bContext *C, int index)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- if (index > 0)
- {
+ if (index > 0) {
ts->skgen_template = BLI_ghash_lookup(TEMPLATES_HASH, SET_INT_IN_POINTER(index));
}
- else
- {
+ else {
ts->skgen_template = NULL;
- if (TEMPLATE_RIGG != NULL)
- {
+ if (TEMPLATE_RIGG != NULL) {
RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG);
}
TEMPLATE_RIGG = NULL;
@@ -357,44 +334,35 @@ void BIF_setTemplate(bContext *C, int index)
static void sk_autoname(bContext *C, ReebArc *arc)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- if (ts->skgen_retarget_options & SK_RETARGET_AUTONAME)
- {
- if (arc == NULL)
- {
+ if (ts->skgen_retarget_options & SK_RETARGET_AUTONAME) {
+ if (arc == NULL) {
char *num = ts->skgen_num_string;
int i = atoi(num);
i++;
BLI_snprintf(num, 8, "%i", i);
}
- else
- {
+ else {
char *side = ts->skgen_side_string;
int valid = 0;
int caps = 0;
- if (side[0] == '\0')
- {
+ 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)
- {
+ if (valid) {
+ if (arc->head->p[0] < 0) {
BLI_snprintf(side, 8, caps?"R":"r");
}
- else
- {
+ else {
BLI_snprintf(side, 8, caps?"L":"l");
}
}
@@ -428,8 +396,7 @@ static ReebArc *sk_strokeToArc(SK_Stroke *stk, float imat[][4], float tmat[][3])
arc->bcount = stk->nb_points - 2; /* first and last are nodes, don't count */
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "Buckets");
- for (i = 0; i < arc->bcount; i++)
- {
+ for (i = 0; i < arc->bcount; i++) {
copy_v3_v3(arc->buckets[i].p, stk->points[i + 1].p);
mul_m4_v3(imat, arc->buckets[i].p);
@@ -473,8 +440,7 @@ static void sk_retargetStroke(bContext *C, SK_Stroke *stk)
static void sk_cancelStroke(SK_Sketch *sketch)
{
- if (sketch->active_stroke != NULL)
- {
+ if (sketch->active_stroke != NULL) {
sk_resetOverdraw(sketch);
sk_removeStroke(sketch, sketch->active_stroke);
}
@@ -501,8 +467,7 @@ static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float si
length = normalize_v3(vec1);
cross_v3_v3v3(axis, vec2, vec1);
- if (is_zero_v3(axis))
- {
+ if (is_zero_v3(axis)) {
axis[1] = 1;
}
@@ -522,8 +487,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig
cross_v3_v3v3(axis, vec2, pt->no);
- if (is_zero_v3(axis))
- {
+ if (is_zero_v3(axis)) {
axis[1] = 1;
}
@@ -544,18 +508,15 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
GLUquadric *quad = gluNewQuadric();
gluQuadricNormals(quad, GLU_SMOOTH);
- if (id != -1)
- {
+ if (id != -1) {
glLoadName(id);
- for (i = 0; i < stk->nb_points; i++)
- {
+ for (i = 0; i < stk->nb_points; i++) {
glPushMatrix();
sk_drawPoint(quad, stk->points + i, 0.1);
- if (i > 0)
- {
+ if (i > 0) {
sk_drawEdge(quad, stk->points + i - 1, stk->points + i, 0.1);
}
@@ -563,44 +524,37 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int
}
}
- else
- {
+ else {
float d_rgb[3] = {1, 1, 1};
copy_v3_v3(rgb, color);
sub_v3_v3(d_rgb, rgb);
mul_v3_fl(d_rgb, 1.0f / (float)stk->nb_points);
- for (i = 0; i < stk->nb_points; i++)
- {
+ for (i = 0; i < stk->nb_points; i++) {
SK_Point *pt = stk->points + i;
glPushMatrix();
- if (pt->type == PT_EXACT)
- {
+ if (pt->type == PT_EXACT) {
glColor3f(0, 0, 0);
sk_drawPoint(quad, pt, 0.15);
sk_drawNormal(quad, pt, 0.05, 0.9);
}
- if (i >= start && i <= end)
- {
+ if (i >= start && i <= end) {
glColor3f(0.3, 0.3, 0.3);
}
- else
- {
+ else {
glColor3fv(rgb);
}
- if (pt->type != PT_EXACT)
- {
+ if (pt->type != PT_EXACT) {
sk_drawPoint(quad, pt, 0.1);
}
- if (i > 0)
- {
+ if (i > 0) {
sk_drawEdge(quad, pt - 1, pt, 0.1);
}
@@ -627,8 +581,7 @@ static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *ite
copy_v3_v3(head, iter->p);
index = next_subdividion(toolsettings, iter, bone_start, end, head, tail);
- while (index != -1)
- {
+ while (index != -1) {
SK_Point *pt = stk->points + index;
glPushMatrix();
@@ -654,41 +607,32 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk)
int head_index = -1;
int i;
- if (toolsettings->bone_sketching_convert == SK_CONVERT_RETARGET)
- {
+ if (toolsettings->bone_sketching_convert == SK_CONVERT_RETARGET) {
return;
}
- for (i = 0; i < stk->nb_points; i++)
- {
+ for (i = 0; i < stk->nb_points; i++) {
SK_Point *pt = stk->points + i;
- if (pt->type == PT_EXACT || i == stk->nb_points - 1) /* stop on exact or on last point */
- {
- if (head_index == -1)
- {
+ if (pt->type == PT_EXACT || i == stk->nb_points - 1) /* stop on exact or on last point */ {
+ if (head_index == -1) {
head_index = i;
}
- else
- {
- if (i - head_index > 1)
- {
+ else {
+ if (i - head_index > 1) {
SK_StrokeIterator sk_iter;
BArcIterator *iter = (BArcIterator*)&sk_iter;
initStrokeIterator(iter, stk, head_index, i);
- if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE)
- {
+ if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) {
drawSubdividedStrokeBy(toolsettings, iter, nextAdaptativeSubdivision);
}
- else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_LENGTH)
- {
+ else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_LENGTH) {
drawSubdividedStrokeBy(toolsettings, iter, nextLengthSubdivision);
}
- else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_FIXED)
- {
+ else if (toolsettings->bone_sketching_convert == SK_CONVERT_CUT_FIXED) {
drawSubdividedStrokeBy(toolsettings, iter, nextFixedSubdivision);
}
@@ -706,10 +650,8 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
SK_Point *pt = NULL;
int i;
- for (i = 0; i < stk->nb_points; i++)
- {
- if (all_pts || stk->points[i].type == PT_EXACT)
- {
+ for (i = 0; i < stk->nb_points; i++) {
+ if (all_pts || stk->points[i].type == PT_EXACT) {
short pval[2];
int pdist;
@@ -717,13 +659,11 @@ static SK_Point *sk_snapPointStroke(bContext *C, SK_Stroke *stk, int mval[2], in
pdist = ABS(pval[0] - mval[0]) + ABS(pval[1] - mval[1]);
- if (pdist < *dist)
- {
+ if (pdist < *dist) {
*dist = pdist;
pt = stk->points + i;
- if (index != NULL)
- {
+ if (index != NULL) {
*index = i;
}
}
@@ -801,75 +741,60 @@ int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk)
static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd)
{
- if (sketch->over.target == NULL)
- {
+ if (sketch->over.target == NULL) {
SK_Stroke *target;
int closest_index = -1;
int dist = SNAP_MIN_DISTANCE * 2;
- for (target = sketch->strokes.first; target; target = target->next)
- {
- if (target != stk)
- {
+ for (target = sketch->strokes.first; target; target = target->next) {
+ if (target != stk) {
int index;
SK_Point *spt = sk_snapPointStroke(C, target, dd->mval, &dist, &index, 1);
- if (spt != NULL)
- {
+ if (spt != NULL) {
sketch->over.target = target;
closest_index = index;
}
}
}
- if (sketch->over.target != NULL)
- {
- if (closest_index > -1)
- {
- if (sk_lastStrokePoint(stk)->type == PT_EXACT)
- {
+ if (sketch->over.target != NULL) {
+ if (closest_index > -1) {
+ if (sk_lastStrokePoint(stk)->type == PT_EXACT) {
sketch->over.count = SK_OVERDRAW_LIMIT;
}
- else
- {
+ else {
sketch->over.count++;
}
}
- if (stk->nb_points == 1)
- {
+ if (stk->nb_points == 1) {
sketch->over.start = closest_index;
}
- else
- {
+ else {
sketch->over.end = closest_index;
}
}
}
- else if (sketch->over.target != NULL)
- {
+ else if (sketch->over.target != NULL) {
SK_Point *closest_pt = NULL;
int dist = SNAP_MIN_DISTANCE * 2;
int index;
closest_pt = sk_snapPointStroke(C, sketch->over.target, dd->mval, &dist, &index, 1);
- if (closest_pt != NULL)
- {
- if (sk_lastStrokePoint(stk)->type == PT_EXACT)
- {
+ if (closest_pt != NULL) {
+ if (sk_lastStrokePoint(stk)->type == PT_EXACT) {
sketch->over.count = SK_OVERDRAW_LIMIT;
}
- else
- {
+ else {
sketch->over.count++;
}
sketch->over.end = index;
}
- else
- {
+ else {
sketch->over.end = -1;
}
}
@@ -883,18 +808,15 @@ static int sk_adjustIndexes(SK_Sketch *sketch, int *start, int *end)
*start = sketch->over.start;
*end = sketch->over.end;
- if (*start == -1)
- {
+ if (*start == -1) {
*start = 0;
}
- if (*end == -1)
- {
+ if (*end == -1) {
*end = sketch->over.target->nb_points - 1;
}
- if (*end < *start)
- {
+ if (*end < *start) {
int tmp = *start;
*start = *end;
*end = tmp;
@@ -908,18 +830,15 @@ static void sk_endOverdraw(SK_Sketch *sketch)
{
SK_Stroke *stk = sketch->active_stroke;
- if (sk_hasOverdraw(sketch, NULL))
- {
+ if (sk_hasOverdraw(sketch, NULL)) {
int start;
int end;
- if (sk_adjustIndexes(sketch, &start, &end))
- {
+ if (sk_adjustIndexes(sketch, &start, &end)) {
sk_reverseStroke(stk);
}
- if (stk->nb_points > 1)
- {
+ if (stk->nb_points > 1) {
stk->points->type = sketch->over.target->points[start].type;
sk_lastStrokePoint(stk)->type = sketch->over.target->points[end].type;
}
@@ -948,8 +867,7 @@ static void sk_endStroke(bContext *C, SK_Sketch *sketch)
ToolSettings *ts = CTX_data_tool_settings(C);
sk_shrinkStrokeBuffer(sketch->active_stroke);
- if (ts->bone_sketching & BONE_SKETCHING_ADJUST)
- {
+ if (ts->bone_sketching & BONE_SKETCHING_ADJUST) {
sk_endOverdraw(sketch);
}
@@ -977,8 +895,7 @@ static float sk_distanceDepth(bContext *C, float p1[3], float p2[3])
distance = len_v3(vec);
- if (dot_v3v3(rv3d->viewinv[2], vec) > 0)
- {
+ if (dot_v3v3(rv3d->viewinv[2], vec) > 0) {
distance *= -1;
}
@@ -996,8 +913,7 @@ static void sk_interpolateDepth(bContext *C, SK_Stroke *stk, int start, int end,
progress = len_v3v3(stk->points[start].p, stk->points[start - 1].p);
- for (i = start; i <= end; i++)
- {
+ for (i = start; i <= end; i++) {
float ray_start[3], ray_normal[3];
float delta = len_v3v3(stk->points[i].p, stk->points[i + 1].p);
float pval[2];
@@ -1022,8 +938,7 @@ static void sk_projectDrawPoint(bContext *C, float vec[3], SK_Stroke *stk, SK_Dr
float dvec[3];
float mval_f[2];
- if (last != NULL)
- {
+ if (last != NULL) {
copy_v3_v3(fp, last->p);
}
@@ -1065,8 +980,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
ToolSettings *ts = CTX_data_tool_settings(C);
int point_added = 0;
- if (ts->snap_mode == SCE_SNAP_MODE_VOLUME)
- {
+ if (ts->snap_mode == SCE_SNAP_MODE_VOLUME) {
DepthPeel *p1, *p2;
float *last_p = NULL;
float dist = FLT_MAX;
@@ -1081,20 +995,16 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
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)
- {
+ if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) {
last_p = stk->points[stk->nb_points - 1].p;
}
- else if (LAST_SNAP_POINT_VALID)
- {
+ else if (LAST_SNAP_POINT_VALID) {
last_p = LAST_SNAP_POINT;
}
- for (p1 = sketch->depth_peels.first; p1; p1 = p1->next)
- {
- if (p1->flag == 0)
- {
+ for (p1 = sketch->depth_peels.first; p1; p1 = p1->next) {
+ if (p1->flag == 0) {
float vec[3];
float new_dist;
float new_size = 0;
@@ -1103,42 +1013,34 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
p1->flag = 1;
/* if peeling objects, take the first and last from each object */
- if (ts->snap_flag & SCE_SNAP_PEEL_OBJECT)
- {
+ if (ts->snap_flag & SCE_SNAP_PEEL_OBJECT) {
DepthPeel *peel;
- for (peel = p1->next; peel; peel = peel->next)
- {
- if (peel->ob == p1->ob)
- {
+ for (peel = p1->next; peel; peel = peel->next) {
+ if (peel->ob == p1->ob) {
peel->flag = 1;
p2 = peel;
}
}
}
/* otherwise, pair first with second and so on */
- else
- {
- for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next)
- {
+ else {
+ for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next) {
/* nothing to do here */
}
}
- if (p2)
- {
+ if (p2) {
p2->flag = 1;
add_v3_v3v3(vec, p1->p, p2->p);
mul_v3_fl(vec, 0.5f);
new_size = len_v3v3(p1->p, p2->p);
}
- else
- {
+ else {
copy_v3_v3(vec, p1->p);
}
- if (last_p == NULL)
- {
+ if (last_p == NULL) {
copy_v3_v3(p, vec);
size = new_size;
dist = 0;
@@ -1147,8 +1049,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
new_dist = len_v3v3(last_p, vec);
- if (new_dist < dist)
- {
+ if (new_dist < dist) {
copy_v3_v3(p, vec);
dist = new_dist;
size = new_size;
@@ -1156,8 +1057,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
}
}
- if (dist != FLT_MAX)
- {
+ if (dist != FLT_MAX) {
pt->type = dd->type;
pt->mode = PT_SNAP;
pt->size = size / 2;
@@ -1168,8 +1068,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
//BLI_freelistN(&depth_peels);
}
- else
- {
+ else {
SK_Stroke *snap_stk;
float vec[3];
float no[3];
@@ -1179,20 +1078,16 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
/* snap to strokes */
// if (ts->snap_mode == SCE_SNAP_MODE_VERTEX) /* snap all the time to strokes */
- for (snap_stk = sketch->strokes.first; snap_stk; snap_stk = snap_stk->next)
- {
+ for (snap_stk = sketch->strokes.first; snap_stk; snap_stk = snap_stk->next) {
SK_Point *spt = NULL;
- if (snap_stk == stk)
- {
+ if (snap_stk == stk) {
spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist, NULL, 0);
}
- else
- {
+ else {
spt = sk_snapPointStroke(C, snap_stk, dd->mval, &dist, NULL, 1);
}
- if (spt != NULL)
- {
+ if (spt != NULL) {
copy_v3_v3(pt->p, spt->p);
point_added = 1;
}
@@ -1203,8 +1098,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
/* try to snap to closer object */
found = snapObjectsContext(C, mval, &dist, vec, no, SNAP_NOT_SELECTED);
- if (found == 1)
- {
+ if (found == 1) {
pt->type = dd->type;
pt->mode = PT_SNAP;
copy_v3_v3(pt->p, vec);
@@ -1227,8 +1121,7 @@ static int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk,
point_added = sk_getStrokeSnapPoint(C, &pt, sketch, stk, dd);
- if (point_added)
- {
+ if (point_added) {
float final_p[3];
float length, distance;
int total;
@@ -1242,18 +1135,15 @@ static int sk_addStrokeSnapPoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk,
/* update all previous point to give smooth Z progresion */
total = 0;
length = 0;
- for (i = stk->nb_points - 2; i > 0; i--)
- {
+ for (i = stk->nb_points - 2; i > 0; i--) {
length += len_v3v3(stk->points[i].p, stk->points[i + 1].p);
total++;
- if (stk->points[i].mode == PT_SNAP || stk->points[i].type == PT_EXACT)
- {
+ if (stk->points[i].mode == PT_SNAP || stk->points[i].type == PT_EXACT) {
break;
}
}
- if (total > 1)
- {
+ if (total > 1) {
distance = sk_distanceDepth(C, final_p, stk->points[i].p);
sk_interpolateDepth(C, stk, i + 1, stk->nb_points - 2, length, distance);
@@ -1272,18 +1162,15 @@ static void sk_addStrokePoint(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK
ToolSettings *ts = CTX_data_tool_settings(C);
int point_added = 0;
- if (snap)
- {
+ if (snap) {
point_added = sk_addStrokeSnapPoint(C, sketch, stk, dd);
}
- if (point_added == 0)
- {
+ if (point_added == 0) {
point_added = sk_addStrokeDrawPoint(C, sketch, stk, dd);
}
- if (stk == sketch->active_stroke && ts->bone_sketching & BONE_SKETCHING_ADJUST)
- {
+ if (stk == sketch->active_stroke && ts->bone_sketching & BONE_SKETCHING_ADJUST) {
sk_updateOverdraw(C, sketch, stk, dd);
}
}
@@ -1292,19 +1179,16 @@ static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_S
{
int point_added = 0;
- if (snap)
- {
+ if (snap) {
point_added = sk_getStrokeSnapPoint(C, pt, sketch, stk, dd);
LAST_SNAP_POINT_VALID = 1;
copy_v3_v3(LAST_SNAP_POINT, pt->p);
}
- else
- {
+ else {
LAST_SNAP_POINT_VALID = 0;
}
- if (point_added == 0)
- {
+ if (point_added == 0) {
point_added = sk_getStrokeDrawPoint(C, pt, sketch, stk, dd);
}
}
@@ -1334,15 +1218,13 @@ static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index)
{
SK_Point *pt = NULL;
- if (index >= 0 && index < iter->length)
- {
+ if (index >= 0 && index < iter->length) {
pt = &(iter->stroke->points[iter->start + (iter->stride * index)]);
iter->p = pt->p;
iter->no = pt->no;
iter->size = pt->size;
}
- else
- {
+ else {
iter->p = NULL;
iter->no = NULL;
iter->size = 0;
@@ -1358,14 +1240,12 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end)
initIteratorFct(iter);
iter->stroke = stk;
- if (start < end)
- {
+ if (start < end) {
iter->start = start + 1;
iter->end = end - 1;
iter->stride = 1;
}
- else
- {
+ else {
iter->start = start - 1;
iter->end = end + 1;
iter->stride = -1;
@@ -1409,8 +1289,7 @@ static void* nextPoint(void *arg)
SK_Point *result = NULL;
iter->index++;
- if (iter->index < iter->length)
- {
+ if (iter->index < iter->length) {
result = setIteratorValues(iter, iter->index);
}
@@ -1425,8 +1304,7 @@ static void* nextNPoint(void *arg, int n)
iter->index += n;
/* check if passed end */
- if (iter->index < iter->length)
- {
+ if (iter->index < iter->length) {
result = setIteratorValues(iter, iter->index);
}
@@ -1440,8 +1318,7 @@ static void* peekPoint(void *arg, int n)
int index = iter->index + n;
/* check if passed end */
- if (index < iter->length)
- {
+ if (index < iter->length) {
result = setIteratorValues(iter, index);
}
@@ -1453,8 +1330,7 @@ static void* previousPoint(void *arg)
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
SK_Point *result = NULL;
- if (iter->index > 0)
- {
+ if (iter->index > 0) {
iter->index--;
result = setIteratorValues(iter, iter->index);
}
@@ -1466,12 +1342,10 @@ static int iteratorStopped(void *arg)
{
SK_StrokeIterator *iter = (SK_StrokeIterator*)arg;
- if (iter->index >= iter->length)
- {
+ if (iter->index >= iter->length) {
return 1;
}
- else
- {
+ else {
return 0;
}
}
@@ -1495,45 +1369,36 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk)
copy_m3_m4(tmat, obedit->obmat);
transpose_m3(tmat);
- for (i = 0; i < stk->nb_points; i++)
- {
+ for (i = 0; i < stk->nb_points; i++) {
SK_Point *pt = stk->points + i;
- if (pt->type == PT_EXACT)
- {
- if (head == NULL)
- {
+ if (pt->type == PT_EXACT) {
+ if (head == NULL) {
head_index = i;
head = pt;
}
- else
- {
+ else {
EditBone *bone = NULL;
EditBone *new_parent;
- if (i - head_index > 1)
- {
+ if (i - head_index > 1) {
SK_StrokeIterator sk_iter;
BArcIterator *iter = (BArcIterator*)&sk_iter;
initStrokeIterator(iter, stk, head_index, i);
- if (ts->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE)
- {
+ if (ts->bone_sketching_convert == SK_CONVERT_CUT_ADAPTATIVE) {
bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision);
}
- else if (ts->bone_sketching_convert == SK_CONVERT_CUT_LENGTH)
- {
+ else if (ts->bone_sketching_convert == SK_CONVERT_CUT_LENGTH) {
bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextLengthSubdivision);
}
- else if (ts->bone_sketching_convert == SK_CONVERT_CUT_FIXED)
- {
+ else if (ts->bone_sketching_convert == SK_CONVERT_CUT_FIXED) {
bone = subdivideArcBy(ts, arm, arm->edbo, iter, invmat, tmat, nextFixedSubdivision);
}
}
- if (bone == NULL)
- {
+ if (bone == NULL) {
bone = ED_armature_edit_bone_add(arm, "Bone");
copy_v3_v3(bone->head, head->p);
@@ -1548,14 +1413,12 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk)
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
/* move to end of chain */
- while (bone->parent != NULL)
- {
+ while (bone->parent != NULL) {
bone = bone->parent;
bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
}
- if (parent != NULL)
- {
+ if (parent != NULL) {
bone->parent = parent;
bone->flag |= BONE_CONNECTED;
}
@@ -1573,16 +1436,12 @@ static void sk_convert(bContext *C, SK_Sketch *sketch)
ToolSettings *ts = CTX_data_tool_settings(C);
SK_Stroke *stk;
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
- if (stk->selected == 1)
- {
- if (ts->bone_sketching_convert == SK_CONVERT_RETARGET)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
+ if (stk->selected == 1) {
+ if (ts->bone_sketching_convert == SK_CONVERT_RETARGET) {
sk_retargetStroke(C, stk);
}
- else
- {
+ else {
sk_convertStroke(C, stk);
}
// XXX
@@ -1600,8 +1459,7 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
int added = 0;
int s_i;
- for (s_i = 0; s_i < gesture->nb_points - 1; s_i++)
- {
+ for (s_i = 0; s_i < gesture->nb_points - 1; s_i++) {
float s_p1[3] = {0, 0, 0};
float s_p2[3] = {0, 0, 0};
int g_i;
@@ -1610,8 +1468,7 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
project_float(ar, gesture->points[s_i + 1].p, s_p2);
/* start checking from second next, because two consecutive cannot intersect */
- for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++)
- {
+ for (g_i = s_i + 2; g_i < gesture->nb_points - 1; g_i++) {
float g_p1[3] = {0, 0, 0};
float g_p2[3] = {0, 0, 0};
float vi[3];
@@ -1620,8 +1477,7 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
project_float(ar, gesture->points[g_i].p, g_p1);
project_float(ar, gesture->points[g_i + 1].p, g_p2);
- if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda))
- {
+ if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
isect->gesture_index = g_i;
@@ -1647,24 +1503,18 @@ static int cmpIntersections(void *i1, void *i2)
{
SK_Intersection *isect1 = i1, *isect2 = i2;
- if (isect1->stroke == isect2->stroke)
- {
- if (isect1->before < isect2->before)
- {
+ if (isect1->stroke == isect2->stroke) {
+ if (isect1->before < isect2->before) {
return -1;
}
- else if (isect1->before > isect2->before)
- {
+ else if (isect1->before > isect2->before) {
return 1;
}
- else
- {
- if (isect1->lambda < isect2->lambda)
- {
+ else {
+ if (isect1->lambda < isect2->lambda) {
return -1;
}
- else if (isect1->lambda > isect2->lambda)
- {
+ else if (isect1->lambda > isect2->lambda) {
return 1;
}
}
@@ -1683,13 +1533,11 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
SK_Stroke *stk;
int added = 0;
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
int s_added = 0;
int s_i;
- for (s_i = 0; s_i < stk->nb_points - 1; s_i++)
- {
+ for (s_i = 0; s_i < stk->nb_points - 1; s_i++) {
float s_p1[3] = {0, 0, 0};
float s_p2[3] = {0, 0, 0};
int g_i;
@@ -1697,8 +1545,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
project_float(ar, stk->points[s_i].p, s_p1);
project_float(ar, stk->points[s_i + 1].p, s_p2);
- for (g_i = 0; g_i < gesture->nb_points - 1; g_i++)
- {
+ for (g_i = 0; g_i < gesture->nb_points - 1; g_i++) {
float g_p1[3] = {0, 0, 0};
float g_p2[3] = {0, 0, 0};
float vi[3];
@@ -1707,8 +1554,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S
project_float(ar, gesture->points[g_i].p, g_p1);
project_float(ar, gesture->points[g_i + 1].p, g_p2);
- if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda))
- {
+ if (isect_line_line_strict_v3(s_p1, s_p2, g_p1, g_p2, vi, &lambda)) {
SK_Intersection *isect = MEM_callocN(sizeof(SK_Intersection), "Intersection");
float ray_start[3], ray_end[3];
float mval[2];
@@ -1759,15 +1605,13 @@ static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
initStrokeIterator(iter, gesture, 0, gesture->nb_points - 1);
- for (i = 1, j = 0; i < gesture->nb_points; i++)
- {
+ for (i = 1, j = 0; i < gesture->nb_points; i++) {
float n[3];
/* Calculate normal */
sub_v3_v3v3(n, gesture->points[i].p, vec);
- if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD)
- {
+ if (calcArcCorrelation(iter, j, i, vec, n) < CORRELATION_THRESHOLD) {
j = i - 1;
sk_appendStrokePoint(segments, &gesture->points[j]);
vec = segments->points[segments->nb_points - 1].p;
@@ -1782,8 +1626,7 @@ static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture)
int sk_detectCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments == 1 && gest->nb_intersections == 1)
- {
+ if (gest->nb_segments == 1 && gest->nb_intersections == 1) {
return 1;
}
@@ -1794,8 +1637,7 @@ void sk_applyCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED
{
SK_Intersection *isect;
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
SK_Point pt;
pt.type = PT_EXACT;
@@ -1809,8 +1651,7 @@ void sk_applyCutGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED
int sk_detectTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments == 2 && gest->nb_intersections == 1 && gest->nb_self_intersections == 0)
- {
+ if (gest->nb_segments == 2 && gest->nb_intersections == 1 && gest->nb_self_intersections == 0) {
float s1[3], s2[3];
float angle;
@@ -1819,8 +1660,7 @@ int sk_detectTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSE
angle = RAD2DEGF(angle_v2v2(s1, s2));
- if (angle > 60 && angle < 120)
- {
+ if (angle > 60 && angle < 120) {
return 1;
}
}
@@ -1835,8 +1675,7 @@ void sk_applyTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSE
sub_v3_v3v3(trim_dir, gest->segments->points[2].p, gest->segments->points[1].p);
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
SK_Point pt;
float stroke_dir[3];
@@ -1848,14 +1687,12 @@ void sk_applyTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSE
sub_v3_v3v3(stroke_dir, isect->stroke->points[isect->after].p, isect->stroke->points[isect->before].p);
/* same direction, trim end */
- if (dot_v3v3(stroke_dir, trim_dir) > 0)
- {
+ if (dot_v3v3(stroke_dir, trim_dir) > 0) {
sk_replaceStrokePoint(isect->stroke, &pt, isect->after);
sk_trimStroke(isect->stroke, 0, isect->after);
}
/* else, trim start */
- else
- {
+ else {
sk_replaceStrokePoint(isect->stroke, &pt, isect->before);
sk_trimStroke(isect->stroke, isect->before, isect->stroke->nb_points - 1);
}
@@ -1865,15 +1702,12 @@ void sk_applyTrimGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSE
int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 1)
- {
+ if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 1) {
SK_Intersection *isect, *self_isect;
/* get the the last intersection of the first pair */
- for ( isect = gest->intersections.first; isect; isect = isect->next )
- {
- if (isect->stroke == isect->next->stroke)
- {
+ for ( isect = gest->intersections.first; isect; isect = isect->next ) {
+ if (isect->stroke == isect->next->stroke) {
isect = isect->next;
break;
}
@@ -1881,8 +1715,7 @@ int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
self_isect = gest->self_intersections.first;
- if (isect && isect->gesture_index < self_isect->gesture_index)
- {
+ if (isect && isect->gesture_index < self_isect->gesture_index) {
return 1;
}
}
@@ -1899,16 +1732,13 @@ void sk_applyCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
// command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3");
if (command < 1) return;
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
SK_Intersection *i2;
i2 = isect->next;
- if (i2 && i2->stroke == isect->stroke)
- {
- switch (command)
- {
+ if (i2 && i2->stroke == isect->stroke) {
+ switch (command) {
case 1:
sk_flattenStroke(isect->stroke, isect->before, i2->after);
break;
@@ -1927,8 +1757,7 @@ void sk_applyCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
int sk_detectDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments == 2 && gest->nb_intersections == 2)
- {
+ if (gest->nb_segments == 2 && gest->nb_intersections == 2) {
float s1[3], s2[3];
float angle;
@@ -1937,8 +1766,7 @@ int sk_detectDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNU
angle = RAD2DEGF(angle_v2v2(s1, s2));
- if (angle > 120)
- {
+ if (angle > 120) {
return 1;
}
}
@@ -1950,11 +1778,9 @@ void sk_applyDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *ske
{
SK_Intersection *isect;
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
/* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke)
- {
+ if (isect->next && isect->next->stroke == isect->stroke) {
isect = isect->next;
sk_removeStroke(sketch, isect->stroke);
@@ -1965,8 +1791,7 @@ void sk_applyDeleteGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *ske
int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
ARegion *ar = CTX_wm_region(C);
- if (gest->nb_segments > 2 && gest->nb_intersections == 2)
- {
+ if (gest->nb_segments > 2 && gest->nb_intersections == 2) {
short start_val[2], end_val[2];
short dist;
@@ -1976,26 +1801,21 @@ 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 */
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
/* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke)
- {
+ if (isect->next && isect->next->stroke == isect->stroke) {
int start_index, end_index;
int i;
start_index = MIN2(isect->after, isect->next->after);
end_index = MAX2(isect->before, isect->next->before);
- for (i = start_index; i <= end_index; i++)
- {
- if (isect->stroke->points[i].type == PT_EXACT)
- {
+ for (i = start_index; i <= end_index; i++) {
+ if (isect->stroke->points[i].type == PT_EXACT) {
return 1; /* at least one exact point found, stop detect here */
}
}
@@ -2015,22 +1835,18 @@ void sk_applyMergeGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUS
SK_Intersection *isect;
/* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
/* only merge strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke)
- {
+ if (isect->next && isect->next->stroke == isect->stroke) {
int start_index, end_index;
int i;
start_index = MIN2(isect->after, isect->next->after);
end_index = MAX2(isect->before, isect->next->before);
- for (i = start_index; i <= end_index; i++)
- {
+ for (i = start_index; i <= end_index; i++) {
/* if exact, switch to continuous */
- if (isect->stroke->points[i].type == PT_EXACT)
- {
+ if (isect->stroke->points[i].type == PT_EXACT) {
isect->stroke->points[i].type = PT_CONTINUOUS;
}
}
@@ -2043,34 +1859,28 @@ void sk_applyMergeGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUS
int sk_detectReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 0)
- {
+ if (gest->nb_segments > 2 && gest->nb_intersections == 2 && gest->nb_self_intersections == 0) {
SK_Intersection *isect;
/* check if it circled around an exact point */
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
/* only delete strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke)
- {
+ if (isect->next && isect->next->stroke == isect->stroke) {
float start_v[3], end_v[3];
float angle;
- if (isect->gesture_index < isect->next->gesture_index)
- {
+ if (isect->gesture_index < isect->next->gesture_index) {
sub_v3_v3v3(start_v, isect->p, gest->stk->points[0].p);
sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->next->p);
}
- else
- {
+ else {
sub_v3_v3v3(start_v, isect->next->p, gest->stk->points[0].p);
sub_v3_v3v3(end_v, sk_lastStrokePoint(gest->stk)->p, isect->p);
}
angle = RAD2DEGF(angle_v2v2(start_v, end_v));
- if (angle > 120)
- {
+ if (angle > 120) {
return 1;
}
@@ -2087,11 +1897,9 @@ void sk_applyReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
{
SK_Intersection *isect;
- for (isect = gest->intersections.first; isect; isect = isect->next)
- {
+ for (isect = gest->intersections.first; isect; isect = isect->next) {
/* only reverse strokes that are crossed twice */
- if (isect->next && isect->next->stroke == isect->stroke)
- {
+ if (isect->next && isect->next->stroke == isect->stroke) {
sk_reverseStroke(isect->stroke);
/* skip next */
@@ -2102,8 +1910,7 @@ void sk_applyReverseGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN
int sk_detectConvertGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UNUSED(sketch))
{
- if (gest->nb_segments == 3 && gest->nb_self_intersections == 1)
- {
+ if (gest->nb_segments == 3 && gest->nb_self_intersections == 1) {
return 1;
}
return 0;
@@ -2142,10 +1949,8 @@ static void sk_applyGesture(bContext *C, SK_Sketch *sketch)
sk_initGesture(C, &gest, sketch);
/* detect and apply */
- for (act = GESTURE_ACTIONS; act->apply != NULL; act++)
- {
- if (act->detect(C, &gest, sketch))
- {
+ for (act = GESTURE_ACTIONS; act->apply != NULL; act++) {
+ if (act->detect(C, &gest, sketch)) {
act->apply(C, &gest, sketch);
break;
}
@@ -2173,8 +1978,7 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in
hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
- if (hits>0)
- {
+ if (hits>0) {
int besthitresult = -1;
if (hits == 1) {
@@ -2185,18 +1989,15 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in
/* loop and get best hit */
}
- if (besthitresult > 0)
- {
+ if (besthitresult > 0) {
SK_Stroke *selected_stk = BLI_findlink(&sketch->strokes, besthitresult - 1);
- if (extend == 0)
- {
+ if (extend == 0) {
sk_selectAllSketch(sketch, -1);
selected_stk->selected = 1;
}
- else
- {
+ else {
selected_stk->selected ^= 1;
}
@@ -2232,50 +2033,41 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
- if (with_names)
- {
+ if (with_names) {
int id;
- for (id = 1, stk = sketch->strokes.first; stk; id++, stk = stk->next)
- {
+ for (id = 1, stk = sketch->strokes.first; stk; id++, stk = stk->next) {
sk_drawStroke(stk, id, NULL, -1, -1);
}
glLoadName(-1);
}
- else
- {
+ else {
float selected_rgb[3] = {1, 0, 0};
float unselected_rgb[3] = {1, 0.5, 0};
- for (stk = sketch->strokes.first; stk; stk = stk->next)
- {
+ for (stk = sketch->strokes.first; stk; stk = stk->next) {
int start = -1;
int end = -1;
- if (sk_hasOverdraw(sketch, stk))
- {
+ if (sk_hasOverdraw(sketch, stk)) {
sk_adjustIndexes(sketch, &start, &end);
}
sk_drawStroke(stk, -1, (stk->selected==1?selected_rgb:unselected_rgb), start, end);
- if (stk->selected == 1)
- {
+ if (stk->selected == 1) {
sk_drawStrokeSubdivision(ts, stk);
}
}
- if (sketch->active_stroke != NULL)
- {
+ if (sketch->active_stroke != NULL) {
SK_Point *last = sk_lastStrokePoint(sketch->active_stroke);
- if (ts->bone_sketching & BONE_SKETCHING_QUICK)
- {
+ if (ts->bone_sketching & BONE_SKETCHING_QUICK) {
sk_drawStrokeSubdivision(ts, sketch->active_stroke);
}
- if (last != NULL)
- {
+ if (last != NULL) {
GLUquadric *quad = gluNewQuadric();
gluQuadricNormals(quad, GLU_SMOOTH);
@@ -2284,8 +2076,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- switch (sketch->next_point.mode)
- {
+ switch (sketch->next_point.mode) {
case PT_SNAP:
glColor3f(0, 1, 0);
break;
@@ -2345,8 +2136,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
glDisable(GL_DEPTH_TEST);
/* only draw gesture in active area */
- if (sketch->gesture != NULL /*&& area_is_active_area(G.vd->area)*/)
- {
+ if (sketch->gesture != NULL /* && area_is_active_area(G.vd->area) */) {
float gesture_rgb[3] = {0, 0.5, 1};
sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1);
}
@@ -2356,20 +2146,16 @@ static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- if (sketch->active_stroke != NULL)
- {
+ if (sketch->active_stroke != NULL) {
SK_Stroke *stk = sketch->active_stroke;
sk_endStroke(C, sketch);
- if (ts->bone_sketching & BONE_SKETCHING_QUICK)
- {
- if (ts->bone_sketching_convert == SK_CONVERT_RETARGET)
- {
+ if (ts->bone_sketching & BONE_SKETCHING_QUICK) {
+ if (ts->bone_sketching_convert == SK_CONVERT_RETARGET) {
sk_retargetStroke(C, stk);
}
- else
- {
+ else {
sk_convertStroke(C, stk);
}
// XXX
@@ -2389,8 +2175,7 @@ static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
static void sk_start_draw_stroke(SK_Sketch *sketch)
{
- if (sketch->active_stroke == NULL)
- {
+ if (sketch->active_stroke == NULL) {
sk_startStroke(sketch);
sk_selectAllSketch(sketch, -1);
@@ -2405,8 +2190,7 @@ static void sk_start_draw_gesture(SK_Sketch *sketch)
static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd, short snap)
{
- if (sk_stroke_filtermval(dd))
- {
+ if (sk_stroke_filtermval(dd)) {
sk_addStrokePoint(C, sketch, stk, dd, snap);
sk_updateDrawData(dd);
sk_updateNextPoint(sketch, stk);
@@ -2428,19 +2212,16 @@ static int ValidSketchViewContext(ViewContext *vc)
{
return 1;
}
- else
- {
+ else {
return 0;
}
}
int BDR_drawSketchNames(ViewContext *vc)
{
- if (ValidSketchViewContext(vc))
- {
+ if (ValidSketchViewContext(vc)) {
SK_Sketch *sketch = viewcontextSketch(vc, 0);
- if (sketch)
- {
+ if (sketch) {
sk_drawSketch(vc->scene, vc->v3d, sketch, 1);
return 1;
}
@@ -2451,11 +2232,9 @@ int BDR_drawSketchNames(ViewContext *vc)
void BDR_drawSketch(const bContext *C)
{
- if (ED_operator_sketch_mode(C))
- {
+ if (ED_operator_sketch_mode(C)) {
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
sk_drawSketch(CTX_data_scene(C), CTX_wm_view3d(C), sketch, 0);
}
}
@@ -2464,8 +2243,7 @@ void BDR_drawSketch(const bContext *C)
static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
sk_deleteSelectedStrokes(sketch);
// allqueue(REDRAWVIEW3D, 0);
}
@@ -2478,8 +2256,7 @@ void BIF_sk_selectStroke(bContext *C, const int mval[2], short extend)
ToolSettings *ts = CTX_data_tool_settings(C);
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING)
- {
+ if (sketch != NULL && ts->bone_sketching & BONE_SKETCHING) {
if (sk_selectStroke(C, sketch, mval, extend))
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -2487,11 +2264,9 @@ void BIF_sk_selectStroke(bContext *C, const int mval[2], short extend)
void BIF_convertSketch(bContext *C)
{
- if (ED_operator_sketch_full_mode(C))
- {
+ if (ED_operator_sketch_full_mode(C)) {
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
sk_convert(C, sketch);
// BIF_undo_push("Convert Sketch");
// allqueue(REDRAWVIEW3D, 0);
@@ -2502,11 +2277,9 @@ void BIF_convertSketch(bContext *C)
void BIF_deleteSketch(bContext *C)
{
- if (ED_operator_sketch_full_mode(C))
- {
+ if (ED_operator_sketch_full_mode(C)) {
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
sk_deleteSelectedStrokes(sketch);
// BIF_undo_push("Convert Sketch");
// allqueue(REDRAWVIEW3D, 0);
@@ -2535,12 +2308,10 @@ SK_Sketch* contextSketch(const bContext *C, int create)
Object *obedit = CTX_data_edit_object(C);
SK_Sketch *sketch = NULL;
- if (obedit && obedit->type == OB_ARMATURE)
- {
+ if (obedit && obedit->type == OB_ARMATURE) {
bArmature *arm = obedit->data;
- if (arm->sketch == NULL && create)
- {
+ if (arm->sketch == NULL && create) {
arm->sketch = createSketch();
}
sketch = arm->sketch;
@@ -2554,12 +2325,10 @@ SK_Sketch* viewcontextSketch(ViewContext *vc, int create)
Object *obedit = vc->obedit;
SK_Sketch *sketch = NULL;
- if (obedit && obedit->type == OB_ARMATURE)
- {
+ if (obedit && obedit->type == OB_ARMATURE) {
bArmature *arm = obedit->data;
- if (arm->sketch == NULL && create)
- {
+ if (arm->sketch == NULL && create) {
arm->sketch = createSketch();
}
sketch = arm->sketch;
@@ -2571,8 +2340,7 @@ SK_Sketch* viewcontextSketch(ViewContext *vc, int create)
static int sketch_convert(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL)
- {
+ if (sketch != NULL) {
sk_convert(C, sketch);
ED_area_tag_redraw(CTX_wm_area(C));
}
@@ -2582,8 +2350,7 @@ static int sketch_convert(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(e
static int sketch_cancel(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL)
- {
+ if (sketch != NULL) {
sk_cancelStroke(sketch);
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
@@ -2594,10 +2361,8 @@ static int sketch_cancel(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev
static int sketch_finish(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch != NULL)
- {
- if (sk_finish_stroke(C, sketch))
- {
+ if (sketch != NULL) {
+ if (sk_finish_stroke(C, sketch)) {
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
@@ -2608,8 +2373,7 @@ static int sketch_finish(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev
static int sketch_select(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
{
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
short extend = 0;
if (sk_selectStroke(C, sketch, event->mval, extend))
ED_area_tag_redraw(CTX_wm_area(C));
@@ -2677,8 +2441,7 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
SK_Sketch *sketch = contextSketch(C, 1); /* create just to be sure */
int retval = OPERATOR_RUNNING_MODAL;
- switch (event->type)
- {
+ switch (event->type) {
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
snap = event->ctrl;
@@ -2697,10 +2460,8 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
retval = OPERATOR_CANCELLED;
break;
case LEFTMOUSE:
- if (event->val == KM_RELEASE)
- {
- if (gesture == 0)
- {
+ if (event->val == KM_RELEASE) {
+ if (gesture == 0) {
sk_endContinuousStroke(stk);
sk_filterLastContinuousStroke(stk);
sk_updateNextPoint(sketch, stk);
@@ -2708,13 +2469,11 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short
MEM_freeN(op->customdata);
retval = OPERATOR_FINISHED;
}
- else
- {
+ else {
sk_endContinuousStroke(stk);
sk_filterLastContinuousStroke(stk);
- if (stk->nb_points > 1)
- {
+ if (stk->nb_points > 1) {
/* apply gesture here */
sk_applyGesture(C, sketch);
}
@@ -2750,8 +2509,7 @@ static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event)
short snap = RNA_boolean_get(op->ptr, "snap");
SK_Sketch *sketch = contextSketch(C, 0);
- if (sketch)
- {
+ if (sketch) {
SK_DrawData dd;
sk_initDrawData(&dd, event->mval);
@@ -2775,8 +2533,7 @@ int ED_operator_sketch_mode_active_stroke(bContext *C)
{
return 1;
}
- else
- {
+ else {
return 0;
}
}
@@ -2793,8 +2550,7 @@ static int ED_operator_sketch_mode_gesture(bContext *C)
{
return 1;
}
- else
- {
+ else {
return 0;
}
}
@@ -2811,8 +2567,7 @@ int ED_operator_sketch_full_mode(bContext *C)
{
return 1;
}
- else
- {
+ else {
return 0;
}
}
@@ -2828,8 +2583,7 @@ int ED_operator_sketch_mode(const bContext *C)
{
return 1;
}
- else
- {
+ else {
return 0;
}
}
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 2799d7994bc..ea2b28380e0 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -897,10 +897,12 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
}
else if (pchan->bone) {
/* only ok if bone is visible and selected */
- if ( (pchan->bone->flag & BONE_SELECTED) &&
- (pchan->bone->flag & BONE_HIDDEN_P)==0 &&
- (pchan->bone->layer & arm->layer) )
+ if ((pchan->bone->flag & BONE_SELECTED) &&
+ (pchan->bone->flag & BONE_HIDDEN_P) == 0 &&
+ (pchan->bone->layer & arm->layer))
+ {
ok = 1;
+ }
}
if (ok)
diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c
index 546bcb1f40f..f5e7770a7fc 100644
--- a/source/blender/editors/armature/reeb.c
+++ b/source/blender/editors/armature/reeb.c
@@ -183,16 +183,14 @@ void REEB_freeGraph(ReebGraph *rg)
ReebNode *node;
// free nodes
- for ( node = rg->nodes.first; node; node = node->next )
- {
+ for (node = rg->nodes.first; node; node = node->next) {
BLI_freeNode((BGraph*)rg, (BNode*)node);
}
BLI_freelistN(&rg->nodes);
// free arcs
arc = rg->arcs.first;
- while ( arc )
- {
+ while ( arc ) {
ReebArc *next = arc->next;
REEB_freeArc((BArc*)arc);
arc = next;
@@ -202,8 +200,7 @@ void REEB_freeGraph(ReebGraph *rg)
BLI_edgehash_free(rg->emap, NULL);
/* free linked graph */
- if (rg->link_up)
- {
+ if (rg->link_up) {
REEB_freeGraph(rg->link_up);
}
@@ -229,8 +226,7 @@ ReebGraph * newReebGraph(void)
void BIF_flagMultiArcs(ReebGraph *rg, int flag)
{
- for ( ; rg; rg = rg->link_up)
- {
+ for ( ; rg; rg = rg->link_up) {
BLI_flagArcs((BGraph*)rg, flag);
}
}
@@ -318,8 +314,7 @@ ReebNode *BIF_NodeFromIndex(ReebArc *arc, ReebNode *node)
ReebNode *BIF_lowestLevelNode(ReebNode *node)
{
- while (node->link_down)
- {
+ while (node->link_down) {
node = node->link_down;
}
@@ -407,8 +402,7 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node)
{
ReebGraph *multi_rg = rg;
- while (multi_rg && multi_rg->multi_level != node->multi_level)
- {
+ while (multi_rg && multi_rg->multi_level != node->multi_level) {
multi_rg = multi_rg->link_up;
}
@@ -484,15 +478,12 @@ void repositionNodes(ReebGraph *rg)
BNode *node = NULL;
// Reset node positions
- for (node = rg->nodes.first; node; node = node->next)
- {
+ for (node = rg->nodes.first; node; node = node->next) {
node->p[0] = node->p[1] = node->p[2] = 0;
}
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (((ReebArc*)arc)->bcount > 0)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (((ReebArc*)arc)->bcount > 0) {
float p[3];
copy_v3_v3(p, ((ReebArc*)arc)->buckets[0].p);
@@ -512,22 +503,17 @@ void verifyNodeDegree(ReebGraph *rg)
ReebNode *node = NULL;
ReebArc *arc = NULL;
- for (node = rg->nodes.first; node; node = node->next)
- {
+ for (node = rg->nodes.first; node; node = node->next) {
int count = 0;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (arc->head == node || arc->tail == node)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (arc->head == node || arc->tail == node) {
count++;
}
}
- if (count != node->degree)
- {
+ if (count != node->degree) {
printf("degree error in node %i: expected %i got %i\n", node->index, count, node->degree);
}
- if (node->degree == 0)
- {
+ if (node->degree == 0) {
printf("zero degree node %i with weight %f\n", node->index, node->weight);
}
}
@@ -539,25 +525,20 @@ static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc)
ReebNode *head = (ReebNode*)arc->head;
ReebNode *tail = (ReebNode*)arc->tail;
- if (arc->bcount > 0)
- {
+ if (arc->bcount > 0) {
int i;
- for (i = 0; i < arc->bcount; i++)
- {
- if (arc->buckets[i].nv == 0)
- {
+ 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);
}
}
- if (ceilf(head->weight) != arc->buckets[0].val)
- {
+ if (ceilf(head->weight) != arc->buckets[0].val) {
printArc(arc);
printf("alloc error in first bucket: %f should be %f\n", arc->buckets[0].val, ceil(head->weight));
}
- if (floorf(tail->weight) != arc->buckets[arc->bcount - 1].val)
- {
+ if (floorf(tail->weight) != arc->buckets[arc->bcount - 1].val) {
printArc(arc);
printf("alloc error in last bucket: %f should be %f\n", arc->buckets[arc->bcount - 1].val, floor(tail->weight));
}
@@ -568,8 +549,7 @@ void verifyBuckets(ReebGraph *rg)
{
#ifdef DEBUG_REEB
ReebArc *arc = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
verifyBucketsArc(rg, arc);
}
#endif
@@ -580,8 +560,7 @@ void verifyFaces(ReebGraph *rg)
#ifdef DEBUG_REEB
int total = 0;
ReebArc *arc = NULL;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
total += BLI_ghash_size(arc->faces);
}
@@ -592,10 +571,8 @@ void verifyArcs(ReebGraph *rg)
{
ReebArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (arc->head->weight > arc->tail->weight)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (arc->head->weight > arc->tail->weight) {
printf("FLIPPED ARC!\n");
}
}
@@ -606,14 +583,11 @@ static void verifyMultiResolutionLinks(ReebGraph *rg, int level)
#ifdef DEBUG_REEB
ReebGraph *lower_rg = rg->link_up;
- if (lower_rg)
- {
+ if (lower_rg) {
ReebArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1) {
printf("missing arc %p for level %i\n", (void *)arc->link_up, level);
printf("Source arc was ---\n");
printArc(arc);
@@ -647,13 +621,11 @@ static void removeVertFromBucket(EmbedBucket *b, float co[3])
static void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc)
{
- if (bDst->nv > 0 && bSrc->nv > 0)
- {
+ if (bDst->nv > 0 && bSrc->nv > 0) {
bDst->nv += bSrc->nv;
interp_v3_v3v3(bDst->p, bDst->p, bSrc->p, (float)bSrc->nv / (float)(bDst->nv));
}
- else if (bSrc->nv > 0)
- {
+ else if (bSrc->nv > 0) {
bDst->nv = bSrc->nv;
copy_v3_v3(bDst->p, bSrc->p);
}
@@ -661,19 +633,16 @@ static void mergeBuckets(EmbedBucket *bDst, EmbedBucket *bSrc)
static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end)
{
- if (aDst->bcount > 0 && aSrc->bcount > 0)
- {
+ if (aDst->bcount > 0 && aSrc->bcount > 0) {
int indexDst = 0, indexSrc = 0;
start = MAX3(start, aDst->buckets[0].val, aSrc->buckets[0].val);
- while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start)
- {
+ while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) {
indexDst++;
}
- while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start)
- {
+ while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) {
indexSrc++;
}
@@ -693,8 +662,7 @@ void flipArcBuckets(ReebArc *arc)
{
int i, j;
- for (i = 0, j = arc->bcount - 1; i < j; i++, j--)
- {
+ for (i = 0, j = arc->bcount - 1; i < j; i++, j--) {
EmbedBucket tmp;
tmp = arc->buckets[i];
@@ -714,20 +682,16 @@ static void allocArcBuckets(ReebArc *arc)
float start = ceil(arc->head->weight);
arc->bcount = countArcBuckets(arc);
- if (arc->bcount > 0)
- {
+ if (arc->bcount > 0) {
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "embed bucket");
- for (i = 0; i < arc->bcount; i++)
- {
+ for (i = 0; i < arc->bcount; i++) {
arc->buckets[i].val = start + i;
}
}
- else
- {
+ else {
arc->buckets = NULL;
}
-
}
static void resizeArcBuckets(ReebArc *arc)
@@ -735,15 +699,13 @@ static void resizeArcBuckets(ReebArc *arc)
EmbedBucket *oldBuckets = arc->buckets;
int oldBCount = arc->bcount;
- if (countArcBuckets(arc) == oldBCount)
- {
+ if (countArcBuckets(arc) == oldBCount) {
return;
}
allocArcBuckets(arc);
- if (oldBCount != 0 && arc->bcount != 0)
- {
+ if (oldBCount != 0 && arc->bcount != 0) {
int oldStart = (int)oldBuckets[0].val;
int oldEnd = (int)oldBuckets[oldBCount - 1].val;
int newStart = (int)arc->buckets[0].val;
@@ -752,12 +714,10 @@ static void resizeArcBuckets(ReebArc *arc)
int newOffset = 0;
int len;
- if (oldStart < newStart)
- {
+ if (oldStart < newStart) {
oldOffset = newStart - oldStart;
}
- else
- {
+ else {
newOffset = oldStart - newStart;
}
@@ -766,8 +726,7 @@ static void resizeArcBuckets(ReebArc *arc)
memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket));
}
- if (oldBuckets != NULL)
- {
+ if (oldBuckets != NULL) {
MEM_freeN(oldBuckets);
}
}
@@ -777,10 +736,8 @@ static void reweightBuckets(ReebArc *arc)
int i;
float start = ceil((arc->head)->weight);
- if (arc->bcount > 0)
- {
- for (i = 0; i < arc->bcount; i++)
- {
+ if (arc->bcount > 0) {
+ for (i = 0; i < arc->bcount; i++) {
arc->buckets[i].val = start + i;
}
}
@@ -793,8 +750,7 @@ static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int s
total = end_index - start_index + 2;
- for (j = start_index; j <= end_index; j++)
- {
+ for (j = start_index; j <= end_index; j++) {
EmbedBucket *empty = arc->buckets + j;
empty->nv = 1;
interp_v3_v3v3(empty->p, start_p, end_p, (float)(j - start_index + 1) / total);
@@ -810,14 +766,11 @@ static void fillArcEmptyBuckets(ReebArc *arc)
start_p = arc->head->p;
- for (i = 0; i < arc->bcount; i++)
- {
+ for (i = 0; i < arc->bcount; i++) {
EmbedBucket *bucket = arc->buckets + i;
- if (missing)
- {
- if (bucket->nv > 0)
- {
+ if (missing) {
+ if (bucket->nv > 0) {
missing = 0;
end_p = bucket->p;
@@ -826,14 +779,11 @@ static void fillArcEmptyBuckets(ReebArc *arc)
interpolateBuckets(arc, start_p, end_p, start_index, end_index);
}
}
- else
- {
- if (bucket->nv == 0)
- {
+ else {
+ if (bucket->nv == 0) {
missing = 1;
- if (i > 0)
- {
+ if (i > 0) {
start_p = arc->buckets[i - 1].p;
}
start_index = i;
@@ -841,8 +791,7 @@ static void fillArcEmptyBuckets(ReebArc *arc)
}
}
- if (missing)
- {
+ if (missing) {
end_p = arc->tail->p;
end_index = arc->bcount - 1;
@@ -859,8 +808,7 @@ static void ExtendArcBuckets(ReebArc *arc)
float average_length = 0, length;
int padding_head = 0, padding_tail = 0;
- if (arc->bcount == 0)
- {
+ if (arc->bcount == 0) {
return; /* failsafe, shouldn't happen */
}
@@ -881,19 +829,16 @@ static void ExtendArcBuckets(ReebArc *arc)
last_bucket = arc->buckets + (arc->bcount - 1);
length = len_v3v3(first_bucket->p, arc->head->p);
- if (length > 2 * average_length)
- {
+ if (length > 2 * average_length) {
padding_head = (int)floor(length / average_length);
}
length = len_v3v3(last_bucket->p, arc->tail->p);
- if (length > 2 * average_length)
- {
+ if (length > 2 * average_length) {
padding_tail = (int)floor(length / average_length);
}
- if (padding_head + padding_tail > 0)
- {
+ if (padding_head + padding_tail > 0) {
EmbedBucket *old_buckets = arc->buckets;
arc->buckets = MEM_callocN(sizeof(EmbedBucket) * (padding_head + arc->bcount + padding_tail), "embed bucket");
@@ -904,13 +849,11 @@ static void ExtendArcBuckets(ReebArc *arc)
MEM_freeN(old_buckets);
}
- if (padding_head > 0)
- {
+ if (padding_head > 0) {
interpolateBuckets(arc, arc->head->p, first_bucket->p, 0, padding_head);
}
- if (padding_tail > 0)
- {
+ if (padding_tail > 0) {
interpolateBuckets(arc, last_bucket->p, arc->tail->p, arc->bcount - padding_tail, arc->bcount - 1);
}
}
@@ -920,8 +863,7 @@ static void extendGraphBuckets(ReebGraph *rg)
{
ReebArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
ExtendArcBuckets(arc);
}
}
@@ -941,8 +883,7 @@ static void calculateArcLength(ReebArc *arc)
vec0 = arc->head->p;
vec1 = arc->head->p; /* in case there's no embedding */
- while (IT_next(iter))
- {
+ while (IT_next(iter)) {
vec1 = iter->p;
arc->length += len_v3v3(vec0, vec1);
@@ -957,8 +898,7 @@ static void calculateGraphLength(ReebGraph *rg)
{
ReebArc *arc;
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
calculateArcLength(arc);
}
}
@@ -975,8 +915,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
copy_v3_v3(axis, root_node->symmetry_axis);
/* first pass, merge incrementally */
- for (i = 0; i < count - 1; i++)
- {
+ for (i = 0; i < count - 1; i++) {
ReebNode *node1, *node2;
ReebArc *arc1, *arc2;
float tangent[3];
@@ -999,8 +938,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
/* Merge buckets
* there shouldn't be any null arcs here, but just to be safe
* */
- if (arc1->bcount > 0 && arc2->bcount > 0)
- {
+ if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
@@ -1013,19 +951,16 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
bucket2 = IT_next(iter2);
/* Make sure they both start at the same value */
- while (bucket1 && bucket2 && bucket1->val < bucket2->val)
- {
+ while (bucket1 && bucket2 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
- while (bucket1 && bucket2 && bucket2->val < bucket1->val)
- {
+ while (bucket1 && bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
- 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 */
@@ -1037,8 +972,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
}
/* second pass, mirror back on previous arcs */
- for (i = count - 1; i > 0; i--)
- {
+ for (i = count - 1; i > 0; i--) {
ReebNode *node1, *node2;
ReebArc *arc1, *arc2;
float tangent[3];
@@ -1061,8 +995,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
/* Copy buckets
* there shouldn't be any null arcs here, but just to be safe
* */
- if (arc1->bcount > 0 && arc2->bcount > 0)
- {
+ if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
@@ -1075,19 +1008,16 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count)
bucket2 = IT_next(iter2);
/* Make sure they both start at the same value */
- while (bucket1 && bucket1->val < bucket2->val)
- {
+ while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
- while (bucket2 && bucket2->val < bucket1->val)
- {
+ while (bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
- 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);
@@ -1122,8 +1052,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr
/* Merge buckets
* there shouldn't be any null arcs here, but just to be safe
* */
- if (arc1->bcount > 0 && arc2->bcount > 0)
- {
+ if (arc1->bcount > 0 && arc2->bcount > 0) {
ReebArcIterator arc_iter1, arc_iter2;
BArcIterator *iter1 = (BArcIterator*)&arc_iter1;
BArcIterator *iter2 = (BArcIterator*)&arc_iter2;
@@ -1136,19 +1065,16 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr
bucket2 = IT_next(iter2);
/* Make sure they both start at the same value */
- while (bucket1 && bucket1->val < bucket2->val)
- {
+ while (bucket1 && bucket1->val < bucket2->val) {
bucket1 = IT_next(iter1);
}
- while (bucket2 && bucket2->val < bucket1->val)
- {
+ while (bucket2 && bucket2->val < bucket1->val) {
bucket2 = IT_next(iter2);
}
- 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 */
@@ -1175,7 +1101,7 @@ void postprocessGraph(ReebGraph *rg, char mode)
ReebArc *arc;
float fac1 = 0, fac2 = 1, fac3 = 0;
- switch(mode)
+ switch (mode)
{
case SKGEN_AVERAGE:
fac1 = fac2 = fac3 = 1.0f / 3.0f;
@@ -1490,16 +1416,13 @@ static int compareArcs(void *varc1, void *varc2)
float len1 = lengthArc(arc1);
float len2 = lengthArc(arc2);
- if (len1 < len2)
- {
+ if (len1 < len2) {
return -1;
}
- if (len1 > len2)
- {
+ if (len1 > len2) {
return 1;
}
- else
- {
+ else {
return 0;
}
}
@@ -1508,13 +1431,10 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
{
ReebArc *arc = NULL, *nextArc = NULL;
- if (merging)
- {
+ if (merging) {
/* first pass, merge buckets for arcs that spawned the two nodes into the source arc*/
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
- if (arc->head == srcArc->head && arc->tail == srcArc->tail && arc != srcArc)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
+ if (arc->head == srcArc->head && arc->tail == srcArc->tail && arc != srcArc) {
ReebNode *head = srcArc->head;
ReebNode *tail = srcArc->tail;
mergeArcBuckets(srcArc, arc, head->weight, tail->weight);
@@ -1524,47 +1444,38 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R
/* second pass, replace removedNode by newNode, remove arcs that are collapsed in a loop */
arc = rg->arcs.first;
- while (arc)
- {
+ while (arc) {
nextArc = arc->next;
- if (arc->head == removedNode || arc->tail == removedNode)
- {
- if (arc->head == removedNode)
- {
+ if (arc->head == removedNode || arc->tail == removedNode) {
+ if (arc->head == removedNode) {
arc->head = newNode;
}
- else
- {
+ else {
arc->tail = newNode;
}
// Remove looped arcs
- if (arc->head == arc->tail)
- {
+ if (arc->head == arc->tail) {
// v1 or v2 was already newNode, since we're removing an arc, decrement degree
NodeDegreeDecrement(rg, newNode);
// If it's srcArc, it'll be removed later, so keep it for now
- if (arc != srcArc)
- {
+ if (arc != srcArc) {
BLI_remlink(&rg->arcs, arc);
REEB_freeArc((BArc*)arc);
}
}
- else
- {
+ else {
/* flip arcs that flipped, can happen on diamond shapes, mostly on null arcs */
- if (arc->head->weight > arc->tail->weight)
- {
+ if (arc->head->weight > arc->tail->weight) {
flipArc(arc);
}
//newNode->degree++; // incrementing degree since we're adding an arc
NodeDegreeIncrement(rg, newNode);
mergeArcFaces(rg, arc, srcArc);
- if (merging)
- {
+ if (merging) {
ReebNode *head = arc->head;
ReebNode *tail = arc->tail;
@@ -1587,12 +1498,10 @@ void filterNullReebGraph(ReebGraph *rg)
ReebArc *arc = NULL, *nextArc = NULL;
arc = rg->arcs.first;
- while (arc)
- {
+ while (arc) {
nextArc = arc->next;
// Only collapse arcs too short to have any embed bucket
- if (arc->bcount == 0)
- {
+ if (arc->bcount == 0) {
ReebNode *newNode = (ReebNode*)arc->head;
ReebNode *removedNode = (ReebNode*)arc->tail;
float blend;
@@ -1623,12 +1532,14 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
BLI_sortlist(&rg->arcs, compareArcs);
- for (arc = rg->arcs.first; arc; arc = nextArc)
- {
+ for (arc = rg->arcs.first; arc; arc = nextArc) {
nextArc = arc->next;
- // Only collapse non-terminal arcs that are shorter than threshold
- if (threshold_internal > 0 && arc->head->degree > 1 && arc->tail->degree > 1 && (lengthArc(arc) < threshold_internal))
+ /* Only collapse non-terminal arcs that are shorter than threshold */
+ if ((threshold_internal > 0) &&
+ (arc->head->degree > 1) &&
+ (arc->tail->degree > 1) &&
+ (lengthArc(arc) < threshold_internal))
{
ReebNode *newNode = NULL;
ReebNode *removedNode = NULL;
@@ -1650,26 +1561,25 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
}
// Only collapse terminal arcs that are shorter than threshold
- else if (threshold_external > 0 && (arc->head->degree == 1 || arc->tail->degree == 1) && (lengthArc(arc) < threshold_external))
+ else if ((threshold_external > 0) &&
+ (arc->head->degree == 1 || arc->tail->degree == 1) &&
+ (lengthArc(arc) < threshold_external))
{
ReebNode *terminalNode = NULL;
ReebNode *middleNode = NULL;
ReebNode *removedNode = NULL;
// Assign terminal and middle nodes
- if (arc->head->degree == 1)
- {
+ if (arc->head->degree == 1) {
terminalNode = arc->head;
middleNode = arc->tail;
}
- else
- {
+ else {
terminalNode = arc->tail;
middleNode = arc->head;
}
- if (middleNode->degree == 2 && middleNode != rg->nodes.first)
- {
+ if (middleNode->degree == 2 && middleNode != rg->nodes.first) {
#if 1
// If middle node is a normal node, it will be removed later
// Only if middle node is not the root node
@@ -1685,8 +1595,7 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern
#endif
}
// Otherwise, just plain remove of the arc
- else
- {
+ else {
removedNode = terminalNode;
// removing arc, so we need to decrease the degree of the remaining node
@@ -1713,13 +1622,10 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold)
ReebArc *next2;
int filtered = 0;
- for (arc1 = rg->arcs.first; arc1; arc1 = arc1->next)
- {
- for (arc2 = arc1->next; arc2; arc2 = next2)
- {
+ for (arc1 = rg->arcs.first; arc1; arc1 = arc1->next) {
+ for (arc2 = arc1->next; arc2; arc2 = next2) {
next2 = arc2->next;
- if (arc1 != arc2 && arc1->head == arc2->head && arc1->tail == arc2->tail)
- {
+ if (arc1 != arc2 && arc1->head == arc2->head && arc1->tail == arc2->tail) {
mergeArcEdges(rg, arc1, arc2, MERGE_APPEND);
mergeArcFaces(rg, arc1, arc2);
mergeArcBuckets(arc1, arc2, arc1->head->weight, arc1->tail->weight);
@@ -1848,8 +1754,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
if (avg_angle > threshold)
merging = 1;
- if (merging)
- {
+ if (merging) {
ReebNode *terminalNode = NULL;
ReebNode *middleNode = NULL;
ReebNode *newNode = NULL;
@@ -1857,39 +1762,33 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold))
int merging = 0;
// Assign terminal and middle nodes
- if (arc->head->degree == 1)
- {
+ if (arc->head->degree == 1) {
terminalNode = arc->head;
middleNode = arc->tail;
}
- else
- {
+ else {
terminalNode = arc->tail;
middleNode = arc->head;
}
// If middle node is a normal node, merge to terminal node
- if (middleNode->degree == 2)
- {
+ if (middleNode->degree == 2) {
merging = 1;
newNode = terminalNode;
removedNode = middleNode;
}
// Otherwise, just plain remove of the arc
- else
- {
+ else {
merging = 0;
newNode = middleNode;
removedNode = terminalNode;
}
// Merging arc
- if (merging)
- {
+ if (merging) {
filterArc(rg, newNode, removedNode, arc, 1);
}
- else
- {
+ else {
// removing arc, so we need to decrease the degree of the remaining node
//newNode->degree--;
NodeDegreeDecrement(rg, newNode);
@@ -1920,29 +1819,24 @@ static void filterGraph(ReebGraph *rg, short options, float threshold_internal,
calculateGraphLength(rg);
- if ((options & SKGEN_FILTER_EXTERNAL) == 0)
- {
+ if ((options & SKGEN_FILTER_EXTERNAL) == 0) {
threshold_external = 0;
}
- if ((options & SKGEN_FILTER_INTERNAL) == 0)
- {
+ if ((options & SKGEN_FILTER_INTERNAL) == 0) {
threshold_internal = 0;
}
- if (threshold_internal > 0 || threshold_external > 0)
- {
+ if (threshold_internal > 0 || threshold_external > 0) {
/* filter until there's nothing more to do */
- while (done == 1)
- {
+ while (done == 1) {
done = 0; /* no work done yet */
done = filterInternalExternalReebGraph(rg, threshold_internal, threshold_external);
}
}
- if (options & SKGEN_FILTER_SMART)
- {
+ if (options & SKGEN_FILTER_SMART) {
filterSmartReebGraph(rg, 0.5);
filterCyclesReebGraph(rg, 0.5);
}
@@ -1963,8 +1857,7 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method)
sortArcs(rg);
- for (i = 0; i < passes; i++)
- {
+ for (i = 0; i < passes; i++) {
postprocessGraph(rg, method);
}
@@ -1979,12 +1872,10 @@ static int compareVerts( const void* a, const void* b )
EditVert *vb = *(EditVert**)b;
int value = 0;
- if (weightData(va) < weightData(vb))
- {
+ if (weightData(va) < weightData(vb)) {
value = -1;
}
- else if (weightData(va) > weightData(vb))
- {
+ else if (weightData(va) > weightData(vb)) {
value = 1;
}
@@ -2001,26 +1892,21 @@ static void spreadWeight(EditMesh *em)
verts = MEM_callocN(sizeof(EditVert*) * totvert, "verts array");
- for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++)
- {
+ for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) {
verts[i] = eve;
}
- while (work_needed == 1)
- {
+ while (work_needed == 1) {
work_needed = 0;
qsort(verts, totvert, sizeof(EditVert*), compareVerts);
- for (i = 0; i < totvert; i++)
- {
+ for (i = 0; i < totvert; i++) {
eve = verts[i];
- if (i == 0 || (weightData(eve) - lastWeight) > FLT_EPSILON)
- {
+ if (i == 0 || (weightData(eve) - lastWeight) > FLT_EPSILON) {
lastWeight = weightData(eve);
}
- else
- {
+ else {
work_needed = 1;
weightSetData(eve, lastWeight + FLT_EPSILON * 2);
lastWeight = weightData(eve);
@@ -2044,8 +1930,7 @@ void REEB_exportGraph(ReebGraph *rg, int count)
char filename[128];
FILE *f;
- if (count == -1)
- {
+ if (count == -1) {
strcpy(filename, "test.txt");
}
else {
@@ -2053,15 +1938,13 @@ void REEB_exportGraph(ReebGraph *rg, int count)
}
f = BLI_fopen(filename, "w");
- for (arc = rg->arcs.first; arc; arc = arc->next)
- {
+ for (arc = rg->arcs.first; arc; arc = arc->next) {
int i;
float p[3];
exportNode(f, "v1", arc->head);
- for (i = 0; i < arc->bcount; i++)
- {
+ for (i = 0; i < arc->bcount; i++) {
fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]);
}
@@ -2082,12 +1965,10 @@ static void removeZeroNodes(ReebGraph *rg)
{
ReebNode *node, *next_node;
- for (node = rg->nodes.first; node; node = next_node)
- {
+ for (node = rg->nodes.first; node; node = next_node) {
next_node = node->next;
- if (node->degree == 0)
- {
+ if (node->degree == 0) {
BLI_removeNode((BGraph*)rg, (BNode*)node);
}
}
@@ -2098,63 +1979,51 @@ void removeNormalNodes(ReebGraph *rg)
ReebArc *arc, *nextArc;
// Merge degree 2 nodes
- for (arc = rg->arcs.first; arc; arc = nextArc)
- {
+ for (arc = rg->arcs.first; arc; arc = nextArc) {
nextArc = arc->next;
- while (arc->head->degree == 2 || arc->tail->degree == 2)
- {
+ while (arc->head->degree == 2 || arc->tail->degree == 2) {
// merge at v1
- if (arc->head->degree == 2)
- {
+ if (arc->head->degree == 2) {
ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->head);
/* If arcs are one after the other */
- if (arc->head == connectedArc->tail)
- {
+ if (arc->head == connectedArc->tail) {
/* remove furthest arc */
- if (arc->tail->weight < connectedArc->head->weight)
- {
+ if (arc->tail->weight < connectedArc->head->weight) {
mergeConnectedArcs(rg, arc, connectedArc);
nextArc = arc->next;
}
- else
- {
+ else {
mergeConnectedArcs(rg, connectedArc, arc);
break; /* arc was removed, move to next */
}
}
/* Otherwise, arcs are side by side */
- else
- {
+ else {
/* Don't do anything, we need to keep the lowest node, even if degree 2 */
break;
}
}
- // merge at v2
- if (arc->tail->degree == 2)
- {
+ /* merge at v2 */
+ if (arc->tail->degree == 2) {
ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->tail);
/* If arcs are one after the other */
- if (arc->tail == connectedArc->head)
- {
+ if (arc->tail == connectedArc->head) {
/* remove furthest arc */
- if (arc->head->weight < connectedArc->tail->weight)
- {
+ if (arc->head->weight < connectedArc->tail->weight) {
mergeConnectedArcs(rg, arc, connectedArc);
nextArc = arc->next;
}
- else
- {
+ else {
mergeConnectedArcs(rg, connectedArc, arc);
break; /* arc was removed, move to next */
}
}
/* Otherwise, arcs are side by side */
- else
- {
+ else {
/* Don't do anything, we need to keep the lowest node, even if degree 2 */
break;
}
@@ -2176,13 +2045,11 @@ static ReebArc *nextArcMappedToEdge(ReebArc *arc, ReebEdge *e)
ReebArc *result = NULL;
/* Find the ReebEdge in the edge list */
- for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next)
- { }
+ for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) { }
nextEdge = edge->nextEdge;
- if (nextEdge != NULL)
- {
+ if (nextEdge != NULL) {
result = nextEdge->arc;
}
@@ -2211,51 +2078,42 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d
{
ReebEdge *e = NULL;
- if (direction == MERGE_APPEND)
- {
- for (e = aSrc->edges.first; e; e = e->next)
- {
+ if (direction == MERGE_APPEND) {
+ for (e = aSrc->edges.first; e; e = e->next) {
e->arc = aDst; // Edge is stolen by new arc
}
BLI_movelisttolist(&aDst->edges , &aSrc->edges);
}
- else
- {
- for (e = aSrc->edges.first; e; e = e->next)
- {
+ else {
+ for (e = aSrc->edges.first; e; e = e->next) {
ReebEdge *newEdge = copyEdge(e);
newEdge->arc = aDst;
BLI_addtail(&aDst->edges, newEdge);
- if (direction == MERGE_LOWER)
- {
+ if (direction == MERGE_LOWER) {
void **p = BLI_edgehash_lookup_p(rg->emap, e->v1->index, e->v2->index);
newEdge->nextEdge = e;
// if edge was the first in the list, point the edit edge to the new reeb edge instead.
- if (*p == e)
- {
+ if (*p == e) {
*p = (void*)newEdge;
}
// otherwise, advance in the list until the predecessor is found then insert it there
- else
- {
+ else {
ReebEdge *previous = (ReebEdge*)*p;
- while (previous->nextEdge != e)
- {
+ while (previous->nextEdge != e) {
previous = previous->nextEdge;
}
previous->nextEdge = newEdge;
}
}
- else
- {
+ else {
newEdge->nextEdge = e->nextEdge;
e->nextEdge = newEdge;
}
@@ -2275,13 +2133,11 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
mergeArcFaces(rg, a0, a1);
// Bring a0 to the combine length of both arcs
- if (a0->tail == a1->head)
- {
+ if (a0->tail == a1->head) {
removedNode = a0->tail;
a0->tail = a1->tail;
}
- else if (a0->head == a1->tail)
- {
+ else if (a0->head == a1->tail) {
removedNode = a0->head;
a0->head = a1->head;
}
@@ -2303,11 +2159,9 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
{
int result = 0;
- // TRIANGLE POINTS DOWN
- if (a0->head->weight == a1->head->weight) // heads are the same
- {
- if (a0->tail->weight == a1->tail->weight) // tails also the same, arcs can be totally merge together
- {
+ /* TRIANGLE POINTS DOWN */
+ if (a0->head->weight == a1->head->weight) { /* heads are the same */
+ if (a0->tail->weight == a1->tail->weight) { /* tails also the same, arcs can be totally merge together */
mergeArcEdges(rg, a0, a1, MERGE_APPEND);
mergeArcFaces(rg, a0, a1);
@@ -2325,8 +2179,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
REEB_freeArc((BArc*)a1);
result = 1;
}
- else if (a0->tail->weight > a1->tail->weight) // a1->tail->weight is in the middle
- {
+ else if (a0->tail->weight > a1->tail->weight) { /* a1->tail->weight is in the middle */
mergeArcEdges(rg, a1, a0, MERGE_LOWER);
mergeArcFaces(rg, a1, a0);
@@ -2340,8 +2193,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
a0->head = a1->tail;
resizeArcBuckets(a0);
}
- else // a0>n2 is in the middle
- {
+ else { /* a0>n2 is in the middle */
mergeArcEdges(rg, a0, a1, MERGE_LOWER);
mergeArcFaces(rg, a0, a1);
@@ -2356,11 +2208,9 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
resizeArcBuckets(a1);
}
}
- // TRIANGLE POINTS UP
- else if (a0->tail->weight == a1->tail->weight) // tails are the same
- {
- if (a0->head->weight > a1->head->weight) // a0->head->weight is in the middle
- {
+ /* TRIANGLE POINTS UP */
+ else if (a0->tail->weight == a1->tail->weight) { /* tails are the same */
+ if (a0->head->weight > a1->head->weight) { /* a0->head->weight is in the middle */
mergeArcEdges(rg, a0, a1, MERGE_HIGHER);
mergeArcFaces(rg, a0, a1);
@@ -2374,8 +2224,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
a1->tail = a0->head;
resizeArcBuckets(a1);
}
- else // a1->head->weight is in the middle
- {
+ else { /* a1->head->weight is in the middle */
mergeArcEdges(rg, a1, a0, MERGE_HIGHER);
mergeArcFaces(rg, a1, a0);
@@ -2390,9 +2239,8 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
resizeArcBuckets(a0);
}
}
- else
- {
- // Need something here (OR NOT)
+ else {
+ /* Need something here (OR NOT) */
}
return result;
@@ -2401,18 +2249,14 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1)
static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e0, ReebEdge *e1)
{
int total = 0;
- while (total == 0 && a0 != a1 && a0 != NULL && a1 != NULL)
- {
+ while (total == 0 && a0 != a1 && a0 != NULL && a1 != NULL) {
total = mergeArcs(rg, a0, a1);
- if (total == 0) // if it wasn't a total merge, go forward
- {
- if (a0->tail->weight < a1->tail->weight)
- {
+ if (total == 0) // if it wasn't a total merge, go forward {
+ if (a0->tail->weight < a1->tail->weight) {
a0 = nextArcMappedToEdge(a0, e0);
}
- else
- {
+ else {
a1 = nextArcMappedToEdge(a1, e1);
}
}
@@ -2437,8 +2281,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
edge = BLI_edgehash_lookup(rg->emap, node1->index, node2->index);
// Only add existing edges that haven't been added yet
- if (edge == NULL)
- {
+ if (edge == NULL) {
ReebArc *arc;
ReebNode *v1, *v2;
float len, offset;
@@ -2451,13 +2294,11 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
arc->symmetry_level = 0;
arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createArc gh");
- if (node1->weight <= node2->weight)
- {
+ if (node1->weight <= node2->weight) {
v1 = node1;
v2 = node2;
}
- else
- {
+ else {
v1 = node2;
v2 = node1;
}
@@ -2497,8 +2338,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
addVertToBucket(&(arc->buckets[arc->bcount - 1]), arc->tail->co);
}
#else
- for (i = 0; i < arc->bcount; i++)
- {
+ for (i = 0; i < arc->bcount; i++) {
float co[3];
float f = (arc->buckets[i].val - offset) / len;
@@ -2532,20 +2372,17 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, Reeb
/* The rest of the algorithm assumes that e1 is the longest edge */
- if (len1 >= len2 && len1 >= len3)
- {
+ if (len1 >= len2 && len1 >= len3) {
e1 = re1;
e2 = re2;
e3 = re3;
}
- else if (len2 >= len1 && len2 >= len3)
- {
+ else if (len2 >= len1 && len2 >= len3) {
e1 = re2;
e2 = re1;
e3 = re3;
}
- else
- {
+ else {
e1 = re3;
e2 = re2;
e3 = re1;
@@ -2554,8 +2391,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, Reeb
/* And e2 is the lowest edge
* If e3 is lower than e2, swap them
*/
- if (e3->v1->weight < e2->v1->weight)
- {
+ if (e3->v1->weight < e2->v1->weight) {
ReebEdge *etmp = e2;
e2 = e3;
e3 = etmp;
@@ -2595,10 +2431,8 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions)
renormalizeWeight(em, (float)rg->resolution);
/* Adding vertice */
- for (index = 0, eve = em->verts.first; eve; eve = eve->next)
- {
- if (eve->h == 0)
- {
+ for (index = 0, eve = em->verts.first; eve; eve = eve->next) {
+ if (eve->h == 0) {
addNode(rg, eve);
eve->f2 = 0;
index++;
@@ -2606,10 +2440,8 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions)
}
/* Adding face, edge per edge */
- for (efa = em->faces.first; efa; efa = efa->next)
- {
- if (efa->h == 0)
- {
+ for (efa = em->faces.first; efa; efa = efa->next) {
+ if (efa->h == 0) {
ReebNode *n1, *n2, *n3;
n1 = nodeData(efa->v1);
@@ -2618,15 +2450,13 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions)
addTriangleToGraph(rg, n1, n2, n3, efa);
- if (efa->v4)
- {
+ if (efa->v4) {
ReebNode *n4 = nodeData(efa->v4);
addTriangleToGraph(rg, n1, n3, n4, efa);
}
#ifdef DEBUG_REEB
countfaces++;
- if (countfaces % 100 == 0)
- {
+ if (countfaces % 100 == 0) {
printf("\rface %i of %i", countfaces, totfaces);
}
#endif
@@ -2656,8 +2486,7 @@ void renormalizeWeight(EditMesh *em, float newmax)
eve = em->verts.first;
minimum = weightData(eve);
maximum = minimum;
- for (; eve; eve = eve->next)
- {
+ for (; eve; eve = eve->next) {
maximum = MAX2(maximum, weightData(eve));
minimum = MIN2(minimum, weightData(eve));
}
@@ -2665,8 +2494,7 @@ void renormalizeWeight(EditMesh *em, float newmax)
range = maximum - minimum;
/* Normalize weights */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
float weight = (weightData(eve) - minimum) / range * newmax;
weightSetData(eve, weight);
}
@@ -2681,8 +2509,7 @@ int weightFromLoc(EditMesh *em, int axis)
return 0;
/* Copy coordinate in weight */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
weightSetData(eve, eve->co[axis]);
}
@@ -2745,8 +2572,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
int rval;
/* Find local extrema */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
totvert++;
}
@@ -2759,52 +2585,42 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
nlBegin(NL_SYSTEM);
/* Find local extrema */
- for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next)
- {
- if (eve->h == 0)
- {
+ for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) {
+ if (eve->h == 0) {
EditEdge *eed;
int maximum = 1;
int minimum = 1;
NextEdgeForVert(indexed_edges, -1); /* Reset next edge */
- for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index))
- {
+ for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) {
EditVert *eve2;
- if (eed->v1 == eve)
- {
+ if (eed->v1 == eve) {
eve2 = eed->v2;
}
- else
- {
+ else {
eve2 = eed->v1;
}
- if (eve2->h == 0)
- {
+ if (eve2->h == 0) {
/* Adjacent vertex is bigger, not a local maximum */
- if (weightData(eve2) > weightData(eve))
- {
+ if (weightData(eve2) > weightData(eve)) {
maximum = 0;
}
/* Adjacent vertex is smaller, not a local minimum */
- else if (weightData(eve2) < weightData(eve))
- {
+ else if (weightData(eve2) < weightData(eve)) {
minimum = 0;
}
}
}
- if (maximum || minimum)
- {
+ if (maximum || minimum) {
float w = weightData(eve);
eve->f1 = 0;
nlSetVariable(0, index, w);
nlLockVariable(index);
}
- else
- {
+ else {
eve->f1 = 1;
}
}
@@ -2813,38 +2629,30 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
nlBegin(NL_MATRIX);
/* Zero edge weight */
- for (eed = em->edges.first; eed; eed = eed->next)
- {
+ for (eed = em->edges.first; eed; eed = eed->next) {
eed->tmp.l = 0;
}
/* Add faces count to the edge weight */
- for (efa = em->faces.first; efa; efa = efa->next)
- {
- if (efa->h == 0)
- {
+ for (efa = em->faces.first; efa; efa = efa->next) {
+ if (efa->h == 0) {
efa->e1->tmp.l++;
efa->e2->tmp.l++;
efa->e3->tmp.l++;
- if (efa->e4)
- {
+ if (efa->e4) {
efa->e4->tmp.l++;
}
}
}
/* Add faces angle to the edge weight */
- for (efa = em->faces.first; efa; efa = efa->next)
- {
- if (efa->h == 0)
- {
- if (efa->v4 == NULL)
- {
+ for (efa = em->faces.first; efa; efa = efa->next) {
+ if (efa->h == 0) {
+ if (efa->v4 == NULL) {
addTriangle(efa->v1, efa->v2, efa->v3, efa->e1->tmp.l, efa->e2->tmp.l, efa->e3->tmp.l);
}
- else
- {
+ else {
addTriangle(efa->v1, efa->v2, efa->v3, efa->e1->tmp.l, efa->e2->tmp.l, 2);
addTriangle(efa->v3, efa->v4, efa->v1, efa->e3->tmp.l, efa->e4->tmp.l, 2);
}
@@ -2857,16 +2665,13 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges)
success = nlSolveAdvanced(NULL, NL_TRUE);
- if (success)
- {
+ if (success) {
rval = 1;
- for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next)
- {
+ for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) {
weightSetData(eve, nlGetVariable(0, index));
}
}
- else
- {
+ else {
rval = 0;
}
@@ -2881,20 +2686,17 @@ EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index)
static int offset = -1;
/* Reset method, call with NULL mesh pointer */
- if (index == -1)
- {
+ if (index == -1) {
offset = -1;
return NULL;
}
/* first pass, start at the head of the list */
- if (offset == -1)
- {
+ if (offset == -1) {
offset = indexed_edges->offset[index];
}
/* subsequent passes, start on the next edge */
- else
- {
+ else {
offset++;
}
@@ -2916,23 +2718,19 @@ 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;
}
- while (BLI_heap_size(edge_heap) > 0)
- {
+ while (BLI_heap_size(edge_heap) > 0) {
float current_weight;
current_eve->f1 = 1; /* mark vertex as selected */
/* Add all new edges connected to current_eve to the list */
NextEdgeForVert(indexed_edges, -1); // Reset next edge
- for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve)))
- {
- if (eed->f1 == 0)
- {
+ for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) {
+ if (eed->f1 == 0) {
BLI_heap_insert(edge_heap, weightData(current_eve) + eed->tmp.fp, eed);
eed->f1 = 1;
}
@@ -2945,16 +2743,13 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd
select_eed = BLI_heap_popmin(edge_heap);
} while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1);
- if (select_eed != NULL)
- {
+ if (select_eed != NULL) {
select_eed->f1 = 2;
- if (select_eed->v1->f1 == 0) /* v1 is the new vertex */
- {
+ if (select_eed->v1->f1 == 0) /* v1 is the new vertex */ {
current_eve = select_eed->v1;
}
- else /* otherwise, it's v2 */
- {
+ else { /* otherwise, it's v2 */
current_eve = select_eed->v2;
}
@@ -2983,10 +2778,8 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
indexed_edges->offset = MEM_callocN(totvert * sizeof(int), "EdgeIndex offset");
- for (eed = em->edges.first; eed; eed = eed->next)
- {
- if (eed->v1->h == 0 && eed->v2->h == 0)
- {
+ for (eed = em->edges.first; eed; eed = eed->next) {
+ if (eed->v1->h == 0 && eed->v2->h == 0) {
tot_indexed += 2;
indexed_edges->offset[indexData(eed->v1)]++;
indexed_edges->offset[indexData(eed->v2)]++;
@@ -2998,10 +2791,8 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge*), "EdgeIndex edges");
/* setting vert offsets */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
- if (eve->h == 0)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
+ if (eve->h == 0) {
int d = indexed_edges->offset[indexData(eve)];
indexed_edges->offset[indexData(eve)] = offset;
offset += d + 1;
@@ -3009,24 +2800,18 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges)
}
/* adding edges in array */
- for (eed = em->edges.first; eed; eed= eed->next)
- {
- if (eed->v1->h == 0 && eed->v2->h == 0)
- {
+ 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++)
- {
- if (indexed_edges->edges[i] == NULL)
- {
+ for (i = indexed_edges->offset[indexData(eed->v1)]; i < tot_indexed; i++) {
+ if (indexed_edges->edges[i] == NULL) {
indexed_edges->edges[i] = eed;
break;
}
}
- for (i = indexed_edges->offset[indexData(eed->v2)]; i < tot_indexed; i++)
- {
- if (indexed_edges->edges[i] == NULL)
- {
+ for (i = indexed_edges->offset[indexData(eed->v2)]; i < tot_indexed; i++) {
+ if (indexed_edges->edges[i] == NULL) {
indexed_edges->edges[i] = eed;
break;
}
@@ -3044,80 +2829,64 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
totvert = BLI_countlist(&em->verts);
- if (em == NULL || totvert == 0)
- {
+ if (em == NULL || totvert == 0) {
return 0;
}
totedge = BLI_countlist(&em->edges);
- if (totedge == 0)
- {
+ if (totedge == 0) {
return 0;
}
/* Initialize vertice flag and find at least one selected vertex */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
eve->f1 = 0;
- if (eve->f & SELECT)
- {
+ if (eve->f & SELECT) {
vCount = 1;
}
}
- if (vCount == 0)
- {
+ if (vCount == 0) {
return 0; /* no selected vert, failure */
}
- else
- {
+ else {
EditEdge *eed;
int allDone = 0;
/* Calculate edge weight */
- for (eed = em->edges.first; eed; eed= eed->next)
- {
- if (eed->v1->h == 0 && eed->v2->h == 0)
- {
+ 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);
}
}
/* Apply dijkstra spf for each selected vert */
- for (eve = em->verts.first; eve; eve = eve->next)
- {
- if (eve->f & SELECT)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
+ if (eve->f & SELECT) {
shortestPathsFromVert(em, eve, indexed_edges);
}
}
/* connect unselected islands */
- while (allDone == 0)
- {
+ while (allDone == 0) {
EditVert *selected_eve = NULL;
float selected_weight = 0;
float min_distance = FLT_MAX;
allDone = 1;
- for (eve = em->verts.first; eve; eve = eve->next)
- {
+ for (eve = em->verts.first; eve; eve = eve->next) {
/* for every vertex visible that hasn't been processed yet */
- if (eve->h == 0 && eve->f1 != 1)
- {
+ if (eve->h == 0 && eve->f1 != 1) {
EditVert *closest_eve;
/* find the closest processed vertex */
- for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next)
- {
+ for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next) {
/* vertex is already processed and distance is smaller than current minimum */
- if (closest_eve->f1 == 1)
- {
+ if (closest_eve->f1 == 1) {
float distance = len_v3v3(closest_eve->co, eve->co);
- if (distance < min_distance)
- {
+ if (distance < min_distance) {
min_distance = distance;
selected_eve = eve;
selected_weight = weightData(closest_eve);
@@ -3127,8 +2896,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
}
}
- if (selected_eve)
- {
+ if (selected_eve) {
allDone = 0;
weightSetData(selected_eve, selected_weight + min_distance);
@@ -3137,10 +2905,8 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges)
}
}
- for (eve = em->verts.first; eve && vCount == 0; eve = eve->next)
- {
- if (eve->f1 == 0)
- {
+ for (eve = em->verts.first; eve && vCount == 0; eve = eve->next) {
+ if (eve->f1 == 0) {
printf("vertex not reached\n");
break;
}
@@ -3173,13 +2939,11 @@ static void initIteratorFct(ReebArcIterator *iter)
static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket)
{
- if (bucket)
- {
+ if (bucket) {
iter->p = bucket->p;
iter->no = bucket->no;
}
- else
- {
+ else {
iter->p = NULL;
iter->no = NULL;
}
@@ -3193,14 +2957,12 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head)
initIteratorFct(iter);
iter->arc = arc;
- if (head == arc->head)
- {
+ if (head == arc->head) {
iter->start = 0;
iter->end = arc->bcount - 1;
iter->stride = 1;
}
- else
- {
+ else {
iter->start = arc->bcount - 1;
iter->end = 0;
iter->stride = -1;
@@ -3218,14 +2980,12 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod
initIteratorFct(iter);
iter->arc = arc;
- if (head == arc->head)
- {
+ if (head == arc->head) {
iter->start = start;
iter->end = arc->bcount - 1;
iter->stride = 1;
}
- else
- {
+ else {
iter->start = arc->bcount - 1 - start;
iter->end = 0;
iter->stride = -1;
@@ -3235,8 +2995,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod
iter->length = arc->bcount - start;
- if (start >= arc->bcount)
- {
+ if (start >= arc->bcount) {
iter->start = iter->end; /* stop iterator since it's past its end */
}
}
@@ -3251,12 +3010,10 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end)
iter->start = start;
iter->end = end;
- if (end > start)
- {
+ if (end > start) {
iter->stride = 1;
}
- else
- {
+ else {
iter->stride = -1;
}
@@ -3270,12 +3027,10 @@ static void* headNode(void *arg)
ReebArcIterator *iter = (ReebArcIterator*)arg;
ReebNode *node;
- if (iter->start < iter->end)
- {
+ if (iter->start < iter->end) {
node = iter->arc->head;
}
- else
- {
+ else {
node = iter->arc->tail;
}
@@ -3291,12 +3046,10 @@ static void* tailNode(void *arg)
ReebArcIterator *iter = (ReebArcIterator*)arg;
ReebNode *node;
- if (iter->start < iter->end)
- {
+ if (iter->start < iter->end) {
node = iter->arc->tail;
}
- else
- {
+ else {
node = iter->arc->head;
}
@@ -3314,8 +3067,7 @@ static void* nextBucket(void *arg)
iter->index++;
- if (iter->index < iter->length)
- {
+ if (iter->index < iter->length) {
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
}
@@ -3331,8 +3083,7 @@ static void* nextNBucket(void *arg, int n)
iter->index += n;
/* check if passed end */
- if (iter->index < iter->length)
- {
+ if (iter->index < iter->length) {
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
}
@@ -3347,8 +3098,7 @@ static void* peekBucket(void *arg, int n)
int index = iter->index + n;
/* check if passed end */
- if (index < iter->length)
- {
+ if (index < iter->length) {
result = &(iter->arc->buckets[iter->start + (iter->stride * index)]);
}
@@ -3361,8 +3111,7 @@ static void* previousBucket(void *arg)
ReebArcIterator *iter = (ReebArcIterator*)arg;
EmbedBucket *result = NULL;
- if (iter->index > 0)
- {
+ if (iter->index > 0) {
iter->index--;
result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]);
}
@@ -3375,12 +3124,10 @@ static int iteratorStopped(void *arg)
{
ReebArcIterator *iter = (ReebArcIterator*)arg;
- if (iter->index >= iter->length)
- {
+ if (iter->index >= iter->length) {
return 1;
}
- else
- {
+ else {
return 0;
}
}
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index c19041b817e..0b21e514f0e 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -6207,7 +6207,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob)
nu->resolv= cu->resolv;
}
- switch(stype) {
+ switch (stype) {
case CU_PRIM_CURVE: /* curve */
nu->resolu= cu->resolu;
if (cutype==CU_BEZIER) {
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index 1f1d1495276..29bebfab9e0 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -520,13 +520,17 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines)
}
/********************** utilities ***************************/
-
static short next_word(Curve *cu)
{
short s;
- for (s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
- (cu->str[s]!=1) && (cu->str[s]!='\r'); s++);
- if (cu->str[s]) return(s+1); else return(s);
+ for (s=cu->pos; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') &&
+ (cu->str[s] != 1) && (cu->str[s] != '\r'));
+ s++)
+ {
+ /* pass */
+ }
+
+ return cu->str[s] ? (s + 1) : s;
}
static short prev_word(Curve *cu)
@@ -534,9 +538,14 @@ static short prev_word(Curve *cu)
short s;
if (cu->pos==0) return(0);
- for (s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') &&
- (cu->str[s]!=1) && (cu->str[s]!='\r'); s--);
- if (cu->str[s]) return(s+1); else return(s);
+ for (s = cu->pos - 2; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') &&
+ (cu->str[s] != 1) && (cu->str[s] != '\r'));
+ s--)
+ {
+ /* pass */
+ }
+
+ return cu->str[s] ? (s + 1) : s;
}
static int kill_selection(Object *obedit, int ins) /* 1 == new character */
@@ -816,7 +825,7 @@ static int move_cursor(bContext *C, int type, int select)
EditFont *ef= cu->editfont;
int cursmove= -1;
- switch(type) {
+ switch (type) {
case LINE_BEGIN:
if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1;
while (cu->pos>0) {
@@ -1121,7 +1130,7 @@ static int delete_exec(bContext *C, wmOperator *op)
else if (type == DEL_PREV_SEL) type= DEL_PREV_CHAR;
}
- switch(type) {
+ switch (type) {
case DEL_ALL:
cu->len = cu->pos = 0;
ef->textbuf[0]= 0;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a7ff1565c3d..e64446be84b 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -782,8 +782,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to)
/* (1) get the object */
CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) {
- for (sens_iter = ob_iter->sensors.first; sens_iter; sens_iter = sens_iter->next)
- {
+ for (sens_iter = ob_iter->sensors.first; sens_iter; sens_iter = sens_iter->next) {
if (&(sens_iter->links) == sens_from_links) {
ob = ob_iter;
break;
@@ -1564,8 +1563,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste
len = strlen(str);
}
- for (y = 0; y < strlen(buf); y++)
- {
+ for (y = 0; y < strlen(buf); y++) {
/* add contents of buffer */
if (len + 1 < data->maxlen) {
for (x = data->maxlen; x > but->pos; x--)
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index cce037822e3..03ceeb68c4c 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1061,8 +1061,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect)
/* after the leading text is gone, chop off the : and following space, with ofs */
- while ((but->strwidth > okwidth) && (but->ofs < 2))
- {
+ while ((but->strwidth > okwidth) && (but->ofs < 2)) {
ui_text_clip_give_next_off(but);
but->strwidth = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs);
if (but->strwidth < 10) break;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 9f4a351c66d..2d222059fc1 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1151,8 +1151,7 @@ void UI_ThemeClearColor(int colorid)
void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis)
{
- switch (axis)
- {
+ switch (axis) {
case 'X':
dst_col[0] = src_col[0] > 219 ? 255 : src_col[0] + 36;
dst_col[1] = src_col[1] < 26 ? 0 : src_col[1] - 26;
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index e88b34b5812..f68c40d5f8a 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -927,7 +927,9 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
//"Erase Only Faces";
if (!EDBM_op_callf(em, op, "del geom=%hf context=%i",
BM_ELEM_SELECT, DEL_ONLYFACES))
+ {
return OPERATOR_CANCELLED;
+ }
}
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
@@ -1021,8 +1023,7 @@ static int edbm_add_edge_face__smooth_get(BMesh *bm)
unsigned int vote_on_smooth[2] = {0, 0};
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
- if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l)
- {
+ if (BM_elem_flag_test(e, BM_ELEM_SELECT) && e->l) {
vote_on_smooth[BM_elem_flag_test_bool(e->l->f, BM_ELEM_SMOOTH)]++;
}
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 96fb2afbac4..0a6368daf74 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -928,9 +928,10 @@ static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, f
/* ignore nan verts */
if (!finite(co[0]) ||
!finite(co[1]) ||
- !finite(co[2])
- )
+ !finite(co[2]))
+ {
return NULL;
+ }
vec[0] = -co[0];
vec[1] = co[1];
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 3717591e412..ba527e6fa6a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -430,7 +430,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type)
ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer);
rename_id(&ob->id, "Field");
- switch(type) {
+ switch (type) {
case PFIELD_WIND:
case PFIELD_VORTEX:
ob->empty_drawtype = OB_SINGLE_ARROW;
@@ -1680,7 +1680,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base
id= obn->data;
didit= 0;
- switch(obn->type) {
+ switch (obn->type) {
case OB_MESH:
if (dupflag & USER_DUP_MESH) {
ID_NEW_US2( obn->data )
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 1f012c6f0be..8b22b4613b8 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -862,7 +862,7 @@ static void bake_images(MultiresBakeRender *bkr)
if (ibuf->x>0 && ibuf->y>0) {
ibuf->userdata= MEM_callocN(ibuf->y*ibuf->x, "MultiresBake imbuf mask");
- switch(bkr->mode) {
+ switch (bkr->mode) {
case RE_BAKE_NORMALS:
do_multires_bake(bkr, ima, apply_tangmat_callback, init_normal_data, NULL, free_normal_data);
break;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 2fbc2966bc8..8531ec5701d 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1354,14 +1354,16 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(
ob = CTX_data_active_object(C);
while (ob && input->identifier) {
if ((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) ||
- (ob->type == OB_CURVE) || (ob->type == OB_SURF) ||
- (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) ||
- (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
- (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) ||
- ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT ||
- input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) ||
- (input->value == OB_MODE_OBJECT))
+ (ob->type == OB_CURVE) || (ob->type == OB_SURF) ||
+ (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) ||
+ (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) ||
+ (input->value == OB_MODE_PARTICLE_EDIT && ob->particlesystem.first) ||
+ ((input->value == OB_MODE_SCULPT || input->value == OB_MODE_VERTEX_PAINT ||
+ input->value == OB_MODE_WEIGHT_PAINT || input->value == OB_MODE_TEXTURE_PAINT) && (ob->type == OB_MESH)) ||
+ (input->value == OB_MODE_OBJECT))
+ {
RNA_enum_item_add(&item, &totitem, input);
+ }
++input;
}
@@ -1401,7 +1403,7 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o
if (mode == OB_MODE_OBJECT)
return 1;
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
if (mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT))
return 1;
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index ef428b5b1b7..f4d8cd5ae11 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -301,7 +301,7 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int *
*tot= 0;
name[0]= 0;
- switch(obedit->type) {
+ switch (obedit->type) {
case OB_MESH:
{
Mesh *me= obedit->data;
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index a666f04034b..40e852ebf7c 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1232,7 +1232,7 @@ enum {
/* Return 1 if make link data is allow, zero otherwise */
static int allow_make_links_data(int ev, Object *ob, Object *obt)
{
- switch(ev) {
+ switch (ev) {
case MAKE_LINKS_OBDATA:
if (ob->type == obt->type && ob->type != OB_EMPTY)
return 1;
@@ -1268,7 +1268,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) {
if (ob != obt) {
if (allow_make_links_data(event, ob, obt)) {
- switch(event) {
+ switch (event) {
case MAKE_LINKS_OBDATA: /* obdata */
id= obt->data;
id->us--;
@@ -1464,7 +1464,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag)
BKE_copy_animdata_id_action(id);
- switch(ob->type) {
+ switch (ob->type) {
case OB_LAMP:
ob->data= la= copy_lamp(ob->data);
for (a=0; a<MAX_MTEX; a++) {
diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c
index 79b1ca13c9e..9e31fc2d765 100644
--- a/source/blender/editors/object/object_shapekey.c
+++ b/source/blender/editors/object/object_shapekey.c
@@ -113,7 +113,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob)
if (key->refkey) {
/* apply new basis key on original data */
- switch(ob->type) {
+ switch (ob->type) {
case OB_MESH:
key_to_mesh(key->refkey, ob->data);
break;
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index b5c34f1c750..e74819f10bf 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -184,7 +184,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
*dvert_arr = NULL;
if (id) {
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_ME:
{
Mesh *me = (Mesh *)id;
@@ -287,7 +287,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to
int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot)
{
if (id) {
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_ME:
{
Mesh *me = (Mesh *)id;
@@ -412,7 +412,7 @@ static void ED_vgroup_nr_vert_add(Object *ob,
dw= defvert_find_index(dv, def_nr);
if (dw) {
- switch(assignmode) {
+ switch (assignmode) {
case WEIGHT_REPLACE:
dw->weight = weight;
break;
@@ -437,7 +437,7 @@ static void ED_vgroup_nr_vert_add(Object *ob,
* we must take a different form of action ...
*/
- switch(assignmode) {
+ switch (assignmode) {
case WEIGHT_SUBTRACT:
/* if we are subtracting then we don't
* need to do anything
@@ -1043,8 +1043,9 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in
dm_deform_clear(dm, ob); dm = NULL;
}
}
- } while (wasChange && (distToStart-distToBe)/fabsf(distToStart-distToBe) ==
- (dists[bestIndex]-distToBe)/fabsf(dists[bestIndex]-distToBe));
+ } while (wasChange && ((distToStart - distToBe) / fabsf(distToStart - distToBe) ==
+ (dists[bestIndex] - distToBe) / fabsf(dists[bestIndex] - distToBe)));
+
MEM_freeN(upDown);
MEM_freeN(changes);
MEM_freeN(dists);
@@ -1193,7 +1194,7 @@ static void vgroup_lock_all(Object *ob, int action)
}
for (dg= ob->defbase.first; dg; dg= dg->next) {
- switch(action) {
+ switch (action) {
case SEL_SELECT:
dg->flag |= DG_LOCK_WEIGHT;
break;
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 417cddb74fe..c82e0459218 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -291,8 +291,7 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf
if (!dynamicPaint_createUVSurface(surface)) return 0;
/* Loop through selected frames */
- for (frame=surface->start_frame; frame<=surface->end_frame; frame++)
- {
+ for (frame=surface->start_frame; frame<=surface->end_frame; frame++) {
float progress = (frame - surface->start_frame) / (float)frames * 100;
surface->current_frame = frame;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 591015a7479..4f8f2ea3642 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -215,7 +215,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create)
/* in the case of only one editable thing, set pset->edittype accordingly */
if (pidlist.first && pidlist.first == pidlist.last) {
pid = pidlist.first;
- switch(pid->type) {
+ switch (pid->type) {
case PTCACHE_TYPE_PARTICLES:
pset->edittype = PE_TYPE_PARTICLES;
break;
@@ -477,10 +477,12 @@ static int key_inside_rect(PEData *data, const float co[3])
if (sco[0] == IS_CLIPPED)
return 0;
-
+
if (sco[0] > data->rect->xmin && sco[0] < data->rect->xmax &&
- sco[1] > data->rect->ymin && sco[1] < data->rect->ymax)
+ sco[1] > data->rect->ymin && sco[1] < data->rect->ymax)
+ {
return key_test_depth(data, co);
+ }
return 0;
}
@@ -3493,7 +3495,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
mval[0] = bedit->lastmouse[0] + step*dx;
mval[1] = bedit->lastmouse[1] + step*dy;
- switch(pset->brushtype) {
+ switch (pset->brushtype) {
case PE_BRUSH_COMB:
{
float mval_f[2];
@@ -3710,7 +3712,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int brush_edit_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case MIDDLEMOUSE:
case RIGHTMOUSE: // XXX hardcoded
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 20fa4c5753f..c0d3e505873 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -594,8 +594,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom
int channelObjCount = 0;
int fluidInputCount = 0;
- for (base=scene->base.first; base; base= base->next)
- {
+ for (base=scene->base.first; base; base= base->next) {
Object *ob = base->object;
FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index bed17048ea1..eb1688a76e2 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -115,7 +115,7 @@ void ED_region_pixelspace(ARegion *ar)
void ED_region_do_listen(ARegion *ar, wmNotifier *note)
{
/* generic notes first */
- switch(note->category) {
+ switch (note->category) {
case NC_WM:
if (note->data==ND_FILEREAD)
ED_region_tag_redraw(ar);
@@ -247,7 +247,7 @@ static void region_draw_azone_tab_plus(AZone *az)
glEnable(GL_BLEND);
/* add code to draw region hidden as 'too small' */
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
break;
@@ -282,7 +282,7 @@ static void region_draw_azone_tab(AZone *az)
glColor4f(col[0], col[1], col[2], 0.5f);
/* add code to draw region hidden as 'too small' */
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA);
@@ -325,7 +325,7 @@ static void region_draw_azone_tria(AZone *az)
glColor4f(0.0f, 0.0f, 0.0f, 0.35f);
/* add code to draw region hidden as 'too small' */
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1+az->x2)/2, (float)az->y2);
break;
@@ -623,7 +623,7 @@ static void area_azone_initialize(ScrArea *sa)
#define AZONEPAD_ICON 9
static void region_azone_edge(AZone *az, ARegion *ar)
{
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
az->x1= ar->winrct.xmin;
az->y1= ar->winrct.ymax - AZONEPAD_EDGE;
@@ -665,7 +665,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar)
if (azt->edge == az->edge) tot++;
}
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON;
az->y1= ar->winrct.ymax + AZONEPAD_ICON;
@@ -725,7 +725,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar)
if (azt->edge == az->edge) tot++;
}
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW;
@@ -770,7 +770,7 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar)
if (azt->edge == az->edge) tot++;
}
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW;
@@ -815,7 +815,7 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar)
if (azt->edge == az->edge) tot++;
}
- switch(az->edge) {
+ switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT:
if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0;
az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW;
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 5ba0e86e0c1..5b73645abde 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -825,7 +825,7 @@ int bglPointHack(void)
void bglVertex3fv(const float vec[3])
{
- switch(curmode) {
+ switch (curmode) {
case GL_POINTS:
if (pointhack) {
glRasterPos3fv(vec);
@@ -838,7 +838,7 @@ void bglVertex3fv(const float vec[3])
void bglVertex3f(float x, float y, float z)
{
- switch(curmode) {
+ switch (curmode) {
case GL_POINTS:
if (pointhack) {
glRasterPos3f(x, y, z);
@@ -851,7 +851,7 @@ void bglVertex3f(float x, float y, float z)
void bglVertex2fv(const float vec[2])
{
- switch(curmode) {
+ switch (curmode) {
case GL_POINTS:
if (pointhack) {
glRasterPos2fv(vec);
@@ -882,11 +882,15 @@ void bgl_get_mats(bglMats *mats)
/* Very strange code here - it seems that certain bad values in the
* modelview matrix can cause gluUnProject to give bad results. */
if (mats->modelview[0] < badvalue &&
- mats->modelview[0] > -badvalue)
- mats->modelview[0]= 0;
+ mats->modelview[0] > -badvalue)
+ {
+ mats->modelview[0] = 0;
+ }
if (mats->modelview[5] < badvalue &&
- mats->modelview[5] > -badvalue)
- mats->modelview[5]= 0;
+ mats->modelview[5] > -badvalue)
+ {
+ mats->modelview[5] = 0;
+ }
/* Set up viewport so that gluUnProject will give correct values */
mats->viewport[0] = 0;
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index cafa4527c20..512cd404273 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -963,7 +963,7 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note)
wmWindow *win= CTX_wm_window(C);
/* generic notes */
- switch(note->category) {
+ switch (note->category) {
case NC_WM:
if (note->data==ND_FILEREAD)
win->screen->do_draw= 1;
@@ -1009,7 +1009,7 @@ void ED_screen_draw(wmWindow *win)
if (sa1 && sa2) {
dir = area_getorientation(sa1, sa2);
if (dir >= 0) {
- switch(dir) {
+ switch (dir) {
case 0: /* W */
dir = 'r';
dira = 'l';
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index e427e1e21cf..3777547fa90 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -597,7 +597,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
int deltax, deltay;
int mindelta= sad->az->type==AZONE_REGION?1:12;
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
/* calculate gesture direction */
deltax= (event->x - sad->x);
@@ -735,7 +735,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
{
sActionzoneData *sad= op->customdata;
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
/* second area, for join */
sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
@@ -1045,7 +1045,7 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event)
int delta, x, y;
/* execute the events */
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
x= RNA_int_get(op->ptr, "x");
@@ -1438,7 +1438,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
int dir;
/* execute the events */
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
dir= RNA_enum_get(op->ptr, "direction");
@@ -1711,7 +1711,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
int delta;
/* execute the events */
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) {
@@ -2262,7 +2262,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
/* execute the events */
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
{
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 5d4710accad..553a9a335d7 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -377,7 +377,9 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush,
/* check for overlay mode */
if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) ||
!(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED)))
+ {
return;
+ }
/* save lots of GL state
* TODO: check on whether all of these are needed? */
@@ -566,7 +568,9 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
+ {
outline_col = brush->sub_col;
+ }
/* only do if brush is over the mesh */
if (hit)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 157be337823..507fbe0f4b8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2817,8 +2817,10 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss)
/* update the clip tolerance */
if (mmd->tolerance >
ss->cache->clip_tolerance[i])
+ {
ss->cache->clip_tolerance[i] =
- mmd->tolerance;
+ mmd->tolerance;
+ }
}
}
}
@@ -2928,8 +2930,11 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio
SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB,
SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE))
- if (!(brush->flag & BRUSH_ACCUMULATE))
+ {
+ if (!(brush->flag & BRUSH_ACCUMULATE)) {
cache->original = 1;
+ }
+ }
cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0;
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 89a786d02a9..c08ed2e85b9 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -237,7 +237,9 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb)
else if (unode->maxgrid && dm->getGridData) {
if ((dm->getNumGrids(dm) != unode->maxgrid) ||
(dm->getGridSize(dm) != unode->gridsize))
+ {
continue;
+ }
}
else {
continue;
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index b50c3f11534..c238789446f 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -437,8 +437,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_def_property_flag(prop_codec, PROP_HIDDEN);
RNA_def_property_flag(prop_format, PROP_HIDDEN);
- switch(container)
- {
+ switch (container) {
case AUD_CONTAINER_AC3:
RNA_def_property_clear_flag(prop_format, PROP_HIDDEN);
RNA_def_property_enum_items(prop_format, ac3_format_items);
@@ -460,8 +459,7 @@ static void sound_mixdown_draw(bContext *C, wmOperator *op)
RNA_def_property_clear_flag(prop_codec, PROP_HIDDEN);
RNA_def_property_enum_items(prop_codec, all_codec_items);
- switch(codec)
- {
+ switch (codec) {
case AUD_CODEC_AAC:
RNA_enum_set(op->ptr, "format", AUD_FORMAT_S16);
break;
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index 9d0dab7d34e..c1875eb3a9a 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -269,12 +269,12 @@ static void action_header_area_draw(const bContext *C, ARegion *ar)
static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE:
case ND_FRAME:
ED_region_tag_redraw(ar);
@@ -282,7 +282,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
@@ -307,12 +307,12 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn)
static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
@@ -322,7 +322,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_TRANSFORM:
/* moving object shouldn't need to redraw action */
break;
@@ -334,7 +334,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_NODE:
- switch(wmn->action) {
+ switch (wmn->action) {
case NA_EDITED:
ED_region_tag_redraw(ar);
break;
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index b698ec03668..20d5257a62f 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -535,7 +535,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
/* now for each buttons context type, we try to construct a path,
* tracing back recursively */
- switch(mainb) {
+ switch (mainb) {
case BCONTEXT_SCENE:
case BCONTEXT_RENDER:
found= buttons_context_path_scene(path);
diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c
index fcc5b488ca9..2385bfd75b7 100644
--- a/source/blender/editors/space_buttons/buttons_header.c
+++ b/source/blender/editors/space_buttons/buttons_header.c
@@ -56,7 +56,7 @@
static void set_texture_context(bContext *C, SpaceButs *sbuts)
{
- switch(sbuts->mainb) {
+ switch (sbuts->mainb) {
case BCONTEXT_MATERIAL:
sbuts->texture_context = SB_TEXC_MAT_OR_LAMP;
break;
@@ -83,7 +83,7 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event)
if (!sbuts) /* editor type switch */
return;
- switch(event) {
+ switch (event) {
case B_CONTEXT_SWITCH:
case B_BUTSPREVIEW:
ED_area_tag_redraw(CTX_wm_area(C));
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index f1f4fb37b6e..b2a58041832 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -234,9 +234,9 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
SpaceButs *sbuts= sa->spacedata.first;
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_RENDER_OPTIONS:
buttons_area_redraw(sa, BCONTEXT_RENDER);
break;
@@ -262,7 +262,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_TRANSFORM:
buttons_area_redraw(sa, BCONTEXT_OBJECT);
buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */
@@ -307,7 +307,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_GEOM:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_SELECT:
case ND_DATA:
ED_area_tag_redraw(sa);
@@ -316,7 +316,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
break;
case NC_MATERIAL:
ED_area_tag_redraw(sa);
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_SHADING:
case ND_SHADING_DRAW:
case ND_NODES:
@@ -350,7 +350,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
break;
case NC_ANIMATION:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_KEYFRAME:
if (wmn->action == NA_EDITED)
ED_area_tag_redraw(sa);
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index f8c81c2944a..b569469d304 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -82,7 +82,7 @@ static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker)
{
SelectUserData *data = (SelectUserData *)userdata;
- switch(data->action) {
+ switch (data->action) {
case SEL_SELECT:
marker->flag |= MARKER_GRAPH_SEL;
break;
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 7e1bbc254e9..64ce529345c 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -361,7 +361,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event)
ViewPanData *vpd = op->customdata;
float offset[2];
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
copy_v2_v2(vpd->vec, &vpd->xorig);
offset[0] = (vpd->x - event->x) / sc->zoom;
@@ -496,7 +496,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event)
ViewZoomData *vpd = op->customdata;
float factor;
- switch(event->type) {
+ switch (event->type) {
case MOUSEMOVE:
factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f;
RNA_float_set(op->ptr, "factor", factor);
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 228c716e3b6..4de790bc00c 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -236,9 +236,9 @@ static SpaceLink *clip_duplicate(SpaceLink *sl)
static void clip_listener(ScrArea *sa, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_FRAME:
clip_scopes_tag_refresh(sa);
/* no break! */
@@ -249,14 +249,14 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_MOVIECLIP:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_DISPLAY:
case ND_SELECT:
clip_scopes_tag_refresh(sa);
ED_area_tag_redraw(sa);
break;
}
- switch(wmn->action) {
+ switch (wmn->action) {
case NA_REMOVED:
case NA_EDITED:
case NA_EVALUATED:
@@ -270,7 +270,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_GEOM:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_SELECT:
clip_scopes_tag_refresh(sa);
ED_area_tag_redraw(sa);
@@ -808,7 +808,7 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar)
static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCREEN:
if (wmn->data == ND_GPENCIL)
ED_region_tag_redraw(ar);
@@ -896,7 +896,7 @@ static void clip_tools_area_draw(const bContext *C, ARegion *ar)
static void clip_props_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_WM:
if (wmn->data == ND_HISTORY)
ED_region_tag_redraw(ar);
@@ -941,7 +941,7 @@ static void clip_properties_area_draw(const bContext *C, ARegion *ar)
static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCREEN:
if (wmn->data ==ND_GPENCIL)
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index 35986fa2700..2b1b311b89d 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -526,7 +526,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
SlideMarkerData *data = (SlideMarkerData *)op->customdata;
float dx, dy, mdelta[2];
- switch(event->type) {
+ switch (event->type) {
case LEFTCTRLKEY:
case RIGHTCTRLKEY:
case LEFTSHIFTKEY:
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 193fa2d2c65..36b38661463 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -82,7 +82,7 @@ enum {
static void do_file_buttons(bContext *C, void *UNUSED(arg), int event)
{
- switch(event) {
+ switch (event) {
case B_FS_FILENAME:
file_filename_exec(C, NULL);
break;
@@ -417,8 +417,7 @@ static void draw_background(FileLayout *layout, View2D *v2d)
int sy;
/* alternating flat shade background */
- for (i=0; (i <= layout->rows); i+=2)
- {
+ for (i=0; (i <= layout->rows); i+=2) {
sy = (int)v2d->cur.ymax - i*(layout->tile_h+2*layout->tile_border_y) - layout->tile_border_y;
UI_ThemeColorShade(TH_BACK, -7);
@@ -490,8 +489,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
align = ( FILE_IMGDISPLAY == params->display) ? UI_STYLE_TEXT_CENTER : UI_STYLE_TEXT_LEFT;
- for (i=offset; (i < numfiles) && (i<offset+numfiles_layout); ++i)
- {
+ for (i = offset; (i < numfiles) && (i<offset+numfiles_layout); i++) {
ED_fileselect_layout_tilepos(layout, i, &sx, &sy);
sx += (int)(v2d->tot.xmin+2.0f);
sy = (int)(v2d->tot.ymax - sy);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7d1981a5a3b..aa1ab823ee1 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -911,8 +911,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
numfiles = filelist_numfiles(sfile->files);
/* check if we are editing a name */
- for (i=0; i < numfiles; ++i)
- {
+ for (i=0; i < numfiles; ++i) {
if (filelist_is_selected(sfile->files, i, CHECK_ALL) ) {
edit_idx=i;
break;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 45a271cc7e9..a05eba2daeb 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -520,7 +520,7 @@ static void filelist_read_dir(struct FileList* filelist);
struct FileList* filelist_new(short type)
{
FileList* p = MEM_callocN( sizeof(FileList), "filelist" );
- switch(type) {
+ switch (type) {
case FILE_MAIN:
p->readf = filelist_read_main;
p->filterf = is_filtered_main;
@@ -982,7 +982,7 @@ int filelist_is_selected(struct FileList* filelist, int index, FileCheckType che
void filelist_sort(struct FileList* filelist, short sort)
{
- switch(sort) {
+ switch (sort) {
case FILE_SORT_ALPHA:
qsort(filelist->filelist, filelist->numfiles, sizeof(struct direntry), compare_name);
break;
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 31695ddd776..b17ca5ee319 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -447,8 +447,7 @@ static void column_widths(struct FileList* files, struct FileLayout* layout)
layout->column_widths[i] = 0;
}
- for (i=0; (i < numfiles); ++i)
- {
+ for (i=0; (i < numfiles); ++i) {
struct direntry* file = filelist_file(files, i);
if (file) {
float len;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 48449ac8870..a4da1975c56 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -99,7 +99,7 @@ static FSMenuEntry *fsmenu_get_category(struct FSMenu* fsmenu, FSMenuCategory ca
{
FSMenuEntry *fsms = NULL;
- switch(category) {
+ switch (category) {
case FS_CATEGORY_SYSTEM:
fsms = fsmenu->fsmenu_system;
break;
@@ -115,7 +115,7 @@ static FSMenuEntry *fsmenu_get_category(struct FSMenu* fsmenu, FSMenuCategory ca
static void fsmenu_set_category(struct FSMenu* fsmenu, FSMenuCategory category, FSMenuEntry *fsms)
{
- switch(category) {
+ switch (category) {
case FS_CATEGORY_SYSTEM:
fsmenu->fsmenu_system = fsms;
break;
@@ -268,8 +268,7 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename)
fp = BLI_fopen(filename, "r");
if (!fp) return;
- while ( fgets ( line, 256, fp ) != NULL ) /* read a line */
- {
+ while ( fgets ( line, 256, fp ) != NULL ) { /* read a line */
if (strncmp(line, "[Bookmarks]", 11)==0) {
category = FS_CATEGORY_BOOKMARKS;
}
@@ -329,8 +328,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
const char *home;
/* loop through all the OS X Volumes, and add them to the SYSTEM section */
- for (i=1; err!=nsvErr; i++)
- {
+ for (i = 1; err != nsvErr; i++) {
FSRef dir;
unsigned char path[FILE_MAX];
@@ -389,8 +387,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
pathesArray = LSSharedFileListCopySnapshot(list, &seed);
pathesCount = CFArrayGetCount(pathesArray);
- for (i=0; i<pathesCount; i++)
- {
+ for (i=0; i<pathesCount; i++) {
itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
err = LSSharedFileListItemResolve(itemRef,
@@ -415,8 +412,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
/* Then get network volumes */
err = noErr;
- for (i=1; err!=nsvErr; i++)
- {
+ for (i=1; err!=nsvErr; i++) {
FSRef dir;
FSVolumeRefNum volRefNum;
struct GetVolParmsInfoBuffer volParmsBuffer;
@@ -440,8 +436,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu)
pathesArray = LSSharedFileListCopySnapshot(list, &seed);
pathesCount = CFArrayGetCount(pathesArray);
- for (i=0; i<pathesCount; i++)
- {
+ for (i=0; i<pathesCount; i++) {
itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
err = LSSharedFileListItemResolve(itemRef,
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 0cf15c22efa..e166914b36f 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -251,7 +251,7 @@ static void file_listener(ScrArea *sa, wmNotifier *wmn)
/* SpaceFile* sfile = (SpaceFile*)sa->spacedata.first; */
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SPACE:
switch (wmn->data) {
case ND_SPACE_FILE_LIST:
@@ -287,7 +287,7 @@ static void file_main_area_init(wmWindowManager *wm, ARegion *ar)
static void file_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SPACE:
switch (wmn->data) {
case ND_SPACE_FILE_LIST:
@@ -476,7 +476,7 @@ static void file_channel_area_draw(const bContext *C, ARegion *ar)
static void file_channel_area_listener(ARegion *UNUSED(ar), wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
}
}
@@ -536,7 +536,7 @@ static void file_ui_area_draw(const bContext *C, ARegion *ar)
static void file_ui_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SPACE:
switch (wmn->data) {
case ND_SPACE_FILE_LIST:
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 4d2fe2cd568..8bc2eda7e33 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -85,7 +85,7 @@ static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int
{
//Scene *scene= CTX_data_scene(C);
- switch(event) {
+ switch (event) {
}
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 37cdbd4963a..6214201a87d 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -374,12 +374,12 @@ static void graph_buttons_area_draw(const bContext *C, ARegion *ar)
static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
@@ -393,7 +393,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
@@ -406,7 +406,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_NODE:
- switch(wmn->action) {
+ switch (wmn->action) {
case NA_EDITED:
case NA_SELECTED:
ED_region_tag_redraw(ar);
@@ -552,7 +552,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
*/
float *col= fcu->color;
- switch(fcu->array_index) {
+ switch (fcu->array_index) {
case 0:
col[0]= 1.0f; col[1]= 0.0f; col[2]= 0.0f;
break;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 08aa69fe499..447028b8bef 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -205,7 +205,9 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy)
if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) ||
(ima->aspx == 0.0f || ima->aspy == 0.0f))
+ {
return;
+ }
/* x is always 1 */
*aspy = ima->aspy / ima->aspx;
diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c
index dcead6c01db..16fe48f314a 100644
--- a/source/blender/editors/space_logic/logic_buttons.c
+++ b/source/blender/editors/space_logic/logic_buttons.c
@@ -119,8 +119,7 @@ static int cut_links_exec(bContext *C, wmOperator *op)
uiBlock *block;
uiLinkLine *line, *nline;
uiBut *but;
- for (block= ar->uiblocks.first; block; block= block->next)
- {
+ for (block= ar->uiblocks.first; block; block= block->next) {
but= block->buttons.first;
while (but) {
if (but->type==LINK && but->link) {
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index f7c69c80067..9f5ae19d92c 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -371,7 +371,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
ob= CTX_data_active_object(C);
if (ob==NULL) return;
- switch(event) {
+ switch (event) {
case B_SETPROP:
/* check for inconsistent types */
@@ -551,13 +551,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
didit= 0;
for (ob=bmain->object.first; ob; ob=ob->id.next) {
act= ob->actuators.first;
- while (act)
- {
- if (act->type==ACT_SOUND)
- {
+ while (act) {
+ if (act->type==ACT_SOUND) {
bSoundActuator *sa= act->data;
- if (sa->sndnr)
- {
+ if (sa->sndnr) {
ID *sound= bmain->sound.first;
int nr= 1;
@@ -567,8 +564,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event)
break;
}
- while (sound)
- {
+ while (sound) {
if (nr==sa->sndnr)
break;
nr++;
@@ -727,8 +723,7 @@ static const char *actuator_name(int type)
static const char *actuator_pup(Object *owner)
{
- switch (owner->type)
- {
+ switch (owner->type) {
case OB_ARMATURE:
return "Actuators %t|Action %x15|Armature %x23|Motion %x0|Constraint %x9|Ipo %x1"
"|Camera %x3|Sound %x5|Property %x6|Edit Object %x10"
@@ -945,7 +940,7 @@ static int get_col_sensor(int type)
{
/* XXX themecolors not here */
- switch(type) {
+ switch (type) {
case SENS_ALWAYS: return TH_PANEL;
case SENS_DELAY: return TH_PANEL;
case SENS_TOUCH: return TH_PANEL;
@@ -1161,8 +1156,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short
set_col_sensor(sens->type, 0);
- switch (sens->type)
- {
+ switch (sens->type) {
case SENS_ALWAYS:
{
ysize= 24;
@@ -1347,14 +1341,12 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short
uiDefButI(block, MENU, B_REDR, str, xco+30,yco-44,width-60, 19,
&ps->type, 0, 31, 0, 0, "Type");
- if (ps->type != SENS_PROP_EXPRESSION)
- {
+ if (ps->type != SENS_PROP_EXPRESSION) {
uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-68,width-60, 19,
ps->name, 0, MAX_NAME, 0, 0, "Property name");
}
- if (ps->type == SENS_PROP_INTERVAL)
- {
+ if (ps->type == SENS_PROP_INTERVAL) {
uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19,
ps->value, 0, MAX_NAME, 0, 0, "check for min value");
uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19,
@@ -1401,8 +1393,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short
uiDefButI(block, MENU, B_REDR, str, xco+10,yco-66,0.4*(width-20), 19,
&arm->type, 0, 31, 0, 0, "Type");
- if (arm->type != SENS_ARM_STATE_CHANGED)
- {
+ if (arm->type != SENS_ARM_STATE_CHANGED) {
uiDefButF(block, NUM, 1, "Value: ", xco+10+0.4*(width-20),yco-66,0.6*(width-20), 19,
&arm->value, -10000.0, 10000.0, 100, 0, "Test the error against this value");
}
@@ -1489,8 +1480,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short
draw_default_sensor_header(sens, block, xco, yco, width);
randomSensor = sens->data;
/* some files were wrongly written, avoid crash now */
- if (randomSensor)
- {
+ if (randomSensor) {
uiDefButI(block, NUM, 1, "Seed: ", xco+10,yco-44,(width-20), 19,
&randomSensor->seed, 0, 1000, 0, 0,
"Initial seed of the generator. (Choose 0 for not random)");
@@ -1610,8 +1600,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short
&joy->flag, 0, 0, 0, 0,
"Triggered by all events on this joysticks current type (axis/button/hat)");
}
- if (joy->type == SENS_JOY_BUTTON)
- {
+ if (joy->type == SENS_JOY_BUTTON) {
if ((joy->flag & SENS_JOY_ANY_EVENT)==0) {
uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19,
&joy->button, 0, 18, 100, 0,
@@ -1727,7 +1716,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco
static int get_col_actuator(int type)
{
- switch(type) {
+ switch (type) {
case ACT_ACTION: return TH_PANEL;
case ACT_SHAPEACTION: return TH_PANEL;
case ACT_OBJECT: return TH_PANEL;
@@ -1869,14 +1858,12 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
/* yco is at the top of the rect, draw downwards */
set_col_actuator(act->type, 0);
- switch (act->type)
- {
+ switch (act->type) {
case ACT_OBJECT:
{
oa = act->data;
wval = (width-100)/3;
- if (oa->type == ACT_OBJECT_NORMAL)
- {
+ if (oa->type == ACT_OBJECT_NORMAL) {
if (ob->gameflag & OB_DYNAMIC) {
ysize= 175;
}
@@ -1904,8 +1891,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation");
- if ( ob->gameflag & OB_DYNAMIC )
- {
+ if (ob->gameflag & OB_DYNAMIC) {
uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, "");
@@ -1921,8 +1907,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
uiBlockEndAlign(block);
}
- if ( ob->gameflag & OB_DYNAMIC )
- {
+ if (ob->gameflag & OB_DYNAMIC) {
uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity");
uiBlockBeginAlign(block);
uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, "");
@@ -1948,8 +1933,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "use_additive",xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV");
}
}
- else if (oa->type == ACT_OBJECT_SERVO)
- {
+ else if (oa->type == ACT_OBJECT_SERVO) {
ysize= 195;
glRects(xco, yco-ysize, xco+width, yco);
@@ -2824,8 +2808,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
glRects( xco, yco-ysize, xco+width, yco );
uiEmboss( (float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1 );
- switch(tdfa->type)
- {
+ switch (tdfa->type) {
case ACT_2DFILTER_MOTIONBLUR:
if (!tdfa->flag) {
uiDefButS(block, TOG, B_REDR, "D", xco+30,yco-44,19, 19, &tdfa->flag, 0.0, 0.0, 0.0, 0.0, "Disable Motion Blur");
@@ -3759,8 +3742,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr)
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode"))
- {
+ switch (RNA_enum_get(ptr, "mode")) {
case ACT_ARM_RUN:
break;
case ACT_ARM_ENABLE:
@@ -3835,8 +3817,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext
RNA_main_pointer_create(CTX_data_main(C), &main_ptr);
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode"))
- {
+ switch (RNA_enum_get(ptr, "mode")) {
case ACT_CONST_TYPE_LOC:
uiItemR(layout, ptr, "limit", 0, NULL, ICON_NONE);
@@ -3934,8 +3915,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr)
uiLayout *row, *split, *sub;
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode"))
- {
+ switch (RNA_enum_get(ptr, "mode")) {
case ACT_EDOB_ADD_OBJECT:
row = uiLayoutRow(layout, 0);
uiItemR(row, ptr, "object", 0, NULL, ICON_NONE);
@@ -3988,8 +3968,7 @@ static void draw_actuator_filter_2d(uiLayout *layout, PointerRNA *ptr)
uiLayout *row, *split;
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
- switch (RNA_enum_get(ptr, "mode"))
- {
+ switch (RNA_enum_get(ptr, "mode")) {
case ACT_2DFILTER_CUSTOMFILTER:
uiItemR(layout, ptr, "filter_pass", 0, NULL, ICON_NONE);
uiItemR(layout, ptr, "glsl_shader", 0, NULL, ICON_NONE);
@@ -4163,8 +4142,7 @@ static void draw_actuator_property(uiLayout *layout, PointerRNA *ptr)
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
uiItemPointerR(layout, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE);
- switch(RNA_enum_get(ptr, "mode"))
- {
+ switch (RNA_enum_get(ptr, "mode")) {
case ACT_PROP_TOGGLE:
break;
case ACT_PROP_ADD:
diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c
index 82175f83d39..93105c39f39 100644
--- a/source/blender/editors/space_logic/space_logic.c
+++ b/source/blender/editors/space_logic/space_logic.c
@@ -195,12 +195,12 @@ static void logic_refresh(const bContext *UNUSED(C), ScrArea *UNUSED(sa))
static void logic_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_LOGIC:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_FRAME:
ED_region_tag_redraw(ar);
break;
diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c
index de42e4a783d..a133d370d99 100644
--- a/source/blender/editors/space_nla/nla_buttons.c
+++ b/source/blender/editors/space_nla/nla_buttons.c
@@ -76,7 +76,7 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event)
{
//Scene *scene= CTX_data_scene(C);
- switch(event) {
+ switch (event) {
}
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index 4dc3aef7d2c..27c48d2232f 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -348,12 +348,12 @@ static void nla_buttons_area_draw(const bContext *C, ARegion *ar)
static void nla_region_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE:
case ND_FRAME:
case ND_MARKERS:
@@ -362,7 +362,7 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
@@ -381,12 +381,12 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn)
static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_RENDER_OPTIONS:
case ND_OB_ACTIVE:
case ND_FRAME:
@@ -396,7 +396,7 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
@@ -406,7 +406,7 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_NODE:
- switch(wmn->action) {
+ switch (wmn->action) {
case NA_EDITED:
ED_region_tag_redraw(ar);
break;
@@ -425,19 +425,19 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn)
static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_ANIMATION:
ED_region_tag_redraw(ar);
break;
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE:
ED_region_tag_redraw(ar);
break;
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_BONE_ACTIVE:
case ND_BONE_SELECT:
case ND_KEYS:
diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c
index 42aea32b7f6..e00abff30f2 100644
--- a/source/blender/editors/space_node/drawnode.c
+++ b/source/blender/editors/space_node/drawnode.c
@@ -963,7 +963,7 @@ static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree
static void node_common_set_butfunc(bNodeType *ntype)
{
- switch(ntype->type) {
+ switch (ntype->type) {
case NODE_GROUP:
ntype->uifunc= node_uifunc_group;
ntype->drawfunc= node_draw_group;
@@ -1176,7 +1176,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *
static void node_shader_set_butfunc(bNodeType *ntype)
{
ntype->uifuncbut = NULL;
- switch(ntype->type) {
+ switch (ntype->type) {
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
case SH_NODE_MATERIAL:
@@ -1941,7 +1941,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po
static void node_composit_set_butfunc(bNodeType *ntype)
{
ntype->uifuncbut = NULL;
- switch(ntype->type) {
+ switch (ntype->type) {
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
case CMP_NODE_IMAGE:
@@ -2137,7 +2137,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe
col= uiLayoutColumn(layout, 0);
- switch( tex->type ) {
+ switch ( tex->type ) {
case TEX_BLEND:
uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
row= uiLayoutRow(col, 0);
@@ -2222,45 +2222,50 @@ static void node_texture_set_butfunc(bNodeType *ntype)
if ( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) {
ntype->uifunc = node_texture_buts_proc;
}
- else switch(ntype->type) {
-
+ else {
+ switch (ntype->type) {
+
case TEX_NODE_MATH:
ntype->uifunc = node_buts_math;
break;
-
+
case TEX_NODE_MIX_RGB:
ntype->uifunc = node_buts_mix_rgb;
break;
-
+
case TEX_NODE_VALTORGB:
ntype->uifunc = node_buts_colorramp;
break;
-
+
case TEX_NODE_CURVE_RGB:
ntype->uifunc= node_buts_curvecol;
break;
-
+
case TEX_NODE_CURVE_TIME:
ntype->uifunc = node_buts_time;
break;
-
+
case TEX_NODE_TEXTURE:
ntype->uifunc = node_buts_texture;
break;
-
+
case TEX_NODE_BRICKS:
ntype->uifunc = node_texture_buts_bricks;
break;
-
+
case TEX_NODE_IMAGE:
ntype->uifunc = node_texture_buts_image;
break;
-
+
case TEX_NODE_OUTPUT:
ntype->uifunc = node_texture_buts_output;
break;
+ }
+ }
+
+ if (ntype->uifuncbut == NULL) {
+ ntype->uifuncbut = ntype->uifunc;
}
- if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
}
/* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
@@ -2305,7 +2310,7 @@ void ED_init_node_butfuncs(void)
for (i=0; i < NUM_SOCKET_TYPES; ++i) {
stype = ntreeGetSocketType(i);
if (stype) {
- switch(stype->type) {
+ switch (stype->type) {
case SOCK_FLOAT:
case SOCK_INT:
case SOCK_BOOLEAN:
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index dda06267237..247dd0c1fa7 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -284,7 +284,7 @@ void ED_node_shader_default(Scene *scene, ID *id)
ntree= ntreeAddTree("Shader Nodetree", NTREE_SHADER, 0);
- switch(GS(id->name)) {
+ switch (GS(id->name)) {
case ID_MA: {
Material *ma= (Material*)id;
ma->nodetree = ntree;
@@ -1458,7 +1458,7 @@ static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
static int sample_modal(bContext *C, wmOperator *op, wmEvent *event)
{
- switch(event->type) {
+ switch (event->type) {
case LEFTMOUSE:
case RIGHTMOUSE: // XXX hardcoded
sample_exit(C, op);
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 049886b1d66..13e85c7f74d 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -220,8 +220,10 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
/* also preserve mapping for texture nodes */
if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
- node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ {
memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase));
+ }
/* remove node */
node_remove_linked(ntree, node_prev);
@@ -295,11 +297,14 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR])
BLI_strncpy(node_name, node->typeinfo->name, UI_MAX_NAME_STR);
if (node->inputs.first == NULL &&
- node->outputs.first != node->outputs.last &&
- !(node->typeinfo->flag & NODE_OPTIONS))
+ node->outputs.first != node->outputs.last &&
+ !(node->typeinfo->flag & NODE_OPTIONS))
+ {
BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", node_name, sock->link->fromsock->name);
- else
+ }
+ else {
BLI_strncpy(name, node_name, UI_MAX_NAME_STR);
+ }
}
else if (sock->type == SOCK_SHADER)
BLI_strncpy(name, "None", UI_MAX_NAME_STR);
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index fca9927b0f5..3540c20e515 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -172,7 +172,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
short shader_type = snode->shaderfrom;
/* preview renders */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCENE:
switch (wmn->data) {
case ND_NODES:
@@ -244,7 +244,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn)
ED_area_tag_redraw(sa);
break;
case NC_SCREEN:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_ANIMPLAY:
ED_area_tag_refresh(sa);
break;
@@ -429,7 +429,7 @@ static void node_header_area_draw(const bContext *C, ARegion *ar)
static void node_region_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SPACE:
if (wmn->data==ND_SPACE_NODE)
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 779475943dd..7b2bbf3e285 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -278,7 +278,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
if (tselem->type==0) {
test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort
- switch(GS(tselem->id->name)) {
+ switch (GS(tselem->id->name)) {
case ID_MA:
WM_event_add_notifier(C, NC_MATERIAL, NULL); break;
case ID_TE:
@@ -305,7 +305,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
}
}
else {
- switch(tselem->type) {
+ switch (tselem->type) {
case TSE_DEFGROUP:
defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object
break;
@@ -719,7 +719,7 @@ static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v))
short maptype= keymap_menu_type(kmi->type);
if (maptype!=kmi->maptype) {
- switch(kmi->maptype) {
+ switch (kmi->maptype) {
case OL_KM_KEYBOARD:
kmi->type= AKEY;
kmi->val= KM_PRESS;
@@ -776,7 +776,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
xstart+= butw2+5;
/* edit actual event */
- switch(kmi->maptype) {
+ switch (kmi->maptype) {
case OL_KM_KEYBOARD:
uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code");
xstart+= butw2+5;
@@ -904,7 +904,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
arg.alpha= alpha;
if (tselem->type) {
- switch( tselem->type) {
+ switch ( tselem->type) {
case TSE_ANIM_DATA:
UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx
case TSE_NLA:
@@ -932,7 +932,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
{
Object *ob= (Object *)tselem->id;
ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr);
- switch(md->type) {
+ switch (md->type) {
case eModifierType_Subsurf:
UI_icon_draw(x, y, ICON_MOD_SUBSURF); break;
case eModifierType_Armature:
@@ -1093,7 +1093,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
}
}
else {
- switch( GS(tselem->id->name)) {
+ switch ( GS(tselem->id->name)) {
case ID_SCE:
tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break;
case ID_ME:
@@ -1108,7 +1108,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
{
Lamp *la= (Lamp *)tselem->id;
- switch(la->type) {
+ switch (la->type) {
case LA_LOCAL:
tselem_draw_icon_uibut(&arg, ICON_LAMP_POINT); break;
case LA_SUN:
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index c06576e48a6..5515ec45269 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -629,7 +629,7 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te,
int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set)
{
- switch(te->idcode) {
+ switch (te->idcode) {
/* Note: no ID_OB: objects are handled specially to allow multiple
* selection. See do_outliner_item_activate. */
case ID_MA:
@@ -652,7 +652,7 @@ int tree_element_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement
/* Context can be NULL when set==0 */
int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, int set)
{
- switch(tselem->type) {
+ switch (tselem->type) {
case TSE_DEFGROUP:
return tree_element_active_defgroup(C, scene, te, tselem, set);
case TSE_BONE:
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 5c527face83..13e86209f3a 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -96,7 +96,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb,
}
else {
int idcode= GS(tselem->id->name);
- switch(idcode) {
+ switch (idcode) {
case ID_SCE:
*scenelevel= 1;
break;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index ed050b7f93d..c2a3affa1b6 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -182,9 +182,9 @@ static void outliner_main_area_free(ARegion *UNUSED(ar))
static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCENE:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_OB_ACTIVE:
case ND_OB_SELECT:
case ND_OB_VISIBLE:
@@ -200,7 +200,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_OBJECT:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_TRANSFORM:
/* transform doesn't change outliner data */
break;
@@ -212,7 +212,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
case ND_CONSTRAINT:
- switch(wmn->action) {
+ switch (wmn->action) {
case NA_ADDED:
case NA_REMOVED:
case NA_RENAME:
@@ -244,7 +244,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
case NC_MATERIAL:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_SHADING:
case ND_SHADING_DRAW:
ED_region_tag_redraw(ar);
@@ -255,7 +255,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
ED_region_tag_redraw(ar);
break;
case NC_GEOM:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_DATA:
/* needed for vertex groups only, no special notifier atm so use NC_GEOM|ND_DATA */
ED_region_tag_redraw(ar);
@@ -263,7 +263,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
}
break;
case NC_ANIMATION:
- switch(wmn->data) {
+ switch (wmn->data) {
case ND_NLA_ACTCHANGE:
case ND_KEYFRAME:
ED_region_tag_redraw(ar);
@@ -299,7 +299,7 @@ static void outliner_header_area_free(ARegion *UNUSED(ar))
static void outliner_header_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCENE:
if (wmn->data == ND_KEYINGSET)
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index cd0c8779c39..5431156de45 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -206,14 +206,12 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
length = floor((waveform->length - startsample) / samplestep);
glBegin(GL_LINE_STRIP);
- for (i = 0; i < length; i++)
- {
+ for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
value = waveform->data[pos * 3];
- for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++)
- {
+ for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value > waveform->data[j * 3])
value = waveform->data[j * 3];
}
@@ -223,14 +221,12 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
glEnd();
glBegin(GL_LINE_STRIP);
- for (i = 0; i < length; i++)
- {
+ for (i = 0; i < length; i++) {
pos = startsample + i * samplestep;
value = waveform->data[pos * 3 + 1];
- for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++)
- {
+ for (j = pos + 1; (j < waveform->length) && (j < pos + samplestep); j++) {
if (value < waveform->data[j * 3 + 1])
value = waveform->data[j * 3 + 1];
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 84f960ecf2a..ffb686b6810 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -130,8 +130,7 @@ static void flatten_string_append(FlattenString *fs, const char *c, int accum, i
fs->accum = naccum;
}
- for (i = 0; i < len; i++)
- {
+ for (i = 0; i < len; i++) {
fs->buf[fs->pos + i] = c[i];
fs->accum[fs->pos + i] = accum;
}
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 5e56dfa728e..fbb3f3c609f 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -111,7 +111,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
int i, sta = pid->cache->startframe, end = pid->cache->endframe;
int len = (end - sta + 1)*4;
- switch(pid->type) {
+ switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue;
break;
@@ -171,7 +171,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob)
glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0);
glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0);
- switch(pid->type) {
+ switch (pid->type) {
case PTCACHE_TYPE_SOFTBODY:
col[0] = 1.0; col[1] = 0.4; col[2] = 0.02;
col[3] = 0.1;
@@ -509,7 +509,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
static void time_main_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SPACE:
if (wmn->data == ND_SPACE_TIME)
ED_region_tag_redraw(ar);
@@ -549,7 +549,7 @@ static void time_header_area_draw(const bContext *C, ARegion *ar)
static void time_header_area_listener(ARegion *ar, wmNotifier *wmn)
{
/* context changes */
- switch(wmn->category) {
+ switch (wmn->category) {
case NC_SCREEN:
if (wmn->data==ND_ANIMPLAY)
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index e9bf9345b5c..6c683eba085 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -145,7 +145,7 @@ static void userpref_header_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn
{
/* context changes */
#if 0
- switch(wmn->category) {
+ switch (wmn->category) {
default:
break;
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 6f637afd293..2f66fdf8cd4 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -700,11 +700,12 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
fac = fac * fac;
interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac);
}
- else
-#endif
- {
+ else {
copy_v3_v3(xaxis, m_inv[0]);
}
+#else
+ copy_v3_v3(xaxis, m_inv[0]);
+#endif
/* Determine the direction of the x vector (for rotating up and down) */
/* This can likely be computed directly from the quaternion. */
@@ -1554,7 +1555,9 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom,
if (!use_cam_zoom) {
if (zfac != 1.0f && zfac * vod->rv3d->dist > 0.001f * vod->grid &&
zfac * vod->rv3d->dist < 10.0f * vod->far)
+ {
view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy);
+ }
}
/* these limits were in old code too */
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index f3819a1b83c..233719033c7 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -298,8 +298,7 @@ void removeAspectRatio(TransInfo *t, float *vec)
static void viewRedrawForce(const bContext *C, TransInfo *t)
{
- if (t->spacetype == SPACE_VIEW3D)
- {
+ if (t->spacetype == SPACE_VIEW3D) {
/* Do we need more refined tags? */
if (t->flag & T_POSE)
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
@@ -415,7 +414,7 @@ static void view_editmove(unsigned short UNUSED(event))
if (Trans.flag & T_2D_EDIT)
return;
- switch(event) {
+ switch (event) {
case WHEELUPMOUSE:
if ( G.qual & LR_SHIFTKEY ) {
@@ -586,8 +585,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
t->redraw |= handleMouseInput(t, &t->mouse, event);
- if (event->type == MOUSEMOVE)
- {
+ if (event->type == MOUSEMOVE) {
if (t->modifiers & MOD_CONSTRAINT_SELECT)
t->con.mode |= CON_SELECT;
@@ -802,7 +800,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
t->redraw |= handleNumInput(&(t->num), event);
}
/* else do non-mapped events */
- else if (event->val==KM_PRESS) {
+ else if (event->val == KM_PRESS) {
switch (event->type) {
case RIGHTMOUSE:
t->state = TRANS_CANCEL;
@@ -1088,11 +1086,9 @@ int transformEvent(TransInfo *t, wmEvent *event)
}
/* confirm transform if launch key is released after mouse move */
- if (t->flag & T_RELEASE_CONFIRM)
- {
+ if (t->flag & T_RELEASE_CONFIRM) {
/* XXX Keyrepeat bug in Xorg fucks this up, will test when fixed */
- if (event->type == t->launch_event && (t->launch_event == LEFTMOUSE || t->launch_event == RIGHTMOUSE))
- {
+ if (event->type == t->launch_event && (t->launch_event == LEFTMOUSE || t->launch_event == RIGHTMOUSE)) {
t->state = TRANS_CONFIRM;
}
}
@@ -1156,8 +1152,7 @@ typedef enum {
} ArrowDirection;
static void drawArrow(ArrowDirection d, short offset, short length, short size)
{
- switch(d)
- {
+ switch (d) {
case LEFT:
offset = -offset;
length = -length;
@@ -1191,8 +1186,7 @@ static void drawArrow(ArrowDirection d, short offset, short length, short size)
static void drawArrowHead(ArrowDirection d, short size)
{
- switch(d)
- {
+ switch (d) {
case LEFT:
size = -size;
case RIGHT:
@@ -1223,8 +1217,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments
glBegin(GL_LINE_STRIP);
- for ( angle = angle_start; angle < angle_end; angle += delta)
- {
+ for ( angle = angle_start; angle < angle_end; angle += delta) {
glVertex2f( cosf(angle) * size, sinf(angle) * size);
}
glVertex2f( cosf(angle_end) * size, sinf(angle_end) * size);
@@ -1245,8 +1238,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
{
TransInfo *t = (TransInfo*)customdata;
- if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR))
- {
+ if (t->helpline != HLP_NONE && !(t->flag & T_USES_MANIPULATOR)) {
float vecrot[3], cent[2];
int mval[2];
@@ -1267,8 +1259,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
glPushMatrix();
- switch(t->helpline)
- {
+ switch (t->helpline) {
case HLP_SPRING:
UI_ThemeColor(TH_WIRE);
@@ -1417,23 +1408,23 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
/* convert flag to enum */
- switch(t->flag & (T_PROP_EDIT|T_PROP_CONNECTED))
- {
- case (T_PROP_EDIT|T_PROP_CONNECTED):
- proportional = PROP_EDIT_CONNECTED;
- break;
- case T_PROP_EDIT:
- proportional = PROP_EDIT_ON;
- break;
- default:
- proportional = PROP_EDIT_OFF;
+ switch (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) {
+ case (T_PROP_EDIT|T_PROP_CONNECTED):
+ proportional = PROP_EDIT_CONNECTED;
+ break;
+ case T_PROP_EDIT:
+ proportional = PROP_EDIT_ON;
+ break;
+ default:
+ proportional = PROP_EDIT_OFF;
}
// If modal, save settings back in scene if not set as operator argument
if (t->flag & T_MODAL) {
/* save settings if not set in operator */
- if ( (prop = RNA_struct_find_property(op->ptr, "proportional")) && !RNA_property_is_set(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "proportional")) &&
+ !RNA_property_is_set(op->ptr, prop))
{
if (t->obedit)
ts->proportional = proportional;
@@ -1441,12 +1432,14 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
ts->proportional_objects = (proportional != PROP_EDIT_OFF);
}
- if ( (prop = RNA_struct_find_property(op->ptr, "proportional_size")) && !RNA_property_is_set(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) &&
+ !RNA_property_is_set(op->ptr, prop))
{
ts->proportional_size = t->prop_size;
}
- if ( (prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && !RNA_property_is_set(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) &&
+ !RNA_property_is_set(op->ptr, prop))
{
ts->prop_mode = t->prop_mode;
}
@@ -1460,34 +1453,31 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
if (t->spacetype == SPACE_VIEW3D) {
- if ( (prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) && !RNA_property_is_set(op->ptr, prop))
+ if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
+ !RNA_property_is_set(op->ptr, prop))
{
View3D *v3d = t->view;
-
+
v3d->twmode = t->current_orientation;
}
}
}
- if (RNA_struct_find_property(op->ptr, "proportional"))
- {
+ if (RNA_struct_find_property(op->ptr, "proportional")) {
RNA_enum_set(op->ptr, "proportional", proportional);
RNA_enum_set(op->ptr, "proportional_edit_falloff", t->prop_mode);
RNA_float_set(op->ptr, "proportional_size", t->prop_size);
}
- if ((prop = RNA_struct_find_property(op->ptr, "axis")))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "axis"))) {
RNA_property_float_set_array(op->ptr, prop, t->axis);
}
- if ((prop = RNA_struct_find_property(op->ptr, "mirror")))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
RNA_property_boolean_set(op->ptr, prop, t->flag & T_MIRROR);
}
- if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
/* constraint orientation can be global, event if user selects something else
* so use the orientation in the constraint if set
* */
@@ -1498,8 +1488,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
RNA_enum_set(op->ptr, "constraint_orientation", t->current_orientation);
}
- if (t->con.mode & CON_APPLY)
- {
+ if (t->con.mode & CON_APPLY) {
if (t->con.mode & CON_AXIS0) {
constraint_axis[0] = 1;
}
@@ -1527,8 +1516,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->state = TRANS_STARTING;
- if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop))
- {
+ if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
options |= CTX_TEXTURE;
}
@@ -1540,8 +1528,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->launch_event = event ? event->type : -1;
- if (t->launch_event == EVT_TWEAK_R)
- {
+ if (t->launch_event == EVT_TWEAK_R) {
t->launch_event = RIGHTMOUSE;
}
else if (t->launch_event == EVT_TWEAK_L) {
@@ -1550,18 +1537,15 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
// XXX Remove this when wm_operator_call_internal doesn't use window->eventstate (which can have type = 0)
// For manipulator only, so assume LEFTMOUSE
- if (t->launch_event == 0)
- {
+ if (t->launch_event == 0) {
t->launch_event = LEFTMOUSE;
}
- if (!initTransInfo(C, t, op, event)) // internal data, mouse, vectors
- {
+ if (!initTransInfo(C, t, op, event)) { /* internal data, mouse, vectors */
return 0;
}
- if (t->spacetype == SPACE_VIEW3D)
- {
+ if (t->spacetype == SPACE_VIEW3D) {
//calc_manipulator_stats(curarea);
initTransformOrientation(C, t);
@@ -1592,15 +1576,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
}
/* Stupid code to have Ctrl-Click on manipulator work ok */
- if (event)
- {
+ if (event) {
wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap);
wmKeyMapItem *kmi;
- for (kmi = keymap->items.first; kmi; kmi = kmi->next)
- {
- if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS)
- {
+ for (kmi = keymap->items.first; kmi; kmi = kmi->next) {
+ if (kmi->propvalue == TFM_MODAL_SNAP_INV_ON && kmi->val == KM_PRESS) {
if ((ELEM(kmi->type, LEFTCTRLKEY, RIGHTCTRLKEY) && event->ctrl) ||
(ELEM(kmi->type, LEFTSHIFTKEY, RIGHTSHIFTKEY) && event->shift) ||
(ELEM(kmi->type, LEFTALTKEY, RIGHTALTKEY) && event->alt) ||
@@ -1731,16 +1712,14 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
break;
}
- if (t->state == TRANS_CANCEL)
- {
+ if (t->state == TRANS_CANCEL) {
postTrans(C, t);
return 0;
}
/* overwrite initial values if operator supplied a non-null vector */
- if ( (prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) {
float values[4]= {0}; /* in case value isn't length 4, avoid uninitialized memory */
if (RNA_property_array_check(prop)) {
@@ -1756,22 +1735,19 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
}
/* Transformation axis from operator */
- if ((prop = RNA_struct_find_property(op->ptr, "axis")) && RNA_property_is_set(op->ptr, prop))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "axis")) && RNA_property_is_set(op->ptr, prop)) {
RNA_property_float_get_array(op->ptr, prop, t->axis);
normalize_v3(t->axis);
copy_v3_v3(t->axis_orig, t->axis);
}
/* Constraint init from operator */
- if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop))
- {
+ if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) {
int constraint_axis[3];
RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
- if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2])
- {
+ if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
t->con.mode |= CON_APPLY;
if (constraint_axis[0]) {
@@ -1797,8 +1773,7 @@ void transformApply(bContext *C, TransInfo *t)
{
t->context = C;
- if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT)))
- {
+ if ((t->redraw & TREDRAW_HARD) || (t->draw_handle_apply == NULL && (t->redraw & TREDRAW_SOFT))) {
selectConstraint(t);
if (t->transform) {
t->transform(t, t->mval); // calls recalcData()
@@ -1811,13 +1786,11 @@ void transformApply(bContext *C, TransInfo *t)
}
/* If auto confirm is on, break after one pass */
- if (t->options & CTX_AUTOCONFIRM)
- {
+ if (t->options & CTX_AUTOCONFIRM) {
t->state = TRANS_CONFIRM;
}
- if (BKE_ptcache_get_continue_physics())
- {
+ if (BKE_ptcache_get_continue_physics()) {
// TRANSFORM_FIX_ME
//do_screenhandlers(G.curscreen);
t->redraw |= TREDRAW_HARD;
@@ -1842,11 +1815,9 @@ int transformEnd(bContext *C, TransInfo *t)
t->context = C;
- if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING)
- {
+ if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) {
/* handle restoring objects */
- if (t->state == TRANS_CANCEL)
- {
+ if (t->state == TRANS_CANCEL) {
/* exception, edge slide transformed UVs too */
if (t->mode==TFM_EDGE_SLIDE)
doEdgeSlide(t, 0.0f);
@@ -2097,8 +2068,7 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
* - current space should be local
*/
memset(cob, 0, sizeof(bConstraintOb));
- if (td->ext)
- {
+ if (td->ext) {
if (td->ext->rotOrder == ROT_MODE_QUAT) {
/* quats */
/* objects and bones do normalization first too, otherwise
@@ -2271,8 +2241,7 @@ static void postInputWarp(TransInfo *t, float values[3])
{
mul_v3_fl(values, (float)(M_PI * 2));
- if (t->customData) /* non-null value indicates reversed input */
- {
+ if (t->customData) { /* non-null value indicates reversed input */
negate_v3(values);
}
}
@@ -2324,8 +2293,7 @@ int handleEventWarp(TransInfo *t, wmEvent *event)
{
int status = 0;
- if (event->type == MIDDLEMOUSE && event->val==KM_PRESS)
- {
+ if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
// Use customData pointer to signal warp direction
if (t->customData == NULL)
t->customData = (void*)1;
@@ -2465,11 +2433,9 @@ int handleEventShear(TransInfo *t, wmEvent *event)
{
int status = 0;
- if (event->type == MIDDLEMOUSE && event->val==KM_PRESS)
- {
+ if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
// Use customData pointer to signal Shear direction
- if (t->customData == NULL)
- {
+ if (t->customData == NULL) {
initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
t->customData = (void*)1;
}
@@ -2603,7 +2569,7 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
}
if (t->con.mode & CON_APPLY) {
- switch(t->num.idx_max) {
+ switch (t->num.idx_max) {
case 0:
spos += sprintf(spos, "Scale: %s%s %s", &tvec[0], t->con.text, t->proptext);
break;
@@ -2755,8 +2721,7 @@ int Resize(TransInfo *t, const int mval[2])
char str[200];
/* for manipulator, center handle, the scaling can't be done relative to center */
- if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0)
- {
+ if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) {
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f;
}
else {
@@ -2774,8 +2739,7 @@ int Resize(TransInfo *t, const int mval[2])
applySnapping(t, size);
- if (t->flag & T_AUTOVALUES)
- {
+ if (t->flag & T_AUTOVALUES) {
copy_v3_v3(size, t->auto_values);
}
@@ -3008,8 +2972,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
copy_m3_m4(pmtx, t->poseobj->obmat);
invert_m3_m3(imtx, pmtx);
- if ((td->flag & TD_NO_LOC) == 0)
- {
+ if ((td->flag & TD_NO_LOC) == 0) {
sub_v3_v3v3(vec, td->center, center);
mul_m3_v3(pmtx, vec); // To Global space
@@ -3093,8 +3056,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
}
}
else {
- if ((td->flag & TD_NO_LOC) == 0)
- {
+ if ((td->flag & TD_NO_LOC) == 0) {
/* translation */
sub_v3_v3v3(vec, td->center, center);
mul_m3_v3(mat, vec);
@@ -3440,7 +3402,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
autoik[0]= '\0';
if (t->con.mode & CON_APPLY) {
- switch(t->num.idx_max) {
+ switch (t->num.idx_max) {
case 0:
spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]);
break;
@@ -3899,7 +3861,7 @@ void initBevel(TransInfo *t)
int handleEventBevel(TransInfo *t, wmEvent *event)
{
- if (event->val==KM_PRESS) {
+ if (event->val == KM_PRESS) {
if (!G.editBMesh) return 0;
switch (event->type) {
@@ -5243,8 +5205,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
/* saving original center */
copy_v3_v3(center, t->center);
- for (i = 0 ; i < t->total; i++, td++)
- {
+ for (i = 0 ; i < t->total; i++, td++) {
float mat[3][3], invmat[3][3];
if (td->flag & TD_NOACTION)
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 18e9c1a47b8..ebded7b0a6e 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -76,8 +76,7 @@ static void drawObjectConstraint(TransInfo *t);
static void constraintAutoValues(TransInfo *t, float vec[3])
{
int mode = t->con.mode;
- if (mode & CON_APPLY)
- {
+ if (mode & CON_APPLY) {
float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
if ((mode & CON_AXIS0) == 0) {
@@ -478,7 +477,7 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
if (!td && t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
- switch(mode) {
+ switch (mode) {
case CON_AXIS0:
case (CON_AXIS1|CON_AXIS2):
copy_v3_v3(vec, t->con.mtx[0]);
@@ -525,7 +524,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
td= t->data;
}
- switch(mode) {
+ switch (mode) {
case CON_AXIS0:
case (CON_AXIS1|CON_AXIS2):
copy_v3_v3(vec, td->axismtx[0]);
@@ -604,7 +603,7 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
{
char text[40];
- switch(orientation) {
+ switch (orientation) {
case V3D_MANIP_GLOBAL:
{
float mtx[3][3]= MAT3_UNITY;
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 062f88f8837..d33b8787121 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -127,8 +127,7 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
TransData *itail = tail;
*temp = *head;
- while (head < tail)
- {
+ while (head < tail) {
if (t->flag & T_PROP_CONNECTED) {
while ((tail->dist >= temp->dist) && (head < tail))
tail--;
@@ -138,8 +137,7 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
tail--;
}
- if (head != tail)
- {
+ if (head != tail) {
*head = *tail;
head++;
}
@@ -153,8 +151,7 @@ static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, Tra
head++;
}
- if (head != tail)
- {
+ if (head != tail) {
*tail = *head;
tail--;
}
@@ -535,13 +532,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
td->ob = ob;
td->flag = TD_SELECTED;
- if (bone->flag & BONE_HINGE_CHILD_TRANSFORM)
- {
+ if (bone->flag & BONE_HINGE_CHILD_TRANSFORM) {
td->flag |= TD_NOCENTER;
}
- if (bone->flag & BONE_TRANSFORM_CHILD)
- {
+ if (bone->flag & BONE_TRANSFORM_CHILD) {
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
@@ -2707,8 +2702,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
center[2]= 0.0f;
/* set td's based on which handles are applicable */
- if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA))
- {
+ if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) {
/* just set tdn to assume that it only has one handle for now */
tdn->handle= -1;
@@ -2739,8 +2733,7 @@ static void createTransNlaData(bContext *C, TransInfo *t)
td->extra= tdn;
td++;
}
- if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA))
- {
+ if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) {
/* if tdn is already holding the start handle, then we're doing both, otherwise, only end */
tdn->handle= (tdn->handle) ? 2 : 1;
@@ -3993,7 +3986,7 @@ static TransData *SeqToTransData(TransData *td, TransData2D *td2d, TransDataSeq
{
int start_left;
- switch(sel_flag) {
+ switch (sel_flag) {
case SELECT:
/* Use seq_tx_get_final_left() and an offset here
* so transform has the left hand location of the strip.
@@ -4447,8 +4440,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
}
/* set active flag */
- if (ob == OBACT)
- {
+ if (ob == OBACT) {
td->flag |= TD_ACTIVE;
}
}
@@ -4500,8 +4492,7 @@ static void set_trans_object_base_flags(TransInfo *t)
parsel= parsel->parent;
}
- if (parsel)
- {
+ if (parsel) {
/* rotation around local centers are allowed to propagate */
if ((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL) {
base->flag |= BA_TRANSFORM_CHILD;
@@ -4534,10 +4525,8 @@ static int mark_children(Object *ob)
if (ob->flag & (SELECT|BA_TRANSFORM_CHILD))
return 1;
- if (ob->parent)
- {
- if (mark_children(ob->parent))
- {
+ if (ob->parent) {
+ if (mark_children(ob->parent)) {
ob->flag |= BA_TRANSFORM_CHILD;
return 1;
}
@@ -4554,8 +4543,7 @@ static int count_proportional_objects(TransInfo *t)
Base *base;
/* rotations around local centers are allowed to propagate, so we take all objects */
- if (!((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL))
- {
+ if (!((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL)) {
/* mark all parents */
for (base= scene->base.first; base; base= base->next) {
if (TESTBASELIB_BGMODE(v3d, scene, base)) {
@@ -4616,8 +4604,7 @@ static void clear_trans_object_base_flags(TransInfo *t)
Scene *sce = t->scene;
Base *base;
- for (base= sce->base.first; base; base = base->next)
- {
+ for (base= sce->base.first; base; base = base->next) {
if (base->flag & BA_WAS_SEL)
base->flag |= SELECT;
@@ -5070,8 +5057,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
- if (ac.datatype)
- {
+ if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE);
@@ -5120,8 +5106,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
if (ANIM_animdata_get_context(C, &ac) == 0)
return;
- if (ac.datatype)
- {
+ if (ac.datatype) {
ListBase anim_data = {NULL, NULL};
bAnimListElem *ale;
short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT);
@@ -5147,8 +5132,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
}
}
else if (t->obedit) {
- if (t->obedit->type == OB_MESH)
- {
+ if (t->obedit->type == OB_MESH) {
BMEditMesh *em = BMEdit_FromObject(t->obedit);
/* table needs to be created for each edit command, since vertices can move etc */
mesh_octree_table(t->obedit, em, NULL, 'e');
@@ -5298,8 +5282,7 @@ static void createTransObject(bContext *C, TransInfo *t)
return;
}
- if (propmode)
- {
+ if (propmode) {
t->total += count_proportional_objects(t);
}
@@ -5315,8 +5298,7 @@ static void createTransObject(bContext *C, TransInfo *t)
td->ext = tx;
td->ext->rotOrder= ob->rotmode;
- if (base->flag & BA_TRANSFORM_CHILD)
- {
+ if (base->flag & BA_TRANSFORM_CHILD) {
td->flag |= TD_NOCENTER;
td->flag |= TD_NO_LOC;
}
@@ -5333,8 +5315,7 @@ static void createTransObject(bContext *C, TransInfo *t)
}
CTX_DATA_END;
- if (propmode)
- {
+ if (propmode) {
Scene *scene = t->scene;
View3D *v3d = t->view;
Base *base;
@@ -5343,7 +5324,8 @@ static void createTransObject(bContext *C, TransInfo *t)
Object *ob= base->object;
/* if base is not selected, not a parent of selection or not a child of selection and it is editable */
- if ((ob->flag & (SELECT|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT)) == 0 && BASE_EDITABLE_BGMODE(v3d, scene, base))
+ if ((ob->flag & (SELECT | BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 &&
+ BASE_EDITABLE_BGMODE(v3d, scene, base))
{
td->protectflag= ob->protectflag;
td->ext = tx;
@@ -6032,12 +6014,10 @@ void createTransData(bContext *C, TransInfo *t)
sort_trans_data_dist(t);
}
- if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW))
- {
+ if ((t->spacetype == SPACE_VIEW3D) && (t->ar->regiontype == RGN_TYPE_WINDOW)) {
View3D *v3d = t->view;
RegionView3D *rv3d = CTX_wm_region_view3d(C);
- if (rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB)
- {
+ if (rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB) {
t->flag |= T_CAMERA;
}
}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index b500398dd76..2c5d074e2cf 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -111,8 +111,7 @@
void getViewVector(TransInfo *t, float coord[3], float vec[3])
{
- if (t->persp != RV3D_ORTHO)
- {
+ if (t->persp != RV3D_ORTHO) {
float p1[4], p2[4];
copy_v3_v3(p1, coord);
@@ -256,8 +255,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t)
eve->co[2]= td->loc[2];
}
- if (td->flag & TD_MIRROR_EDGE)
- {
+ if (td->flag & TD_MIRROR_EDGE) {
td->loc[0] = 0;
}
}
@@ -775,21 +773,17 @@ static void recalcData_view3d(TransInfo *t)
}
- if (t->mode != TFM_BONE_ROLL)
- {
+ if (t->mode != TFM_BONE_ROLL) {
/* fix roll */
- for (i = 0; i < t->total; i++, td++)
- {
- if (td->extra)
- {
+ for (i = 0; i < t->total; i++, td++) {
+ if (td->extra) {
float vec[3], up_axis[3];
float qrot[4];
ebo = td->extra;
copy_v3_v3(up_axis, td->axismtx[2]);
- if (t->mode != TFM_ROTATION)
- {
+ if (t->mode != TFM_ROTATION) {
sub_v3_v3v3(vec, ebo->tail, ebo->head);
normalize_v3(vec);
rotation_between_vecs_to_quat(qrot, td->axismtx[1], vec);
@@ -915,8 +909,7 @@ void drawLine(TransInfo *t, float *center, float *dir, char axis, short options)
float v1[3], v2[3], v3[3];
unsigned char col[3], col2[3];
- if (t->spacetype == SPACE_VIEW3D)
- {
+ if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = t->view;
glPushMatrix();
@@ -984,8 +977,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->redraw = 1; /* redraw first time */
- if (event)
- {
+ if (event) {
copy_v2_v2_int(t->imval, event->mval);
t->event_type = event->type;
}
@@ -1043,8 +1035,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
- if (t->spacetype == SPACE_VIEW3D)
- {
+ if (t->spacetype == SPACE_VIEW3D) {
View3D *v3d = sa->spacedata.first;
t->view = v3d;
@@ -1060,12 +1051,12 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN;
t->around = v3d->around;
- if (op && RNA_struct_find_property(op->ptr, "constraint_orientation") && RNA_struct_property_is_set(op->ptr, "constraint_orientation"))
+ if (op && (RNA_struct_find_property(op->ptr, "constraint_orientation") &&
+ RNA_struct_property_is_set(op->ptr, "constraint_orientation")))
{
t->current_orientation = RNA_enum_get(op->ptr, "constraint_orientation");
-
- if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C))
- {
+
+ if (t->current_orientation >= V3D_MANIP_CUSTOM + BIF_countTransformOrientation(C)) {
t->current_orientation = V3D_MANIP_GLOBAL;
}
}
@@ -1124,10 +1115,8 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->around = V3D_CENTER;
}
- if (op && RNA_struct_property_is_set(op->ptr, "release_confirm"))
- {
- if (RNA_boolean_get(op->ptr, "release_confirm"))
- {
+ if (op && RNA_struct_property_is_set(op->ptr, "release_confirm")) {
+ if (RNA_boolean_get(op->ptr, "release_confirm")) {
t->flag |= T_RELEASE_CONFIRM;
}
}
@@ -1137,35 +1126,31 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
}
- if (op && RNA_struct_find_property(op->ptr, "mirror") && RNA_struct_property_is_set(op->ptr, "mirror"))
+ if (op && (RNA_struct_find_property(op->ptr, "mirror") &&
+ RNA_struct_property_is_set(op->ptr, "mirror")))
{
- if (RNA_boolean_get(op->ptr, "mirror"))
- {
+ if (RNA_boolean_get(op->ptr, "mirror")) {
t->flag |= T_MIRROR;
t->mirror = 1;
}
}
// Need stuff to take it from edit mesh or whatnot here
else if (t->spacetype == SPACE_VIEW3D) {
- if (t->obedit && t->obedit->type == OB_MESH && (((Mesh *)t->obedit->data)->editflag & ME_EDIT_MIRROR_X))
- {
+ if (t->obedit && t->obedit->type == OB_MESH && (((Mesh *)t->obedit->data)->editflag & ME_EDIT_MIRROR_X)) {
t->flag |= T_MIRROR;
t->mirror = 1;
}
}
/* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */
- if (op && RNA_struct_find_property(op->ptr, "proportional"))
- {
- if (RNA_struct_property_is_set(op->ptr, "proportional"))
- {
- switch(RNA_enum_get(op->ptr, "proportional"))
- {
- case PROP_EDIT_CONNECTED:
- t->flag |= T_PROP_CONNECTED;
- case PROP_EDIT_ON:
- t->flag |= T_PROP_EDIT;
- break;
+ if (op && RNA_struct_find_property(op->ptr, "proportional")) {
+ if (RNA_struct_property_is_set(op->ptr, "proportional")) {
+ switch (RNA_enum_get(op->ptr, "proportional")) {
+ case PROP_EDIT_CONNECTED:
+ t->flag |= T_PROP_CONNECTED;
+ case PROP_EDIT_ON:
+ t->flag |= T_PROP_EDIT;
+ break;
}
}
else {
@@ -1186,7 +1171,8 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
}
}
- if (op && RNA_struct_find_property(op->ptr, "proportional_size") && RNA_struct_property_is_set(op->ptr, "proportional_size"))
+ if (op && (RNA_struct_find_property(op->ptr, "proportional_size") &&
+ RNA_struct_property_is_set(op->ptr, "proportional_size")))
{
t->prop_size = RNA_float_get(op->ptr, "proportional_size");
}
@@ -1196,13 +1182,13 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
/* TRANSFORM_FIX_ME rna restrictions */
- if (t->prop_size <= 0.00001f)
- {
+ if (t->prop_size <= 0.00001f) {
printf("Proportional size (%f) under 0.00001, reseting to 1!\n", t->prop_size);
t->prop_size = 1.0f;
}
- if (op && RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && RNA_struct_property_is_set(op->ptr, "proportional_edit_falloff"))
+ if (op && (RNA_struct_find_property(op->ptr, "proportional_edit_falloff") &&
+ RNA_struct_property_is_set(op->ptr, "proportional_edit_falloff")))
{
t->prop_mode = RNA_enum_get(op->ptr, "proportional_edit_falloff");
}
@@ -1210,14 +1196,12 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event)
t->prop_mode = ts->prop_mode;
}
}
- else /* add not pet option to context when not available */
- {
+ else { /* add not pet option to context when not available */
t->options |= CTX_NO_PET;
}
// Mirror is not supported with PET, turn it off.
- if (t->flag & T_PROP_EDIT)
- {
+ if (t->flag & T_PROP_EDIT) {
t->flag &= ~T_MIRROR;
}
@@ -1282,8 +1266,7 @@ void postTrans (bContext *C, TransInfo *t)
}
}
- if (t->mouse.data)
- {
+ if (t->mouse.data) {
MEM_freeN(t->mouse.data);
}
}
@@ -1440,8 +1423,7 @@ void calculateCenterMedian(TransInfo *t)
for (i = 0; i < t->total; i++) {
if (t->data[i].flag & TD_SELECTED) {
- if (!(t->data[i].flag & TD_NOCENTER))
- {
+ if (!(t->data[i].flag & TD_NOCENTER)) {
add_v3_v3(partial, t->data[i].center);
total++;
}
@@ -1493,7 +1475,7 @@ void calculateCenterBound(TransInfo *t)
void calculateCenter(TransInfo *t)
{
- switch(t->around) {
+ switch (t->around) {
case V3D_CENTER:
calculateCenterBound(t);
break;
@@ -1542,8 +1524,7 @@ void calculateCenter(TransInfo *t)
} /* END EDIT MODE ACTIVE ELEMENT */
calculateCenterMedian(t);
- if ((t->flag & (T_EDIT|T_POSE))==0)
- {
+ if ((t->flag & (T_EDIT|T_POSE))==0) {
Scene *scene = t->scene;
Object *ob= OBACT;
if (ob) {
@@ -1583,8 +1564,7 @@ void calculateCenter(TransInfo *t)
projectIntView(t, axis, t->center2d);
/* rotate only needs correct 2d center, grab needs initgrabz() value */
- if (t->mode==TFM_TRANSLATION)
- {
+ if (t->mode==TFM_TRANSLATION) {
copy_v3_v3(t->center, axis);
copy_v3_v3(t->con.center, t->center);
}
@@ -1625,11 +1605,8 @@ void calculatePropRatio(TransInfo *t)
td->factor = 0.0f;
restoreElement(td);
}
- else if ((connected &&
- (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size))
- ||
- (connected == 0 &&
- td->rdist > t->prop_size))
+ else if ((connected && (td->flag & TD_NOTCONNECTED || td->dist > t->prop_size)) ||
+ (connected == 0 && td->rdist > t->prop_size))
{
/*
* The elements are sorted according to their dist member in the array,
@@ -1656,7 +1633,7 @@ void calculatePropRatio(TransInfo *t)
if (dist < 0.0f)
dist = 0.0f;
- switch(t->prop_mode) {
+ switch (t->prop_mode) {
case PROP_SHARP:
td->factor= dist*dist;
break;
@@ -1684,7 +1661,7 @@ void calculatePropRatio(TransInfo *t)
}
}
}
- switch(t->prop_mode) {
+ switch (t->prop_mode) {
case PROP_SHARP:
strcpy(t->proptext, "(Sharp)");
break;
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index bd3fb20f77f..467e3dc600e 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -313,8 +313,7 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
}
#endif
- switch(mode)
- {
+ switch (mode) {
case INPUT_VECTOR:
mi->apply = InputVector;
t->helpline = HLP_NONE;
@@ -391,8 +390,7 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)
{
int redraw = TREDRAW_NOTHING;
- switch (event->type)
- {
+ switch (event->type) {
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 5b70b25c894..c043be0c7f8 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -549,7 +549,7 @@ int calc_manipulator_stats(const bContext *C)
/* global, local or normal orientation? */
if (ob && totsel) {
- switch(v3d->twmode) {
+ switch (v3d->twmode) {
case V3D_MANIP_GLOBAL:
break; /* nothing to do */
@@ -761,7 +761,7 @@ static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned c
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
}
else {
- switch(axis) {
+ switch (axis) {
case 'C':
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
if (v3d->twmode == V3D_MANIP_LOCAL) {
@@ -1483,7 +1483,7 @@ void BIF_draw_manipulator(const bContext *C)
v3d->twflag |= V3D_DRAW_MANIPULATOR;
/* now we can define center */
- switch(v3d->around) {
+ switch (v3d->around) {
case V3D_CENTER:
case V3D_ACTIVE:
rv3d->twmat[3][0]= (scene->twmin[0] + scene->twmax[0])/2.0f;
@@ -1639,7 +1639,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
if (drawflags==0) drawflags= val;
if (drawflags & MAN_TRANS_C) {
- switch(drawflags) {
+ switch (drawflags) {
case MAN_TRANS_C:
break;
case MAN_TRANS_X:
@@ -1672,7 +1672,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
//wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_translate", 0), event, op->ptr, NULL, FALSE);
}
else if (drawflags & MAN_SCALE_C) {
- switch(drawflags) {
+ switch (drawflags) {
case MAN_SCALE_X:
if (shift) {
constraint_axis[1] = 1;
@@ -1707,7 +1707,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op)
//wm_operator_invoke(C, WM_operatortype_find("TRANSFORM_OT_trackball", 0), event, op->ptr, NULL, FALSE);
}
else if (drawflags & MAN_ROT_C) {
- switch(drawflags) {
+ switch (drawflags) {
case MAN_ROT_X:
constraint_axis[0] = 1;
break;
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index 09078c199c4..b9ae3180591 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -317,23 +317,19 @@ static void transformops_exit(bContext *C, wmOperator *op)
static int transformops_data(bContext *C, wmOperator *op, wmEvent *event)
{
int retval = 1;
- if (op->customdata == NULL)
- {
+ if (op->customdata == NULL) {
TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
TransformModeItem *tmode;
int mode = -1;
- for (tmode = transform_modes; tmode->idname; tmode++)
- {
- if (op->type->idname == tmode->idname)
- {
+ for (tmode = transform_modes; tmode->idname; tmode++) {
+ if (op->type->idname == tmode->idname) {
mode = tmode->mode;
break;
}
}
- if (mode == -1)
- {
+ if (mode == -1) {
mode = RNA_enum_get(op->ptr, "mode");
}
@@ -376,8 +372,7 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
exit_code |= transformEnd(C, t);
- if ((exit_code & OPERATOR_RUNNING_MODAL) == 0)
- {
+ if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
transformops_exit(C, op);
exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
}
@@ -400,8 +395,7 @@ static int transform_exec(bContext *C, wmOperator *op)
{
TransInfo *t;
- if (!transformops_data(C, op, NULL))
- {
+ if (!transformops_data(C, op, NULL)) {
G.moving = 0;
return OPERATOR_CANCELLED;
}
@@ -423,8 +417,7 @@ static int transform_exec(bContext *C, wmOperator *op)
static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- if (!transformops_data(C, op, event))
- {
+ if (!transformops_data(C, op, event)) {
G.moving = 0;
return OPERATOR_CANCELLED;
}
@@ -445,8 +438,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
{
PropertyRNA *prop;
- if (flags & P_AXIS)
- {
+ if (flags & P_AXIS) {
prop= RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
RNA_def_property_array(prop, 3);
/* Make this not hidden when there's a nice axis selection widget */
@@ -455,8 +447,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
- if (flags & P_CONSTRAINT)
- {
+ if (flags & P_CONSTRAINT) {
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
prop= RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
@@ -465,21 +456,18 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
- if (flags & P_MIRROR)
- {
+ if (flags & P_MIRROR) {
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
- if (flags & P_PROPORTIONAL)
- {
+ if (flags & P_PROPORTIONAL) {
RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", "");
RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode");
RNA_def_float(ot->srna, "proportional_size", 1, 0.00001f, FLT_MAX, "Proportional Size", "", 0.001, 100);
}
- if (flags & P_SNAP)
- {
+ if (flags & P_SNAP) {
prop= RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
RNA_def_property_flag(prop, PROP_HIDDEN);
@@ -497,14 +485,12 @@ void Transform_Properties(struct wmOperatorType *ot, int flags)
}
}
}
-
- if (flags & P_OPTIONS)
- {
+
+ if (flags & P_OPTIONS) {
RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
}
- if (flags & P_CORRECT_UV)
- {
+ if (flags & P_CORRECT_UV) {
RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
}
@@ -827,8 +813,7 @@ void transform_operatortypes(void)
{
TransformModeItem *tmode;
- for (tmode = transform_modes; tmode->idname; tmode++)
- {
+ for (tmode = transform_modes; tmode->idname; tmode++) {
WM_operatortype_append(tmode->opfunc);
}
@@ -853,15 +838,13 @@ void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spac
if (modalmap) {
TransformModeItem *tmode;
- for (tmode = transform_modes; tmode->idname; tmode++)
- {
+ for (tmode = transform_modes; tmode->idname; tmode++) {
WM_modalkeymap_assign(modalmap, tmode->idname);
}
WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform");
}
- switch(spaceid)
- {
+ switch (spaceid) {
case SPACE_VIEW3D:
WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 0f929003e8f..0f9f90819d0 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -176,8 +176,7 @@ TransformOrientation *createMeshSpace(bContext *C, ReportList *reports, char *na
type = getTransformOrientation(C, normal, plane, 0);
- switch (type)
- {
+ switch (type) {
case ORIENTATION_VERT:
if (createSpaceNormal(mat, normal) == 0) {
BKE_reports_prepend(reports, "Cannot use vertex with zero-length normal");
@@ -493,7 +492,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
Object *ob = CTX_data_active_object(C);
Object *obedit = CTX_data_active_object(C);
- switch(t->current_orientation) {
+ switch (t->current_orientation) {
case V3D_MANIP_GLOBAL:
unit_m3(t->spacemtx);
strcpy(t->spacename, "global");
@@ -581,8 +580,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
BM_editselection_normal(&ese, normal);
BM_editselection_plane(&ese, plane);
- switch (ese.htype)
- {
+ switch (ese.htype) {
case BM_VERT:
result = ORIENTATION_VERT;
break;
@@ -724,8 +722,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
- while (a--)
- {
+ while (a--) {
/* exception */
if ((bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT) {
sub_v3_v3v3(normal, bezt->vec[0], bezt->vec[2]);
@@ -886,8 +883,7 @@ void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[]
type = getTransformOrientation(C, normal, plane, activeOnly);
- switch (type)
- {
+ switch (type) {
case ORIENTATION_NORMAL:
if (createSpaceNormalTangent(orientation_mat, normal, plane) == 0) {
type = ORIENTATION_NONE;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 7bdd3ddc069..0a5613bca22 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -140,8 +140,7 @@ int activeSnap(TransInfo *t)
void drawSnapping(const struct bContext *C, TransInfo *t)
{
- if (validSnap(t) && activeSnap(t))
- {
+ if (validSnap(t) && activeSnap(t)) {
unsigned char col[4], selectedCol[4], activeCol[4];
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
@@ -184,8 +183,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
}
/* draw normal if needed */
- if (usingSnappingNormal(t) && validSnappingNormal(t))
- {
+ if (usingSnappingNormal(t) && validSnappingNormal(t)) {
glColor4ubv(activeCol);
glBegin(GL_LINES);
@@ -240,16 +238,14 @@ int handleSnapping(TransInfo *t, wmEvent *event)
int status = 0;
#if 0 // XXX need a proper selector for all snap mode
- if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift)
- {
+ if (BIF_snappingSupported(t->obedit) && event->type == TABKEY && event->shift) {
/* toggle snap and reinit */
t->settings->snap_flag ^= SCE_SNAP;
initSnapping(t, NULL);
status = 1;
}
#endif
- if (event->type == MOUSEMOVE)
- {
+ if (event->type == MOUSEMOVE) {
status |= updateSelectedSnapPoint(t);
}
@@ -259,8 +255,7 @@ int handleSnapping(TransInfo *t, wmEvent *event)
void applyProject(TransInfo *t)
{
/* XXX FLICKER IN OBJECT MODE */
- if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0)
- {
+ if ((t->tsnap.project) && activeSnap(t) && (t->flag & T_NO_PROJECT) == 0) {
TransData *td = t->data;
float tvec[3];
float imat[4][4];
@@ -283,8 +278,7 @@ void applyProject(TransInfo *t)
continue;
copy_v3_v3(iloc, td->loc);
- if (t->flag & (T_EDIT|T_POSE))
- {
+ if (t->flag & (T_EDIT|T_POSE)) {
Object *ob = t->obedit?t->obedit:t->poseobj;
mul_m4_v3(ob->obmat, iloc);
}
@@ -296,8 +290,7 @@ void applyProject(TransInfo *t)
project_float(t->ar, iloc, mval);
- if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect))
- {
+ if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) {
// if (t->flag & (T_EDIT|T_POSE)) {
// mul_m4_v3(imat, loc);
// }
@@ -320,8 +313,7 @@ void applySnapping(TransInfo *t, float *vec)
if (t->tsnap.project)
return;
- if (t->tsnap.status & SNAP_FORCED)
- {
+ if (t->tsnap.status & SNAP_FORCED) {
t->tsnap.targetSnap(t);
t->tsnap.applySnap(t, vec);
@@ -331,15 +323,13 @@ void applySnapping(TransInfo *t, float *vec)
// Time base quirky code to go around findnearest slowness
/* !TODO! add exception for object mode, no need to slow it down then */
- if (current - t->tsnap.last >= 0.01)
- {
+ if (current - t->tsnap.last >= 0.01) {
t->tsnap.calcSnap(t, vec);
t->tsnap.targetSnap(t);
t->tsnap.last = current;
}
- if (validSnap(t))
- {
+ if (validSnap(t)) {
t->tsnap.applySnap(t, vec);
}
}
@@ -368,10 +358,8 @@ int usingSnappingNormal(TransInfo *t)
int validSnappingNormal(TransInfo *t)
{
- if (validSnap(t))
- {
- if (dot_v3v3(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0)
- {
+ if (validSnap(t)) {
+ if (dot_v3v3(t->tsnap.snapNormal, t->tsnap.snapNormal) > 0) {
return 1;
}
}
@@ -439,38 +427,31 @@ void initSnapping(TransInfo *t, wmOperator *op)
resetSnapping(t);
/* if snap property exists */
- if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_property_is_set(op->ptr, "snap"))
- {
- if (RNA_boolean_get(op->ptr, "snap"))
- {
+ if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_property_is_set(op->ptr, "snap")) {
+ if (RNA_boolean_get(op->ptr, "snap")) {
t->modifiers |= MOD_SNAP;
- if (RNA_struct_property_is_set(op->ptr, "snap_target"))
- {
+ if (RNA_struct_property_is_set(op->ptr, "snap_target")) {
snap_target = RNA_enum_get(op->ptr, "snap_target");
}
- if (RNA_struct_property_is_set(op->ptr, "snap_point"))
- {
+ if (RNA_struct_property_is_set(op->ptr, "snap_point")) {
RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
t->tsnap.status |= SNAP_FORCED|POINT_INIT;
}
/* snap align only defined in specific cases */
- if (RNA_struct_find_property(op->ptr, "snap_align"))
- {
+ if (RNA_struct_find_property(op->ptr, "snap_align")) {
t->tsnap.align = RNA_boolean_get(op->ptr, "snap_align");
RNA_float_get_array(op->ptr, "snap_normal", t->tsnap.snapNormal);
normalize_v3(t->tsnap.snapNormal);
}
- if (RNA_struct_find_property(op->ptr, "use_snap_project"))
- {
+ if (RNA_struct_find_property(op->ptr, "use_snap_project")) {
t->tsnap.project = RNA_boolean_get(op->ptr, "use_snap_project");
}
- if (RNA_struct_find_property(op->ptr, "use_snap_self"))
- {
+ if (RNA_struct_find_property(op->ptr, "use_snap_self")) {
t->tsnap.snap_self = RNA_boolean_get(op->ptr, "use_snap_self");
}
}
@@ -498,8 +479,7 @@ static void setSnappingCallback(TransInfo *t)
{
t->tsnap.calcSnap = CalcSnapGeometry;
- switch(t->tsnap.target)
- {
+ switch (t->tsnap.target) {
case SCE_SNAP_TARGET_CLOSEST:
t->tsnap.targetSnap = TargetSnapClosest;
break;
@@ -515,8 +495,7 @@ static void setSnappingCallback(TransInfo *t)
}
- switch (t->mode)
- {
+ switch (t->mode) {
case TFM_TRANSLATION:
t->tsnap.applySnap = ApplySnapTranslation;
t->tsnap.distance = TranslationBetween;
@@ -766,8 +745,7 @@ static void UNUSED_FUNCTION(CalcSnapGrid)(TransInfo *t, float *UNUSED(vec))
static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
{
- if (t->spacetype == SPACE_VIEW3D)
- {
+ if (t->spacetype == SPACE_VIEW3D) {
float loc[3];
float no[3];
float mval[2];
@@ -777,8 +755,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
mval[0] = t->mval[0];
mval[1] = t->mval[1];
- if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME)
- {
+ if (t->tsnap.mode == SCE_SNAP_MODE_VOLUME) {
ListBase depth_peels;
DepthPeel *p1, *p2;
float *last_p = NULL;
@@ -799,10 +776,8 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
// }
- for (p1 = depth_peels.first; p1; p1 = p1->next)
- {
- if (p1->flag == 0)
- {
+ for (p1 = depth_peels.first; p1; p1 = p1->next) {
+ if (p1->flag == 0) {
float vec[3];
float new_dist;
@@ -810,13 +785,10 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
p1->flag = 1;
/* if peeling objects, take the first and last from each object */
- if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT)
- {
+ if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) {
DepthPeel *peel;
- for (peel = p1->next; peel; peel = peel->next)
- {
- if (peel->ob == p1->ob)
- {
+ for (peel = p1->next; peel; peel = peel->next) {
+ if (peel->ob == p1->ob) {
peel->flag = 1;
p2 = peel;
}
@@ -824,8 +796,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
}
/* otherwise, pair first with second and so on */
else {
- for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next)
- {
+ for (p2 = p1->next; p2 && p2->ob != p1->ob; p2 = p2->next) {
/* nothing to do here */
}
}
@@ -839,9 +810,8 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
else {
copy_v3_v3(vec, p1->p);
}
-
- if (last_p == NULL)
- {
+
+ if (last_p == NULL) {
copy_v3_v3(p, vec);
max_dist = 0;
break;
@@ -856,8 +826,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
}
}
- if (max_dist != FLT_MAX)
- {
+ if (max_dist != FLT_MAX) {
copy_v3_v3(loc, p);
/* XXX, is there a correct normal in this case ???, for now just z up */
no[0]= 0.0;
@@ -878,8 +847,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
sub_v3_v3v3(tangent, loc, t->tsnap.snapPoint);
tangent[2] = 0;
- if (dot_v3v3(tangent, tangent) > 0)
- {
+ if (dot_v3v3(tangent, tangent) > 0) {
copy_v3_v3(t->tsnap.snapTangent, tangent);
}
@@ -899,8 +867,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1);
- if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint))
- {
+ if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
t->tsnap.snapPoint[0] *= aspx;
t->tsnap.snapPoint[1] *= aspy;
@@ -917,9 +884,8 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
static void TargetSnapCenter(TransInfo *t)
{
- // Only need to calculate once
- if ((t->tsnap.status & TARGET_INIT) == 0)
- {
+ /* Only need to calculate once */
+ if ((t->tsnap.status & TARGET_INIT) == 0) {
copy_v3_v3(t->tsnap.snapTarget, t->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
@@ -932,24 +898,20 @@ static void TargetSnapCenter(TransInfo *t)
static void TargetSnapActive(TransInfo *t)
{
- // Only need to calculate once
- if ((t->tsnap.status & TARGET_INIT) == 0)
- {
+ /* Only need to calculate once */
+ if ((t->tsnap.status & TARGET_INIT) == 0) {
TransData *td = NULL;
TransData *active_td = NULL;
int i;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
- {
- if (td->flag & TD_ACTIVE)
- {
+ for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
+ if (td->flag & TD_ACTIVE) {
active_td = td;
break;
}
}
- if (active_td)
- {
+ if (active_td) {
copy_v3_v3(t->tsnap.snapTarget, active_td->center);
if (t->flag & (T_EDIT|T_POSE)) {
@@ -971,8 +933,7 @@ static void TargetSnapActive(TransInfo *t)
static void TargetSnapMedian(TransInfo *t)
{
// Only need to calculate once
- if ((t->tsnap.status & TARGET_INIT) == 0)
- {
+ if ((t->tsnap.status & TARGET_INIT) == 0) {
TransData *td = NULL;
int i;
@@ -980,8 +941,7 @@ static void TargetSnapMedian(TransInfo *t)
t->tsnap.snapTarget[1] = 0;
t->tsnap.snapTarget[2] = 0;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
- {
+ for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
add_v3_v3(t->tsnap.snapTarget, td->center);
}
@@ -999,21 +959,17 @@ static void TargetSnapMedian(TransInfo *t)
static void TargetSnapClosest(TransInfo *t)
{
// Only valid if a snap point has been selected
- if (t->tsnap.status & POINT_INIT)
- {
+ if (t->tsnap.status & POINT_INIT) {
TransData *closest = NULL, *td = NULL;
/* Object mode */
- if (t->flag & T_OBJECT)
- {
+ if (t->flag & T_OBJECT) {
int i;
- for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++)
- {
+ for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
struct BoundBox *bb = object_get_boundbox(td->ob);
/* use boundbox if possible */
- if (bb)
- {
+ if (bb) {
int j;
for (j = 0; j < 8; j++) {
@@ -1041,8 +997,7 @@ static void TargetSnapClosest(TransInfo *t)
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
- if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
- {
+ if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist)) {
copy_v3_v3(t->tsnap.snapTarget, loc);
closest = td;
t->tsnap.dist = dist;
@@ -1065,8 +1020,7 @@ static void TargetSnapClosest(TransInfo *t)
dist = t->tsnap.distance(t, loc, t->tsnap.snapPoint);
- if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist))
- {
+ if (closest == NULL || fabs(dist) < fabs(t->tsnap.dist)) {
copy_v3_v3(t->tsnap.snapTarget, loc);
closest = td;
t->tsnap.dist = dist;
@@ -1112,8 +1066,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl
project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
- if (new_dist <= *dist && new_depth < *depth)
- {
+ if (new_dist <= *dist && new_depth < *depth) {
*depth = new_depth;
retval = 1;
@@ -1145,8 +1098,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
result = isect_line_line_v3(v1co, v2co, ray_start_local, ray_end, intersect, dvec); /* dvec used but we don't care about result */
- if (result)
- {
+ if (result) {
float edge_loc[3], vec[3];
float mul;
@@ -1167,8 +1119,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
copy_v3_v3(intersect, v2co);
}
- if (dot_v3v3(ray_normal_local, dvec) > 0)
- {
+ if (dot_v3v3(ray_normal_local, dvec) > 0) {
float location[3];
float new_depth;
int screen_loc[2];
@@ -1187,8 +1138,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
* this takes care of series of connected edges a bit slanted w.r.t the viewport
* otherwise, it would stick to the verts of the closest edge and not slide along merrily
* */
- if (new_dist <= *r_dist && new_depth < *r_depth * 1.001f)
- {
+ if (new_dist <= *r_dist && new_depth < *r_depth * 1.001f) {
float n1[3], n2[3];
*r_depth = new_depth;
@@ -1199,8 +1149,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh
mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc);
- if (r_no)
- {
+ if (r_no) {
normal_short_to_float_v3(n1, v1no);
normal_short_to_float_v3(n2, v2no);
interp_v3_v3v3(r_no, n2, n1, mul);
@@ -1227,8 +1176,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
sub_v3_v3v3(dvec, vco, ray_start_local);
- if (dot_v3v3(ray_normal_local, dvec) > 0)
- {
+ if (dot_v3v3(ray_normal_local, dvec) > 0) {
float location[3];
float new_depth;
int screen_loc[2];
@@ -1243,15 +1191,13 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4],
project_int(ar, location, screen_loc);
new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]);
- if (new_dist <= *r_dist && new_depth < *r_depth)
- {
+ if (new_dist <= *r_dist && new_depth < *r_depth) {
*r_depth = new_depth;
retval = 1;
copy_v3_v3(r_loc, location);
- if (r_no)
- {
+ if (r_no) {
normal_short_to_float_v3(r_no, vno);
mul_m3_v3(timat, r_no);
normalize_v3(r_no);
@@ -1280,16 +1226,14 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
mul_m4_v3(imat, ray_start_local);
mul_mat3_m4_v3(imat, ray_normal_local);
- if (arm->edbo)
- {
+ if (arm->edbo) {
EditBone *eBone;
for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
if (eBone->layer & arm->layer) {
/* skip hidden or moving (selected) bones */
if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) {
- switch (snap_mode)
- {
+ switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
retval |= snapVertex(ar, eBone->tail, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
@@ -1313,8 +1257,7 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
float *head_vec = pchan->pose_head;
float *tail_vec = pchan->pose_tail;
- switch (snap_mode)
- {
+ switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
retval |= snapVertex(ar, head_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
retval |= snapVertex(ar, tail_vec, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
@@ -1366,8 +1309,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
if (test == 1) {
- switch (snap_mode)
- {
+ switch (snap_mode) {
case SCE_SNAP_MODE_FACE:
{
#ifdef USE_BVH_FACE_SNAP // Added for durian
@@ -1383,8 +1325,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
hit.index = -1;
hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale);
- if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1)
- {
+ if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) {
if (hit.dist/local_scale <= *r_depth) {
*r_depth= hit.dist/local_scale;
copy_v3_v3(r_loc, hit.co);
@@ -1409,8 +1350,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
int index = 0;
int i;
- if (em != NULL)
- {
+ if (em != NULL) {
index_array = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
EDBM_index_arrays_init(em, 0, 0, 1);
}
@@ -1421,8 +1361,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
test = 1; /* reset for every face */
- if (em != NULL)
- {
+ if (em != NULL) {
if (index_array) {
index = index_array[i];
}
@@ -1436,8 +1375,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
else {
efa = EDBM_face_at_index(em, index);
- if (efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN))
- {
+ if (efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
test = 0;
}
else if (efa) {
@@ -1456,28 +1394,24 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
}
- if (test)
- {
+ if (test) {
int result;
float *v4co = NULL;
- if (f->v4)
- {
+ if (f->v4) {
v4co = verts[f->v4].co;
}
result = snapFace(ar, verts[f->v1].co, verts[f->v2].co, verts[f->v3].co, v4co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
retval |= result;
- if (f->v4 && result == 0)
- {
+ if (f->v4 && result == 0) {
retval |= snapFace(ar, verts[f->v3].co, verts[f->v4].co, verts[f->v1].co, verts[f->v2].co, mval, ray_start, ray_start_local, ray_normal_local, obmat, timat, loc, no, dist, depth);
}
}
}
- if (em != NULL)
- {
+ if (em != NULL) {
EDBM_index_arrays_free(em);
}
#endif
@@ -1490,8 +1424,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
int index = 0;
int i;
- if (em != NULL)
- {
+ if (em != NULL) {
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
EDBM_index_arrays_init(em, 1, 0, 0);
}
@@ -1516,22 +1449,19 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
else {
eve = EDBM_vert_at_index(em, index);
- if (eve && (BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(eve, BM_ELEM_SELECT)))
- {
+ if (eve && (BM_elem_flag_test(eve, BM_ELEM_HIDDEN) || BM_elem_flag_test(eve, BM_ELEM_SELECT))) {
test = 0;
}
}
}
- if (test)
- {
+ if (test) {
retval |= snapVertex(ar, v->co, v->no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth);
}
}
- if (em != NULL)
- {
+ if (em != NULL) {
EDBM_index_arrays_free(em);
}
break;
@@ -1545,8 +1475,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
int index = 0;
int i;
- if (em != NULL)
- {
+ if (em != NULL) {
index_array = dm->getEdgeDataArray(dm, CD_ORIGINDEX);
EDBM_index_arrays_init(em, 0, 1, 0);
}
@@ -1557,8 +1486,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
test = 1; /* reset for every vert */
- if (em != NULL)
- {
+ if (em != NULL) {
if (index_array) {
index = index_array[i];
}
@@ -1580,16 +1508,13 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
}
}
}
-
-
- if (test)
- {
+
+ if (test) {
retval |= snapEdge(ar, verts[e->v1].co, verts[e->v1].no, verts[e->v2].co, verts[e->v2].no, obmat, timat, ray_start, ray_start_local, ray_normal_local, mval, r_loc, r_no, r_dist, r_depth);
}
}
- if (em != NULL)
- {
+ if (em != NULL) {
EDBM_index_arrays_free(em);
}
break;
@@ -1673,8 +1598,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c
DupliObject *dupli_ob;
ListBase *lb = object_duplilist(scene, ob);
- for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
- {
+ for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
Object *dob = dupli_ob->ob;
retval |= snapObject(scene, ar, dob, 0, dupli_ob->mat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
@@ -1726,8 +1650,7 @@ static void removeDoublesPeel(ListBase *depth_peels)
{
DepthPeel *peel;
- for (peel = depth_peels->first; peel; peel = peel->next)
- {
+ for (peel = depth_peels->first; peel; peel = peel->next) {
DepthPeel *next_peel = peel->next;
if (next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) {
@@ -1881,8 +1804,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L
DupliObject *dupli_ob;
ListBase *lb = object_duplilist(scene, ob);
- for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next)
- {
+ for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) {
Object *dob = dupli_ob->ob;
if (dob->type == OB_MESH) {
diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c
index c037508687b..1f1d5a0c0c0 100644
--- a/source/blender/editors/util/numinput.c
+++ b/source/blender/editors/util/numinput.c
@@ -207,8 +207,7 @@ char handleNumInput(NumInput *n, wmEvent *event)
if (n->flag & NUM_NO_FRACTION)
return 0;
- switch (n->ctrl[idx])
- {
+ switch (n->ctrl[idx]) {
case 0:
case 1:
n->ctrl[idx] = 10;