Merge branch 'master' of github.com:syoyo/tinyobjloader
This commit is contained in:
@@ -1238,6 +1238,8 @@ typedef struct {
|
|||||||
// 3. Do parallel parsing for each line.
|
// 3. Do parallel parsing for each line.
|
||||||
// 4. Reconstruct final mesh data structure.
|
// 4. Reconstruct final mesh data structure.
|
||||||
|
|
||||||
|
// Raise # of max threads if you have more CPU cores...
|
||||||
|
// In 2018, 32 cores are getting common in high-end workstaion PC.
|
||||||
#define kMaxThreads (32)
|
#define kMaxThreads (32)
|
||||||
|
|
||||||
static inline bool is_line_ending(const char *p, size_t i, size_t end_i) {
|
static inline bool is_line_ending(const char *p, size_t i, size_t end_i) {
|
||||||
|
|||||||
@@ -1789,6 +1789,10 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
unsigned int current_smoothing_id =
|
unsigned int current_smoothing_id =
|
||||||
0; // Initial value. 0 means no smoothing.
|
0; // Initial value. 0 means no smoothing.
|
||||||
|
|
||||||
|
int greatest_v_idx = -1;
|
||||||
|
int greatest_vn_idx = -1;
|
||||||
|
int greatest_vt_idx = -1;
|
||||||
|
|
||||||
shape_t shape;
|
shape_t shape;
|
||||||
|
|
||||||
size_t line_num = 0;
|
size_t line_num = 0;
|
||||||
@@ -1907,6 +1911,10 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
greatest_v_idx = greatest_v_idx > vi.v_idx ? greatest_v_idx : vi.v_idx;
|
||||||
|
greatest_vn_idx = greatest_vn_idx > vi.vn_idx ? greatest_vn_idx : vi.vn_idx;
|
||||||
|
greatest_vt_idx = greatest_vt_idx > vi.vt_idx ? greatest_vt_idx : vi.vt_idx;
|
||||||
|
|
||||||
face.vertex_indices.push_back(vi);
|
face.vertex_indices.push_back(vi);
|
||||||
size_t n = strspn(token, " \t\r");
|
size_t n = strspn(token, " \t\r");
|
||||||
token += n;
|
token += n;
|
||||||
@@ -2153,6 +2161,31 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
// Ignore unknown command.
|
// Ignore unknown command.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (greatest_v_idx >= static_cast<int>(v.size() / 3))
|
||||||
|
{
|
||||||
|
if (err) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "WARN: Vertex indices out of bounds.\n" << std::endl;
|
||||||
|
(*err) += ss.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (greatest_vn_idx >= static_cast<int>(vn.size() / 3))
|
||||||
|
{
|
||||||
|
if (err) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "WARN: Vertex normal indices out of bounds.\n" << std::endl;
|
||||||
|
(*err) += ss.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (greatest_vt_idx >= static_cast<int>(vt.size() / 2))
|
||||||
|
{
|
||||||
|
if (err) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "WARN: Vertex texcoord indices out of bounds.\n" << std::endl;
|
||||||
|
(*err) += ss.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ret = exportGroupsToShape(&shape, faceGroup, lineGroup, tags, material,
|
bool ret = exportGroupsToShape(&shape, faceGroup, lineGroup, tags, material,
|
||||||
name, triangulate, v);
|
name, triangulate, v);
|
||||||
// exportGroupsToShape return false when `usemtl` is called in the last
|
// exportGroupsToShape return false when `usemtl` is called in the last
|
||||||
|
|||||||
Reference in New Issue
Block a user