diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:40:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-19 14:40:43 +0400 |
commit | 824ec5a388ca1737418ef4f7d72f1910610a025b (patch) | |
tree | c4f60d38770847196acbd0b0f841d5eb3d04d03f /source/blender | |
parent | cbe43fd385b4023c98579bcc8608fe115512f065 (diff) |
code cleanup: case & brace placement
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 57 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 25 | ||||
-rw-r--r-- | source/blender/collada/TransformWriter.cpp | 11 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 6 | ||||
-rw-r--r-- | source/blender/compositor/nodes/COM_GroupNode.cpp | 9 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 25 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 38 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 6 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_socket.c | 60 |
10 files changed, 147 insertions, 93 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a6da0762b1c..50273cb33f3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -7689,31 +7689,38 @@ static const char *node_get_static_idname(int type, int treetype) static const char *node_socket_get_static_idname(bNodeSocket *sock) { switch (sock->type) { - case SOCK_FLOAT: { - bNodeSocketValueFloat *dval = sock->default_value; - return nodeStaticSocketType(SOCK_FLOAT, dval->subtype); - } - case SOCK_INT: { - bNodeSocketValueInt *dval = sock->default_value; - return nodeStaticSocketType(SOCK_INT, dval->subtype); - } - case SOCK_BOOLEAN: { - return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE); - } - case SOCK_VECTOR: { - bNodeSocketValueVector *dval = sock->default_value; - return nodeStaticSocketType(SOCK_VECTOR, dval->subtype); - } - case SOCK_RGBA: { - return nodeStaticSocketType(SOCK_RGBA, PROP_NONE); - } - case SOCK_STRING: { - bNodeSocketValueString *dval = sock->default_value; - return nodeStaticSocketType(SOCK_STRING, dval->subtype); - } - case SOCK_SHADER: { - return nodeStaticSocketType(SOCK_SHADER, PROP_NONE); - } + case SOCK_FLOAT: + { + bNodeSocketValueFloat *dval = sock->default_value; + return nodeStaticSocketType(SOCK_FLOAT, dval->subtype); + } + case SOCK_INT: + { + bNodeSocketValueInt *dval = sock->default_value; + return nodeStaticSocketType(SOCK_INT, dval->subtype); + } + case SOCK_BOOLEAN: + { + return nodeStaticSocketType(SOCK_BOOLEAN, PROP_NONE); + } + case SOCK_VECTOR: + { + bNodeSocketValueVector *dval = sock->default_value; + return nodeStaticSocketType(SOCK_VECTOR, dval->subtype); + } + case SOCK_RGBA: + { + return nodeStaticSocketType(SOCK_RGBA, PROP_NONE); + } + case SOCK_STRING: + { + bNodeSocketValueString *dval = sock->default_value; + return nodeStaticSocketType(SOCK_STRING, dval->subtype); + } + case SOCK_SHADER: + { + return nodeStaticSocketType(SOCK_SHADER, PROP_NONE); + } } return ""; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index b4b37f7d0bd..1e0f0244072 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -315,7 +315,8 @@ bool MeshImporter::primitive_has_faces(COLLADAFW::MeshPrimitive *mp) { case COLLADAFW::MeshPrimitive::TRIANGLES: case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: case COLLADAFW::MeshPrimitive::POLYLIST: - case COLLADAFW::MeshPrimitive::POLYGONS: { + case COLLADAFW::MeshPrimitive::POLYGONS: + { has_faces = true; break; } @@ -347,8 +348,8 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) case COLLADAFW::MeshPrimitive::TRIANGLES: case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: case COLLADAFW::MeshPrimitive::POLYLIST: - case COLLADAFW::MeshPrimitive::POLYGONS: { - + case COLLADAFW::MeshPrimitive::POLYGONS: + { COLLADAFW::Polygons *mpvc = (COLLADAFW::Polygons *)mp; size_t prim_poly_count = mpvc->getFaceCount(); @@ -361,7 +362,8 @@ void MeshImporter::allocate_poly_data(COLLADAFW::Mesh *collada_mesh, Mesh *me) total_loop_count += prim_loop_count; break; } - default: break; + default: + break; } } @@ -400,16 +402,19 @@ unsigned int MeshImporter::get_vertex_count(COLLADAFW::Polygons *mp, int index) int result; switch (type) { case COLLADAFW::MeshPrimitive::TRIANGLES: - case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: { + case COLLADAFW::MeshPrimitive::TRIANGLE_FANS: + { result = 3; break; } case COLLADAFW::MeshPrimitive::POLYLIST: - case COLLADAFW::MeshPrimitive::POLYGONS: { + case COLLADAFW::MeshPrimitive::POLYGONS: + { result = mp->getGroupedVerticesVertexCountArray()[index]; break; } - default: { + default: + { result = -1; break; } @@ -427,12 +432,14 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) { COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); switch (type) { - case COLLADAFW::MeshPrimitive::LINES: { + case COLLADAFW::MeshPrimitive::LINES: + { size_t prim_totface = mp->getFaceCount(); loose_edge_count += prim_totface; break; } - default: break; + default: + break; } } return loose_edge_count; diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index b088139262c..c3665a33ca4 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -107,15 +107,18 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob, B converter.mat4_to_dae_double(d_obmat, f_obmat); switch (transformation_type) { - case BC_TRANSFORMATION_TYPE_MATRIX : { + case BC_TRANSFORMATION_TYPE_MATRIX: + { node.addMatrix("transform",d_obmat); break; } - case BC_TRANSFORMATION_TYPE_BOTH : { + case BC_TRANSFORMATION_TYPE_BOTH: + { node.addMatrix("transform",d_obmat); - /* intentional fall-through */ + /* fall-through */ } - case BC_TRANSFORMATION_TYPE_TRANSROTLOC: { + case BC_TRANSFORMATION_TYPE_TRANSROTLOC: + { float loc[3], rot[3], scale[3]; TransformBase::decompose(f_obmat, loc, rot, NULL, scale); add_transform(node, loc, rot, scale); diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 41f48a757c0..d4196bacf0d 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -145,11 +145,13 @@ Mesh *bc_get_mesh_copy(Scene *scene, Object *ob, BC_export_mesh_type export_mesh DerivedMesh *dm = NULL; if (apply_modifiers) { switch (export_mesh_type) { - case BC_MESH_TYPE_VIEW: { + case BC_MESH_TYPE_VIEW: + { dm = mesh_create_derived_view(scene, ob, mask); break; } - case BC_MESH_TYPE_RENDER: { + case BC_MESH_TYPE_RENDER: + { dm = mesh_create_derived_render(scene, ob, mask); break; } diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index 85554d7a7aa..7c0499dc04e 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -183,14 +183,16 @@ void GroupNode::addDefaultOutputOperation(ExecutionSystem &system, OutputSocket NodeOperation *operation = NULL; switch (iosock->typeinfo->type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { float value = RNA_float_get(&ptr, "default_value"); SetValueOperation *value_op = new SetValueOperation(); value_op->setValue(value); operation = value_op; break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { float vector[3]; RNA_float_get_array(&ptr, "default_value", vector); SetVectorOperation *vector_op = new SetVectorOperation(); @@ -198,7 +200,8 @@ void GroupNode::addDefaultOutputOperation(ExecutionSystem &system, OutputSocket operation = vector_op; break; } - case SOCK_RGBA: { + case SOCK_RGBA: + { float color[4]; RNA_float_get_array(&ptr, "default_value", color); SetColorOperation *color_op = new SetColorOperation(); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index cbf40bf2e57..bf5e0c77b90 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2768,7 +2768,8 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, case SOCK_VECTOR: uiTemplateComponentMenu(layout, ptr, "default_value", text); break; - case SOCK_RGBA: { + case SOCK_RGBA: + { uiLayout *row = uiLayoutRow(layout, false); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); /* draw the socket name right of the actual button */ @@ -2776,14 +2777,14 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, uiItemL(row, text, 0); break; } - case SOCK_STRING: { + case SOCK_STRING: + { uiLayout *row = uiLayoutRow(layout, true); /* draw the socket name right of the actual button */ uiItemR(row, ptr, "default_value", 0, "", 0); uiItemL(row, text, 0); break; } - default: node_socket_button_label(C, layout, ptr, node_ptr, text); break; @@ -2797,7 +2798,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout /*int subtype = sock->typeinfo->subtype;*/ switch (type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { uiLayout *row; uiItemR(layout, ptr, "default_value", 0, NULL, 0); row = uiLayoutRow(layout, true); @@ -2805,7 +2807,8 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout uiItemR(row, ptr, "max_value", 0, "Max", 0); break; } - case SOCK_INT: { + case SOCK_INT: + { uiLayout *row; uiItemR(layout, ptr, "default_value", 0, NULL, 0); row = uiLayoutRow(layout, true); @@ -2813,11 +2816,13 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout uiItemR(row, ptr, "max_value", 0, "Max", 0); break; } - case SOCK_BOOLEAN: { + case SOCK_BOOLEAN: + { uiItemR(layout, ptr, "default_value", 0, NULL, 0); break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { uiLayout *row; uiItemR(layout, ptr, "default_value", UI_ITEM_R_EXPAND, NULL, 0); row = uiLayoutRow(layout, true); @@ -2825,11 +2830,13 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout uiItemR(row, ptr, "max_value", 0, "Max", 0); break; } - case SOCK_RGBA: { + case SOCK_RGBA: + { uiItemR(layout, ptr, "default_value", 0, NULL, 0); break; } - case SOCK_STRING: { + case SOCK_STRING: + { uiItemR(layout, ptr, "default_value", 0, NULL, 0); break; } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index f8166456a2c..9b48774588d 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -2262,24 +2262,26 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; switch (direction) { - case 1: { /* up */ - bNodeSocket *before = iosock->prev; - BLI_remlink(lb, iosock); - if (before) - BLI_insertlinkbefore(lb, before, iosock); - else - BLI_addhead(lb, iosock); - break; - } - case 2: { /* down */ - bNodeSocket *after = iosock->next; - BLI_remlink(lb, iosock); - if (after) - BLI_insertlinkafter(lb, after, iosock); - else - BLI_addtail(lb, iosock); - break; - } + case 1: + { /* up */ + bNodeSocket *before = iosock->prev; + BLI_remlink(lb, iosock); + if (before) + BLI_insertlinkbefore(lb, before, iosock); + else + BLI_addhead(lb, iosock); + break; + } + case 2: + { /* down */ + bNodeSocket *after = iosock->next; + BLI_remlink(lb, iosock); + if (after) + BLI_insertlinkafter(lb, after, iosock); + else + BLI_addtail(lb, iosock); + break; + } } ntreeUpdateTree(CTX_data_main(C), ntree); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 8d6363d3bbe..f12f7743429 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -392,7 +392,8 @@ static void node_area_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn switch (wmn->category) { case NC_SCENE: switch (wmn->data) { - case ND_NODES: { + case ND_NODES: + { ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); bNodeTreePath *path = snode->treepath.last; /* shift view to node tree center */ diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 9181ab13aa7..210e0fef28f 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -158,10 +158,12 @@ static char *rna_ImageUser_path(PointerRNA *ptr) /* ImageUser *iuser = ptr->data; */ switch (GS(((ID *)ptr->id.data)->name)) { - case ID_TE: { + case ID_TE: + { return BLI_strdup("image_user"); } - case ID_NT: { + case ID_NT: + { return rna_Node_ImageUser_path(ptr); } } diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 0fd6d871dc1..92d403685d0 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -60,26 +60,30 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc /* initialize default_value */ switch (stemp->type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { bNodeSocketValueFloat *dval = sock->default_value; dval->value = stemp->val1; dval->min = stemp->min; dval->max = stemp->max; break; } - case SOCK_INT: { + case SOCK_INT: + { bNodeSocketValueInt *dval = sock->default_value; dval->value = (int)stemp->val1; dval->min = (int)stemp->min; dval->max = (int)stemp->max; break; } - case SOCK_BOOLEAN: { + case SOCK_BOOLEAN: + { bNodeSocketValueBoolean *dval = sock->default_value; dval->value = (int)stemp->val1; break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { bNodeSocketValueVector *dval = sock->default_value; dval->value[0] = stemp->val1; dval->value[1] = stemp->val2; @@ -88,7 +92,8 @@ struct bNodeSocket *node_add_socket_from_template(struct bNodeTree *ntree, struc dval->max = stemp->max; break; } - case SOCK_RGBA: { + case SOCK_RGBA: + { bNodeSocketValueRGBA *dval = sock->default_value; dval->value[0] = stemp->val1; dval->value[1] = stemp->val2; @@ -202,7 +207,8 @@ void node_socket_init_default_value(bNodeSocket *sock) return; /* already initialized */ switch (type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { bNodeSocketValueFloat *dval = MEM_callocN(sizeof(bNodeSocketValueFloat), "node socket value float"); dval->subtype = subtype; dval->value = 0.0f; @@ -212,7 +218,8 @@ void node_socket_init_default_value(bNodeSocket *sock) sock->default_value = dval; break; } - case SOCK_INT: { + case SOCK_INT: + { bNodeSocketValueInt *dval = MEM_callocN(sizeof(bNodeSocketValueInt), "node socket value int"); dval->subtype = subtype; dval->value = 0; @@ -222,14 +229,16 @@ void node_socket_init_default_value(bNodeSocket *sock) sock->default_value = dval; break; } - case SOCK_BOOLEAN: { + case SOCK_BOOLEAN: + { bNodeSocketValueBoolean *dval = MEM_callocN(sizeof(bNodeSocketValueBoolean), "node socket value bool"); dval->value = false; sock->default_value = dval; break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { static float default_value[] = { 0.0f, 0.0f, 0.0f }; bNodeSocketValueVector *dval = MEM_callocN(sizeof(bNodeSocketValueVector), "node socket value vector"); dval->subtype = subtype; @@ -240,7 +249,8 @@ void node_socket_init_default_value(bNodeSocket *sock) sock->default_value = dval; break; } - case SOCK_RGBA: { + case SOCK_RGBA: + { static float default_value[] = { 0.0f, 0.0f, 0.0f, 1.0f }; bNodeSocketValueRGBA *dval = MEM_callocN(sizeof(bNodeSocketValueRGBA), "node socket value color"); copy_v4_v4(dval->value, default_value); @@ -248,7 +258,8 @@ void node_socket_init_default_value(bNodeSocket *sock) sock->default_value = dval; break; } - case SOCK_STRING: { + case SOCK_STRING: + { bNodeSocketValueString *dval = MEM_callocN(sizeof(bNodeSocketValueString), "node socket value string"); dval->subtype = subtype; dval->value[0] = '\0'; @@ -271,37 +282,43 @@ void node_socket_copy_default_value(bNodeSocket *to, bNodeSocket *from) node_socket_init_default_value(to); switch (from->typeinfo->type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { bNodeSocketValueFloat *toval = to->default_value; bNodeSocketValueFloat *fromval = from->default_value; *toval = *fromval; break; } - case SOCK_INT: { + case SOCK_INT: + { bNodeSocketValueInt *toval = to->default_value; bNodeSocketValueInt *fromval = from->default_value; *toval = *fromval; break; } - case SOCK_BOOLEAN: { + case SOCK_BOOLEAN: + { bNodeSocketValueBoolean *toval = to->default_value; bNodeSocketValueBoolean *fromval = from->default_value; *toval = *fromval; break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { bNodeSocketValueVector *toval = to->default_value; bNodeSocketValueVector *fromval = from->default_value; *toval = *fromval; break; } - case SOCK_RGBA: { + case SOCK_RGBA: + { bNodeSocketValueRGBA *toval = to->default_value; bNodeSocketValueRGBA *fromval = from->default_value; *toval = *fromval; break; } - case SOCK_STRING: { + case SOCK_STRING: + { bNodeSocketValueString *toval = to->default_value; bNodeSocketValueString *fromval = from->default_value; *toval = *fromval; @@ -334,21 +351,24 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree node_socket_init_default_value(sock); switch (stemp->typeinfo->type) { - case SOCK_FLOAT: { + case SOCK_FLOAT: + { bNodeSocketValueFloat *toval = sock->default_value; bNodeSocketValueFloat *fromval = stemp->default_value; toval->min = fromval->min; toval->max = fromval->max; break; } - case SOCK_INT: { + case SOCK_INT: + { bNodeSocketValueInt *toval = sock->default_value; bNodeSocketValueInt *fromval = stemp->default_value; toval->min = fromval->min; toval->max = fromval->max; break; } - case SOCK_VECTOR: { + case SOCK_VECTOR: + { bNodeSocketValueVector *toval = sock->default_value; bNodeSocketValueVector *fromval = stemp->default_value; toval->min = fromval->min; |