Fixed importing of shapekey names: name is now taken from geometry name instead of deriving it from the mesh name

This commit is contained in:
Gaia Clary
2013-02-12 17:52:18 +00:00
parent 751bee1845
commit 8996184ac4
4 changed files with 18 additions and 4 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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