diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 10:31:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-28 10:31:57 +0400 |
commit | b340f930ec5639f24e7e2d47fab221fb752b61dd (patch) | |
tree | 0e880a36bb528d133af6d10701fc090716b3b7f8 /source/blender/collada | |
parent | 09dc600839904a198ab4ba3fad62ce58c2d3aa07 (diff) |
style cleanup: changes to brace placement / newlines - for/while/if/switch
Diffstat (limited to 'source/blender/collada')
20 files changed, 150 insertions, 209 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 778e3029266..c93ee832fe6 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -29,7 +29,7 @@ void forEachObjectInScene(Scene *sce, Functor &f) { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; f(ob); @@ -59,13 +59,11 @@ void AnimationExporter::operator() (Object *ob) /* bool isMatAnim = false; */ /* UNUSED */ //Export transform animations - if (ob->adt && ob->adt->action) - { + if (ob->adt && ob->adt->action) { fcu = (FCurve*)ob->adt->action->curves.first; //transform matrix export for bones are temporarily disabled here. - if ( ob->type == OB_ARMATURE ) - { + if ( ob->type == OB_ARMATURE ) { bArmature *arm = (bArmature*)ob->data; for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next) write_bone_animation_matrix(ob, bone); @@ -79,59 +77,63 @@ void AnimationExporter::operator() (Object *ob) transformName = extract_transform_name( fcu->rna_path ); if ((!strcmp(transformName, "location") || !strcmp(transformName, "scale")) || - (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| - (!strcmp(transformName, "rotation_quaternion"))) + (!strcmp(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL)|| + (!strcmp(transformName, "rotation_quaternion"))) + { dae_animation(ob ,fcu, transformName, false); + } fcu = fcu->next; } } //Export Lamp parameter animations - if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) - { + if ( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action ) { fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first); while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))|| - (!strcmp(transformName, "distance")) ) - dae_animation(ob , fcu, transformName, true ); + if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| + (!strcmp(transformName, "spot_blend")) || (!strcmp(transformName, "distance"))) + { + dae_animation(ob , fcu, transformName, true); + } fcu = fcu->next; } } //Export Camera parameter animations - if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) - { + if ( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action ) { fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); while (fcu) { transformName = extract_transform_name( fcu->rna_path ); if ((!strcmp(transformName, "lens"))|| - (!strcmp(transformName, "ortho_scale"))|| - (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) - dae_animation(ob , fcu, transformName, true ); + (!strcmp(transformName, "ortho_scale"))|| + (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start"))) + { + dae_animation(ob , fcu, transformName, true); + } fcu = fcu->next; } } //Export Material parameter animations. - for (int a = 0; a < ob->totcol; a++) - { + for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); if (!ma) continue; - if (ma->adt && ma->adt->action) - { + if (ma->adt && ma->adt->action) { /* isMatAnim = true; */ fcu = (FCurve*)ma->adt->action->curves.first; while (fcu) { transformName = extract_transform_name( fcu->rna_path ); - if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) - ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))|| - (!strcmp(transformName, "ior"))) + if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color")) || + (!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha")) || + (!strcmp(transformName, "ior"))) + { dae_animation(ob ,fcu, transformName, true, ma ); + } fcu = fcu->next; } } @@ -148,8 +150,7 @@ float * AnimationExporter::get_eul_source_for_quat(Object *ob ) float *eul = (float*)MEM_callocN(sizeof(float) * fcu->totvert * 3, "quat output source values"); float temp_quat[4]; float temp_eul[3]; - while(fcu) - { + while (fcu) { char * transformName = extract_transform_name( fcu->rna_path ); if ( !strcmp(transformName, "rotation_quaternion") ) { @@ -199,8 +200,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa bool has_tangents = false; bool quatRotation = false; - if ( !strcmp(transformName, "rotation_quaternion") ) - { + if ( !strcmp(transformName, "rotation_quaternion") ) { fprintf(stderr, "quaternion rotation curves are not supported. rotation curve will not be exported\n"); quatRotation = true; return; @@ -223,23 +223,20 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa if (fcu->array_index < 3) axis_name = axis_names[fcu->array_index]; } - - //no axis name. single parameter. - else{ + else { + /* no axis name. single parameter */ axis_name = ""; } std::string ob_name = std::string("null"); //Create anim Id - if (ob->type == OB_ARMATURE) - { + if (ob->type == OB_ARMATURE) { ob_name = getObjectBoneName( ob , fcu); BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char*)translate_id(ob_name).c_str(), transformName, axis_name); } - else - { + else { if (ma) ob_name = id_name(ob) + "_material"; else @@ -257,18 +254,17 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa std::string output_id; //quat rotations are skipped for now, because of complications with determining axis. - if (quatRotation) - { - float * eul = get_eul_source_for_quat(ob); - float * eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); - for ( int i = 0 ; i< fcu->totvert ; i++) + if (quatRotation) { + float *eul = get_eul_source_for_quat(ob); + float *eul_axis = (float*)MEM_callocN(sizeof(float) * fcu->totvert, "quat output source values"); + for (int i = 0 ; i< fcu->totvert ; i++) { eul_axis[i] = eul[i*3 + fcu->array_index]; + } output_id= create_source_from_array(COLLADASW::InputSemantic::OUTPUT, eul_axis , fcu->totvert, quatRotation, anim_id, axis_name); MEM_freeN(eul); MEM_freeN(eul_axis); } - else - { + else { output_id= create_source_from_fcurve(COLLADASW::InputSemantic::OUTPUT, fcu, anim_id, axis_name); } // create interpolations source @@ -307,8 +303,7 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa if ( !is_param ) target = translate_id(ob_name) + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); - else - { + else { if ( ob->type == OB_LAMP ) target = get_light_id(ob) + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); @@ -349,8 +344,7 @@ bool AnimationExporter::is_bone_deform_group(Bone * bone) //Check if current bone is deform if ((bone->flag & BONE_NO_DEFORM) == 0 ) return true; //Check child bones - else - { + else { for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { //loop through all the children until deform bone is found, and then return is_def = is_bone_deform_group(child); @@ -369,8 +363,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B //char prefix[256]; FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first; - while(fcu) - { + while (fcu) { std::string bone_name = getObjectBoneName(ob_arm,fcu); int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name); if (val==0) break; @@ -511,7 +504,7 @@ float AnimationExporter::convert_angle(float angle) std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic) { - switch(semantic) { + switch (semantic) { case COLLADASW::InputSemantic::INPUT: return INPUT_SOURCE_ID_SUFFIX; case COLLADASW::InputSemantic::OUTPUT: @@ -531,7 +524,7 @@ std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Sem void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform) { - switch(semantic) { + switch (semantic) { case COLLADASW::InputSemantic::INPUT: param.push_back("TIME"); break; @@ -544,8 +537,7 @@ void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNa param.push_back(axis); } else - if ( transform ) - { + if ( transform ) { param.push_back("TRANSFORM"); } else { //assumes if axis isn't specified all axises are added @@ -778,8 +770,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob // SECOND_LIFE_COMPATIBILITY // AFAIK animation to second life is via BVH, but no // reason to not have the collada-animation be correct - if (export_settings->second_life) - { + if (export_settings->second_life) { float temp[4][4]; copy_m4_m4(temp, bone->arm_mat); temp[3][0] = temp[3][1] = temp[3][2] = 0.0f; @@ -787,8 +778,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames , Ob mult_m4_m4m4(mat, mat, temp); - if (bone->parent) - { + if (bone->parent) { copy_m4_m4(temp, bone->parent->arm_mat); temp[3][0] = temp[3][1] = temp[3][2] = 0.0f; @@ -1128,7 +1118,7 @@ bool AnimationExporter::hasAnimations(Scene *sce) { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; FCurve *fcu = 0; @@ -1143,12 +1133,10 @@ bool AnimationExporter::hasAnimations(Scene *sce) fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first); //Check Material Effect parameter animations. - for (int a = 0; a < ob->totcol; a++) - { + for (int a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); if (!ma) continue; - if (ma->adt && ma->adt->action) - { + if (ma->adt && ma->adt->action) { fcu = (FCurve*)ma->adt->action->curves.first; } } diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index e0079fbb8a0..8ef2235b6fb 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -138,8 +138,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) bez.ipo = BEZT_IPO_CONST; //bez.h1 = bez.h2 = HD_AUTO; } - else - { + else { bez.h1 = bez.h2 = HD_AUTO; bez.ipo = BEZT_IPO_LIN; } @@ -789,17 +788,15 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , bool is_joint = node->getType() == COLLADAFW::Node::JOINT; COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()]; Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map[node->getUniqueId()]; - if (!ob) - { + if (!ob) { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); return; } bAction * act; - if ( (animType->transform) != 0 ) - { - const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; + if ( (animType->transform) != 0 ) { + /* const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; */ /* UNUSED */ char joint_path[200]; if ( is_joint ) @@ -867,8 +864,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } - if ((animType->light) != 0) - { + if ((animType->light) != 0) { Lamp * lamp = (Lamp*) ob->data; if (!lamp->adt || !lamp->adt->action) act = verify_adt_action((ID*)&lamp->id, 1); @@ -880,22 +876,19 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , for (unsigned int i = 0; i < nodeLights.getCount(); i++) { const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()]; - if ((animType->light & LIGHT_COLOR) != 0) - { + if ((animType->light & LIGHT_COLOR) != 0) { const COLLADAFW::Color *col = &(light->getColor()); const COLLADAFW::UniqueId& listid = col->getAnimationList(); Assign_color_animations(listid, AnimCurves, "color"); } - if ((animType->light & LIGHT_FOA) != 0 ) - { + if ((animType->light & LIGHT_FOA) != 0 ) { const COLLADAFW::AnimatableFloat *foa = &(light->getFallOffAngle()); const COLLADAFW::UniqueId& listid = foa->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "spot_size"); } - if ( (animType->light & LIGHT_FOE) != 0 ) - { + if ( (animType->light & LIGHT_FOE) != 0 ) { const COLLADAFW::AnimatableFloat *foe = &(light->getFallOffExponent()); const COLLADAFW::UniqueId& listid = foe->getAnimationList(); @@ -905,8 +898,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , } } - if ( (animType->camera) != 0) - { + if ( (animType->camera) != 0) { Camera * camera = (Camera*) ob->data; if (!camera->adt || !camera->adt->action) act = verify_adt_action((ID*)&camera->id, 1); @@ -918,29 +910,25 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; - if ((animType->camera & CAMERA_XFOV) != 0 ) - { + if ((animType->camera & CAMERA_XFOV) != 0 ) { const COLLADAFW::AnimatableFloat *xfov = &(camera->getXFov()); const COLLADAFW::UniqueId& listid = xfov->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "lens"); } - else if ((animType->camera & CAMERA_XMAG) != 0 ) - { + else if ((animType->camera & CAMERA_XMAG) != 0 ) { const COLLADAFW::AnimatableFloat *xmag = &(camera->getXMag()); const COLLADAFW::UniqueId& listid = xmag->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "ortho_scale"); } - if ((animType->camera & CAMERA_ZFAR) != 0 ) - { + if ((animType->camera & CAMERA_ZFAR) != 0 ) { const COLLADAFW::AnimatableFloat *zfar = &(camera->getFarClippingPlane()); const COLLADAFW::UniqueId& listid = zfar->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "clip_end"); } - if ((animType->camera & CAMERA_ZNEAR) != 0 ) - { + if ((animType->camera & CAMERA_ZNEAR) != 0 ) { const COLLADAFW::AnimatableFloat *znear = &(camera->getNearClippingPlane()); const COLLADAFW::UniqueId& listid = znear->getAnimationList(); Assign_float_animations( listid ,AnimCurves, "clip_start"); @@ -1162,12 +1150,10 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; - if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) - { + if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV); } - else - { + else { types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG); } types->camera = setAnimType(&(camera->getFarClippingPlane()),(types->camera), CAMERA_ZFAR); @@ -1641,7 +1627,7 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float COLLADABU::Math::Vector3& axis = ((COLLADAFW::Rotate*)tm)->getRotationAxis(); - float ax[3] = {axis[0], axis[1], axis[2]}; + float ax[3] = {(float)axis[0], (float)axis[1], (float)axis[2]}; float angle = evaluate_fcurve(curves[0], fra); axis_angle_to_mat4(mat, ax, angle); diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 743d3c2a158..0d45df37796 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -127,7 +127,7 @@ void ArmatureExporter::find_objects_using_armature(Object *ob_arm, std::vector<O objects.clear(); Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; if (ob->type == OB_MESH && get_assigned_armature(ob) == ob_arm) { @@ -191,10 +191,8 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, // Write nodes of childobjects, remove written objects from list std::list<Object*>::iterator i = child_objects.begin(); - while( i != child_objects.end() ) - { - if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) - { + while (i != child_objects.end()) { + if ((*i)->partype == PARBONE && (0 == strcmp((*i)->parsubstr, bone->name))) { float backup_parinv[4][4]; copy_m4_m4(backup_parinv, (*i)->parentinv); @@ -210,8 +208,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, // TODO: when such objects are animated as // single matrix the tweak must be applied // to the result. - if (export_settings->second_life) - { + if (export_settings->second_life) { // tweak objects parentinverse to match compatibility float temp[4][4]; @@ -274,8 +271,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]; @@ -285,8 +281,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: mult_m4_m4m4(mat, mat, temp); - if (bone->parent) - { + if (bone->parent) { copy_m4_m4(temp, bone->parent->arm_mat); temp[3][0] = temp[3][1] = temp[3][2] = 0.0f; @@ -370,25 +365,21 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm) for (j = 0; j < vert->totweight; j++) { int joint_index = joint_index_by_def_index[vert->dw[j].def_nr]; - if (joint_index != -1 && vert->dw[j].weight > 0.0f) - { + if (joint_index != -1 && vert->dw[j].weight > 0.0f) { jw[joint_index] += vert->dw[j].weight; sumw += vert->dw[j].weight; } } - if (sumw > 0.0f) - { + if (sumw > 0.0f) { float invsumw = 1.0f/sumw; vcounts.push_back(jw.size()); - for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) - { + for (std::map<int, float>::iterator m = jw.begin(); m != jw.end(); ++m) { joints.push_back((*m).first); weights.push_back(invsumw*(*m).second); } } - else - { + else { vcounts.push_back(0); /*vcounts.push_back(1); joints.push_back(-1); @@ -502,16 +493,14 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase float inv_bind_mat[4][4]; // SECOND_LIFE_COMPATIBILITY - if (export_settings->second_life) - { + if (export_settings->second_life) { // Only translations, no rotation vs armature float temp[4][4]; unit_m4(temp); copy_v3_v3(temp[3], pchan->bone->arm_mat[3]); mult_m4_m4m4(world, ob_arm->obmat, temp); } - else - { + else { // make world-space matrix, arm_mat is armature-space mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat); } @@ -597,8 +586,7 @@ void ArmatureExporter::add_vertex_weights_element(const std::string& weights_sou // write deformer index - weight index pairs int weight_index = 0; - for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) - { + for (std::list<int>::const_iterator i = joints.begin(); i != joints.end(); ++i) { weightselem.appendValues(*i, weight_index++); } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index a978a4757a7..05a2e5643f2 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -278,8 +278,7 @@ void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW: TagsMap::iterator etit; ExtraTags *et = 0; etit = uid_tags_map.find(node->getUniqueId().toAscii()); - if (etit != uid_tags_map.end()) - { + if (etit != uid_tags_map.end()) { et = etit->second; //else return; diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index fcb98cc7c32..8640e544dbf 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -42,15 +42,14 @@ CamerasExporter::CamerasExporter(COLLADASW::StreamWriter *sw, const ExportSettin template<class Functor> void forEachCameraObjectInScene(Scene *sce, Functor &f, bool export_selected) { - Base *base= (Base*) sce->base.first; - while(base) { + Base *base = (Base*) sce->base.first; + while (base) { Object *ob = base->object; - - if (ob->type == OB_CAMERA && ob->data - && !(export_selected && !(ob->flag & SELECT))) { + + if (ob->type == OB_CAMERA && ob->data && !(export_selected && !(ob->flag & SELECT))) { f(ob, sce); } - base= base->next; + base = base->next; } } diff --git a/source/blender/collada/DocumentExporter.cpp b/source/blender/collada/DocumentExporter.cpp index 52261346acb..19fc30a2790 100644 --- a/source/blender/collada/DocumentExporter.cpp +++ b/source/blender/collada/DocumentExporter.cpp @@ -175,7 +175,7 @@ void DocumentExporter::exportCurrentScene(Scene *sce) std::string unitname = "meter"; float linearmeasure = RNA_float_get(&unit_settings, "scale_length"); - switch(RNA_property_enum_get(&unit_settings, system)) { + switch (RNA_property_enum_get(&unit_settings, system)) { case USER_UNIT_NONE: case USER_UNIT_METRIC: if (linearmeasure == 0.001f) { diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index bc0606107ab..d81ffebae66 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -106,7 +106,7 @@ DocumentImporter::~DocumentImporter() { TagsMap::iterator etit; etit = uid_tags_map.begin(); - while(etit!=uid_tags_map.end()) { + while (etit!=uid_tags_map.end()) { delete etit->second; etit++; } @@ -178,7 +178,7 @@ void DocumentImporter::finish() system = RNA_struct_find_property(&unit_settings, "system"); scale = RNA_struct_find_property(&unit_settings, "scale_length"); - switch(unit_converter.isMetricSystem()) { + switch (unit_converter.isMetricSystem()) { case UnitConverter::Metric: RNA_property_enum_set(&unit_settings, system, USER_UNIT_METRIC); break; @@ -744,8 +744,7 @@ bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) Material *ma = uid_effect_map[uid]; std::map<COLLADAFW::UniqueId, Material*>::iterator iter; - for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ ) - { + for (iter = uid_material_map.begin(); iter != uid_material_map.end() ; iter++ ) { if ( iter->second == ma ) { this->FW_object_map[iter->first] = effect; break; @@ -789,7 +788,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) cam->clipend = camera->getFarClippingPlane().getValue(); COLLADAFW::Camera::CameraType type = camera->getCameraType(); - switch(type) { + switch (type) { case COLLADAFW::Camera::ORTHOGRAPHIC: { cam->type = CAM_ORTHO; @@ -808,10 +807,10 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) break; } - switch(camera->getDescriptionType()) { + switch (camera->getDescriptionType()) { case COLLADAFW::Camera::ASPECTRATIO_AND_Y: { - switch(cam->type) { + switch (cam->type) { case CAM_ORTHO: { double ymag = camera->getYMag().getValue(); @@ -839,7 +838,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) case COLLADAFW::Camera::SINGLE_X: case COLLADAFW::Camera::X_AND_Y: { - switch(cam->type) { + switch (cam->type) { case CAM_ORTHO: cam->ortho_scale = (float)camera->getXMag().getValue(); break; @@ -856,7 +855,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) break; case COLLADAFW::Camera::SINGLE_Y: { - switch(cam->type) { + switch (cam->type) { case CAM_ORTHO: cam->ortho_scale = (float)camera->getYMag().getValue(); break; @@ -1030,7 +1029,7 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) lamp->dist = d; COLLADAFW::Light::LightType type = light->getLightType(); - switch(type) { + switch (type) { case COLLADAFW::Light::AMBIENT_LIGHT: { lamp->type = LA_HEMI; diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index 9720b92ffae..bbc7677c279 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -60,11 +60,10 @@ bool EffectsExporter::hasEffects(Scene *sce) { Base *base = (Base *)sce->base.first; - while(base) { + while (base) { Object *ob= base->object; int a; - for (a = 0; a < ob->totcol; a++) - { + for (a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); // no material, but check all of the slots diff --git a/source/blender/collada/ErrorHandler.cpp b/source/blender/collada/ErrorHandler.cpp index 1c0f40d2185..530158ed418 100644 --- a/source/blender/collada/ErrorHandler.cpp +++ b/source/blender/collada/ErrorHandler.cpp @@ -49,37 +49,31 @@ bool ErrorHandler::handleError( const COLLADASaxFWL::IError* error ) { mError = true; - if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER ) - { + if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXPARSER ) { COLLADASaxFWL::SaxParserError* saxParserError = (COLLADASaxFWL::SaxParserError*) error; const GeneratedSaxParser::ParserError& parserError = saxParserError->getError(); // Workaround to avoid wrong error - if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) - { - if ( strcmp(parserError.getElement(), "effect") == 0 ) - { + if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_MIN_OCCURS_UNMATCHED) { + if ( strcmp(parserError.getElement(), "effect") == 0 ) { mError = false; } } - if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) - { - if ( !((strcmp(parserError.getElement(), "extra") == 0) - && (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0))) + if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_VALIDATION_SEQUENCE_PREVIOUS_SIBLING_NOT_PRESENT) { + if ( !((strcmp(parserError.getElement(), "extra") == 0) && + (strcmp(parserError.getAdditionalText().c_str(), "sibling: fx_profile_abstract") == 0))) { mError = false; } } - if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) - { + if ( parserError.getErrorType() == GeneratedSaxParser::ParserError::ERROR_COULD_NOT_OPEN_FILE) { std::cout << "Couldn't open file" << std::endl; } std::cout << "Schema validation error: " << parserError.getErrorMessage() << std::endl; } - else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL ) - { + else if ( error->getErrorClass() == COLLADASaxFWL::IError::ERROR_SAXFWL ) { COLLADASaxFWL::SaxFWLError* saxFWLError = (COLLADASaxFWL::SaxFWLError*) error; std::cout << "Sax FWL Error: " << saxFWLError->getErrorMessage() << std::endl; } diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index ca112abc0af..8e4fa057daf 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -440,9 +440,9 @@ void GeometryExporter::create_normals(std::vector<Normal> &nor, std::vector<Face *nn = nshar[*vv]; else { Normal n = { - vert[*vv].no[0]/32767.0, - vert[*vv].no[1]/32767.0, - vert[*vv].no[2]/32767.0 + (float)vert[*vv].no[0] / 32767.0f, + (float)vert[*vv].no[1] / 32767.0f, + (float)vert[*vv].no[2] / 32767.0f }; nor.push_back(n); *nn = (unsigned int)nor.size() - 1; diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index f6dc5a18449..0085e3755aa 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -108,12 +108,13 @@ struct GeometryFunctor { { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; - if (ob->type == OB_MESH && ob->data - && !(export_selected && !(ob->flag && SELECT)) - && ((sce->lay & ob->lay)!=0)) { + if (ob->type == OB_MESH && ob->data && + !(export_selected && !(ob->flag && SELECT)) && + ((sce->lay & ob->lay)!=0)) + { f(ob); } base= base->next; diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index 946effda832..4d7c56ab419 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -48,11 +48,10 @@ bool ImagesExporter::hasImages(Scene *sce) { Base *base = (Base *)sce->base.first; - while(base) { + while (base) { Object *ob= base->object; int a; - for (a = 0; a < ob->totcol; a++) - { + for (a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); // no material, but check all of the slots diff --git a/source/blender/collada/LightExporter.cpp b/source/blender/collada/LightExporter.cpp index 51242b36b64..1d7afb9b1a1 100644 --- a/source/blender/collada/LightExporter.cpp +++ b/source/blender/collada/LightExporter.cpp @@ -39,11 +39,10 @@ template<class Functor> void forEachLampObjectInScene(Scene *sce, Functor &f, bool export_selected) { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; - - if (ob->type == OB_LAMP && ob->data - && !(export_selected && !(ob->flag & SELECT))) { + + if (ob->type == OB_LAMP && ob->data && !(export_selected && !(ob->flag & SELECT))) { f(ob); } base= base->next; diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 1e3358c9216..ac1a5d32a08 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -50,11 +50,10 @@ bool MaterialsExporter::hasMaterials(Scene *sce) { Base *base = (Base *)sce->base.first; - while(base) { + while (base) { Object *ob= base->object; int a; - for (a = 0; a < ob->totcol; a++) - { + for (a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); // no material, but check all of the slots diff --git a/source/blender/collada/MaterialExporter.h b/source/blender/collada/MaterialExporter.h index eb7886c23b9..4a5422184d4 100644 --- a/source/blender/collada/MaterialExporter.h +++ b/source/blender/collada/MaterialExporter.h @@ -68,7 +68,7 @@ public: void operator ()(Object *ob) { int a; - for(a = 0; a < ob->totcol; a++) { + for (a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a+1); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 5c01c31bd0d..0bf33206fa7 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -116,7 +116,7 @@ UVDataWrapper::UVDataWrapper(COLLADAFW::MeshVertexData& vdata) : mVData(&vdata) void WVDataWrapper::print() { fprintf(stderr, "UVs:\n"); - switch(mVData->getType()) { + switch (mVData->getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues(); @@ -147,7 +147,7 @@ void UVDataWrapper::getUV(int uv_index, float *uv) int stride = mVData->getStride(0); if (stride==0) stride = 2; - switch(mVData->getType()) { + switch (mVData->getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType<float>* values = mVData->getFloatValues(); @@ -676,7 +676,7 @@ void MeshImporter::get_vector(float v[3], COLLADAFW::MeshVertexData& arr, int i, { i *= stride; - switch(arr.getType()) { + switch (arr.getType()) { case COLLADAFW::MeshVertexData::DATA_TYPE_FLOAT: { COLLADAFW::ArrayPrimitiveType<float>* values = arr.getFloatValues(); @@ -797,7 +797,7 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri // what we already have handled. std::multimap<COLLADAFW::UniqueId, COLLADAFW::UniqueId>::iterator it; it=materials_mapped_to_geom.find(*geom_uid); - while(it!=materials_mapped_to_geom.end()) { + while (it!=materials_mapped_to_geom.end()) { if (it->second == ma_uid && it->first == *geom_uid) return NULL; // do nothing if already found it++; } diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp index 9010fd5062a..cd36267fd56 100644 --- a/source/blender/collada/SceneExporter.cpp +++ b/source/blender/collada/SceneExporter.cpp @@ -43,12 +43,12 @@ void SceneExporter::exportScene(Scene *sce) void SceneExporter::exportHierarchy(Scene *sce) { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; if (!ob->parent) { if (sce->lay & ob->lay) { - switch(ob->type) { + switch (ob->type) { case OB_MESH: case OB_CAMERA: case OB_LAMP: @@ -81,12 +81,12 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) // list child objects Base *b = (Base*) sce->base.first; - while(b) { + while (b) { // cob - child object Object *cob = b->object; if (cob->parent == ob) { - switch(cob->type) { + switch (cob->type) { case OB_MESH: case OB_CAMERA: case OB_LAMP: @@ -154,8 +154,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce) } } - for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) - { + for (std::list<Object*>::iterator i= child_objects.begin(); i != child_objects.end(); ++i) { writeNodes(*i, sce); } diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index a73d5243624..4c7fde8ef17 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -43,7 +43,7 @@ void TransformReader::get_node_mat(float mat[][4], COLLADAFW::Node *node, std::m COLLADAFW::Transformation *tm = node->getTransformations()[i]; COLLADAFW::Transformation::TransformationType type = tm->getTransformationType(); - switch(type) { + switch (type) { case COLLADAFW::Transformation::TRANSLATE: dae_translate_to_mat4(tm, cur); break; diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index f441833233c..f96aff8aa90 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -95,19 +95,16 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) */ /* Using parentinv should allow use of existing curves */ - if (ob->parent) - { + if (ob->parent) { // If parentinv is identity don't add it. bool add_parinv = false; - for (int i = 0; i < 16; ++i) - { + for (int i = 0; i < 16; ++i) { float f = (i % 4 == i / 4) ? 1.0f : 0.0f; add_parinv |= (ob->parentinv[i % 4][i / 4] != f); } - if (add_parinv) - { + if (add_parinv) { double dmat[4][4]; UnitConverter converter; converter.mat4_to_dae_double(dmat, ob->parentinv); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index fc4093bd795..fa99d460184 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -40,7 +40,7 @@ void UnitConverter::read_asset(const COLLADAFW::FileInfo* asset) UnitConverter::UnitSystem UnitConverter::isMetricSystem() { - switch(unit.getLinearUnitUnit()) { + switch (unit.getLinearUnitUnit()) { case COLLADAFW::FileInfo::Unit::MILLIMETER: case COLLADAFW::FileInfo::Unit::CENTIMETER: case COLLADAFW::FileInfo::Unit::DECIMETER: @@ -198,44 +198,39 @@ void clear_global_id_map() /** Look at documentation of translate_map */ std::string translate_id(const std::string &id) { - if (id.size() == 0) - { return id; } + if (id.size() == 0) { + return id; + } + std::string id_translated = id; id_translated[0] = translate_start_name_map[(unsigned int)id_translated[0]]; - for (unsigned int i=1; i < id_translated.size(); i++) - { + for (unsigned int i=1; i < id_translated.size(); i++) { id_translated[i] = translate_name_map[(unsigned int)id_translated[i]]; } // It's so much workload now, the if () should speed up things. - if (id_translated != id) - { + if (id_translated != id) { // Search duplicates map_string_list::iterator iter = global_id_map.find(id_translated); - if (iter != global_id_map.end()) - { + if (iter != global_id_map.end()) { unsigned int i = 0; bool found = false; - for (i=0; i < iter->second.size(); i++) - { - if (id == iter->second[i]) - { + for (i=0; i < iter->second.size(); i++) { + if (id == iter->second[i]) { found = true; break; } } bool convert = false; - if (found) - { - if (i > 0) - { convert = true; } + if (found) { + if (i > 0) { + convert = true; + } } - else - { + else { convert = true; global_id_map[id_translated].push_back(id); } - if (convert) - { + if (convert) { std::stringstream out; out << ++i; id_translated += out.str(); @@ -279,7 +274,7 @@ std::string get_material_id(Material *mat) bool has_object_type(Scene *sce, short obtype) { Base *base= (Base*) sce->base.first; - while(base) { + while (base) { Object *ob = base->object; if (ob->type == obtype && ob->data) { |