关于3D模型加载的问题
当使用 cstdio 等库处理 3D 模型文件时,将整个文件加载到具有文件长度大小的新缓冲区中,然后对其进行处理,而不是频繁使用文件数据访问函数不是更快吗?
我的问题适用于二进制和文本模型格式,但尤其适用于第二种格式,其中读取通常是通过逐行访问文件的函数完成的(例如 Wavefront .OBJ)。
缺点/优点? 另外,我知道内存复杂性更大,还有其他负面影响吗?
When processing a 3D model file with libraries like cstdio, wouldn't it be faster to load whole file to a new buffer with a file's length size, and then process it instead of frequent using file data accessing functions ?
My question applies both to binary and text model formats, but especially to the second ones where reading is usually done with functions accessing file line by line (for example Wavefront .OBJ).
cons/pros ?
also, I'm aware of bigger memory complexity, any other negative aspects?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个负面的方面是,如果这是单线程的,则在将整个文件读入内存时,CPU 不会执行任何操作,这甚至可能会延长加载时间。
然而,无论如何,速度的增益或损失可能可以忽略不计。
同样,不是直接解决问题,而是:如果处理时间是一个大问题,您可以编写一个应用程序来处理模型并将其存储为可以进行 mmap 编辑或某种形式的顶点缓冲区的格式。
编辑:我不太确定映射此类数据的建议有多好,有人可以对此发表评论吗?
One negative aspect would be that if this is single threaded the CPU isn't doing anything while the entire file is being read into memory which could even extend loading times.
However the speed gains or losses are probably negligible in any case.
Again, not directly addressing the problem but: If processing time is a big issue you could write an application which processes the model and stores it in a format which could just be mmap ed or something into a vertex buffer of some sorts.
Edit: I'm not too sure how good advice mmapping this sort of data is, can somebody comment on this?