MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / LoadObjWithCallback

Function LoadObjWithCallback

engine/3rdparty/tinyobjloader/tiny_obj_loader.h:2989–3271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2987}
2988
2989bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
2990 void *user_data /*= NULL*/,
2991 MaterialReader *readMatFn /*= NULL*/,
2992 std::string *warn, /* = NULL*/
2993 std::string *err /*= NULL*/) {
2994 std::stringstream errss;
2995
2996 // material
2997 std::map<std::string, int> material_map;
2998 int material_id = -1; // -1 = invalid
2999
3000 std::vector<index_t> indices;
3001 std::vector<material_t> materials;
3002 std::vector<std::string> names;
3003 names.reserve(2);
3004 std::vector<const char *> names_out;
3005
3006 std::string linebuf;
3007 while (inStream.peek() != -1) {
3008 safeGetline(inStream, linebuf);
3009
3010 // Trim newline '\r\n' or '\n'
3011 if (linebuf.size() > 0) {
3012 if (linebuf[linebuf.size() - 1] == '\n')
3013 linebuf.erase(linebuf.size() - 1);
3014 }
3015 if (linebuf.size() > 0) {
3016 if (linebuf[linebuf.size() - 1] == '\r')
3017 linebuf.erase(linebuf.size() - 1);
3018 }
3019
3020 // Skip if empty line.
3021 if (linebuf.empty()) {
3022 continue;
3023 }
3024
3025 // Skip leading space.
3026 const char *token = linebuf.c_str();
3027 token += strspn(token, " \t");
3028
3029 assert(token);
3030 if (token[0] == '\0') continue; // empty line
3031
3032 if (token[0] == '#') continue; // comment line
3033
3034 // vertex
3035 if (token[0] == 'v' && IS_SPACE((token[1]))) {
3036 token += 2;
3037 // TODO(syoyo): Support parsing vertex color extension.
3038 real_t x, y, z, w; // w is optional. default = 1.0
3039 parseV(&x, &y, &z, &w, &token);
3040 if (callback.vertex_cb) {
3041 callback.vertex_cb(user_data, x, y, z, w);
3042 }
3043 continue;
3044 }
3045
3046 // normal

Callers 1

mainFunction · 0.85

Calls 15

parseVFunction · 0.85
parseReal3Function · 0.85
SplitStringFunction · 0.85
parseTagTripleFunction · 0.85
parseRealFunction · 0.85
parseRawTripleFunction · 0.70
parseStringFunction · 0.70
reserveMethod · 0.45
sizeMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected