MCPcopy Create free account
hub / github.com/SaschaWillems/HowToVulkan / parseVertexWithColor

Function parseVertexWithColor

source/external/tinyobj/tiny_obj_loader.h:1096–1130  ·  view source on GitHub ↗

Extension: parse vertex with colors(6 items) Return 3: xyz, 4: xyzw, 6: xyzrgb `r`: red(case 6) or [w](case 4)

Source from the content-addressed store, hash-verified

1094// Return 3: xyz, 4: xyzw, 6: xyzrgb
1095// `r`: red(case 6) or [w](case 4)
1096static inline int parseVertexWithColor(real_t *x, real_t *y, real_t *z,
1097 real_t *r, real_t *g, real_t *b,
1098 const char **token,
1099 const double default_x = 0.0,
1100 const double default_y = 0.0,
1101 const double default_z = 0.0) {
1102 // TODO: Check error
1103 (*x) = parseReal(token, default_x);
1104 (*y) = parseReal(token, default_y);
1105 (*z) = parseReal(token, default_z);
1106
1107 // - 4 components(x, y, z, w) ot 6 components
1108 bool has_r = parseReal(token, r);
1109
1110 if (!has_r) {
1111 (*r) = (*g) = (*b) = 1.0;
1112 return 3;
1113 }
1114
1115 bool has_g = parseReal(token, g);
1116
1117 if (!has_g) {
1118 (*g) = (*b) = 1.0;
1119 return 4;
1120 }
1121
1122 bool has_b = parseReal(token, b);
1123
1124 if (!has_b) {
1125 (*r) = (*g) = (*b) = 1.0;
1126 return 3; // treated as xyz
1127 }
1128
1129 return 6;
1130}
1131
1132static inline bool parseOnOff(const char **token, bool default_value = true) {
1133 (*token) += strspn((*token), " \t");

Callers 2

LoadObjFunction · 0.85
LoadObjWithCallbackFunction · 0.85

Calls 1

parseRealFunction · 0.85

Tested by

no test coverage detected