diff options
Diffstat (limited to 'source/blender/collada/MeshImporter.cpp')
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 0bf33206fa7..ba6be75e051 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -727,6 +727,22 @@ bool MeshImporter::flat_face(unsigned int *nind, COLLADAFW::MeshVertexData& nor, MeshImporter::MeshImporter(UnitConverter *unitconv, ArmatureImporter *arm, Scene *sce) : unitconverter(unitconv), scene(sce), armature_importer(arm) {} +void MeshImporter::bmeshConversion() +{ + for (std::map<COLLADAFW::UniqueId, Mesh*>::iterator m = uid_mesh_map.begin(); + m != uid_mesh_map.end(); ++m) + { + if ((*m).second) { + Mesh *me = (*m).second; + BKE_mesh_convert_mfaces_to_mpolys(me); + BKE_mesh_tessface_clear(me); + + mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + } + } +} + + Object *MeshImporter::get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid) { if (uid_object_map.find(geom_uid) != uid_object_map.end()) @@ -839,13 +855,12 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri for (it = prims.begin(); it != prims.end(); it++) { Primitive& prim = *it; - i = 0; - while (i++ < prim.totface) { - prim.mface->mat_nr = mat_index; - prim.mface++; + MFace *mface = prim.mface; + + for (i = 0; i < prim.totface; i++, mface++) { + mface->mat_nr = mat_index; // bind texture images to faces if (texture_face && (*color_texture)) { - texture_face->mode = TF_TEX; texture_face->tpage = (Image*)(*color_texture)->tex->ima; texture_face++; } @@ -856,7 +871,6 @@ MTFace *MeshImporter::assign_material_to_geom(COLLADAFW::MaterialBinding cmateri return texture_face; } - Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::InstanceGeometry *geom, bool isController, std::map<COLLADAFW::UniqueId, Material*>& uid_material_map, @@ -885,16 +899,16 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta } if (!uid_mesh_map[*geom_uid]) return NULL; - Object *ob = add_object(scene, OB_MESH); + // name Object + const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId(); + const char *name = (id.length())? id.c_str(): NULL; + + // add object + Object *ob = bc_add_object(scene, OB_MESH, name); // store object pointer for ArmatureImporter uid_object_map[*geom_uid] = ob; - // name Object - const std::string& id = node->getName().size() ? node->getName() : node->getOriginalId(); - if (id.length()) - rename_id(&ob->id, (char*)id.c_str()); - // replace ob->data freeing the old one Mesh *old_mesh = (Mesh*)ob->data; @@ -922,7 +936,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta fprintf(stderr, "invalid referenced material for %s\n", mat_array[i].getName().c_str()); } } - + return ob; } @@ -949,6 +963,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); Mesh *me = add_mesh((char*)str_geom_id.c_str()); + me->id.us--; // is already 1 here, but will be set later in set_mesh // store the Mesh pointer to link it later with an Object this->uid_mesh_map[mesh->getUniqueId()] = me; @@ -963,8 +978,5 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) make_edges(me, 0); - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); - - BKE_mesh_convert_mfaces_to_mpolys(me); return true; } |