rapidobj icon indicating copy to clipboard operation
rapidobj copied to clipboard

Add some progress/callback for file loading

Open P1nkL1on opened this issue 1 year ago • 0 comments

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.

P1nkL1on avatar Jun 04 '24 06:06 P1nkL1on