diff options
Diffstat (limited to 'source/blender/collada/ArmatureExporter.cpp')
-rw-r--r-- | source/blender/collada/ArmatureExporter.cpp | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 0d45df37796..743d3c2a158 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,8 +191,10 @@ 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); @@ -208,7 +210,8 @@ 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]; @@ -271,7 +274,8 @@ 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]; @@ -281,7 +285,8 @@ 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; @@ -365,21 +370,25 @@ 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); @@ -493,14 +502,16 @@ 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); } @@ -586,7 +597,8 @@ 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++); } |