Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenMesh
OpenMesh
Commits
c577810d
Commit
c577810d
authored
Oct 01, 2016
by
Max Limper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
range check for vertex colors and normals in OBJ loader
parent
8b7be54e
Pipeline
#2974
passed with stage
in 30 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
5 deletions
+15
-5
src/OpenMesh/Core/IO/reader/OBJReader.cc
src/OpenMesh/Core/IO/reader/OBJReader.cc
+15
-5
No files found.
src/OpenMesh/Core/IO/reader/OBJReader.cc
View file @
c577810d
...
...
@@ -597,8 +597,14 @@ read(std::istream& _in, BaseImporter& _bi, Options& _opt)
// Obj counts from 1 and not zero .. array counts from zero therefore -1
vhandles
.
push_back
(
VertexHandle
(
value
-
1
));
faceVertices
.
push_back
(
VertexHandle
(
value
-
1
));
if
(
fileOptions
.
vertex_has_color
()
)
_bi
.
set_color
(
vhandles
.
back
(),
colors
[
value
-
1
]);
if
(
fileOptions
.
vertex_has_color
())
{
if
((
unsigned
int
)(
value
-
1
)
<
colors
.
size
())
{
_bi
.
set_color
(
vhandles
.
back
(),
colors
[
value
-
1
]);
}
else
{
omerr
()
<<
"Error setting vertex color"
<<
std
::
endl
;
}
}
break
;
case
1
:
// texture coord
...
...
@@ -648,9 +654,13 @@ read(std::istream& _in, BaseImporter& _bi, Options& _opt)
// Obj counts from 1 and not zero .. array counts from zero therefore -1
if
(
fileOptions
.
vertex_has_normal
()
)
{
assert
(
!
vhandles
.
empty
());
assert
((
unsigned
int
)(
value
-
1
)
<
normals
.
size
());
_bi
.
set_normal
(
vhandles
.
back
(),
normals
[
value
-
1
]);
assert
(
!
vhandles
.
empty
());
if
((
unsigned
int
)(
value
-
1
)
<
normals
.
size
())
{
_bi
.
set_normal
(
vhandles
.
back
(),
normals
[
value
-
1
]);
}
else
{
omerr
()
<<
"Error setting vertex normal"
<<
std
::
endl
;
}
}
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment