Compare commits
11 Commits
a957ebe002
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f37fed32f3 | ||
|
|
85d92bb5cb | ||
|
|
40d00fd935 | ||
|
|
7712f1bebd | ||
|
|
e96e994355 | ||
|
|
8f16866c37 | ||
|
|
5e668b398a | ||
|
|
df3bb6f8e8 | ||
|
|
546aa09d8d | ||
|
|
aa90b5466f | ||
|
|
b404f3af67 |
@@ -46,15 +46,13 @@ set(TINYOBJLOADER_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
set(TINYOBJLOADER_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR})
|
||||
|
||||
option(TINYOBJLOADER_BUILD_TEST_LOADER "Build Example Loader Application" OFF)
|
||||
option(TINYOBJLOADER_COMPILATION_SHARED "Build as shared library" OFF)
|
||||
|
||||
if(TINYOBJLOADER_COMPILATION_SHARED)
|
||||
add_library(${LIBRARY_NAME} SHARED ${tinyobjloader-Source})
|
||||
add_library(${LIBRARY_NAME} ${tinyobjloader-Source})
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES
|
||||
SOVERSION ${TINYOBJLOADER_SOVERSION}
|
||||
)
|
||||
else()
|
||||
add_library(${LIBRARY_NAME} STATIC ${tinyobjloader-Source})
|
||||
endif()
|
||||
|
||||
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION ${TINYOBJLOADER_VERSION})
|
||||
@@ -120,6 +118,8 @@ install(TARGETS
|
||||
)
|
||||
install(EXPORT
|
||||
${PROJECT_NAME}-targets
|
||||
NAMESPACE
|
||||
tinyobjloader::
|
||||
DESTINATION
|
||||
${TINYOBJLOADER_CMAKE_DIR}
|
||||
)
|
||||
|
||||
@@ -1414,8 +1414,9 @@ bool parseObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
||||
}
|
||||
|
||||
if (command.type == COMMAND_MTLLIB) {
|
||||
// Save the indices of the `mtllib` command in `commands` to easily find it later
|
||||
mtllib_t_index = t;
|
||||
mtllib_i_index = commands->size();
|
||||
mtllib_i_index = commands[t].size();
|
||||
}
|
||||
|
||||
commands[t].emplace_back(std::move(command));
|
||||
|
||||
@@ -435,7 +435,7 @@ struct face_t {
|
||||
int pad_;
|
||||
std::vector<vertex_index_t> vertex_indices; // face vertex indices.
|
||||
|
||||
face_t() : smoothing_group_id(0) {}
|
||||
face_t() : smoothing_group_id(0), pad_(0) {}
|
||||
};
|
||||
|
||||
struct line_t {
|
||||
@@ -1171,20 +1171,34 @@ static bool exportGroupsToShape(shape_t *shape,
|
||||
area += (v0x * v1y - v0y * v1x) * static_cast<real_t>(0.5);
|
||||
}
|
||||
|
||||
int maxRounds = 10; // arbitrary max loop count to protect against
|
||||
// unexpected errors
|
||||
|
||||
face_t remainingFace = face; // copy
|
||||
size_t guess_vert = 0;
|
||||
vertex_index_t ind[3];
|
||||
real_t vx[3];
|
||||
real_t vy[3];
|
||||
while (remainingFace.vertex_indices.size() > 3 && maxRounds > 0) {
|
||||
|
||||
// How many iterations can we do without decreasing the remaining
|
||||
// vertices.
|
||||
size_t remainingIterations = face.vertex_indices.size();
|
||||
size_t previousRemainingVertices = remainingFace.vertex_indices.size();
|
||||
|
||||
while (remainingFace.vertex_indices.size() > 3 && remainingIterations > 0){
|
||||
npolys = remainingFace.vertex_indices.size();
|
||||
if (guess_vert >= npolys) {
|
||||
maxRounds -= 1;
|
||||
guess_vert -= npolys;
|
||||
}
|
||||
|
||||
if (previousRemainingVertices != npolys) {
|
||||
// The number of remaining vertices decreased. Reset counters.
|
||||
previousRemainingVertices = npolys;
|
||||
remainingIterations = npolys;
|
||||
} else {
|
||||
// We didn't consume a vertex on previous iteration, reduce the
|
||||
// available iterations.
|
||||
remainingIterations--;
|
||||
}
|
||||
|
||||
for (size_t k = 0; k < 3; k++) {
|
||||
ind[k] = remainingFace.vertex_indices[(guess_vert + k) % npolys];
|
||||
size_t vi = size_t(ind[k].v_idx);
|
||||
|
||||
Reference in New Issue
Block a user