Revision: 33668
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33668
Author:   jesterking
Date:     2010-12-14 22:46:03 +0100 (Tue, 14 Dec 2010)

Log Message:
-----------
Apply patch [#25224] Refactor COLLADA DocumentImporter
Submitted by Martijn Berger.

Make DocumentImporter class the actual IWriter implementation and move 
prototype to the header.
Group together functions that we should move out of the class.

No functional changes.

Modified Paths:
--------------
    trunk/blender/source/blender/collada/DocumentImporter.cpp
    trunk/blender/source/blender/collada/DocumentImporter.h
    trunk/blender/source/blender/collada/collada.cpp

Modified: trunk/blender/source/blender/collada/DocumentImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/DocumentImporter.cpp   2010-12-14 
19:25:49 UTC (rev 33667)
+++ trunk/blender/source/blender/collada/DocumentImporter.cpp   2010-12-14 
21:46:03 UTC (rev 33668)
@@ -30,16 +30,9 @@
 #include <algorithm> // sort()
 
 #include "COLLADAFWRoot.h"
-#include "COLLADAFWIWriter.h"
 #include "COLLADAFWStableHeaders.h"
-#include "COLLADAFWCamera.h"
 #include "COLLADAFWColorOrTexture.h"
-#include "COLLADAFWEffect.h"
-#include "COLLADAFWImage.h"
 #include "COLLADAFWIndexList.h"
-#include "COLLADAFWInstanceGeometry.h"
-#include "COLLADAFWLight.h"
-#include "COLLADAFWMaterial.h"
 #include "COLLADAFWMeshPrimitiveWithFaceVertexCount.h"
 #include "COLLADAFWPolygons.h"
 #include "COLLADAFWSampler.h"
@@ -47,6 +40,8 @@
 #include "COLLADAFWVisualScene.h"
 #include "COLLADAFWArrayPrimitiveType.h"
 #include "COLLADAFWLibraryNodes.h"
+#include "COLLADAFWCamera.h"
+#include "COLLADAFWLight.h"
 
 #include "COLLADASaxFWLLoader.h"
 
@@ -58,7 +53,6 @@
 #include "BLI_path_util.h"
 #include "BKE_scene.h"
 #include "BKE_global.h"
-#include "BKE_object.h"
 #include "BKE_material.h"
 #include "BKE_utildefines.h"
 #include "BKE_image.h"
@@ -77,10 +71,6 @@
 #include "DocumentImporter.h"
 #include "collada_internal.h"
 
-#include "TransformReader.h"
-#include "AnimationImporter.h"
-#include "ArmatureImporter.h"
-#include "MeshImporter.h"
 #include "collada_utils.h"
 
 
@@ -95,8 +85,7 @@
 
 /** Class that needs to be implemented by a writer. 
        IMPORTANT: The write functions are called in arbitrary order.*/
-class Writer: public COLLADAFW::IWriter
-{
+/*
 private:
        std::string mFilename;
        
@@ -118,25 +107,27 @@
        std::vector<const COLLADAFW::VisualScene*> vscenes;
        std::vector<Object*> libnode_ob;
 
-       std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; // find root 
joint by child joint uid, for bone tree evaluation during resampling
+       std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> root_map; 
+       */
+       // find root joint by child joint uid, for bone tree evaluation during 
resampling
 
        // animation
        // std::map<COLLADAFW::UniqueId, std::vector<FCurve*> > uid_fcurve_map;
        // Nodes don't share AnimationLists (Arystan)
        // std::map<COLLADAFW::UniqueId, Animation> uid_animated_map; // 
AnimationList->uniqueId to AnimatedObject map
 
-public:
+//public:
 
        /** Constructor. */
-       Writer(bContext *C, const char *filename) : mFilename(filename), 
mContext(C),
+       DocumentImporter::DocumentImporter(bContext *C, const char *filename) : 
mFilename(filename), mContext(C),
                                                                                
                armature_importer(&unit_converter, &mesh_importer, 
&anim_importer, CTX_data_scene(C)),
                                                                                
                mesh_importer(&unit_converter, &armature_importer, 
CTX_data_scene(C)),
                                                                                
                anim_importer(&unit_converter, &armature_importer, 
CTX_data_scene(C)) {}
 
        /** Destructor. */
-       ~Writer() {}
+       DocumentImporter::~DocumentImporter() {}
 
-       bool write()
+       bool DocumentImporter::import()
        {
                COLLADASaxFWL::Loader loader;
                COLLADAFW::Root root(&loader, this);
@@ -147,12 +138,8 @@
 
                return true;
        }
-
-       /** This method will be called if an error in the loading process 
occurred and the loader cannot
-               continue to load. The writer should undo all operations that 
have been performed.
-               @param errorMessage A message containing informations about the 
error that occurred.
-       */
-       virtual void cancel(const COLLADAFW::String& errorMessage)
+       
+       void DocumentImporter::cancel(const COLLADAFW::String& errorMessage)
        {
                // TODO: if possible show error info
                //
@@ -162,13 +149,10 @@
                // The latter sounds better.
        }
 
-       /** This is the method called. The writer hast to prepare to receive 
data.*/
-       virtual void start()
-       {
-       }
+       void DocumentImporter::start(){}
 
        /** This method is called after the last write* method. No other 
methods will be called after this.*/
-       virtual void finish()
+       void DocumentImporter::finish()
        {
                std::vector<const COLLADAFW::VisualScene*>::iterator it;
                for (it = vscenes.begin(); it != vscenes.end(); it++) {
@@ -213,7 +197,7 @@
                        const COLLADAFW::NodePointerArray& roots = 
(*it)->getRootNodes();
 
                        for (unsigned int i = 0; i < roots.getCount(); i++)
-                               translate_anim_recursive(roots[i]);
+                               translate_anim_recursive(roots[i],NULL,NULL);
                }
 
                if (libnode_ob.size()) {
@@ -242,7 +226,7 @@
        }
 
 
-       void translate_anim_recursive(COLLADAFW::Node *node, COLLADAFW::Node 
*par = NULL, Object *parob = NULL)
+       void DocumentImporter::translate_anim_recursive(COLLADAFW::Node *node, 
COLLADAFW::Node *par = NULL, Object *parob = NULL)
        {
                if (par && par->getType() == COLLADAFW::Node::JOINT) {
                        // par is root if there's no corresp. key in root_map
@@ -273,7 +257,7 @@
 
        /** When this method is called, the writer must write the global 
document asset.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeGlobalAsset ( const COLLADAFW::FileInfo* asset ) 
+       bool DocumentImporter::writeGlobalAsset ( const COLLADAFW::FileInfo* 
asset ) 
        {
                unit_converter.read_asset(asset);
 
@@ -282,12 +266,12 @@
 
        /** When this method is called, the writer must write the scene.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeScene ( const COLLADAFW::Scene* scene ) 
+       bool DocumentImporter::writeScene ( const COLLADAFW::Scene* scene ) 
        {
                // XXX could store the scene id, but do nothing for now
                return true;
        }
-       Object *create_camera_object(COLLADAFW::InstanceCamera *camera, Scene 
*sce)
+       Object* 
DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene 
*sce)
        {
                const COLLADAFW::UniqueId& cam_uid = 
camera->getInstanciatedObjectId();
                if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {     
@@ -304,7 +288,7 @@
                return ob;
        }
        
-       Object *create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce)
+       Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight 
*lamp, Scene *sce)
        {
                const COLLADAFW::UniqueId& lamp_uid = 
lamp->getInstanciatedObjectId();
                if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) {        
@@ -321,7 +305,7 @@
                return ob;
        }
 
-       Object *create_instance_node(Object *source_ob, COLLADAFW::Node 
*source_node, COLLADAFW::Node *instance_node, Scene *sce, bool is_library_node)
+       Object* DocumentImporter::create_instance_node(Object *source_ob, 
COLLADAFW::Node *source_node, COLLADAFW::Node *instance_node, Scene *sce, bool 
is_library_node)
        {
                Object *obn = copy_object(source_ob);
                obn->recalc |= OB_RECALC_ALL;
@@ -361,7 +345,7 @@
                return obn;
        }
        
-       void write_node (COLLADAFW::Node *node, COLLADAFW::Node *parent_node, 
Scene *sce, Object *par, bool is_library_node)
+       void DocumentImporter::write_node (COLLADAFW::Node *node, 
COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node)
        {
                Object *ob = NULL;
                bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
@@ -452,7 +436,7 @@
 
        /** When this method is called, the writer must write the entire visual 
scene.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeVisualScene ( const COLLADAFW::VisualScene* 
visualScene ) 
+       bool DocumentImporter::writeVisualScene ( const COLLADAFW::VisualScene* 
visualScene ) 
        {
                // this method called on post process after writeGeometry, 
writeMaterial, etc.
 
@@ -472,7 +456,7 @@
        /** When this method is called, the writer must handle all nodes 
contained in the 
                library nodes.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeLibraryNodes ( const COLLADAFW::LibraryNodes* 
libraryNodes ) 
+       bool DocumentImporter::writeLibraryNodes ( const 
COLLADAFW::LibraryNodes* libraryNodes ) 
        {
                Scene *sce = CTX_data_scene(mContext);
 
@@ -487,14 +471,14 @@
 
        /** When this method is called, the writer must write the geometry.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeGeometry ( const COLLADAFW::Geometry* geom ) 
+       bool DocumentImporter::writeGeometry ( const COLLADAFW::Geometry* geom 
) 
        {
                return mesh_importer.write_geometry(geom);
        }
 
        /** When this method is called, the writer must write the material.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeMaterial( const COLLADAFW::Material* cmat ) 
+       bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) 
        {
                const std::string& str_mat_id = cmat->getOriginalId();
                Material *ma = add_material((char*)str_mat_id.c_str());
@@ -506,7 +490,7 @@
        }
        
        // create mtex, create texture, set texture image
-       MTex *create_texture(COLLADAFW::EffectCommon *ef, COLLADAFW::Texture 
&ctex, Material *ma,
+       MTex* DocumentImporter::create_texture(COLLADAFW::EffectCommon *ef, 
COLLADAFW::Texture &ctex, Material *ma,
                                                 int i, TexIndexTextureArrayMap 
&texindex_texarray_map)
        {
                COLLADAFW::SamplerPointerArray& samp_array = 
ef->getSamplerPointerArray();
@@ -531,7 +515,7 @@
                return ma->mtex[i];
        }
        
-       void write_profile_COMMON(COLLADAFW::EffectCommon *ef, Material *ma)
+       void DocumentImporter::write_profile_COMMON(COLLADAFW::EffectCommon 
*ef, Material *ma)
        {
                COLLADAFW::EffectCommon::ShaderType shader = 
ef->getShaderType();
                
@@ -668,7 +652,7 @@
        /** When this method is called, the writer must write the effect.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
        
-       virtual bool writeEffect( const COLLADAFW::Effect* effect ) 
+       bool DocumentImporter::writeEffect( const COLLADAFW::Effect* effect ) 
        {
                
                const COLLADAFW::UniqueId& uid = effect->getUniqueId();
@@ -695,7 +679,7 @@
        
        /** When this method is called, the writer must write the camera.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeCamera( const COLLADAFW::Camera* camera ) 
+       bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) 
        {
                Camera *cam = NULL;
                std::string cam_id, cam_name;
@@ -807,7 +791,7 @@
 
        /** When this method is called, the writer must write the image.
                @return The writer should return true, if writing succeeded, 
false otherwise.*/
-       virtual bool writeImage( const COLLADAFW::Image* image ) 
+       bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) 
        {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to