Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2012-05-27 02:46:28 +0400
committerGaia Clary <gaia.clary@machinimatrix.org>2012-05-27 02:46:28 +0400
commit822362189badefd6c0014f608d36d98e8ab57282 (patch)
tree3f1a8a574aa311b11bbefe5f4191149e659a9f7f /source/blender
parent54b64cfd612922054f014460f1c08ec4b0374a3d (diff)
[#31607] Collada: (Exporter) Implementation of 'use Object Instantiation' Option
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/collada/ArmatureExporter.cpp3
-rw-r--r--source/blender/collada/ExportSettings.h1
-rw-r--r--source/blender/collada/GeometryExporter.cpp10
-rw-r--r--source/blender/collada/SceneExporter.cpp2
-rw-r--r--source/blender/collada/collada.cpp2
-rw-r--r--source/blender/collada/collada.h1
-rw-r--r--source/blender/collada/collada_internal.cpp7
-rw-r--r--source/blender/collada/collada_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_scene_api.c4
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c16
10 files changed, 35 insertions, 13 deletions
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 38a5e9b5df4..9d59be39f33 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -324,6 +324,7 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
} MDeformWeight;
*/
+ bool use_instantiation = this->export_settings->use_object_instantiation;
Mesh *me = (Mesh*)ob->data;
if (!me->dvert) return;
@@ -331,7 +332,7 @@ void ArmatureExporter::export_controller(Object* ob, Object *ob_arm)
std::string controller_id = get_controller_id(ob_arm, ob);
openSkin(controller_id, controller_name,
- COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob)));
+ COLLADABU::URI(COLLADABU::Utils::EMPTY_STRING, get_geometry_id(ob, use_instantiation)));
add_bind_shape_mat(ob);
diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h
index b875282ac33..f0d3f810831 100644
--- a/source/blender/collada/ExportSettings.h
+++ b/source/blender/collada/ExportSettings.h
@@ -33,6 +33,7 @@ struct ExportSettings
bool selected;
bool apply_modifiers;
bool include_bone_children;
+ bool use_object_instantiation;
bool second_life;
char *filepath;
};
diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp
index f92ee1a2b79..6df16165e4b 100644
--- a/source/blender/collada/GeometryExporter.cpp
+++ b/source/blender/collada/GeometryExporter.cpp
@@ -92,16 +92,20 @@ void GeometryExporter::operator()(Object *ob)
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<Normal> nor;
std::vector<Face> 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);
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index f79ae2b52a9..83ac496db0e 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -117,7 +117,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
}
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);
diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp
index c947144412a..951fecec049 100644
--- a/source/blender/collada/collada.cpp
+++ b/source/blender/collada/collada.cpp
@@ -55,6 +55,7 @@ extern "C"
int selected,
int apply_modifiers,
int include_bone_children,
+ int use_object_instantiation,
int second_life)
{
ExportSettings export_settings;
@@ -63,6 +64,7 @@ extern "C"
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] */
diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h
index d5c26bb402c..67aaf1ff6c7 100644
--- a/source/blender/collada/collada.h
+++ b/source/blender/collada/collada.h
@@ -43,6 +43,7 @@ extern "C" {
int selected,
int apply_modifiers,
int include_bone_children,
+ int use_object_instantiation,
int second_life);
#ifdef __cplusplus
}
diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp
index fa99d460184..81e5f88a3f8 100644
--- a/source/blender/collada/collada_internal.cpp
+++ b/source/blender/collada/collada_internal.cpp
@@ -251,6 +251,13 @@ std::string get_geometry_id(Object *ob)
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";
diff --git a/source/blender/collada/collada_internal.h b/source/blender/collada/collada_internal.h
index 4f555acb882..d00af791a1f 100644
--- a/source/blender/collada/collada_internal.h
+++ b/source/blender/collada/collada_internal.h
@@ -86,7 +86,7 @@ extern std::string translate_id(const std::string &id);
extern std::string id_name(void *id);
-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);
diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c
index 439335e69b4..09e0428058a 100644
--- a/source/blender/makesrna/intern/rna_scene_api.c
+++ b/source/blender/makesrna/intern/rna_scene_api.c
@@ -91,9 +91,10 @@ static void rna_Scene_collada_export(
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 @@ void RNA_api_scene(StructRNA *srna)
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", "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
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 05af3c04573..8ce882e887e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -2155,7 +2155,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED
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,11 +2165,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
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");
-
- second_life = RNA_boolean_get(op->ptr, "second_life");
+ 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");
/* get editmode results */
ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */
@@ -2180,6 +2180,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
selected,
apply_modifiers,
include_bone_children,
+ use_object_instantiation,
second_life)) {
return OPERATOR_FINISHED;
}
@@ -2211,6 +2212,9 @@ static void WM_OT_collada_export(wmOperatorType *ot)
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",
+ "Instantiate multiple Objects from same Data");
+
RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life",
"Compatibility mode for Second Life");
}