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:
authorCampbell Barton <ideasman42@gmail.com>2012-04-28 10:31:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-28 10:31:57 +0400
commitb340f930ec5639f24e7e2d47fab221fb752b61dd (patch)
tree0e880a36bb528d133af6d10701fc090716b3b7f8 /source/blender/collada/AnimationExporter.cpp
parent09dc600839904a198ab4ba3fad62ce58c2d3aa07 (diff)
style cleanup: changes to brace placement / newlines - for/while/if/switch
Diffstat (limited to 'source/blender/collada/AnimationExporter.cpp')
-rw-r--r--source/blender/collada/AnimationExporter.cpp110
1 files changed, 49 insertions, 61 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;
}
}