Selaa lähdekoodia

Refactorings: come code cleanups

Kim Kulling 1 vuosi sitten
vanhempi
commit
636fbd65b3
3 muutettua tiedostoa jossa 26 lisäystä ja 50 poistoa
  1. 3 11
      code/Pbrt/PbrtExporter.cpp
  2. 21 31
      code/Pbrt/PbrtExporter.h
  3. 2 8
      include/assimp/IOSystem.hpp

+ 3 - 11
code/Pbrt/PbrtExporter.cpp

@@ -89,15 +89,11 @@ using namespace Assimp;
 
 namespace Assimp {
 
-void ExportScenePbrt (
-    const char* pFile,
-    IOSystem* pIOSystem,
-    const aiScene* pScene,
-    const ExportProperties* /*pProperties*/
-){
+void ExportScenePbrt(const char *pFile, IOSystem *pIOSystem, const aiScene *pScene,
+        const ExportProperties *) {
     std::string path = DefaultIOSystem::absolutePath(std::string(pFile));
     std::string file = DefaultIOSystem::completeBaseName(std::string(pFile));
-    path = path + file + ".brt";
+    path = path + file + ".pbrt";
     // initialize the exporter
     PbrtExporter exporter(pScene, pIOSystem, path, file);
 }
@@ -114,7 +110,6 @@ static void create_embedded_textures_folder(const aiScene *scene, IOSystem *pIOS
     }
 }
 
-// Constructor
 PbrtExporter::PbrtExporter(
         const aiScene *pScene, IOSystem *pIOSystem,
         const std::string &path, const std::string &file) :
@@ -186,9 +181,6 @@ PbrtExporter::PbrtExporter(
     outfile->Write(mOutput.str().c_str(), mOutput.str().length(), 1);
 }
 
-// Destructor
-PbrtExporter::~PbrtExporter() = default;
-
 void PbrtExporter::WriteMetaData() {
     mOutput << "#############################\n";
     mOutput << "# Scene metadata:\n";

+ 21 - 31
code/Pbrt/PbrtExporter.h

@@ -70,15 +70,33 @@ class ExportProperties;
 // ---------------------------------------------------------------------
 /** Helper class to export a given scene to a Pbrt file. */
 // ---------------------------------------------------------------------
-class PbrtExporter
-{
+class PbrtExporter {
 public:
     /// Constructor for a specific scene to export
     PbrtExporter(const aiScene *pScene, IOSystem *pIOSystem,
             const std::string &path, const std::string &file);
 
     /// Destructor
-    virtual ~PbrtExporter();
+    virtual ~PbrtExporter() = default;
+
+private:
+    aiMatrix4x4 GetNodeTransform(const aiString &name) const;
+    static std::string TransformAsString(const aiMatrix4x4 &m);
+    static std::string RemoveSuffix(std::string filename);
+    std::string CleanTextureFilename(const aiString &f, bool rewriteExtension = true) const;
+    void WriteMetaData();
+    void WriteWorldDefinition();
+    void WriteCameras();
+    void WriteCamera(int i);
+    void WriteLights();
+    void WriteTextures();
+    static bool TextureHasAlphaMask(const std::string &filename);
+    void WriteMaterials();
+    void WriteMaterial(int i);
+    void WriteMesh(aiMesh *mesh);
+    void WriteInstanceDefinition(int i);
+    void WriteGeometricObjects(aiNode *node, aiMatrix4x4 parentTransform,
+            std::map<int, int> &meshUses);
 
 private:
     // the scene to export
@@ -96,39 +114,11 @@ private:
     /// Name of the file (without extension) where the scene will be exported
     const std::string mFile;
 
-private:
     //  A private set to keep track of which textures have been declared
     std::set<std::string> mTextureSet;
 
     // Transform to apply to the root node and all root objects such as cameras, lights, etc.
     aiMatrix4x4 mRootTransform;
-
-    aiMatrix4x4 GetNodeTransform(const aiString& name) const;
-    static std::string TransformAsString(const aiMatrix4x4& m);
-
-    static std::string RemoveSuffix(std::string filename);
-    std::string CleanTextureFilename(const aiString &f, bool rewriteExtension = true) const;
-
-    void WriteMetaData();
-
-    void WriteWorldDefinition();
-
-    void WriteCameras();
-    void WriteCamera(int i);
-
-    void WriteLights();
-
-    void WriteTextures();
-    static bool TextureHasAlphaMask(const std::string &filename);
-
-    void WriteMaterials();
-    void WriteMaterial(int i);
-
-    void WriteMesh(aiMesh* mesh);
-
-    void WriteInstanceDefinition(int i);
-    void WriteGeometricObjects(aiNode* node, aiMatrix4x4 parentTransform,
-                               std::map<int, int> &meshUses);
 };
 
 } // namespace Assimp

+ 2 - 8
include/assimp/IOSystem.hpp

@@ -97,7 +97,7 @@ public:
      *  Create an instance of your derived class and assign it to an
      *  #Assimp::Importer instance by calling Importer::SetIOHandler().
      */
-    IOSystem() AI_NO_EXCEPT;
+    IOSystem() AI_NO_EXCEPT = default;
 
     // -------------------------------------------------------------------
     /** @brief Virtual destructor.
@@ -105,7 +105,7 @@ public:
      *  It is safe to be called from within DLL Assimp, we're constructed
      *  on Assimp's heap.
      */
-    virtual ~IOSystem();
+    virtual ~IOSystem() = default;
 
     // -------------------------------------------------------------------
     /** @brief For backward compatibility
@@ -236,12 +236,6 @@ private:
     std::vector<std::string> m_pathStack;
 };
 
-// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::IOSystem() AI_NO_EXCEPT = default;
-
-// ----------------------------------------------------------------------------
-AI_FORCE_INLINE IOSystem::~IOSystem() = default;
-
 // ----------------------------------------------------------------------------
 // For compatibility, the interface of some functions taking a std::string was
 // changed to const char* to avoid crashes between binary incompatible STL