diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-02-12 21:52:18 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2013-02-12 21:52:18 +0400 |
commit | 8996184ac4e96af4c7e2e46d3f836c962ccdb0b0 (patch) | |
tree | d6571083a2ea6ec496bc1f85297ad32025ab0f46 /source/blender | |
parent | 751bee184598859d99922d228e0de4a0df96de26 (diff) |
Fixed importing of shapekey names: name is now taken from geometry name instead of deriving it from the mesh name
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/collada/ArmatureImporter.cpp | 5 | ||||
-rw-r--r-- | source/blender/collada/GeometryExporter.cpp | 2 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.cpp | 11 | ||||
-rw-r--r-- | source/blender/collada/MeshImporter.h | 4 |
4 files changed, 18 insertions, 4 deletions
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 6e8bf337abb..fefad7dd8ec 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -673,11 +673,14 @@ void ArmatureImporter::make_shape_keys() for (int i = 0 ; i < morphTargetIds.getCount() ; i++ ) { //better to have a seperate map of morph objects, //This'll do for now since only mesh morphing is imported + Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]); if (me) { me->key = key; - kb = BKE_keyblock_add_ctime(key, me->id.name, FALSE); + std::string morph_name = *this->mesh_importer->get_geometry_name(me->id.name); + + kb = BKE_keyblock_add_ctime(key, morph_name.c_str(), FALSE); BKE_key_convert_from_mesh(me, kb); //apply weights diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 19d67f37476..4a6c5b43ce2 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -187,7 +187,7 @@ void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb) return; } - std::string geom_name = id_name(ob) + "_morph_" + kb->name; + std::string geom_name = kb->name; exportedGeometry.insert(geom_id); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index bf5a39cfae8..26915f37002 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -952,6 +952,13 @@ Mesh *MeshImporter::get_mesh_by_geom_uid(const COLLADAFW::UniqueId& mesh_uid) return NULL; } +std::string *MeshImporter::get_geometry_name(const std::string &mesh_name) +{ + if (this->mesh_geom_map.find(mesh_name) != this->mesh_geom_map.end()) + return &this->mesh_geom_map[mesh_name]; + return NULL; +} + MTex *MeshImporter::assign_textures_to_uvlayer(COLLADAFW::TextureCoordinateBinding &ctexture, Mesh *me, TexIndexTextureArrayMap& texindex_texarray_map, MTex *color_texture) @@ -1300,7 +1307,9 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry *geom) // store the Mesh pointer to link it later with an Object this->uid_mesh_map[mesh->getUniqueId()] = me; - + // needed to map mesh to its geometry name (needed for shape key naming) + this->mesh_geom_map[std::string(me->id.name)] = str_geom_id; + int new_tris = 0; read_vertices(mesh, me); diff --git a/source/blender/collada/MeshImporter.h b/source/blender/collada/MeshImporter.h index 5ab068160a4..d0412985540 100644 --- a/source/blender/collada/MeshImporter.h +++ b/source/blender/collada/MeshImporter.h @@ -60,6 +60,7 @@ class MeshImporterBase public: virtual Object *get_object_by_geom_uid(const COLLADAFW::UniqueId& geom_uid) = 0; virtual Mesh *get_mesh_by_geom_uid(const COLLADAFW::UniqueId& mesh_uid) = 0; + virtual std::string *get_geometry_name(const std::string &mesh_name) = 0; }; class UVDataWrapper @@ -84,6 +85,7 @@ private: Scene *scene; ArmatureImporter *armature_importer; + std::map<std::string, std::string> mesh_geom_map; // needed for correct shape key naming std::map<COLLADAFW::UniqueId, Mesh*> uid_mesh_map; // geometry unique id-to-mesh map std::map<COLLADAFW::UniqueId, Object*> uid_object_map; // geom uid-to-object std::vector<Object*> imported_objects; // list of imported objects @@ -175,7 +177,7 @@ public: // create a mesh storing a pointer in a map so it can be retrieved later by geometry UID bool write_geometry(const COLLADAFW::Geometry* geom); - + std::string *MeshImporter::get_geometry_name(const std::string &mesh_name); }; #endif |