guybrush77 / rapidobj

A fast, header-only, C++17 library for parsing Wavefront .obj files.
MIT License
178 stars 16 forks source link

Add some progress/callback for file loading #27

Open P1nkL1on opened 5 months ago

P1nkL1on commented 5 months ago

Just asking about some progress callback API. It would be convenient to pass something like OpenImage::ProgressCallback onto the rapidobj::ParseFile. E.x.

/// Pointer to a function called periodically by ParseFile.
/// It returns a bool, which if 'true' will STOP the read.
typedef bool (*ProgressCallback)(float portion_done);

inline Result ParseFile(
    const std::filesystem::path& obj_filepath,
    const MaterialLibrary&       mtl_library = MaterialLibrary::Default(),
    const ProgressCallback&      progress_callback = nullptr);

As shown, it also can be used to terminate the reading, returning an error probably. It's a QoL for loading large files / using slow PC.