code cleanup: function naming, use BKE_*type* prefix.
[blender.git] / source / blender / collada / AnimationImporter.cpp
index 097e9902de52ab8edd0f45b131a80fb49068c304..34f7efa9de0fc13e85d5d363f4cd5f8b12cb0719 100644 (file)
@@ -119,7 +119,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
                                        bez.vec[1][1] = bc_get_float_value(output, j * dim + i);
 
 
-                                       if( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
+                                       if ( curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER ||
                                                curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_STEP) 
                                        {
                                                COLLADAFW::FloatOrDoubleArray& intan = curve->getInTangentValues();
@@ -132,14 +132,13 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve)
                                                // outtangent
                                                bez.vec[2][0] = bc_get_float_value(outtan, (j * 2 * dim ) + (2 * i)) * fps;
                                                bez.vec[2][1] = bc_get_float_value(outtan, (j * 2 * dim )+ (2 * i) + 1);
-                                               if(curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) 
+                                               if (curve->getInterpolationType() == COLLADAFW::AnimationCurve::INTERPOLATION_BEZIER) 
                                                        bez.ipo = BEZT_IPO_BEZ;
                                                else 
                                                        bez.ipo = BEZT_IPO_CONST;
                                                //bez.h1 = bez.h2 = HD_AUTO;    
                                        }
-                                       else 
-                                       {
+                                       else {
                                                bez.h1 = bez.h2 = HD_AUTO; 
                                                bez.ipo = BEZT_IPO_LIN;
                                        }
@@ -261,7 +260,7 @@ bool AnimationImporter::write_animation(const COLLADAFW::Animation* anim)
                // XXX Don't know if it's necessary
                // Should we check outPhysicalDimension?
                if (curve->getInPhysicalDimension() != COLLADAFW::PHYSICAL_DIMENSION_TIME) {
-                       fprintf(stderr, "Inputs physical dimension is not time. \n");
+                       fprintf(stderr, "Inputs physical dimension is not time.\n");
                        return true;
                }
 
@@ -325,7 +324,7 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob)
        TransformReader::get_node_mat(mat, node, &uid_animated_map, ob);
        if (ob) {
                copy_m4_m4(ob->obmat, mat);
-               object_apply_mat4(ob, ob->obmat, 0, 0);
+               BKE_object_apply_mat4(ob, ob->obmat, 0, 0);
        }
 }
 
@@ -424,7 +423,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act)
 
 
 //sets the rna_path and array index to curve
-void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , const char* rna_path , int array_index )
+void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index )
 {
        std::vector<FCurve*>::iterator it;
        int i;
@@ -439,7 +438,17 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , const char*
        }
 }
 
-void AnimationImporter::find_frames( std::vector<float>* frames , std::vector<FCurve*>* curves)
+void AnimationImporter::unused_fcurve(std::vector<FCurve*>* curves)
+{
+       // when an error happens and we can't actually use curve remove it from unused_curves
+       std::vector<FCurve*>::iterator it;
+       for (it = curves->begin(); it != curves->end(); it++) {
+               FCurve *fcu = *it;
+               unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
+       }
+}
+
+void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves)
 {
        std::vector<FCurve*>::iterator iter;
        for (iter = curves->begin(); iter != curves->end(); iter++) {
@@ -457,7 +466,7 @@ void AnimationImporter::find_frames( std::vector<float>* frames , std::vector<FC
 }
 
 //creates the rna_paths and array indices of fcurves from animations using transformation and bound animation class of each animation.
-void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * transform , 
+void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation * transform,
                                                                                                         const COLLADAFW::AnimationList::AnimationBinding * binding,
                                                                                                         std::vector<FCurve*>* curves, bool is_joint, char * joint_path)
 {
@@ -500,6 +509,7 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
                        modify_fcurve(curves, rna_path, -1 );
                        break;
                default:
+                       unused_fcurve(curves);
                        fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
                                binding->animationClass, loc ? "TRANSLATE" : "SCALE");
                                }
@@ -535,10 +545,13 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
                        else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
                                modify_fcurve(curves, rna_path, 2 );
                        }
+                       else
+                               unused_fcurve(curves);
                        break;
                case COLLADAFW::AnimationList::AXISANGLE:
                        // TODO convert axis-angle to quat? or XYZ?
                default:
+                       unused_fcurve(curves);
                        fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n",
                                binding->animationClass);
                                }
@@ -554,9 +567,11 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
 
                        }
                        }*/
+                       unused_fcurve(curves);
                        break;
                case COLLADAFW::Transformation::SKEW:
                case COLLADAFW::Transformation::LOOKAT:
+                       unused_fcurve(curves);
                        fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n");
                        break;
        }
@@ -564,10 +579,10 @@ void AnimationImporter:: Assign_transform_animations(COLLADAFW::Transformation *
 }
 
 //creates the rna_paths and array indices of fcurves from animations using color and bound animation class of each animation.
-void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurves ,const char * anim_type)
+void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& listid, ListBase *AnimCurvesconst char * anim_type)
 {
        char rna_path[100];
-       BLI_strncpy(rna_path,anim_type, sizeof(rna_path));
+       BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
 
        const COLLADAFW::AnimationList *animlist = animlist_map[listid];
        const COLLADAFW::AnimationList::AnimationBindings& bindings = animlist->getAnimationBindings();
@@ -592,6 +607,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list
                        break;
 
                default:
+                       unused_fcurve(&animcurves);
                        fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
                                bindings[j].animationClass, "COLOR" );
                }
@@ -622,7 +638,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
                for (unsigned int j = 0; j < bindings.getCount(); j++) {
                        animcurves = curve_map[bindings[j].animation];
 
-                       BLI_strncpy(rna_path, anim_type , sizeof(rna_path));
+                       BLI_strncpy(rna_path, anim_type, sizeof(rna_path));
                        modify_fcurve(&animcurves, rna_path, 0 );
                        std::vector<FCurve*>::iterator iter;
                        //Add the curves of the current animation to the object
@@ -635,7 +651,7 @@ void AnimationImporter:: Assign_float_animations(const COLLADAFW::UniqueId& list
        
 }
 
-void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root ,COLLADAFW::Node* node, 
+void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& animcurves, COLLADAFW::Node* root, COLLADAFW::Node* node,
                                                                                                        COLLADAFW::Transformation * tm )
 {
        bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
@@ -726,7 +742,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
                        calc_joint_parent_mat_rest(par, NULL, root, node);
                        mult_m4_m4m4(temp, par, matfra);
 
-                       // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
+                       // evaluate_joint_world_transform_at_frame(temp, NULL, node, fra);
 
                        // calc special matrix
                        mul_serie_m4(mat, irest, temp, irest_dae, rest, NULL, NULL, NULL, NULL);
@@ -779,27 +795,25 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>&
 
 }
 
-void AnimationImporter::translate_Animations ( COLLADAFW::Node * node , 
-                                                                                                  std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
-                                                                                                  std::map<COLLADAFW::UniqueId, Object*>& object_map,
-                                                                                                  std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
+void AnimationImporter::translate_Animations ( COLLADAFW::Node * node,
+                                                                                               std::map<COLLADAFW::UniqueId, COLLADAFW::Node*>& root_map,
+                                                                                               std::multimap<COLLADAFW::UniqueId, Object*>& object_map,
+                                                                                               std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
 {
        AnimationImporter::AnimMix* animType = get_animation_type(node, FW_object_map );
 
        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)
-       {
+    Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map.find(node->getUniqueId())->second;
+       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 ) 
@@ -837,7 +851,7 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
                                for (unsigned int j = 0; j < bindings.getCount(); j++) {
                                        animcurves = curve_map[bindings[j].animation];
                                        if ( is_matrix ) {
-                                               apply_matrix_curves(ob, animcurves, root , node,  transform  );
+                                               apply_matrix_curves(ob, animcurves, root, node,  transform  );
                                        }
                                        else {                          
 
@@ -867,8 +881,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,33 +893,29 @@ 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"); 
+                               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();
 
-                               Assign_float_animations( listid ,AnimCurves, "spot_blend"); 
+                               Assign_float_animations( listid, AnimCurves, "spot_blend");
 
                        }
                }
        }
 
-       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,37 +927,33 @@ 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"); 
+                               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"); 
+                               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"); 
+                               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"); 
+                               Assign_float_animations( listid, AnimCurves, "clip_start");
                        }
 
                }
        }
-       if ( animType->material != 0){
+       if ( animType->material != 0) {
                Material *ma = give_current_material(ob, 1);
                if (!ma->adt || !ma->adt->action) act = verify_adt_action((ID*)&ma->id, 1);
                else act = ma->adt->action;
@@ -964,28 +969,28 @@ void AnimationImporter::translate_Animations ( COLLADAFW::Node * node ,
                                if (ef != NULL) { /* can be NULL [#28909] */
                                        const COLLADAFW::CommonEffectPointerArray& commonEffects  =  ef->getCommonEffects();
                                        COLLADAFW::EffectCommon *efc = commonEffects[0];
-                                       if((animType->material & MATERIAL_SHININESS) != 0){
+                                       if ((animType->material & MATERIAL_SHININESS) != 0) {
                                                const COLLADAFW::FloatOrParam *shin = &(efc->getShininess());
                                                const COLLADAFW::UniqueId& listid =  shin->getAnimationList();
-                                               Assign_float_animations( listid, AnimCurves , "specular_hardness" );
+                                               Assign_float_animations( listid, AnimCurves, "specular_hardness" );
                                        }
 
-                                       if((animType->material & MATERIAL_IOR) != 0){
+                                       if ((animType->material & MATERIAL_IOR) != 0) {
                                                const COLLADAFW::FloatOrParam *ior = &(efc->getIndexOfRefraction());
                                                const COLLADAFW::UniqueId& listid =  ior->getAnimationList();
-                                               Assign_float_animations( listid, AnimCurves , "raytrace_transparency.ior" );
+                                               Assign_float_animations( listid, AnimCurves, "raytrace_transparency.ior" );
                                        }
 
-                                       if((animType->material & MATERIAL_SPEC_COLOR) != 0){
+                                       if ((animType->material & MATERIAL_SPEC_COLOR) != 0) {
                                                const COLLADAFW::ColorOrTexture *cot = &(efc->getSpecular());
                                                const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
-                                               Assign_color_animations( listid, AnimCurves , "specular_color" );
+                                               Assign_color_animations( listid, AnimCurves, "specular_color" );
                                        }
 
-                                       if((animType->material & MATERIAL_DIFF_COLOR) != 0){
+                                       if ((animType->material & MATERIAL_DIFF_COLOR) != 0) {
                                                const COLLADAFW::ColorOrTexture *cot = &(efc->getDiffuse());
                                                const COLLADAFW::UniqueId& listid =  cot->getColor().getAnimationList();
-                                               Assign_color_animations( listid, AnimCurves , "diffuse_color" );
+                                               Assign_color_animations( listid, AnimCurves, "diffuse_color" );
                                        }
                                }
                        }
@@ -1090,7 +1095,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
                calc_joint_parent_mat_rest(par, NULL, root, node);
                mult_m4_m4m4(temp, par, matfra);
 
-               // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
+               // evaluate_joint_world_transform_at_frame(temp, NULL,, node, fra);
 
                // calc special matrix
                mul_serie_m4(mat, irest, temp, irest_dae, rest, NULL, NULL, NULL, NULL);
@@ -1125,7 +1130,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vector<FCur
 
 
 //Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
-AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node , 
+AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node,
                                                                                        std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map) 
 {
        AnimMix *types = new AnimMix();
@@ -1150,9 +1155,9 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
 
        for (unsigned int i = 0; i < nodeLights.getCount(); i++) {
                const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()];
-               types->light = setAnimType(&(light->getColor()),(types->light), LIGHT_COLOR);
-               types->light = setAnimType(&(light->getFallOffAngle()),(types->light), LIGHT_FOA);
-               types->light = setAnimType(&(light->getFallOffExponent()),(types->light), LIGHT_FOE);
+               types->light = setAnimType(&(light->getColor()), (types->light), LIGHT_COLOR);
+               types->light = setAnimType(&(light->getFallOffAngle()), (types->light), LIGHT_FOA);
+               types->light = setAnimType(&(light->getFallOffExponent()), (types->light), LIGHT_FOE);
 
                if ( types->light != 0) break;
 
@@ -1162,16 +1167,14 @@ 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 )
-               {
-                       types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XFOV);
+               if ( camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE ) {
+                       types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XFOV);
                }
-               else
-               {
-                       types->camera = setAnimType(&(camera->getXMag()),(types->camera), CAMERA_XMAG);
+               else {
+                       types->camera = setAnimType(&(camera->getXMag()), (types->camera), CAMERA_XMAG);
                }
-               types->camera = setAnimType(&(camera->getFarClippingPlane()),(types->camera), CAMERA_ZFAR);
-               types->camera = setAnimType(&(camera->getNearClippingPlane()),(types->camera), CAMERA_ZNEAR);
+               types->camera = setAnimType(&(camera->getFarClippingPlane()), (types->camera), CAMERA_ZFAR);
+               types->camera = setAnimType(&(camera->getNearClippingPlane()), (types->camera), CAMERA_ZNEAR);
 
                if ( types->camera != 0) break;
 
@@ -1185,13 +1188,13 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
                        const COLLADAFW::Effect *ef = (COLLADAFW::Effect *) (FW_object_map[matuid]);
                        if (ef != NULL) { /* can be NULL [#28909] */
                                const COLLADAFW::CommonEffectPointerArray& commonEffects = ef->getCommonEffects();
-                               if(!commonEffects.empty()) {
+                               if (!commonEffects.empty()) {
                                        COLLADAFW::EffectCommon *efc = commonEffects[0];
-                                       types->material =  setAnimType(&(efc->getShininess()),(types->material), MATERIAL_SHININESS);
-                                       types->material =  setAnimType(&(efc->getSpecular().getColor()),(types->material), MATERIAL_SPEC_COLOR);
-                                       types->material =  setAnimType(&(efc->getDiffuse().getColor()),(types->material), MATERIAL_DIFF_COLOR);
-                                       // types->material =  setAnimType(&(efc->get()),(types->material), MATERIAL_TRANSPARENCY);
-                                       types->material =  setAnimType(&(efc->getIndexOfRefraction()),(types->material), MATERIAL_IOR);
+                                       types->material =  setAnimType(&(efc->getShininess()), (types->material), MATERIAL_SHININESS);
+                                       types->material =  setAnimType(&(efc->getSpecular().getColor()), (types->material), MATERIAL_SPEC_COLOR);
+                                       types->material =  setAnimType(&(efc->getDiffuse().getColor()), (types->material), MATERIAL_DIFF_COLOR);
+                                       // types->material =  setAnimType(&(efc->get()), (types->material), MATERIAL_TRANSPARENCY);
+                                       types->material =  setAnimType(&(efc->getIndexOfRefraction()), (types->material), MATERIAL_IOR);
                                }
                        }
                }
@@ -1199,7 +1202,7 @@ AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLAD
        return types;
 }
 
-int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop , int types, int addition)
+int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop, int types, int addition)
 {
        const COLLADAFW::UniqueId& listid =  prop->getAnimationList();
        if (animlist_map.find(listid) != animlist_map.end())
@@ -1208,7 +1211,7 @@ int AnimationImporter::setAnimType ( const COLLADAFW::Animatable * prop , int ty
 }              
 
 // Is not used anymore.
-void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node , COLLADAFW::Transformation::TransformationType tm_type)
+void AnimationImporter::find_frames_old(std::vector<float> * frames, COLLADAFW::Node * node, COLLADAFW::Transformation::TransformationType tm_type)
 {
        bool is_matrix = tm_type == COLLADAFW::Transformation::MATRIX;
        bool is_rotation = tm_type == COLLADAFW::Transformation::ROTATE;
@@ -1293,7 +1296,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
        // frames at which to sample
        std::vector<float> frames;
        
-       find_frames_old(&frames, node , tm_type);
+       find_frames_old(&frames, node, tm_type);
        
        unsigned int i;
        
@@ -1410,7 +1413,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node,
                        calc_joint_parent_mat_rest(par, NULL, root, node);
                        mult_m4_m4m4(temp, par, matfra);
 
-                       // evaluate_joint_world_transform_at_frame(temp, NULL, , node, fra);
+                       // evaluate_joint_world_transform_at_frame(temp, NULL,, node, fra);
 
                        // calc special matrix
                        mul_serie_m4(mat, irest, temp, irest_dae, rest, NULL, NULL, NULL, NULL);
@@ -1641,7 +1644,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);
 
@@ -1767,9 +1770,7 @@ bool AnimationImporter::calc_joint_parent_mat_rest(float mat[4][4], float par[4]
 Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::Node *node, Object *par_job)
 {
        if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) {
-               Object *job = add_object(scene, OB_EMPTY);
-
-               rename_id((ID*)&job->id, (char*)get_joint_name(node));
+               Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node));
 
                job->lay = object_in_scene(job, scene)->lay = 2;
 
@@ -1799,7 +1800,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No
                        job->parsubstr[0] = 0;
                }
 
-               where_is_object(scene, job);
+               BKE_object_where_is_calc(scene, job);
 
                // after parenting and layer change
                DAG_scene_sort(CTX_data_main(C), scene);