forked from bartvdbraak/blender
fixed: [#34080] import of COLLADA breaks on '#' in filepath
This commit is contained in:
parent
deeeaed3d8
commit
e3488af838
@ -131,7 +131,8 @@ bool DocumentImporter::import()
|
||||
// deselect all to select new objects
|
||||
BKE_scene_base_deselect_all(CTX_data_scene(mContext));
|
||||
|
||||
if (!root.loadDocument(mFilename)) {
|
||||
const std::string encodedFilename = bc_url_encode(mFilename);
|
||||
if (!root.loadDocument(encodedFilename)) {
|
||||
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n");
|
||||
return false;
|
||||
}
|
||||
@ -146,7 +147,7 @@ bool DocumentImporter::import()
|
||||
COLLADASaxFWL::Loader loader2;
|
||||
COLLADAFW::Root root2(&loader2, this);
|
||||
|
||||
if (!root2.loadDocument(mFilename)) {
|
||||
if (!root2.loadDocument(encodedFilename)) {
|
||||
fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 2nd pass\n");
|
||||
return false;
|
||||
}
|
||||
@ -1235,3 +1236,4 @@ bool DocumentImporter::is_armature(COLLADAFW::Node *node){
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
@ -286,3 +286,20 @@ int bc_get_active_UVLayer(Object *ob)
|
||||
Mesh *me = (Mesh *)ob->data;
|
||||
return CustomData_get_active_layer_index(&me->fdata, CD_MTFACE);
|
||||
}
|
||||
|
||||
std::string bc_url_encode(std::string data) {
|
||||
/* XXX We probably do not need to do a full encoding.
|
||||
But in case that is necessary,then it can be added here.
|
||||
*/
|
||||
return bc_replace_string(data,"#", "%23");
|
||||
}
|
||||
|
||||
std::string bc_replace_string(std::string data, const std::string& pattern,
|
||||
const std::string& replacement) {
|
||||
size_t pos = 0;
|
||||
while((pos = data.find(pattern, pos)) != std::string::npos) {
|
||||
data.replace(pos, pattern.length(), replacement);
|
||||
pos += replacement.length();
|
||||
}
|
||||
return data;
|
||||
}
|
@ -77,4 +77,7 @@ extern void bc_bubble_sort_by_Object_name(LinkNode *export_set);
|
||||
extern bool bc_is_root_bone(Bone *aBone, bool deform_bones_only);
|
||||
extern int bc_get_active_UVLayer(Object *ob);
|
||||
|
||||
extern std::string bc_replace_string(std::string data, const std::string& pattern, const std::string& replacement);
|
||||
extern std::string bc_url_encode(std::string data);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user