[Bf-blender-cvs] [766d65a50b9] collada: Cleanup Collada: changed import stage names for better reading.

Gaia Clary noreply at git.blender.org
Wed Mar 28 21:30:25 CEST 2018


Commit: 766d65a50b96d156f8bb30464eacb7f2b66fd23c
Author: Gaia Clary
Date:   Sun Mar 4 18:57:49 2018 +0100
Branches: collada
https://developer.blender.org/rB766d65a50b96d156f8bb30464eacb7f2b66fd23c

Cleanup Collada: changed import stage names for better reading.

The Collada Importer processes the imported files twice. It is still
not clear to me why it needs to do that. However i renamed the
Import stages for now to clarify a bit what really happens:

General -> Fetching_Scene_data
Controller -> Fetching_Controller_data

This change makes it more clear that when the controller data is
fetched these methods are not needed. Before it was much harder
to understand what this is all about.

===================================================================

M	source/blender/collada/DocumentImporter.cpp
M	source/blender/collada/DocumentImporter.h

===================================================================

diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 08ac6e65c11..8fd498e3255 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -102,7 +102,7 @@ extern "C" {
 
 DocumentImporter::DocumentImporter(bContext *C, const ImportSettings *import_settings) :
 	import_settings(import_settings),
-	mImportStage(General),
+	mImportStage(Fetching_Scene_data),
 	mContext(C),
 	armature_importer(&unit_converter, &mesh_importer, CTX_data_scene(C), import_settings),
 	mesh_importer(&unit_converter, &armature_importer, CTX_data_scene(C)),
@@ -147,7 +147,7 @@ bool DocumentImporter::import()
 	
 	/** TODO set up scene graph and such here */
 	
-	mImportStage = Controller;
+	mImportStage = Fetching_Controller_data;
 	
 	COLLADASaxFWL::Loader loader2;
 	COLLADAFW::Root root2(&loader2, this);
@@ -179,7 +179,7 @@ void DocumentImporter::start()
 
 void DocumentImporter::finish()
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return;
 
 	Main *bmain = CTX_data_main(mContext);
@@ -703,7 +703,7 @@ finally:
  *  Return The writer should return true, if writing succeeded, false otherwise. */
 bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScene)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	// this method called on post process after writeGeometry, writeMaterial, etc.
@@ -726,7 +726,7 @@ bool DocumentImporter::writeVisualScene(const COLLADAFW::VisualScene *visualScen
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryNodes)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	Scene *sce = CTX_data_scene(mContext);
@@ -746,7 +746,7 @@ bool DocumentImporter::writeLibraryNodes(const COLLADAFW::LibraryNodes *libraryN
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	return mesh_importer.write_geometry(geom);
@@ -756,7 +756,7 @@ bool DocumentImporter::writeGeometry(const COLLADAFW::Geometry *geom)
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeMaterial(const COLLADAFW::Material *cmat)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId();
@@ -949,7 +949,7 @@ void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon *ef, Materia
 
 bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 	
 	const COLLADAFW::UniqueId& uid = effect->getUniqueId();
@@ -986,7 +986,7 @@ bool DocumentImporter::writeEffect(const COLLADAFW::Effect *effect)
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	Camera *cam = NULL;
@@ -1111,7 +1111,7 @@ bool DocumentImporter::writeCamera(const COLLADAFW::Camera *camera)
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	const std::string& imagepath = image->getImageURI().toNativePath();
@@ -1148,7 +1148,7 @@ bool DocumentImporter::writeImage(const COLLADAFW::Image *image)
  * \return The writer should return true, if writing succeeded, false otherwise.*/
 bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 
 	Lamp *lamp = NULL;
@@ -1322,7 +1322,7 @@ bool DocumentImporter::writeLight(const COLLADAFW::Light *light)
 // this function is called only for animations that pass COLLADAFW::validate
 bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	// return true;
@@ -1332,7 +1332,7 @@ bool DocumentImporter::writeAnimation(const COLLADAFW::Animation *anim)
 // called on post-process stage after writeVisualScenes
 bool DocumentImporter::writeAnimationList(const COLLADAFW::AnimationList *animationList)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	// return true;
@@ -1349,7 +1349,7 @@ bool DocumentImporter::writeSkinControllerData(const COLLADAFW::SkinControllerDa
 // this is called on postprocess, before writeVisualScenes
 bool DocumentImporter::writeController(const COLLADAFW::Controller *controller)
 {
-	if (mImportStage != General)
+	if (mImportStage == Fetching_Controller_data)
 		return true;
 		
 	return armature_importer.write_controller(controller);
diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h
index 62f76dbc022..49e5ffeafe8 100644
--- a/source/blender/collada/DocumentImporter.h
+++ b/source/blender/collada/DocumentImporter.h
@@ -59,8 +59,8 @@ class DocumentImporter : COLLADAFW::IWriter
 public:
 	//! Enumeration to denote the stage of import
 	enum ImportStage {
-		General,		//!< First pass to collect all data except controller
-		Controller,		//!< Second pass to collect controller data
+		Fetching_Scene_data, /* First pass to collect all data except controller */
+		Fetching_Controller_data, /* Second pass to collect controller data */
 	};
 	/** Constructor */
 	DocumentImporter(bContext *C, const ImportSettings *import_settings);



More information about the Bf-blender-cvs mailing list