Index: release/scripts/presets/operator/wm.collada_export/second_life.py =================================================================== --- release/scripts/presets/operator/wm.collada_export/second_life.py (revision 47054) +++ release/scripts/presets/operator/wm.collada_export/second_life.py (working copy) @@ -4,4 +4,5 @@ op.selected = True op.apply_modifiers = True op.include_bone_children = False +op.use_object_instantiation = False op.second_life = True Index: source/blender/collada/collada_internal.h =================================================================== --- source/blender/collada/collada_internal.h (revision 47054) +++ source/blender/collada/collada_internal.h (working copy) @@ -88,6 +88,8 @@ extern std::string get_geometry_id(Object *ob); +extern std::string get_geometry_id(Object *ob, bool use_instantiation); + extern std::string get_light_id(Object *ob); extern std::string get_joint_id(Bone *bone, Object *ob_arm); Index: source/blender/collada/collada_internal.cpp =================================================================== --- source/blender/collada/collada_internal.cpp (revision 47054) +++ source/blender/collada/collada_internal.cpp (working copy) @@ -251,6 +251,13 @@ return translate_id(id_name(ob->data)) + "-mesh"; } +std::string get_geometry_id(Object *ob, bool use_instantiation) +{ + std::string geom_name = (use_instantiation) ? id_name(ob->data) : id_name(ob); + + return translate_id(geom_name) + "-mesh"; +} + std::string get_light_id(Object *ob) { return translate_id(id_name(ob)) + "-light"; Index: source/blender/collada/ExportSettings.h =================================================================== --- source/blender/collada/ExportSettings.h (revision 47054) +++ source/blender/collada/ExportSettings.h (working copy) @@ -33,6 +33,7 @@ bool selected; bool apply_modifiers; bool include_bone_children; + bool use_object_instantiation; bool second_life; char *filepath; }; Index: source/blender/collada/GeometryExporter.cpp =================================================================== --- source/blender/collada/GeometryExporter.cpp (revision 47054) +++ source/blender/collada/GeometryExporter.cpp (working copy) @@ -92,16 +92,20 @@ DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH); #endif + bool use_instantiation = this->export_settings->use_object_instantiation; Mesh *me = get_mesh(ob, this->export_settings->apply_modifiers); - std::string geom_id = get_geometry_id(ob); - std::string geom_name = id_name(ob->data); + std::string geom_id = get_geometry_id(ob, use_instantiation); std::vector nor; std::vector norind; // Skip if linked geometry was already exported from another reference - if (exportedGeometry.find(geom_id) != exportedGeometry.end()) + if (use_instantiation && + exportedGeometry.find(geom_id) != exportedGeometry.end()) return; + + std::string geom_name = (use_instantiation) ? id_name(ob->data) : id_name(ob); + exportedGeometry.insert(geom_id); bool has_color = (bool)CustomData_has_layer(&me->fdata, CD_MCOL); Index: source/blender/collada/collada.h =================================================================== --- source/blender/collada/collada.h (revision 47054) +++ source/blender/collada/collada.h (working copy) @@ -43,6 +43,7 @@ int selected, int apply_modifiers, int include_bone_children, + int use_object_instantiation, int second_life); #ifdef __cplusplus } Index: source/blender/collada/SceneExporter.cpp =================================================================== --- source/blender/collada/SceneExporter.cpp (revision 47054) +++ source/blender/collada/SceneExporter.cpp (working copy) @@ -117,7 +117,7 @@ } else { COLLADASW::InstanceGeometry instGeom(mSW); - instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob))); + instGeom.setUrl(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, this->export_settings->use_object_instantiation))); InstanceWriter::add_material_bindings(instGeom.getBindMaterial(), ob); Index: source/blender/collada/collada.cpp =================================================================== --- source/blender/collada/collada.cpp (revision 47054) +++ source/blender/collada/collada.cpp (working copy) @@ -55,6 +55,7 @@ int selected, int apply_modifiers, int include_bone_children, + int use_object_instantiation, int second_life) { ExportSettings export_settings; @@ -63,6 +64,7 @@ export_settings.apply_modifiers = apply_modifiers != 0; export_settings.include_bone_children = include_bone_children != 0; export_settings.second_life = second_life != 0; + export_settings.use_object_instantiation = use_object_instantiation != 0; export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ Index: source/blender/makesrna/intern/rna_scene_api.c =================================================================== --- source/blender/makesrna/intern/rna_scene_api.c (revision 47054) +++ source/blender/makesrna/intern/rna_scene_api.c (working copy) @@ -91,9 +91,10 @@ int selected, int apply_modifiers, int include_bone_children, + int use_object_instantiation, int second_life) { - collada_export(scene, filepath, selected, apply_modifiers, include_bone_children, second_life); + collada_export(scene, filepath, selected, apply_modifiers, include_bone_children, use_object_instantiation, second_life); } #endif @@ -124,6 +125,7 @@ parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements"); parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)"); parm = RNA_def_boolean(func, "include_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)"); + parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instantiation", "If enabled: instantiate multiple Objects from same Data"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); RNA_def_function_ui_description(func, "Export to collada file"); #endif Index: source/blender/windowmanager/intern/wm_operators.c =================================================================== --- source/blender/windowmanager/intern/wm_operators.c (revision 47054) +++ source/blender/windowmanager/intern/wm_operators.c (working copy) @@ -2155,7 +2155,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - int selected, second_life, apply_modifiers, include_bone_children; + int selected, second_life, apply_modifiers, include_bone_children, use_object_instantiation; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2165,12 +2165,12 @@ RNA_string_get(op->ptr, "filepath", filename); /* Options panel */ - selected = RNA_boolean_get(op->ptr, "selected"); - apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); - include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); + selected = RNA_boolean_get(op->ptr, "selected"); + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); + include_bone_children = RNA_boolean_get(op->ptr, "include_bone_children"); + use_object_instantiation = RNA_boolean_get(op->ptr, "use_object_instantiation"); + second_life = RNA_boolean_get(op->ptr, "second_life"); - second_life = RNA_boolean_get(op->ptr, "second_life"); - /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ @@ -2180,6 +2180,7 @@ selected, apply_modifiers, include_bone_children, + use_object_instantiation, second_life)) { return OPERATOR_FINISHED; } @@ -2211,6 +2212,9 @@ RNA_def_boolean(ot->srna, "include_bone_children", 0, "Include Bone Children", "Include all objects attached to bones of selected Armature(s)"); + RNA_def_boolean(ot->srna, "use_object_instantiation", 1, "Use Object Instantiation", + "If enabled: instantiate multiple Objects from same Data"); + RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); }