From e2b3ff502417df4fb7237e0090dcd2f5564e35da Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 16 Nov 2010 22:27:31 +0000 Subject: [PATCH] Apply patch [#24722] COLLADA exporter: handle instancing Submitted by Wenzel Jakob Patch adds handling of linked meshes: instead of generating separate geometry objects, use instances. --- source/blender/collada/GeometryExporter.cpp | 5 +++++ source/blender/collada/GeometryExporter.h | 3 +++ source/blender/collada/collada_internal.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 1aef6e6489a..7b5b5397955 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -63,6 +63,11 @@ void GeometryExporter::operator()(Object *ob) std::vector nor; std::vector norind; + // Skip if linked geometry was already exported from another reference + if (exportedGeometry.find(geom_id) != exportedGeometry.end()) + return; + exportedGeometry.insert(geom_id); + bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL); create_normals(nor, norind, me); diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 7a78b676f49..27c837418b1 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -28,6 +28,7 @@ #include #include +#include #include "COLLADASWStreamWriter.h" #include "COLLADASWLibraryGeometries.h" @@ -89,6 +90,8 @@ public: COLLADASW::URI makeUrl(std::string id); /* int getTriCount(MFace *faces, int totface);*/ +private: + std::set exportedGeometry; }; struct GeometryFunctor { diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp index 6f401c1856f..4943aa96546 100644 --- a/source/blender/collada/collada_internal.cpp +++ b/source/blender/collada/collada_internal.cpp @@ -247,7 +247,7 @@ std::string id_name(void *id) std::string get_geometry_id(Object *ob) { - return translate_id(id_name(ob)) + "-mesh"; + return translate_id(id_name(ob->data)) + "-mesh"; } std::string get_light_id(Object *ob)