diff options
Diffstat (limited to 'source/blender/collada')
-rw-r--r-- | source/blender/collada/AnimationExporter.cpp | 18 | ||||
-rw-r--r-- | source/blender/collada/AnimationImporter.cpp | 39 | ||||
-rw-r--r-- | source/blender/collada/AnimationImporter.h | 4 | ||||
-rw-r--r-- | source/blender/collada/ArmatureImporter.cpp | 11 | ||||
-rw-r--r-- | source/blender/collada/DocumentImporter.cpp | 21 | ||||
-rw-r--r-- | source/blender/collada/ImageExporter.cpp | 4 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 10 |
7 files changed, 49 insertions, 58 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 9c65aa4d2c5..53c1afd173f 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -1928,15 +1928,21 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i bool AnimationExporter::validateConstraints(bConstraint *con) { - bool valid = true; const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); /* these we can skip completely (invalid constraints...) */ - if (cti == NULL) valid = false; - if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) valid = false; + if (cti == NULL) + return false; + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) + return false; + /* these constraints can't be evaluated anyway */ - if (cti->evaluate_constraint == NULL) valid = false; + if (cti->evaluate_constraint == NULL) + return false; + /* influence == 0 should be ignored */ - if (con->enforce == 0.0f) valid = false; + if (con->enforce == 0.0f) + return false; - return valid; + /* validation passed */ + return true; } diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 4ef256fbcf1..ee3fddbf5b7 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -70,14 +70,15 @@ FCurve *AnimationImporter::create_fcurve(int array_index, const char *rna_path) fcu->array_index = array_index; return fcu; } - -void AnimationImporter::create_bezt(FCurve *fcu, float frame, float output) + +void AnimationImporter::add_bezt(FCurve *fcu, float frame, float value, eBezTriple_Interpolation ipo) { + //float fps = (float)FPS; BezTriple bez; memset(&bez, 0, sizeof(BezTriple)); bez.vec[1][0] = frame; - bez.vec[1][1] = output; - bez.ipo = U.ipo_new; /* use default interpolation mode here... */ + bez.vec[1][1] = value; + bez.ipo = ipo; /* use default interpolation mode here... */ bez.f1 = bez.f2 = bez.f3 = SELECT; bez.h1 = bez.h2 = HD_AUTO; insert_bezt_fcurve(fcu, &bez, 0); @@ -401,7 +402,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) eul_to_quat(quat, eul); for (int k = 0; k < 4; k++) - create_bezt(quatcu[k], frame, quat[k]); + create_bezt(quatcu[k], frame, quat[k], U.ipo_new); } } @@ -1560,7 +1561,8 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, copy_m4_m4(mat, matfra); } - float val[4], rot[4], loc[3], scale[3]; + float val[4] = {}; + float rot[4], loc[3], scale[3]; switch (tm_type) { case COLLADAFW::Transformation::ROTATE: @@ -1832,14 +1834,14 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, float } COLLADABU::Math::Matrix4 matrix; - int i = 0, j = 0; + int mi = 0, mj = 0; for (std::vector<FCurve *>::iterator it = curves.begin(); it != curves.end(); it++) { - matrix.setElement(i, j, evaluate_fcurve(*it, fra)); - j++; - if (j == 4) { - i++; - j = 0; + matrix.setElement(mi, mj, evaluate_fcurve(*it, fra)); + mj++; + if (mj == 4) { + mi++; + mj = 0; } fcurve_is_used(*it); } @@ -2006,19 +2008,6 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv action_groups_add_channel(act, grp, fcu); } -void AnimationImporter::add_bezt(FCurve *fcu, float fra, float value) -{ - //float fps = (float)FPS; - BezTriple bez; - memset(&bez, 0, sizeof(BezTriple)); - bez.vec[1][0] = fra; - bez.vec[1][1] = value; - bez.ipo = BEZT_IPO_LIN; /* use default interpolation mode here... */ - bez.f1 = bez.f2 = bez.f3 = SELECT; - bez.h1 = bez.h2 = HD_AUTO; - insert_bezt_fcurve(fcu, &bez, 0); - calchandles_fcurve(fcu); -} void AnimationImporter::set_import_from_version(std::string import_from_version) { diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index 15dee8ff5f4..7dc4131dd69 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -78,7 +78,7 @@ private: FCurve *create_fcurve(int array_index, const char *rna_path); - void create_bezt(FCurve *fcu, float frame, float output); + void add_bezt(FCurve *fcu, float frame, float value, eBezTriple_Interpolation ipo=BEZT_IPO_LIN); // create one or several fcurves depending on the number of parameters being animated void animation_to_fcurves(COLLADAFW::AnimationCurve *curve); @@ -214,8 +214,6 @@ public: void add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurve *fcu); - void add_bezt(FCurve *fcu, float fra, float value); - void extra_data_importer(std::string elementName); }; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 8832e0fd577..b2794b3bd23 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -284,12 +284,11 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone BoneExtensionMap &extended_bones = bone_extension_manager.getExtensionMap(armature); BoneExtended *dominant_child = NULL; int maxlen = 0; - Bone *child; if (parentbone == NULL) return; - child = (Bone *)parentbone->childbase.first; + Bone *child = (Bone *)parentbone->childbase.first; if (child && (import_settings->find_chains || child->next==NULL)) { for (; child; child = child->next) { BoneExtended *be = extended_bones[child->name]; @@ -339,8 +338,8 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone } } } - for (Bone *child = (Bone *)parentbone->childbase.first; child; child = child->next) { - ArmatureImporter::connect_bone_chains(armature, child, UNLIMITED_CHAIN_MAX); + for (Bone *ch = (Bone *)parentbone->childbase.first; ch; ch = ch->next) { + ArmatureImporter::connect_bone_chains(armature, ch, UNLIMITED_CHAIN_MAX); } } else if (maxlen>1 && maxlen > this->import_settings->min_chain_length) { @@ -350,8 +349,8 @@ void ArmatureImporter::connect_bone_chains(bArmature *armature, Bone *parentbone else { /* can't connect this Bone. Proceed with children ... */ if (pbe) pbe->set_leaf_bone(true); - for (Bone *child = (Bone *)parentbone->childbase.first; child; child = child->next) { - ArmatureImporter::connect_bone_chains(armature, child, UNLIMITED_CHAIN_MAX); + for (Bone *ch = (Bone *)parentbone->childbase.first; ch; ch = ch->next) { + ArmatureImporter::connect_bone_chains(armature, ch, UNLIMITED_CHAIN_MAX); } } diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index dfd662aa66c..7999b3c4727 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -195,8 +195,8 @@ void DocumentImporter::finish() std::vector<Object *> *objects_to_scale = new std::vector<Object *>(); /** TODO Break up and put into 2-pass parsing of DAE */ - std::vector<const COLLADAFW::VisualScene *>::iterator it; - for (it = vscenes.begin(); it != vscenes.end(); it++) { + std::vector<const COLLADAFW::VisualScene *>::iterator sit; + for (sit = vscenes.begin(); sit != vscenes.end(); sit++) { PointerRNA sceneptr, unit_settings; PropertyRNA *system, *scale; @@ -227,7 +227,7 @@ void DocumentImporter::finish() } // Write nodes to scene - const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); + const COLLADAFW::NodePointerArray& roots = (*sit)->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { std::vector<Object *> *objects_done = write_node(roots[i], NULL, sce, NULL, false); objects_to_scale->insert(objects_to_scale->end(), objects_done->begin(), objects_done->end()); @@ -252,8 +252,8 @@ void DocumentImporter::finish() armature_importer.fix_animation(); #endif - for (std::vector<const COLLADAFW::VisualScene *>::iterator it = vscenes.begin(); it != vscenes.end(); it++) { - const COLLADAFW::NodePointerArray& roots = (*it)->getRootNodes(); + for (std::vector<const COLLADAFW::VisualScene *>::iterator vsit = vscenes.begin(); vsit != vscenes.end(); vsit++) { + const COLLADAFW::NodePointerArray& roots = (*vsit)->getRootNodes(); for (unsigned int i = 0; i < roots.getCount(); i++) { translate_anim_recursive(roots[i], NULL, NULL); @@ -261,7 +261,6 @@ void DocumentImporter::finish() } if (libnode_ob.size()) { - Scene *sce = CTX_data_scene(mContext); fprintf(stderr, "got %d library nodes to free\n", (int)libnode_ob.size()); // free all library_nodes @@ -472,9 +471,9 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) { if (et && et->isProfile("blender")) { std::string name; - short* type = 0; - et->setData("type", type); - BKE_constraint_add_for_object(ob, "Test_con", *type); + short type = 0; + et->setData("type", &type); + BKE_constraint_add_for_object(ob, "Test_con", type); } } @@ -585,8 +584,8 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA ++lamp_done; } while (controller_done < controller.getCount()) { - COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done]; - ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map); + COLLADAFW::InstanceGeometry *geometry = (COLLADAFW::InstanceGeometry *)controller[controller_done]; + ob = mesh_importer.create_mesh_object(node, geometry, true, uid_material_map, material_texture_mapping_map); if (ob == NULL) { report_unknown_reference(*node, "instance_controller"); } diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index a2ab3ce520b..3cdc013c137 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -158,8 +158,8 @@ bool ImagesExporter::hasImages(Scene *sce) for (node = this->export_settings->export_set; node; node = node->next) { Object *ob = (Object *)node->link; - int a; - for (a = 0; a < ob->totcol; a++) { + + for (int 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/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index f8cd487c355..ec1b14a3855 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -554,7 +554,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) { CustomData edata; MEdge *medge; - int i, totedge; + int totedge; if (len == 0) return; @@ -574,7 +574,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) /* set default flags */ medge = &mesh->medge[mesh->totedge]; - for (i = 0; i < len; i++, medge++) + for (int i = 0; i < len; i++, medge++) medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT; mesh->totedge = totedge; @@ -608,12 +608,12 @@ void MeshImporter::read_lines(COLLADAFW::Mesh *mesh, Mesh *me) unsigned int edge_count = mp->getFaceCount(); unsigned int *indices = mp->getPositionIndices().getData(); - for (int i = 0; i < edge_count; i++, med++) { + for (int j = 0; j < edge_count; j++, med++) { med->bweight = 0; med->crease = 0; med->flag |= ME_LOOSEEDGE; - med->v1 = indices[2 * i]; - med->v2 = indices[2 * i + 1]; + med->v1 = indices[2 * j]; + med->v2 = indices[2 * j + 1]; } } } |