简体   繁体   English

Assimp查看器在同一个.obj模型文件上比Assimp C ++导入器快得多

[英]Assimp viewer is much faster then Assimp C++ importer on the same .obj model file

The assimp library provides a nice way to load 3D .obj models from file. assimp库提供了一种从文件加载3D .obj模型的好方法。 However I found out that the assimp_viewer.exe that comes with it (I use version 3.1.1) is much faster in importing my .obj file (42Mb, already simplified) then my C++ code that loads the same model. 但是我发现它附带的assimp_viewer.exe(我使用的是3.1.1版)在导入我的.obj文件(42Mb,已经简化)和加载相同模型的C ++代码时要快得多。 The viewer loads the file in a couple of seconds whereas my C++ program (MSVS 2013/Win64/Release) takes 154 seconds to do that. 查看器在几秒钟内加载文件,而我的C ++程序(MSVS 2013 / Win64 / Release)需要154秒才能完成。 I experimented with the importer post processing flags both in the viewer and C++ but I cannot bridge the gap between the two. 我在查看器和C ++中尝试了导入器后处理标志,但我无法弥合两者之间的差距。

Any thoughts on the cause? 有关事业的任何想法? Here is my C++ code: 这是我的C ++代码:

#include <ctime>
#include <iostream>
#include <fstream>
#include <vector>

#include "assimp/Importer.hpp"
#include "assimp/scene.h"
#include "assimp/postprocess.h"
#include "assimp/progresshandler.hpp"

using namespace std;

int main(int argc, char* argv[])
{
    Assimp::Importer importer;
    unsigned int post_processing_flags = aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_JoinIdenticalVertices |
            aiProcess_OptimizeMeshes | aiProcess_OptimizeGraph | aiProcess_ImproveCacheLocality;

    cout << "starting load: ";

    auto begin = clock();
    auto scene = importer.ReadFile( "MODEL.obj", post_processing_flags);
    auto end = clock();

    cout << "done!\n";

    double seconds = (end - begin) / CLOCKS_PER_SEC;

    cout << "loading took " << seconds << " seconds" << endl;

    return 0;
}

Found my own answer: I run it in Visual Studio but start it -with- the debugger in Release mode (F5). 找到了我自己的答案:我在Visual Studio中运行它但是在发布模式(F5)下启动它 - 调试器。 When I start it without debugging (CTRL+F5) it takes now 1 second to load the model as the assimp viewer does. 当我在没有调试的情况下启动它(CTRL + F5)时,现在需要1秒来加载模型,就像assimp查看器一样。 The same applies if you run the executable from outside visual studio using the file explorer or command line. 如果使用文件资源管理器或命令行从Visual Studio外部运行可执行文件,则同样适用。 Still a huge difference between with and without debugging. 有没有调试之间仍然存在巨大差异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM