Skip to content

Commit ab09338

Browse files
authored
Merge branch 'tinyobjloader:release' into master
2 parents 6d19bc3 + 5468409 commit ab09338

24 files changed

+559
-318
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ build/
44
/python/*.egg-info
55
/python/.eggs
66
/python/tiny_obj_loader.h
7+
/tests/tester
8+
/tests/tester.dSYM

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#Tiny Object Loader Cmake configuration file.
22
#This configures the Cmake system with multiple properties, depending
33
#on the platform and configuration it is set to build in.
4-
project(tinyobjloader)
54
cmake_minimum_required(VERSION 3.2)
5+
project(tinyobjloader)
66
set(TINYOBJLOADER_SOVERSION 2)
7-
set(TINYOBJLOADER_VERSION 2.0.0-rc.9)
7+
set(TINYOBJLOADER_VERSION 2.0.0-rc.10)
88

99
#optional double precision support
1010
option(TINYOBJLOADER_USE_DOUBLE "Build library with double precision instead of single (float)" OFF)

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ TinyObjLoader is successfully used in ...
7272
* liblava - A modern C++ and easy-to-use framework for the Vulkan API. [MIT]: https://github.com/liblava/liblava
7373
* rtxON - Simple Vulkan raytracing tutorials https://github.com/iOrange/rtxON
7474
* metal-ray-tracer - Writing ray-tracer using Metal Performance Shaders https://github.com/sergeyreznik/metal-ray-tracer https://sergeyreznik.github.io/metal-ray-tracer/index.html
75+
* Supernova Engine - 2D and 3D projects with Lua or C++ in data oriented design: https://github.com/supernovaengine/supernova
76+
* AGE (Arc Game Engine) - An open-source engine for building 2D & 3D real-time rendering and interactive contents: https://github.com/MohitSethi99/ArcGameEngine
7577
* Your project here! (Letting us know via github issue is welcome!)
7678

7779
### Old version(v0.9.x)
@@ -421,7 +423,7 @@ cibuildwheels + twine upload for each git tagging event is handled in Azure Pipe
421423
#### How to bump version(For developer)
422424

423425
* Bump version in CMakeLists.txt
424-
* Update version in `python/setup.py`
426+
* Update version in `setup.py`
425427
* Commit and push `master`. Confirm C.I. build is OK.
426428
* Create tag starting with `v`(e.g. `v2.1.0`)
427429
* `git push --tags`

azure-pipelines.yml

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
variables:
22
# https://cibuildwheel.readthedocs.io/en/stable/cpp_standards/
3-
# python2.7 + C++11(pybind11) is not available.
4-
CIBW_SKIP: "cp27-win* pp27-win32 pp36-win32"
3+
# cibuildwheel now supports python 3.6+(as of 2022 Oct)
4+
#CIBW_SKIP: "pp*"
55
CIBW_BEFORE_BUILD: "pip install pybind11"
6+
CIBW_ARCHS_LINUXBEFORE_BUILD: "pip install pybind11"
7+
# disable aarch64 build for a while since it(pulling docker aarch64 image) exceeds Azure's 60 min limit
8+
# NOTE: aarch64 linux support in Azure pipeline is not yet officially supported(as of 2022 Oct) https://github.com/microsoft/azure-pipelines-agent/issues/3935
9+
#CIBW_ARCHS_LINUX: auto aarch64
10+
CIBW_ARCHS_MACOS: x86_64 universal2 arm64
611
#CIBW_BEFORE_BUILD_MACOS: "pip install -U pip setuptools"
712
#CIBW_BEFORE_BUILD_LINUX: "pip install -U pip setuptools"
813
#CIBW_TEST_COMMAND: TODO "python -c \"import tinyobjloader; tinyobjloader.test()\""
@@ -24,7 +29,12 @@ jobs:
2429
steps:
2530
- task: UsePythonVersion@0
2631
- script: |
27-
pip install black==19.10b0
32+
# 19.10b0 triggers 'cannot import name '_unicodefun' from 'click'' error.
33+
# https://stackoverflow.com/questions/71673404/importerror-cannot-import-name-unicodefun-from-click
34+
#pip install black==19.10b0
35+
#pip install black==22.3.0
36+
pip install black==22.10.0
37+
2838
black --check python/
2939
displayName: Check Python code format
3040
@@ -37,27 +47,25 @@ jobs:
3747
- bash: |
3848
python3 -m pip install --upgrade pip
3949
pip3 install cibuildwheel twine
40-
# Make the header files available to the build.
41-
cp *.h python
42-
mkdir python/mapbox
43-
cp mapbox/earcut.hpp python/mapbox/
44-
cd python
50+
51+
# Use pipx to build source dist
52+
pip3 install pipx
4553
4654
# Source dist
47-
python3 setup.py sdist
55+
pipx run build --sdist
4856
ls -la dist/*
4957
5058
# build binary wheels
51-
cibuildwheel --output-dir wheelhouse .
59+
cibuildwheel --platform linux --output-dir wheelhouse .
5260
5361
- task: CopyFiles@2
5462
inputs:
55-
contents: 'python/wheelhouse/**'
63+
contents: 'wheelhouse/**'
5664
targetFolder: $(Build.ArtifactStagingDirectory)
5765

5866
- task: CopyFiles@2
5967
inputs:
60-
contents: 'python/dist/**'
68+
contents: 'dist/**'
6169
targetFolder: $(Build.ArtifactStagingDirectory)
6270

6371
- task: PublishBuildArtifacts@1
@@ -66,7 +74,7 @@ jobs:
6674
artifactName: tinyobjDeployLinux
6775

6876
- job: macos
69-
pool: {vmImage: 'macOS-10.15'}
77+
pool: {vmImage: 'macOS-latest'}
7078
variables:
7179
# Support C++11: https://github.com/joerick/cibuildwheel/pull/156
7280
MACOSX_DEPLOYMENT_TARGET: 10.9
@@ -75,37 +83,27 @@ jobs:
7583
- bash: |
7684
python3 -m pip install --upgrade pip
7785
pip3 install cibuildwheel
78-
# Make the header files available to the build.
79-
cp *.h python
80-
mkdir python/mapbox
81-
cp mapbox/earcut.hpp python/mapbox/earcut.hpp
82-
cd python
83-
cibuildwheel --output-dir wheelhouse .
86+
cibuildwheel --platform macos --output-dir wheelhouse .
8487
- task: CopyFiles@2
8588
inputs:
86-
contents: 'python/wheelhouse/*.whl'
89+
contents: 'wheelhouse/*.whl'
8790
targetFolder: $(Build.ArtifactStagingDirectory)
8891
- task: PublishBuildArtifacts@1
8992
inputs:
9093
path: $(Build.ArtifactStagingDirectory)
9194
artifactName: tinyobjDeployMacOS
9295

9396
- job: windows
94-
pool: {vmImage: 'windows-2019'}
97+
pool: {vmImage: 'windows-latest'}
9598
steps:
9699
- task: UsePythonVersion@0
97100
- bash: |
98101
python -m pip install --upgrade pip
99102
pip install cibuildwheel
100-
# Make the header files available to the build.
101-
cp *.h python
102-
mkdir python/mapbox
103-
cp mapbox/earcut.hpp python/mapbox/
104-
cd python
105-
cibuildwheel --output-dir wheelhouse .
103+
cibuildwheel --platform windows --output-dir wheelhouse .
106104
- task: CopyFiles@2
107105
inputs:
108-
contents: 'python/wheelhouse/*.whl'
106+
contents: 'wheelhouse/*.whl'
109107
targetFolder: $(Build.ArtifactStagingDirectory)
110108
- task: PublishBuildArtifacts@1
111109
inputs:
@@ -114,7 +112,7 @@ jobs:
114112

115113
- job: deployPyPI
116114
# Based on vispy: https://github.com/vispy/vispy/blob/master/azure-pipelines.yml
117-
pool: {vmImage: 'Ubuntu-16.04'}
115+
pool: {vmImage: 'ubuntu-latest'}
118116
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
119117
dependsOn:
120118
- linux
@@ -145,9 +143,9 @@ jobs:
145143
find .
146144
python -m pip install --upgrade pip
147145
pip install twine
148-
echo tinyobjDeployLinux/python/dist/*
149-
echo tinyobjDeployLinux/python/wheelhouse/* tinyobjDeployMacOS/python/wheelhouse/* tinyobjDeployWindows/python/wheelhouse/*
150-
twine upload -u "__token__" --skip-existing tinyobjDeployLinux/python/dist/* tinyobjDeployLinux/python/wheelhouse/* tinyobjDeployMacOS/python/wheelhouse/* tinyobjDeployWindows/python/wheelhouse/*
146+
echo tinyobjDeployLinux/dist/*
147+
echo tinyobjDeployLinux/wheelhouse/* tinyobjDeployMacOS/wheelhouse/* tinyobjDeployWindows/wheelhouse/*
148+
twine upload -u "__token__" --skip-existing tinyobjDeployLinux/dist/* tinyobjDeployLinux/wheelhouse/* tinyobjDeployMacOS/wheelhouse/* tinyobjDeployWindows/wheelhouse/*
151149
env:
152150
TWINE_PASSWORD: $(pypiToken2)
153151

examples/viewer/viewer.cc

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ bool mouseRightPressed;
152152
float curr_quat[4];
153153
float prev_quat[4];
154154
float eye[3], lookat[3], up[3];
155+
bool g_show_wire = true;
156+
bool g_cull_face = false;
155157

156158
GLFWwindow* window;
157159

@@ -833,8 +835,19 @@ static void keyboardFunc(GLFWwindow* window, int key, int scancode, int action,
833835
mv_z += -1;
834836
// camera.move(mv_x * 0.05, mv_y * 0.05, mv_z * 0.05);
835837
// Close window
836-
if (key == GLFW_KEY_Q || key == GLFW_KEY_ESCAPE)
838+
if (key == GLFW_KEY_Q || key == GLFW_KEY_ESCAPE) {
837839
glfwSetWindowShouldClose(window, GL_TRUE);
840+
}
841+
842+
if (key == GLFW_KEY_W) {
843+
// toggle wireframe
844+
g_show_wire = !g_show_wire;
845+
}
846+
847+
if (key == GLFW_KEY_C) {
848+
// cull option
849+
g_cull_face = !g_cull_face;
850+
}
838851

839852
// init_frame = true;
840853
}
@@ -898,7 +911,11 @@ static void Draw(const std::vector<DrawObject>& drawObjects,
898911
std::vector<tinyobj::material_t>& materials,
899912
std::map<std::string, GLuint>& textures) {
900913
glPolygonMode(GL_FRONT, GL_FILL);
901-
glPolygonMode(GL_BACK, GL_FILL);
914+
if (g_cull_face) {
915+
glPolygonMode(GL_BACK, GL_LINE);
916+
} else {
917+
glPolygonMode(GL_BACK, GL_FILL);
918+
}
902919

903920
glEnable(GL_POLYGON_OFFSET_FILL);
904921
glPolygonOffset(1.0, 1.0);
@@ -933,29 +950,31 @@ static void Draw(const std::vector<DrawObject>& drawObjects,
933950
}
934951

935952
// draw wireframe
936-
glDisable(GL_POLYGON_OFFSET_FILL);
937-
glPolygonMode(GL_FRONT, GL_LINE);
938-
glPolygonMode(GL_BACK, GL_LINE);
953+
if (g_show_wire) {
954+
glDisable(GL_POLYGON_OFFSET_FILL);
955+
glPolygonMode(GL_FRONT, GL_LINE);
956+
glPolygonMode(GL_BACK, GL_LINE);
957+
958+
glColor3f(0.0f, 0.0f, 0.4f);
959+
for (size_t i = 0; i < drawObjects.size(); i++) {
960+
DrawObject o = drawObjects[i];
961+
if (o.vb_id < 1) {
962+
continue;
963+
}
939964

940-
glColor3f(0.0f, 0.0f, 0.4f);
941-
for (size_t i = 0; i < drawObjects.size(); i++) {
942-
DrawObject o = drawObjects[i];
943-
if (o.vb_id < 1) {
944-
continue;
965+
glBindBuffer(GL_ARRAY_BUFFER, o.vb_id);
966+
glEnableClientState(GL_VERTEX_ARRAY);
967+
glEnableClientState(GL_NORMAL_ARRAY);
968+
glDisableClientState(GL_COLOR_ARRAY);
969+
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
970+
glVertexPointer(3, GL_FLOAT, stride, (const void*)0);
971+
glNormalPointer(GL_FLOAT, stride, (const void*)(sizeof(float) * 3));
972+
glColorPointer(3, GL_FLOAT, stride, (const void*)(sizeof(float) * 6));
973+
glTexCoordPointer(2, GL_FLOAT, stride, (const void*)(sizeof(float) * 9));
974+
975+
glDrawArrays(GL_TRIANGLES, 0, 3 * o.numTriangles);
976+
CheckErrors("drawarrays");
945977
}
946-
947-
glBindBuffer(GL_ARRAY_BUFFER, o.vb_id);
948-
glEnableClientState(GL_VERTEX_ARRAY);
949-
glEnableClientState(GL_NORMAL_ARRAY);
950-
glDisableClientState(GL_COLOR_ARRAY);
951-
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
952-
glVertexPointer(3, GL_FLOAT, stride, (const void*)0);
953-
glNormalPointer(GL_FLOAT, stride, (const void*)(sizeof(float) * 3));
954-
glColorPointer(3, GL_FLOAT, stride, (const void*)(sizeof(float) * 6));
955-
glTexCoordPointer(2, GL_FLOAT, stride, (const void*)(sizeof(float) * 9));
956-
957-
glDrawArrays(GL_TRIANGLES, 0, 3 * o.numTriangles);
958-
CheckErrors("drawarrays");
959978
}
960979
}
961980

@@ -995,6 +1014,11 @@ int main(int argc, char** argv) {
9951014
return 1;
9961015
}
9971016

1017+
std::cout << "W : Toggle wireframe\n";
1018+
std::cout << "C : Toggle face culling\n";
1019+
//std::cout << "K, J, H, L, P, N : Move camera\n";
1020+
std::cout << "Q, Esc : quit\n";
1021+
9981022
glfwMakeContextCurrent(window);
9991023
glfwSwapInterval(1);
10001024

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vt 0 0
2+
f 1/-1 1/-1 1/-2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
f -4 -3 -2

models/issue-319-002.obj

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
###
2+
#
3+
# OBJ File Generated by Meshlab
4+
#
5+
####
6+
# Object ZH2_001.obj
7+
#
8+
# Vertices: 19
9+
# Faces: 3
10+
#
11+
####
12+
v 8219.830078 6406.934082 9.603000
13+
v 8219.632812 6406.582031 9.603000
14+
v 8219.632812 6406.582031 9.139000
15+
v 8219.973633 6405.420898 9.139000
16+
v 8211.128906 6404.090820 9.139000
17+
v 8211.128906 6404.090820 9.603000
18+
v 8211.469727 6402.930176 9.139000
19+
v 8211.469727 6402.930176 9.603000
20+
v 8211.133789 6402.831055 9.603000
21+
v 8210.793945 6403.992188 9.603000
22+
v 8210.713867 6404.264160 9.603000
23+
v 8211.840820 6403.038086 9.139000
24+
v 8219.899414 6404.861816 9.139000
25+
v 8219.755859 6405.352051 9.139000
26+
v 8211.985352 6402.544922 9.139000
27+
v 8232.911133 6378.534180 55.848999
28+
v 8226.281250 6376.591797 55.848999
29+
v 8226.341797 6376.384766 55.848999
30+
v 8233.450195 6378.466797 55.852001
31+
v 8233.450195 6378.466797 55.852001
32+
# 19 vertices, 0 vertices normals
33+
34+
f 2 1 11 10 9 8 6
35+
f 5 7 12 15 13 14 4 3
36+
f 18 19 20 16 17
37+
# 3 faces, 0 coords texture
38+
39+
# End of File

models/issue-319-003.obj

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
####
2+
#
3+
# OBJ File Generated by Meshlab
4+
#
5+
####
6+
# Object new 1.obj
7+
#
8+
# Vertices: 10
9+
# Faces: 1
10+
#
11+
####
12+
v 8434.808594 6083.654785 2.387000
13+
v 8434.808594 6083.654785 71.633003
14+
v 8432.309570 6092.206055 71.633003
15+
v 8432.309570 6092.206055 63.955002
16+
v 8432.309570 6092.206055 2.387000
17+
v 8433.083984 6089.560059 71.633003
18+
v 8433.161133 6089.293945 71.633003
19+
v 8432.309570 6092.206055 64.323997
20+
v 8432.309570 6092.206055 67.152000
21+
v 8432.309570 6092.206055 68.078003
22+
# 10 vertices, 0 vertices normals
23+
24+
f 6 7 2 1 5 4 8 9 10 3
25+
# 1 faces, 0 coords texture
26+
27+
# End of File

models/issue-330.obj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
v -105.342712 40.184242 -16.056709
2+
v -105.463989 40.202003 -16.003181
3+
v -105.564941 40.207558 -15.934708
4+
v -105.722252 40.151146 -16.112091
5+
v -105.610237 40.191372 -16.176643
6+
v -105.667282 40.189800 -15.864197
7+
v -105.751717 40.125790 -15.794304
8+
# 7 vertices, 0 vertices normals
9+
10+
f 2 5 4 3
11+
f 4 6 3
12+
# 2 faces, 0 coords texture

0 commit comments

Comments
 (0)