Skip to content

Commit 8972259

Browse files
committed
Merge branch 'master' into python_add_materialids
2 parents 9cebc39 + d7d5321 commit 8972259

18 files changed

+460
-97
lines changed

CMakeLists.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ set(TINYOBJLOADER_VERSION 1.0.4)
1010
option(TINYOBJLOADER_USE_DOUBLE "Build library with double precision instead of single (float)" OFF)
1111

1212
if(TINYOBJLOADER_USE_DOUBLE)
13-
add_definitions(-DTINYOBJLOADER_USE_DOUBLE)
1413
set(LIBRARY_NAME ${PROJECT_NAME}_double)
1514
else()
1615
set(LIBRARY_NAME ${PROJECT_NAME})
@@ -56,6 +55,10 @@ if(BUILD_SHARED_LIBS)
5655
)
5756
endif()
5857

58+
if(TINYOBJLOADER_USE_DOUBLE)
59+
target_compile_definitions(${LIBRARY_NAME} PUBLIC TINYOBJLOADER_USE_DOUBLE)
60+
endif()
61+
5962
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION ${TINYOBJLOADER_VERSION})
6063

6164
target_include_directories(${LIBRARY_NAME} INTERFACE
@@ -87,7 +90,7 @@ include(CMakePackageConfigHelpers)
8790

8891
configure_package_config_file(
8992
${PROJECT_NAME}-config.cmake.in
90-
${LIBRARY_NAME}-config.cmake
93+
${PROJECT_NAME}-config.cmake
9194
INSTALL_DESTINATION
9295
${TINYOBJLOADER_CMAKE_DIR}
9396
PATH_VARS
@@ -96,7 +99,7 @@ configure_package_config_file(
9699
NO_CHECK_REQUIRED_COMPONENTS_MACRO
97100
)
98101

99-
write_basic_package_version_file(${LIBRARY_NAME}-config-version.cmake
102+
write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
100103
VERSION
101104
${TINYOBJLOADER_VERSION}
102105
COMPATIBILITY
@@ -145,3 +148,13 @@ install(FILES
145148
DESTINATION
146149
${TINYOBJLOADER_PKGCONFIG_DIR}
147150
)
151+
152+
if(NOT TARGET uninstall)
153+
configure_file(
154+
${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
155+
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
156+
157+
add_custom_target(
158+
uninstall COMMAND ${CMAKE_COMMAND} -P
159+
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
160+
endif()

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# tinyobjloader
22

3-
[![Join the chat at https://gitter.im/syoyo/tinyobjloader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/syoyo/tinyobjloader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
5-
[![Build Status](https://travis-ci.org/syoyo/tinyobjloader.svg)](https://travis-ci.org/syoyo/tinyobjloader)
3+
[![Build Status](https://travis-ci.org/tinyobjloader/tinyobjloader.svg?branch=master)](https://travis-ci.org/tinyobjloader/tinyobjloader)
64

75
[![AZ Build Status](https://dev.azure.com/syoyo/lte%20oss/_apis/build/status/syoyo.tinyobjloader?branchName=master)](https://dev.azure.com/syoyo/lte%20oss/_build/latest?definitionId=2&branchName=master)
86

@@ -12,6 +10,9 @@
1210

1311
[![Download](https://api.bintray.com/packages/conan/conan-center/tinyobjloader%3A_/images/download.svg)](https://bintray.com/conan/conan-center/tinyobjloader%3A_/_latestVersion)
1412

13+
[![Join the chat at https://gitter.im/syoyo/tinyobjloader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/syoyo/tinyobjloader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (inactive. gitter chat will be removed in the future. Please use github issue if you have questions and got issues)
14+
15+
1516
Tiny but powerful single file wavefront obj loader written in C++03. No dependency except for C++ STL. It can parse over 10M polygons with moderate memory and time.
1617

1718
`tinyobjloader` is good for embedding .obj loader to your (global illumination) renderer ;-)
@@ -26,6 +27,7 @@ Old version is available as `v0.9.x` branch https://github.com/syoyo/tinyobjload
2627

2728
## What's new
2829

30+
* 19 Feb, 2020 : The repository has been moved to https://github.com/tinyobjloader/tinyobjloader !
2931
* 18 May, 2019 : Python binding!(See `python` folder. Also see https://pypi.org/project/tinyobjloader/)
3032
* 14 Apr, 2019 : Bump version v2.0.0 rc0. New C++ API and python bindings!(1.x API still exists for backward compatibility)
3133
* 20 Aug, 2016 : Bump version v1.0.0. New data structure and API!

azure-pipelines.yml

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -11,86 +11,57 @@ jobs:
1111
make && ./tester
1212
displayName: Run unit tests
1313
14-
- job: python_linux
15-
pool: { vmImage: "Ubuntu-16.04" }
14+
- job: linux
15+
pool: {vmImage: "Ubuntu-16.04"}
1616
steps:
1717
- task: UsePythonVersion@0
1818
- bash: |
19+
python -m pip install --upgrade pip
20+
pip install cibuildwheel==1.1.0
1921
# Make the header files available to the build.
2022
cp *.h python
21-
python -m pip install --upgrade pip
22-
pip install cibuildwheel==0.12.0
2323
cd python
2424
cibuildwheel --output-dir wheelhouse .
2525
- task: PublishBuildArtifacts@1
26-
inputs: { pathtoPublish: "python/wheelhouse" }
26+
inputs: {pathtoPublish: 'python/wheelhouse'}
2727
- script: |
2828
pip install black==19.10b0
2929
black --check python/
3030
displayName: Check Python code format
3131
32-
- job: python_macos
33-
pool: { vmImage: "macOS-10.13" }
32+
- job: macos
33+
pool: {vmImage: 'macOS-10.13'}
3434
variables:
3535
# Support C++11: https://github.com/joerick/cibuildwheel/pull/156
3636
MACOSX_DEPLOYMENT_TARGET: 10.9
3737
steps:
3838
- task: UsePythonVersion@0
3939
- bash: |
40+
python -m pip install --upgrade pip
41+
pip install cibuildwheel==1.1.0
4042
# Make the header files available to the build.
4143
cp *.h python
42-
python -m pip install --upgrade pip
43-
pip install cibuildwheel==0.12.0
4444
cd python
4545
cibuildwheel --output-dir wheelhouse .
4646
- task: PublishBuildArtifacts@1
47-
inputs: { pathtoPublish: "python/wheelhouse" }
47+
inputs: {pathtoPublish: 'python/wheelhouse'}
4848

49-
- job: python_windows
50-
pool: { vmImage: "vs2017-win2016" }
49+
- job: windows
50+
pool: {vmImage: 'vs2017-win2016'}
5151
steps:
52-
- {
53-
task: UsePythonVersion@0,
54-
inputs: { versionSpec: "2.7", architecture: x86 },
55-
}
56-
- {
57-
task: UsePythonVersion@0,
58-
inputs: { versionSpec: "2.7", architecture: x64 },
59-
}
60-
- {
61-
task: UsePythonVersion@0,
62-
inputs: { versionSpec: "3.5", architecture: x86 },
63-
}
64-
- {
65-
task: UsePythonVersion@0,
66-
inputs: { versionSpec: "3.5", architecture: x64 },
67-
}
68-
- {
69-
task: UsePythonVersion@0,
70-
inputs: { versionSpec: "3.6", architecture: x86 },
71-
}
72-
- {
73-
task: UsePythonVersion@0,
74-
inputs: { versionSpec: "3.6", architecture: x64 },
75-
}
76-
- {
77-
task: UsePythonVersion@0,
78-
inputs: { versionSpec: "3.7", architecture: x86 },
79-
}
80-
- {
81-
task: UsePythonVersion@0,
82-
inputs: { versionSpec: "3.7", architecture: x64 },
83-
}
52+
- task: UsePythonVersion@0
8453
- script: choco install vcpython27 -f -y
8554
displayName: Install Visual C++ for Python 2.7
8655
- bash: |
87-
cp *.h python
8856
python -m pip install --upgrade pip
89-
pip install cibuildwheel==0.12.0
57+
pip install cibuildwheel==1.1.0
58+
# Make the header files available to the build.
59+
cp *.h python
9060
cd python
9161
cibuildwheel --output-dir wheelhouse .
9262
- task: PublishBuildArtifacts@1
93-
inputs: { pathtoPublish: "python/wheelhouse" }
63+
inputs: {pathtoPublish: 'python/wheelhouse'}
64+
9465

9566
trigger:
9667
- master

cmake_uninstall.cmake.in

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
2+
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
3+
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
4+
5+
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
6+
string(REGEX REPLACE "\n" ";" files "${files}")
7+
foreach(file ${files})
8+
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
9+
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
10+
exec_program(
11+
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
12+
OUTPUT_VARIABLE rm_out
13+
RETURN_VALUE rm_retval
14+
)
15+
if(NOT "${rm_retval}" STREQUAL 0)
16+
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
17+
endif(NOT "${rm_retval}" STREQUAL 0)
18+
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
19+
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
20+
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
21+
endforeach(file)

examples/viewer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Then,
3737

3838
## TODO
3939

40+
* [ ] Alpha texturing.
4041
* [ ] Support per-face material.
4142
* [ ] Use shader-based GL rendering.
4243
* [ ] PBR shader support.

experimental/viewer.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <limits>
1010
#include <cmath>
1111
#include <cassert>
12-
#include <cstring>
13-
#include <algorithm>
12+
#include <cstring>
13+
#include <algorithm>
1414

1515
#if defined(ENABLE_ZLIB)
1616
#include <zlib.h>
@@ -81,7 +81,7 @@ void CalcNormal(float N[3], float v0[3], float v1[3], float v2[3]) {
8181
float len2 = N[0] * N[0] + N[1] * N[1] + N[2] * N[2];
8282
if (len2 > 0.0f) {
8383
float len = sqrtf(len2);
84-
84+
8585
N[0] /= len;
8686
N[1] /= len;
8787
}
@@ -96,7 +96,7 @@ const char *mmap_file(size_t *len, const char* filename)
9696

9797
HANDLE fileMapping = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
9898
assert(fileMapping != INVALID_HANDLE_VALUE);
99-
99+
100100
LPVOID fileMapView = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, 0);
101101
auto fileMapViewChar = (const char*)fileMapView;
102102
assert(fileMapView != NULL);
@@ -140,7 +140,7 @@ const char *mmap_file(size_t *len, const char* filename)
140140
}
141141

142142
if (!S_ISREG (sb.st_mode)) {
143-
fprintf (stderr, "%s is not a file\n", "lineitem.tbl");
143+
fprintf (stderr, "%s is not a file\n", filename);
144144
return nullptr;
145145
}
146146

@@ -159,7 +159,7 @@ const char *mmap_file(size_t *len, const char* filename)
159159
(*len) = fileSize;
160160

161161
return p;
162-
162+
163163
#endif
164164
}
165165

@@ -175,11 +175,11 @@ bool gz_load(std::vector<char>* buf, const char* filename)
175175
return false;
176176
}
177177
while (1) {
178-
int err;
178+
int err;
179179
int bytes_read;
180180
unsigned char buffer[1024];
181181
bytes_read = gzread (file, buffer, 1024);
182-
buf->insert(buf->end(), buffer, buffer + 1024);
182+
buf->insert(buf->end(), buffer, buffer + 1024);
183183
//printf ("%s", buffer);
184184
if (bytes_read < 1024) {
185185
if (gzeof (file)) {
@@ -305,7 +305,7 @@ const char* get_file_data(size_t *len, const char* filename)
305305
data_len = buf.size();
306306
}
307307
} else {
308-
308+
309309
data = mmap_file(&data_len, filename);
310310

311311
}
@@ -385,7 +385,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
385385

386386
float n[3][3];
387387

388-
if (attrib.normals.size() > 0) {
388+
if (attrib.normals.size() > 0) {
389389
int nf0 = idx0.normal_index;
390390
int nf1 = idx1.normal_index;
391391
int nf2 = idx2.normal_index;
@@ -424,7 +424,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
424424
float len2 = c[0] * c[0] + c[1] * c[1] + c[2] * c[2];
425425
if (len2 > 1.0e-6f) {
426426
float len = sqrtf(len2);
427-
427+
428428
c[0] /= len;
429429
c[1] /= len;
430430
c[2] /= len;
@@ -433,7 +433,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
433433
vb.push_back(c[1] * 0.5 + 0.5);
434434
vb.push_back(c[2] * 0.5 + 0.5);
435435
}
436-
}
436+
}
437437
face_offset += attrib.face_num_verts[v];
438438
}
439439

@@ -448,7 +448,7 @@ bool LoadObjAndConvert(float bmin[3], float bmax[3], const char* filename, int n
448448

449449
gDrawObjects.push_back(o);
450450
}
451-
451+
452452
printf("bmin = %f, %f, %f\n", bmin[0], bmin[1], bmin[2]);
453453
printf("bmax = %f, %f, %f\n", bmax[0], bmax[1], bmax[2]);
454454

@@ -562,7 +562,7 @@ void Draw(const std::vector<DrawObject>& drawObjects)
562562
if (o.vb < 1) {
563563
continue;
564564
}
565-
565+
566566
glBindBuffer(GL_ARRAY_BUFFER, o.vb);
567567
glEnableClientState(GL_VERTEX_ARRAY);
568568
glEnableClientState(GL_NORMAL_ARRAY);
@@ -586,7 +586,7 @@ void Draw(const std::vector<DrawObject>& drawObjects)
586586
if (o.vb < 1) {
587587
continue;
588588
}
589-
589+
590590
glBindBuffer(GL_ARRAY_BUFFER, o.vb);
591591
glEnableClientState(GL_VERTEX_ARRAY);
592592
glEnableClientState(GL_NORMAL_ARRAY);
@@ -677,7 +677,7 @@ int main(int argc, char **argv)
677677
return -1;
678678
}
679679

680-
std::cout << "GLFW OK." << std::endl;
680+
std::cout << "GLFW Init OK." << std::endl;
681681

682682

683683
window = glfwCreateWindow(width, height, "Obj viewer", NULL, NULL);
@@ -738,7 +738,7 @@ int main(int argc, char **argv)
738738

739739
// Centerize object.
740740
glTranslatef(-0.5*(bmax[0] + bmin[0]), -0.5*(bmax[1] + bmin[1]), -0.5*(bmax[2] + bmin[2]));
741-
741+
742742
Draw(gDrawObjects);
743743

744744
glfwSwapBuffers(window);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .mtl is located at tests/assets
2+
mtllib issue-244.mtl
3+
4+
v -1.000000 1.202466 1.000000
5+
v 1.000000 1.202466 1.000000
6+
v -1.000000 1.202466 -1.000000
7+
v 1.000000 1.202466 -1.000000
8+
vn 0.0000 1.0000 0.0000
9+
v -1.000000 0.000000 1.000000
10+
v 1.000000 0.000000 1.000000
11+
v -1.000000 0.000000 -1.000000
12+
v 1.000000 0.000000 -1.000000
13+
vn 0.0000 1.0000 0.0000
14+
15+
usemtl None
16+
o Plane.001
17+
f 1//1 2//1 4//1
18+
19+
# Following geometry is ignored without fix for #235
20+
usemtl None1
21+
o Plane
22+
f 5//2 6//2 8//2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
newmtl 1
2+
Ka 0 0 0
3+
Kd 1 1 1
4+
Ks 0 0 0

0 commit comments

Comments
 (0)