[Bf-blender-cvs] [445b60270fb] collada2.8: fix: collada: preserve original object and bone names in export

Gaia Clary noreply at git.blender.org
Wed Nov 14 20:19:05 CET 2018


Commit: 445b60270fbd85eba978765520274988896e5e32
Author: Gaia Clary
Date:   Wed Nov 14 20:18:29 2018 +0100
Branches: collada2.8
https://developer.blender.org/rB445b60270fbd85eba978765520274988896e5e32

fix: collada: preserve original object and bone names in export

===================================================================

M	source/blender/collada/AnimationExporter.cpp
M	source/blender/collada/GeometryExporter.cpp
M	source/blender/collada/SceneExporter.cpp

===================================================================

diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 217fb08f014..7d11dd7668e 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -61,7 +61,7 @@ bool AnimationExporter::open_animation_container(bool has_container, Object *ob)
 	if (!has_container) {
 		char anim_id[200];
 		sprintf(anim_id, "action_container-%s", translate_id(id_name(ob)).c_str());
-		openAnimation(anim_id, id_name(ob));
+		openAnimation(anim_id, encode_xml(id_name(ob)));
 	}
 	return true;
 }
@@ -229,7 +229,7 @@ void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &
 		bool is_animated = sampler.get_object_samples(samples, ob);
 		if (is_animated) {
 			bAction *action = bc_getSceneObjectAction(ob);
-			std::string name = id_name(ob);
+			std::string name = encode_xml(id_name(ob));
 			std::string action_name = (action == NULL) ? name + "-action" : id_name(action);
 			std::string channel_type = "transform";
 			std::string axis = "";
@@ -329,7 +329,7 @@ void AnimationExporter::export_curve_animation(
 	bAction *action = bc_getSceneObjectAction(ob);
 	action_name = (action) ? id_name(action) : "constraint_anim";
 
-	const std::string curve_name = curve.get_animation_name(ob);
+	const std::string curve_name = encode_xml(curve.get_animation_name(ob));
 	std::string id = bc_get_action_id(action_name, curve_name, channel_target, axis, ".");
 
 	std::string collada_target = translate_id(curve_name);
@@ -353,7 +353,7 @@ void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &
 {
 	bAction* action = bc_getSceneObjectAction(ob);
 	std::string bone_name(bone->name);
-	std::string name = id_name(ob);
+	std::string name = encode_xml(id_name(ob));
 	std::string id = bc_get_action_id(id_name(action), name, bone_name, "pose_matrix");
 	std::string target = translate_id(id_name(ob) + "_" + bone_name) + "/transform";
 
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index 928509cbef9..5030b8f5b26 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -91,6 +91,7 @@ void GeometryExporter::operator()(Object *ob)
 	}
 
 	std::string geom_name = (use_instantiation) ? id_name(ob->data) : id_name(ob);
+	geom_name = encode_xml(geom_name);
 
 	exportedGeometry.insert(geom_id);
 
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index e3d97b37ca6..2981b1c8b30 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -44,8 +44,8 @@ void SceneExporter::exportScene(bContext *C, Depsgraph *depsgraph)
 {
 	ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
 	// <library_visual_scenes> <visual_scene>
-	std::string id_naming = id_name(view_layer);
-	openVisualScene(translate_id(id_naming), id_naming);
+	std::string name = id_name(view_layer);
+	openVisualScene(translate_id(name), encode_xml(name));
 	exportHierarchy(C, depsgraph, view_layer);
 	closeVisualScene();
 	closeLibrary();
@@ -129,7 +129,7 @@ void SceneExporter::writeNodes(bContext *C, Depsgraph *depsgraph, ViewLayer *vie
 	if (can_export) {
 		COLLADASW::Node colladaNode(mSW);
 		colladaNode.setNodeId(translate_id(id_name(ob)));
-		colladaNode.setNodeName(translate_id(id_name(ob)));
+		colladaNode.setNodeName(encode_xml(id_name(ob)));
 		colladaNode.setType(COLLADASW::Node::NODE);
 
 		colladaNode.start();
@@ -151,7 +151,7 @@ void SceneExporter::writeNodes(bContext *C, Depsgraph *depsgraph, ViewLayer *vie
 			if (!instance_controller_created) {
 				COLLADASW::InstanceGeometry instGeom(mSW);
 				instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation)));
-				instGeom.setName(translate_id(id_name(ob)));
+				instGeom.setName(encode_xml(id_name(ob)));
 				InstanceWriter::add_material_bindings(instGeom.getBindMaterial(),
 					ob,
 					this->export_settings->active_uv_only);
@@ -191,7 +191,7 @@ void SceneExporter::writeNodes(bContext *C, Depsgraph *depsgraph, ViewLayer *vie
 			if (BLI_listbase_is_empty(&ob->constraints) == false) {
 				bConstraint *con = (bConstraint *)ob->constraints.first;
 				while (con) {
-					std::string con_name(translate_id(con->name));
+					std::string con_name(encode_xml(con->name));
 					std::string con_tag = con_name + "_constraint";
 					printf("%s\n", con_name.c_str());
 					printf("%s\n\n", con_tag.c_str());



More information about the Bf-blender-cvs mailing list