From 82b21ba1663b253b4bde318599eedd062b5e9f64 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 28 Feb 2011 14:24:52 +0000 Subject: Fix [#26213] Collada exporter id's not unique Reported by Kevin Yoon could get same id as , prevent that by suffixing -material. --- source/blender/collada/InstanceWriter.cpp | 2 +- source/blender/collada/MaterialExporter.cpp | 2 +- source/blender/collada/collada_internal.cpp | 5 +++++ source/blender/collada/collada_internal.h | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) (limited to 'source/blender/collada') diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index c9bcd24f9a7..f822db0f39b 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -50,7 +50,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia COLLADASW::InstanceMaterialList& iml = bind_material.getInstanceMaterialList(); if (ma) { - std::string matid(id_name(ma)); + std::string matid(get_material_id(ma)); matid = translate_id(matid); COLLADASW::InstanceMaterial im(matid, COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index 5814cb8101c..0030f2a6285 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -49,7 +49,7 @@ void MaterialsExporter::operator()(Material *ma, Object *ob) { std::string name(id_name(ma)); - openMaterial(translate_id(name), name); + openMaterial(get_material_id(ma), name); std::string efid = translate_id(name) + "-effect"; addInstanceEffect(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, efid)); diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 1eaa043e180..5ae41fee999 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -272,3 +272,8 @@ std::string get_camera_id(Object *ob) { return translate_id(id_name(ob)) + "-camera"; } + +std::string get_material_id(Material *mat) +{ + return translate_id(id_name(mat)) + "-material"; +} diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h index 815113400b4..db7dd16dfd1 100644 --- a/source/blender/collada/collada_internal.h +++ b/source/blender/collada/collada_internal.h @@ -37,6 +37,7 @@ #include "Math/COLLADABUMathMatrix4.h" #include "DNA_armature_types.h" +#include "DNA_material_types.h" #include "DNA_object_types.h" #include "BLI_math.h" @@ -94,4 +95,6 @@ extern std::string get_joint_id(Bone *bone, Object *ob_arm); extern std::string get_camera_id(Object *ob); +extern std::string get_material_id(Material *mat); + #endif /* COLLADA_INTERNAL_H */ -- cgit v1.2.3