Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ACGL
acgl
Commits
e5e22691
Commit
e5e22691
authored
May 28, 2014
by
Martin Schultz
Browse files
* further performance enhancements
parent
211adda7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ACGL/OpenGL/Data/GeometryDataLoadStoreOBJ.cc
View file @
e5e22691
...
...
@@ -89,6 +89,7 @@ namespace
std
::
vector
<
IndexTuple
>
parseIndices
(
const
char
*
_start
,
const
char
*
_end
)
{
std
::
vector
<
IndexTuple
>
indices
;
indices
.
reserve
(
5
);
const
char
*
it
=
_start
;
if
(
*
it
==
' '
)
//skip starting whitespace
...
...
@@ -96,8 +97,6 @@ namespace
const
char
*
vsit
;
const
char
*
vsend
;
const
char
*
foundSlash
;
std
::
string
vertexString
;
std
::
string
component
;
int
componentIndex
;
int
index
;
while
(
it
<
_end
)
...
...
@@ -106,19 +105,18 @@ namespace
vsend
=
std
::
find
(
it
,
_end
,
' '
);
componentIndex
=
0
;
IndexTuple
indexTuple
;
indices
.
push_back
(
indexTuple
);
//process the string now meaning we split by /
while
(
vsit
<
vsend
)
{
foundSlash
=
std
::
find
(
vsit
,
vsend
,
'/'
);
index
=
std
::
atoi
(
vsit
);
if
(
componentIndex
==
0
)
ind
ices
.
back
()
.
position
=
index
-
1
;
if
(
componentIndex
==
1
)
ind
ices
.
back
()
.
texCoord
=
index
-
1
;
if
(
componentIndex
==
2
)
ind
ices
.
back
()
.
normal
=
index
-
1
;
if
(
componentIndex
==
0
)
ind
exTuple
.
position
=
index
-
1
;
if
(
componentIndex
==
1
)
ind
exTuple
.
texCoord
=
index
-
1
;
if
(
componentIndex
==
2
)
ind
exTuple
.
normal
=
index
-
1
;
componentIndex
++
;
vsit
=
foundSlash
==
vsend
?
vsend
:
foundSlash
+
1
;
}
//
indices.push_back(indexTuple);
indices
.
push_back
(
indexTuple
);
it
=
vsend
==
_end
?
_end
:
vsend
+
1
;
}
return
indices
;
...
...
@@ -157,7 +155,8 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
std
::
vector
<
IndexTuple
>
indices
;
std
::
string
keyword
;
const
char
*
keyword
;
size_t
keywordLength
;
const
char
*
parameters
[
2
];
while
(
pchBuf
<
pchEnd
)
{
...
...
@@ -173,11 +172,12 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
// Otherwise, extract the first word and the remainder
const
char
*
pchKey
=
std
::
find
(
pchBuf
,
pchEnd
,
' '
);
keyword
=
std
::
string
(
pchBuf
,
pchKey
);
keyword
=
pchBuf
;
keywordLength
=
pchKey
-
pchBuf
;
//std::string(pchBuf, pchKey);
parameters
[
0
]
=
pchKey
+
1
;
parameters
[
1
]
=
pchEOL
;
if
(
keyword
==
"v"
)
// vertex position
if
(
strncmp
(
keyword
,
"v"
,
keywordLength
)
==
0
)
// vertex position
{
glm
::
vec4
position
;
int
dimension
;
...
...
@@ -192,7 +192,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
positionData
.
push_back
(
position
);
}
else
if
(
keyword
==
"vt"
)
// vertex tex coord
else
if
(
strncmp
(
keyword
,
"vt"
,
keywordLength
)
==
0
)
// vertex tex coord
{
glm
::
vec3
texCoord
;
int
dimension
;
...
...
@@ -210,7 +210,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
texCoordData
.
push_back
(
texCoord
);
}
else
if
(
keyword
==
"vn"
)
// vertex normal
else
if
(
strncmp
(
keyword
,
"vn"
,
keywordLength
)
==
0
)
// vertex normal
{
glm
::
vec3
normal
;
int
dimension
;
...
...
@@ -226,7 +226,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
normalData
.
push_back
(
normal
);
}
else
if
(
keyword
==
"p"
)
// point
else
if
(
strncmp
(
keyword
,
"p"
,
keywordLength
)
==
0
)
// point
{
if
(
primitiveType
==
GL_INVALID_ENUM
)
primitiveType
=
GL_POINTS
;
...
...
@@ -243,7 +243,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
indices
.
push_back
(
pointIndices
[
i
]);
}
}
else
if
(
keyword
==
"l"
)
// line
else
if
(
strncmp
(
keyword
,
"l"
,
keywordLength
)
==
0
)
// line
{
if
(
primitiveType
==
GL_INVALID_ENUM
)
primitiveType
=
GL_LINES
;
...
...
@@ -261,7 +261,7 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
indices
.
push_back
(
lineIndices
[
i
+
1
]);
}
}
else
if
(
keyword
==
"f"
)
// face
else
if
(
strncmp
(
keyword
,
"f"
,
keywordLength
)
==
0
)
// face
{
if
(
primitiveType
==
GL_INVALID_ENUM
)
primitiveType
=
GL_TRIANGLES
;
...
...
@@ -280,24 +280,24 @@ SharedGeometryData loadGeometryDataFromOBJ(const std::string& _filename, bool _c
indices
.
push_back
(
faceIndices
[
i
+
1
]);
}
}
else
if
(
keyword
==
"bevel"
||
keyword
==
"bmat"
||
keyword
==
"bsp"
||
keyword
==
"bzp"
||
keyword
==
"c_interp"
||
keyword
==
"cdc"
||
keyword
==
"cdp"
||
keyword
==
"con"
||
keyword
==
"cstype"
||
keyword
==
"ctech"
||
keyword
==
"curv"
||
keyword
==
"curv2"
||
keyword
==
"d_interp"
||
keyword
==
"deg"
||
keyword
==
"end"
||
keyword
==
"g"
||
keyword
==
"hole"
||
keyword
==
"lod"
||
keyword
==
"maplib"
||
keyword
==
"mg"
||
keyword
==
"mtllib"
||
keyword
==
"o"
||
keyword
==
"parm"
||
keyword
==
"res"
||
keyword
==
"s"
||
keyword
==
"scrv"
||
keyword
==
"shadow_obj"
||
keyword
==
"sp"
||
keyword
==
"stech"
||
keyword
==
"step"
||
keyword
==
"surf"
||
keyword
==
"trace_obj"
||
keyword
==
"trim"
||
keyword
==
"usemap"
||
keyword
==
"usemtl"
||
keyword
==
"vp"
)
else
if
(
strncmp
(
keyword
,
"bevel"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"bmat"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"bsp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"bzp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"c_interp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"cdc"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"cdp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"con"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"cstype"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"ctech"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"curv"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"curv2"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"d_interp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"deg"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"end"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"g"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"hole"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"lod"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"maplib"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"mg"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"mtllib"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"o"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"parm"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"res"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"s"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"scrv"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"shadow_obj"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"sp"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"stech"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"step"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"surf"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"trace_obj"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"trim"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"usemap"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"usemtl"
,
keywordLength
)
==
0
||
strncmp
(
keyword
,
"vp"
,
keywordLength
)
==
0
)
{
// part of the OBJ specification (i.e. non-polygonal geometry, object groups, etc.)
// is not supported and is silently ignored
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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