diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-10 21:06:05 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-10 21:06:05 +0400 |
commit | 942ad6d9cda2439622875a7a748649a0e3451d0b (patch) | |
tree | 19fec0fb40688334fbc9f29a27f9e6cb1b1c5d78 /source/blender/collada | |
parent | 809e37bf15568080907a008d40aed41c737c2b24 (diff) |
style cleanup
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/AnimationExporter.cpp | 41 | ||||
-rw-r--r-- | source/blender/collada/ArmatureExporter.cpp | 2 | ||||
-rw-r--r-- | source/blender/collada/ArmatureImporter.cpp | 17 | ||||
-rw-r--r-- | source/blender/collada/ControllerExporter.cpp | 8 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 29 | ||||
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 8 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.h | 2 | ||||
-rw-r--r-- | source/blender/collada/SceneExporter.cpp | 6 | ||||
-rw-r--r-- | source/blender/collada/TransformReader.cpp | 2 | ||||
-rw-r--r-- | source/blender/collada/collada_utils.cpp | 16 |
10 files changed, 73 insertions, 58 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 4a0696dc857..a69f7918e40 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -161,9 +161,9 @@ void AnimationExporter::export_morph_animation(Object *ob) FCurve *fcu; char *transformName; Key *key = BKE_key_from_object(ob); - if(!key) return; + if (!key) return; - if(key->adt && key->adt->action){ + if (key->adt && key->adt->action) { fcu = (FCurve *)key->adt->action->curves.first; while (fcu) { @@ -177,17 +177,17 @@ void AnimationExporter::export_morph_animation(Object *ob) } -void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<float> &frames ){ - +void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<float> &frames ) +{ ListBase *conlist = get_active_constraints(ob); - if(conlist == NULL) return; + if (conlist == NULL) return; bConstraint *con; for (con = (bConstraint*)conlist->first; con; con = con->next) { ListBase targets = {NULL, NULL}; bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con); - if(!validateConstraints(con)) continue; + if (!validateConstraints(con)) continue; if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; @@ -197,8 +197,8 @@ void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<fl * - ct->matrix members have not yet been calculated here! */ cti->get_constraint_targets(con, &targets); - if(cti){ - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + if (cti) { + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; find_frames(obtar, frames); } @@ -901,7 +901,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj bPoseChannel *parchan = NULL; bPoseChannel *pchan = NULL; - if (ob->type == OB_ARMATURE ){ + if (ob->type == OB_ARMATURE ) { bPose *pose = ob->pose; pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) @@ -922,15 +922,15 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj //BKE_scene_update_for_newframe(G.main,scene,scene->lay); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); - if (bone){ - if( pchan->flag & POSE_CHAIN) - { + if (bone) { + if (pchan->flag & POSE_CHAIN) { enable_fcurves(ob->adt->action, NULL); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); } - else - BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + else { + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + } // compute bone local mat if (bone->parent) { @@ -1324,9 +1324,9 @@ bool AnimationExporter::hasAnimations(Scene *sce) } //check shape key animation - if(!fcu){ + if (!fcu) { Key *key = BKE_key_from_object(ob); - if(key && key->adt && key->adt->action) + if (key && key->adt && key->adt->action) fcu = (FCurve *)key->adt->action->curves.first; } if (fcu) @@ -1497,8 +1497,8 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i enable_fcurves(ob_arm->adt->action, NULL); } -bool AnimationExporter::validateConstraints(bConstraint *con){ - +bool AnimationExporter::validateConstraints(bConstraint *con) +{ bool valid = true; bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con); /* these we can skip completely (invalid constraints...) */ @@ -1512,7 +1512,8 @@ bool AnimationExporter::validateConstraints(bConstraint *con){ return valid; } -void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[][4]){ +void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[][4]) +{ ListBase *conlist = get_active_constraints(ob); bConstraint *con; for (con = (bConstraint*)conlist->first; con; con = con->next) { @@ -1524,7 +1525,7 @@ void AnimationExporter::calc_ob_mat_at_time(Object *ob, float ctime , float mat[ bConstraintTarget *ct; Object *obtar; cti->get_constraint_targets(con, &targets); - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM); BKE_object_where_is_calc_time(scene, obtar, ctime); diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 0929bfda6e7..a56010aeb27 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -273,7 +273,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: } // SECOND_LIFE_COMPATIBILITY - if (export_settings->second_life) { + if (export_settings->second_life) { // Remove rotations vs armature from transform // parent_rest_rot * mat * irest_rot float temp[4][4]; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 86d9de64085..6e8bf337abb 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -106,13 +106,14 @@ void ArmatureImporter::create_bone(SkinInfo* skin, COLLADAFW::Node *node, EditBo else { // bone-space get_node_mat(obmat, node, NULL, NULL); - + // get world-space - if (parent){ + if (parent) { mult_m4_m4m4(mat, parent_mat, obmat); } - else + else { copy_m4_m4(mat, obmat); + } } if (parent) bone->parent = parent; @@ -645,7 +646,8 @@ bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller) return true; } -void ArmatureImporter::make_shape_keys(){ +void ArmatureImporter::make_shape_keys() +{ std::vector<COLLADAFW::MorphController *>::iterator mc; float weight; @@ -668,12 +670,12 @@ void ArmatureImporter::make_shape_keys(){ BKE_key_convert_from_mesh(source_me, kb); //insert other shape keys - for ( int i = 0 ; i < morphTargetIds.getCount() ; i++ ){ + for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { //better to have a seperate map of morph objects, //This'll do for now since only mesh morphing is imported Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); - if(me){ + if (me) { me->key = key; kb = BKE_keyblock_add_ctime(key, me->id.name, FALSE); BKE_key_convert_from_mesh(me, kb); @@ -682,8 +684,9 @@ void ArmatureImporter::make_shape_keys(){ weight = morphWeights.getFloatValues()->getData()[i]; kb->curval = weight; } - else + else { fprintf(stderr, "Morph target geometry not found.\n"); + } } } } diff --git a/source/blender/collada/ControllerExporter.cpp b/source/blender/collada/ControllerExporter.cpp index 57047346617..41693d4d680 100644 --- a/source/blender/collada/ControllerExporter.cpp +++ b/source/blender/collada/ControllerExporter.cpp @@ -120,9 +120,10 @@ void ControllerExporter::operator()(Object *ob) Object *ob_arm = bc_get_assigned_armature(ob); Key *key = BKE_key_from_object(ob); - if (ob_arm) + if (ob_arm) { export_skin_controller(ob, ob_arm); - if(key){ + } + if (key) { export_morph_controller(ob, key); } } @@ -388,7 +389,8 @@ std::string ControllerExporter::add_morph_weights(Key *key, Object *ob) } //Added to implemente support for animations. -void ControllerExporter::add_weight_extras(Key *key){ +void ControllerExporter::add_weight_extras(Key *key) +{ // can also try the base element and param alternative COLLADASW::BaseExtraTechnique extra; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 7437401ed09..0436dd40744 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -100,7 +100,7 @@ extern "C" { // #define ARMATURE_TEST DocumentImporter::DocumentImporter(bContext *C, const ImportSettings *import_settings) : - import_settings(import_settings), + import_settings(import_settings), mImportStage(General), mContext(C), armature_importer(&unit_converter, &mesh_importer, &anim_importer, CTX_data_scene(C)), @@ -432,8 +432,9 @@ Object *DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod // to create constraints off node <extra> tags. Assumes only constraint data in // current <extra> with blender profile. -void DocumentImporter::create_constraints(ExtraTags *et, Object *ob){ - if ( et && et->isProfile("blender")){ +void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) +{ + if (et && et->isProfile("blender")) { std::string name; short* type = 0; et->setData("type", type); @@ -536,9 +537,12 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent // XXX empty node may not mean it is empty object, not sure about this if ( (geom_done + camera_done + lamp_done + controller_done + inst_done) < 1) { //Check if Object is armature, by checking if immediate child is a JOINT node. - if(is_armature(node)) + if (is_armature(node)) { ob = bc_add_object(sce, OB_ARMATURE, NULL); - else ob = bc_add_object(sce, OB_EMPTY, NULL); + } + else { + ob = bc_add_object(sce, OB_EMPTY, NULL); + } objects_done->push_back(ob); } @@ -1238,15 +1242,18 @@ bool DocumentImporter::addExtraTags(const COLLADAFW::UniqueId &uid, ExtraTags *e return true; } -bool DocumentImporter::is_armature(COLLADAFW::Node *node){ +bool DocumentImporter::is_armature(COLLADAFW::Node *node) +{ COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); - for (unsigned int i = 0; i < child_nodes.getCount(); i++) { - if(child_nodes[i]->getType() == COLLADAFW::Node::JOINT) return true; - else continue; + for (unsigned int i = 0; i < child_nodes.getCount(); i++) { + if (child_nodes[i]->getType() == COLLADAFW::Node::JOINT) { + return true; + } + else { + continue; + } } //no child is JOINT return false; - } - diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 0720c1f9b81..19d67f37476 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -53,7 +53,8 @@ extern "C" { #include "collada_utils.h" // TODO: optimize UV sets by making indexed list with duplicates removed -GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) { +GeometryExporter::GeometryExporter(COLLADASW::StreamWriter *sw, const ExportSettings *export_settings) : COLLADASW::LibraryGeometries(sw), export_settings(export_settings) +{ } @@ -160,7 +161,7 @@ void GeometryExporter::operator()(Object *ob) if (this->export_settings->include_shapekeys) { Key * key = BKE_key_from_object(ob); - if(key) { + if (key) { KeyBlock * kb = (KeyBlock*)key->block.first; //skip the basis kb = kb->next; @@ -175,7 +176,8 @@ void GeometryExporter::operator()(Object *ob) #endif } -void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb){ +void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) +{ std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name); std::vector<Normal> nor; std::vector<Face> norind; diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 946f9ff99e3..5ab068160a4 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -133,7 +133,7 @@ private: CustomData create_edge_custom_data(EdgeHash *eh); - void allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); + void allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); // TODO: import uv set names void read_faces(COLLADAFW::Mesh *mesh, Mesh *me, int new_tris); diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 3a06ca3bc0e..dbf7d40b373 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -182,7 +182,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) colladaNode.end(); } - if (ob->constraints.first != NULL ){ + if (ob->constraints.first != NULL ) { bConstraint *con = (bConstraint*) ob->constraints.first; while (con) { std::string con_name(id_name(con)); @@ -208,8 +208,8 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) Object *obtar; cti->get_constraint_targets(con, &targets); - if(cti){ - for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next){ + if (cti) { + for (ct = (bConstraintTarget*)targets.first; ct; ct = ct->next) { obtar = ct->tar; std::string tar_id(id_name(obtar)); colladaNode.addExtraTechniqueChildParameter("blender",con_tag,"target_id",tar_id); diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index 913c0710cc6..67166d819a6 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -46,7 +46,7 @@ void TransformReader::get_node_mat(float mat[4][4], COLLADAFW::Node *node, std:: COLLADAFW::Transformation *tm = node->getTransformations()[i]; COLLADAFW::Transformation::TransformationType type = tm->getTransformationType(); - if (type == COLLADAFW::Transformation::MATRIX){ + if (type == COLLADAFW::Transformation::MATRIX) { // XXX why does this return and discard all following transformations? dae_matrix_to_mat4(tm, mat); return; diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 27af5c0aba2..ab8491dde01 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -295,11 +295,11 @@ std::string bc_url_encode(std::string data) { } std::string bc_replace_string(std::string data, const std::string& pattern, - const std::string& replacement) { - size_t pos = 0; - while((pos = data.find(pattern, pos)) != std::string::npos) { - data.replace(pos, pattern.length(), replacement); - pos += replacement.length(); - } - return data; -}
\ No newline at end of file + const std::string& replacement) { + size_t pos = 0; + while ((pos = data.find(pattern, pos)) != std::string::npos) { + data.replace(pos, pattern.length(), replacement); + pos += replacement.length(); + } + return data; +} |