[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50026] branches/soc-2012-bratwurst/source /blender/collada: Code cleanup

Sukhitha Jayathilake pr.jayathilake at gmail.com
Sun Aug 19 20:36:03 CEST 2012


Revision: 50026
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50026
Author:   phabtar
Date:     2012-08-19 18:36:02 +0000 (Sun, 19 Aug 2012)
Log Message:
-----------
Code cleanup

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/ArmatureExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.h
    branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.h
    branches/soc-2012-bratwurst/source/blender/collada/DocumentImporter.cpp

Modified: branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp	2012-08-19 18:36:02 UTC (rev 50026)
@@ -242,13 +242,6 @@
 
 }
 
-//from Bake animation script 
-void AnimationExporter::getBakedPoseData(Object *obarm, int startFrame, int endFrame, bool ActionBake = false, bool ActionBakeFirstFrame = true)
-{
-	
-		
-}
-
 //Get proper name for bones
 std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu)
 {
@@ -973,8 +966,6 @@
 			calc_ob_mat_at_time(ob, ctime, mat);
 		}
 		
-		//BIK_release_tree(scene, ob, ctime);
-
 		UnitConverter converter;
 
 		double outmat[4][4];

Modified: branches/soc-2012-bratwurst/source/blender/collada/ArmatureExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ArmatureExporter.cpp	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/ArmatureExporter.cpp	2012-08-19 18:36:02 UTC (rev 50026)
@@ -111,24 +111,10 @@
 	return true;
 }
 
-//void ArmatureExporter::export_controllers(Scene *sce)
-//{
-//	scene = sce;
-//
-//	openLibrary();
-//
-//	GeometryFunctor gf;
-//	gf.forEachMeshObjectInExportSet<ArmatureExporter>(sce, *this, this->export_settings->export_set);
-//
-//	closeLibrary();
-//}
-
 void ArmatureExporter::operator()(Object *ob)
 {
 	Object *ob_arm = bc_get_assigned_armature(ob);
 
-	//if (ob_arm /*&& !already_written(ob_arm)*/);
-//		export_controller(ob, ob_arm);
 }
 #if 0
 
@@ -279,9 +265,9 @@
 
 	}
 	else {
-		//pose mat is object space
-		//copy_m4_m4(mat, pchan->pose_mat);
 		
+		//copy_m4_m4(mat, pchan->pose_mat);
+		//pose mat is object space
 		//New change: export bone->arm_mat
 		copy_m4_m4(mat, bone->arm_mat);
 	}

Modified: branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp	2012-08-19 18:36:02 UTC (rev 50026)
@@ -93,8 +93,7 @@
 
 	float mat[4][4];
 	float obmat[4][4];
-	float bonemat[3][3];
-
+	
 	// TODO rename from Node "name" attrs later
 	EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
 	totbone++;
@@ -118,7 +117,6 @@
 
 	if (parent) bone->parent = parent;
 
-	////mult_m4_m4m4(mat, ob_arm->obmat , mat);
 	float loc[3], size[3], rot[3][3]; 
 	float angle;
 	float vec[3] = {0.0f, 0.5f, 0.0f};
@@ -211,9 +209,7 @@
 		float vec[3] = {0.0f, 0.0f, 0.1f};
 		
 		sub_v3_v3v3(vec, leaf.bone->tail , leaf.bone->head);
-		
 		mul_v3_fl(vec, leaf_bone_length);
-
 		add_v3_v3v3(leaf.bone->tail, leaf.bone->head , vec);
 
 		}
@@ -338,7 +334,6 @@
 		fix_leaf_bones();
 
 		// exit armature edit mode
-	
 		unskinned_armature_map[(*ri)->getUniqueId()] = ob_arm;
 
 		ED_armature_from_edit(ob_arm);
@@ -434,7 +429,6 @@
 	totbone = 0;
 	// bone_direction_row = 1; // TODO: don't default to Y but use asset and based on it decide on default row
 	leaf_bone_length = FLT_MAX;
-	// min_angle = 360.0f;		// minimum angle between bone head-tail and a row of bone matrix
 
 	// create bones
 	/*
@@ -464,22 +458,14 @@
 	ED_armature_edit_free(ob_arm);
 	DAG_id_tag_update(&ob_arm->id, OB_RECALC_OB | OB_RECALC_DATA);
 
-	// set_leaf_bone_shapes(ob_arm);
-	// set_euler_rotmode();
 }
 
-
-// root - if this joint is the top joint in hierarchy, if a joint
-// is a child of a node (not joint), root should be true since
-// this is where we build armature bones from
-
 void ArmatureImporter::set_pose(Object *ob_arm,  COLLADAFW::Node *root_node, const char *parentname, float parent_mat[][4])
 { 
 	char *bone_name = (char *) bc_get_joint_name(root_node);
 	float mat[4][4];
 	float obmat[4][4];
 
-	float ax[3];
 	float angle = 0.0f;
 	
 	// object-space
@@ -517,6 +503,10 @@
 
 }
 
+
+// root - if this joint is the top joint in hierarchy, if a joint
+// is a child of a node (not joint), root should be true since
+// this is where we build armature bones from
 void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce)
 {
 	joint_by_uid[node->getUniqueId()] = node;
@@ -632,7 +622,6 @@
 bool ArmatureImporter::write_controller(const COLLADAFW::Controller *controller)
 {
 	// - create and store armature object
-
 	const COLLADAFW::UniqueId& con_id = controller->getUniqueId();
 
 	if (controller->getControllerType() == COLLADAFW::Controller::CONTROLLER_TYPE_SKIN) {
@@ -653,8 +642,8 @@
 		COLLADAFW::MorphController *co = (COLLADAFW::MorphController *)controller;
 		// to be able to find geom id by controller id
 		geom_uid_by_controller_uid[con_id] = co->getSource();
+		//Shape keys are applied in DocumentImporter->finish()
 		morph_controllers.push_back(co);
-//		fprintf(stderr, "Morph controller is not supported yet.\n");
 	}
 
 	return true;
@@ -662,33 +651,40 @@
 
 void ArmatureImporter::make_shape_keys(){
 	std::vector<COLLADAFW::MorphController *>::iterator mc;
-
+	float weight;
+        
 	for (mc = morph_controllers.begin(); mc != morph_controllers.end(); mc++) {
+		//Controller data
 		COLLADAFW::UniqueIdArray& morphTargetIds = (*mc)->getMorphTargets();
 		COLLADAFW::FloatOrDoubleArray& morphWeights = (*mc)->getMorphWeights();
         
 		//Prereq: all the geometries must be imported and mesh objects must be made
 		Object *source_ob = this->mesh_importer->get_object_by_geom_uid((*mc)->getSource());
+		
 		Mesh *source_me = (Mesh*) source_ob->data;
-		float weight;
-        Key *key = source_me->key = add_key((ID *)source_me);
+		//insert key to source mesh
+		Key *key = source_me->key = add_key((ID *)source_me);
 		key->type = KEY_RELATIVE;
 		KeyBlock *kb;
+		
+		//insert basis key
 		kb = add_keyblock_ctime(key, "Basis", FALSE);
 		mesh_to_key(source_me, kb);
+
+		//insert other shape keys
 		for ( int i = 0 ; i < morphTargetIds.getCount() ; i++ ){
 			//better to have a seperate map of morph objects, 
 			//This'll do for now since only mesh morphing is imported
 			Mesh *me = this->mesh_importer->get_mesh_by_geom_uid(morphTargetIds[i]);
+			
 			if(me){
 				me->key = key;
 				kb = add_keyblock_ctime(key, me->id.name, FALSE);
 				mesh_to_key(me, kb);
+				
+				//apply weights
 				weight =  morphWeights.getFloatValues()->getData()[i];
 				kb->curval = weight;
-				
-				//free object since it is added as shape key
-				//BKE_object_free(ob);
 			}
 			else 
 				fprintf(stderr, "Morph target geometry not found.\n");

Modified: branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.h	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.h	2012-08-19 18:36:02 UTC (rev 50026)
@@ -141,9 +141,6 @@
 	ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, AnimationImporterBase *anim, Scene *sce);
 	~ArmatureImporter();
 
-	// root - if this joint is the top joint in hierarchy, if a joint
-	// is a child of a node (not joint), root should be true since
-	// this is where we build armature bones from
 	void add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce);
 
 #if 0

Modified: branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp	2012-08-19 18:36:02 UTC (rev 50026)
@@ -120,7 +120,7 @@
 	Object *ob_arm = bc_get_assigned_armature(ob);
 	Key *key = ob_get_key(ob);
 
-	if (ob_arm /*&& !already_written(ob_arm)*/)
+	if (ob_arm)
 		export_skin_controller(ob, ob_arm);
 	if(key){
 		export_morph_controller(ob, key);
@@ -200,12 +200,11 @@
 	bool use_instantiation = this->export_settings->use_object_instantiation;
 	Mesh *me;
 
-	if (this->export_settings->apply_modifiers) {
+	if (this->export_settings->apply_modifiers) 
 		me = bc_to_mesh_apply_modifiers(scene, ob, this->export_settings->export_mesh_type);
-	} 
-	else {
+	else 
 		me = (Mesh *)ob->data;
-	}
+	
 	BKE_mesh_tessface_ensure(me);
 
 	if (!me->dvert) return;
@@ -298,8 +297,6 @@
 	}
 	BKE_mesh_tessface_ensure(me);
 
-	//if (!me->dvert) return;
-
 	std::string controller_name = id_name(ob) + "-morph";
 	std::string controller_id = get_controller_id(key, ob);
 
@@ -324,7 +321,8 @@
 		BKE_libblock_free_us(&(G.main->mesh), me);
 	}
     
-	// can also try the base element and param alternative
+	//support for animations
+	//can also try the base element and param alternative
 	add_weight_extras(key);
 	closeMorph();
 	closeController();
@@ -346,7 +344,7 @@
 	source.prepareToAppendValues();
 
 	KeyBlock * kb = (KeyBlock*)key->block.first;
-		//skip the basis
+	//skip the basis
 	kb = kb->next;
 	for (; kb; kb = kb->next) {
 		std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(kb->name);
@@ -375,7 +373,7 @@
 	source.prepareToAppendValues();
 
 	KeyBlock * kb = (KeyBlock*)key->block.first;
-		//skip the basis
+	//skip the basis
 	kb = kb->next;
 	for (; kb; kb = kb->next) {
 		float weight = kb->curval;
@@ -392,7 +390,7 @@
 	COLLADASW::BaseExtraTechnique extra;
 	
 	KeyBlock * kb = (KeyBlock*)key->block.first;
-		//skip the basis
+	//skip the basis
 	kb = kb->next;
 	for (; kb; kb = kb->next) {
 		float weight = kb->curval;

Modified: branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.h	2012-08-19 17:13:45 UTC (rev 50025)
+++ branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.h	2012-08-19 18:36:02 UTC (rev 50026)
@@ -55,9 +55,6 @@
 
 class SceneExporter;
 
-// XXX exporter writes wrong data for shared armatures.  A separate
-// controller should be written for each armature-mesh binding how do
-// we make controller ids then?
 class ControllerExporter : public COLLADASW::LibraryControllers, protected TransformWriter, protected InstanceWriter
 {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list