[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46976] trunk/blender/source/blender: Patch #31570: Implementation of 'Include bone children' Option

Gaia Clary gaia.clary at machinimatrix.org
Thu May 24 16:56:09 CEST 2012


Revision: 46976
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46976
Author:   gaiaclary
Date:     2012-05-24 14:56:09 +0000 (Thu, 24 May 2012)
Log Message:
-----------
Patch #31570: Implementation of 'Include bone children' Option

Modified Paths:
--------------
    trunk/blender/source/blender/collada/ExportSettings.h
    trunk/blender/source/blender/collada/SceneExporter.cpp
    trunk/blender/source/blender/collada/collada.cpp
    trunk/blender/source/blender/collada/collada.h
    trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: trunk/blender/source/blender/collada/ExportSettings.h
===================================================================
--- trunk/blender/source/blender/collada/ExportSettings.h	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/collada/ExportSettings.h	2012-05-24 14:56:09 UTC (rev 46976)
@@ -32,6 +32,7 @@
  public:
  bool selected;
  bool apply_modifiers;
+ bool include_bone_children;
  bool second_life;
  char *filepath;
 };

Modified: trunk/blender/source/blender/collada/SceneExporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/SceneExporter.cpp	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/collada/SceneExporter.cpp	2012-05-24 14:56:09 UTC (rev 46976)
@@ -79,25 +79,28 @@
 	bool is_skinned_mesh = arm_exporter->is_skinned_mesh(ob);
 	std::list<Object*> child_objects;
 
-	// list child objects
-	Base *b = (Base*) sce->base.first;
-	while (b) {
-		// cob - child object
-		Object *cob = b->object;
 
-		if (cob->parent == ob) {
-			switch (cob->type) {
-				case OB_MESH:
-				case OB_CAMERA:
-				case OB_LAMP:
-				case OB_EMPTY:
-				case OB_ARMATURE:
-					child_objects.push_back(cob);
-					break;
+	if (this->export_settings->include_bone_children) {
+		// list child objects
+		Base *b = (Base*) sce->base.first;
+		while (b) {
+			// cob - child object
+			Object *cob = b->object;
+
+			if (cob->parent == ob) {
+				switch (cob->type) {
+					case OB_MESH:
+					case OB_CAMERA:
+					case OB_LAMP:
+					case OB_EMPTY:
+					case OB_ARMATURE:
+						child_objects.push_back(cob);
+						break;
+				}
 			}
+
+			b = b->next;
 		}
-
-		b = b->next;
 	}
 
 

Modified: trunk/blender/source/blender/collada/collada.cpp
===================================================================
--- trunk/blender/source/blender/collada/collada.cpp	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/collada/collada.cpp	2012-05-24 14:56:09 UTC (rev 46976)
@@ -49,14 +49,21 @@
 		return 0;
 	}
 
-	int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life)
+	int collada_export(
+		Scene *sce, 
+		const char *filepath,
+		int selected,
+		int apply_modifiers,
+		int include_bone_children,
+		int second_life)
 	{
 		ExportSettings export_settings;
 		
-		export_settings.selected        = selected != 0;
-		export_settings.apply_modifiers = apply_modifiers != 0;
-		export_settings.second_life     = second_life != 0;
-		export_settings.filepath        = (char *)filepath;
+		export_settings.selected                 = selected != 0;
+		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.filepath                 = (char *)filepath;
 
 		/* annoying, collada crashes if file cant be created! [#27162] */
 		if (!BLI_exists(filepath)) {

Modified: trunk/blender/source/blender/collada/collada.h
===================================================================
--- trunk/blender/source/blender/collada/collada.h	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/collada/collada.h	2012-05-24 14:56:09 UTC (rev 46976)
@@ -37,7 +37,13 @@
 	 * both return 1 on success, 0 on error
 	 */
 	int collada_import(bContext *C, const char *filepath);
-	int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life);
+	int collada_export(
+		Scene *sce,
+		const char *filepath,
+		int selected,
+		int apply_modifiers,
+		int include_bone_children,
+		int second_life);
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/blender/source/blender/makesrna/intern/rna_scene_api.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_scene_api.c	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/makesrna/intern/rna_scene_api.c	2012-05-24 14:56:09 UTC (rev 46976)
@@ -85,9 +85,15 @@
 /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
 #include "../../collada/collada.h"
 
-static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int apply_modifiers, int second_life)
+static void rna_Scene_collada_export(
+    Scene *scene,
+	const char *filepath,
+	int selected,
+	int apply_modifiers,
+	int include_bone_children,
+	int second_life)
 {
-	collada_export(scene, filepath, selected, apply_modifiers, second_life);
+	collada_export(scene, filepath, selected, apply_modifiers, include_bone_children, second_life);
 }
 
 #endif
@@ -117,6 +123,7 @@
 	RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
 	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, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life");
 	RNA_def_function_ui_description(func, "Export to collada file");
 #endif

Modified: trunk/blender/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2012-05-24 14:55:39 UTC (rev 46975)
+++ trunk/blender/source/blender/windowmanager/intern/wm_operators.c	2012-05-24 14:56:09 UTC (rev 46976)
@@ -2155,7 +2155,7 @@
 static int wm_collada_export_exec(bContext *C, wmOperator *op)
 {
 	char filename[FILE_MAX];
-	int selected, second_life, apply_modifiers;
+	int selected, second_life, apply_modifiers, include_bone_children;
 	
 	if (!RNA_struct_property_is_set(op->ptr, "filepath")) {
 		BKE_report(op->reports, RPT_ERROR, "No filename given");
@@ -2165,14 +2165,22 @@
 	RNA_string_get(op->ptr, "filepath", filename);
 
 	/* Options panel */
-	selected        = RNA_boolean_get(op->ptr, "selected");
-	second_life     = RNA_boolean_get(op->ptr, "second_life");
-	apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers");
+	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");
+
 	/* get editmode results */
 	ED_object_exit_editmode(C, 0);  /* 0 = does not exit editmode */
 
-	if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) {
+	if (collada_export(
+		CTX_data_scene(C),
+		filename,
+		selected,
+		apply_modifiers,
+		include_bone_children,
+		second_life)) {
 		return OPERATOR_FINISHED;
 	}
 	else {
@@ -2193,10 +2201,16 @@
 	ot->flag |= OPTYPE_PRESET;
 	
 	WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY);
+
 	RNA_def_boolean(ot->srna, "selected", 0, "Selection Only",
 	                "Export only selected elements");
+
 	RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers",
 	                "Apply modifiers (Preview Resolution)");
+
+	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, "second_life", 0, "Export for Second Life",
 	                "Compatibility mode for Second Life");
 }




More information about the Bf-blender-cvs mailing list