Question about 3D model loading
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 usi开发者_如何学Cng 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?
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?
精彩评论