Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-08-26 19:16:27 +0400
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-08-26 19:16:27 +0400
commitcdbb904b32a859a1b3a65dbe79057248f4425832 (patch)
treefe5abab250cf71501fc716d6e17284c2f94f4bee /source/blender/collada
parentff8daca1f117b34c92462f4ab3bbe2aa50f95166 (diff)
code review fixes
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationExporter.cpp176
-rw-r--r--source/blender/collada/AnimationImporter.cpp3
2 files changed, 79 insertions, 100 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 2f074992076..bbd6fef803f 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -41,126 +41,104 @@ void forEachObjectInScene(Scene *sce, Functor &f)
}
void AnimationExporter::exportAnimations(Scene *sce)
- {
- if(hasAnimations(sce)) {
- this->scene = sce;
+{
+ if(hasAnimations(sce)) {
+ this->scene = sce;
- openLibrary();
+ openLibrary();
- forEachObjectInScene(sce, *this);
+ forEachObjectInScene(sce, *this);
- closeLibrary();
- }
+ closeLibrary();
}
+}
- // called for each exported object
- void AnimationExporter::operator() (Object *ob)
+// called for each exported object
+void AnimationExporter::operator() (Object *ob)
+{
+ FCurve *fcu;
+ char * transformName ;
+ bool isMatAnim = false;
+
+ //Export transform animations
+ if(ob->adt && ob->adt->action)
{
- FCurve *fcu;
- char * transformName ;
- bool isMatAnim = false;
+ fcu = (FCurve*)ob->adt->action->curves.first;
- //Export transform animations
- if(ob->adt && ob->adt->action)
+ //transform matrix export for bones are temporarily disabled here.
+ if ( ob->type == OB_ARMATURE )
{
- fcu = (FCurve*)ob->adt->action->curves.first;
-
- //transform matrix export for bones are temporarily disabled here.
- if ( ob->type == OB_ARMATURE )
- {
- if (!ob->data) return;
- bArmature *arm = (bArmature*)ob->data;
- for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
- write_bone_animation_matrix(ob, bone);
-
- transformName = fcu->rna_path;
- }
- else
- transformName = extract_transform_name( fcu->rna_path );
+ bArmature *arm = (bArmature*)ob->data;
+ for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
+ write_bone_animation_matrix(ob, bone);
- while (fcu) {
- 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")))
- dae_animation(ob ,fcu, transformName, false);
- fcu = fcu->next;
- }
-
+ transformName = fcu->rna_path;
}
-
- //Export Lamp parameter animations
- 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) {
+ else
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 );
- fcu = fcu->next;
- }
+
+ while (fcu) {
+ 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")))
+ dae_animation(ob ,fcu, transformName, false);
+ fcu = fcu->next;
}
+
+ }
- //Export Camera parameter animations
- 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 );
- fcu = fcu->next;
- }
+ //Export Lamp parameter animations
+ 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 );
+ fcu = fcu->next;
}
+ }
- //Export Material parameter animations.
- 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)
- {
- 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")))
- dae_animation(ob ,fcu, transformName, true, ma );
- fcu = fcu->next;
- }
- }
+ //Export Camera parameter animations
+ 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 );
+ fcu = fcu->next;
}
- /* Old System
- if (!ob->adt || !ob->adt->action)
- fcu = (FCurve*)((Lamp*)ob->data)->adt->action->curves.first; //this is already checked in hasAnimations()
- else
- fcu = (FCurve*)ob->adt->action->curves.first;
-
- if (ob->type == OB_ARMATURE) {
- if (!ob->data) return;
- bArmature *arm = (bArmature*)ob->data;
- while(fcu)
- {
+ }
+
+ //Export Material parameter animations.
+ 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)
+ {
+ isMatAnim = true;
+ fcu = (FCurve*)ma->adt->action->curves.first;
+ while (fcu) {
transformName = extract_transform_name( fcu->rna_path );
- // std::string ob_name = getObjectBoneName( ob , fcu);
- // for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
- // write_bone_animation(ob, bone);
- dae_animation(ob, fcu, ob_name, transformName);
+
+ 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;
}
}
- else {*/
}
+}
//euler sources from quternion sources
float * AnimationExporter::get_eul_source_for_quat(Object *ob )
@@ -193,7 +171,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
eul[i*3 + k] = temp_eul[k];
}
-
+ MEM_freeN(quat);
return eul;
}
@@ -287,6 +265,8 @@ void AnimationExporter::exportAnimations(Scene *sce)
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
{
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp
index ee04c270843..4a3cd5eeb06 100644
--- a/source/blender/collada/AnimationImporter.cpp
+++ b/source/blender/collada/AnimationImporter.cpp
@@ -179,7 +179,6 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu)
cu->bezt[i].vec[1][1] *= M_PI / 180.0f;
cu->bezt[i].vec[0][1] *= M_PI / 180.0f;
cu->bezt[i].vec[2][1] *= M_PI / 180.0f;
- cu->bezt[i].vec[1][0];
}
}
@@ -439,7 +438,7 @@ void AnimationImporter::modify_fcurve(std::vector<FCurve*>* curves , char* rna_p
int i;
for (it = curves->begin(), i = 0; it != curves->end(); it++, i++) {
FCurve *fcu = *it;
- fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path));
+ fcu->rna_path = BLI_strdup(rna_path);
if (array_index == -1) fcu->array_index = i;
else fcu->array_index = array_index;