Compare commits

...

6 Commits

Author SHA1 Message Date
Kim Kulling
9a9e4b4a59 Update ObjTools.h 2025-12-25 21:42:41 +01:00
Kim Kulling
ea7f710d70 Update glTF2Asset.h 2025-12-25 21:34:49 +01:00
Kim Kulling
93f3c38ceb Refactor ObjFileParser for improved readability#
Refactor handling of cstype section end and material descriptor parsing.
2025-12-25 21:03:29 +01:00
Kim Kulling
0a9cefe943 Refactor insideCstype condition for clarity 2025-12-25 21:01:46 +01:00
Kim Kulling
daa6d64227 Clean up commented code in ObjFileParser.cpp
Removed commented-out code related to material name parsing.
2025-12-25 20:56:55 +01:00
Kim Kulling
04946cc0f4 Add new presents 2025-12-08 23:43:28 +01:00
4 changed files with 61 additions and 40 deletions

View File

@@ -1,17 +1,54 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "assimp",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF"
}
},
"configurePresets": [
{
"name": "assimp_with_tools",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS" : "ON"
}
}
]
{
"name": "assimp_static",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_SHARED_LIBS": "OFF",
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
"ASSIMP_DOUBLE_PRECISION": "ON"
}
},
{
"name": "assimp_double_precision",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
"ASSIMP_DOUBLE_PRECISION": "ON"
}
},
{
"name": "assimp_with_tools",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON"
}
},
{
"name": "assimp_all",
"binaryDir": "${sourceDir}",
"cacheVariables": {
"ASSIMP_BUILD_ASSIMP_TOOLS": "ON",
"ASSIMP_BUILD_SAMPLES": "ON",
"ASSIMP_BUILD_DOCS": "ON"
}
}
]
}

View File

@@ -139,13 +139,12 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
// handle c-stype section end (http://paulbourke.net/dataformats/obj/)
if (insideCstype) {
switch (*m_DataIt) {
case 'e': {
char *name{nullptr};
size_t len{0};
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//insideCstype = name != "end";
insideCstype = strncmp(name, "end", len) == 0;
} break;
case 'e': {
char *name{nullptr};
size_t len{0};
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
insideCstype = !(len == 3 && strncmp(name, "end", 3) == 0);
} break;
}
goto pf_skip_line;
}
@@ -200,16 +199,10 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
case 'u': // Parse a material desc. setter
{
//std::string name;
char *name{nullptr};
size_t len{ 0 };
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//size_t nextSpace = name.find(' ');
//if (nextSpace != std::string::npos)
// name = name.substr(0, nextSpace);
//if (name == "usemtl") {
if (strncmp(name, "usemtl", len) == 0) {
getMaterialDesc();
}
@@ -217,19 +210,11 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
case 'm': // Parse a material library or merging group ('mg')
{
// std::string name;
char *name{nullptr};
size_t len{ 0 };
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//size_t nextSpace = name.find(' ');
//if (nextSpace != std::string::npos)
// name = name.substr(0, nextSpace);
if (strncmp(name, "mg", len) == 0)
//if (name == "mg")
getGroupNumberAndResolution();
//else if (name == "mtllib")
else if (strncmp(name, "mtllib", len) == 0)
getMaterialLib();
else
@@ -257,7 +242,6 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
char *name{nullptr};
size_t len{0};
getNameNoSpace(m_DataIt, m_DataItEnd, &name, len);
//insideCstype = name == "cstype";
insideCstype = strncmp(name, "cstype", len) == 0;
goto pf_skip_line;
}

View File

@@ -185,6 +185,10 @@ inline char_t getNameNoSpace(char_t it, char_t end, char **name, size_t &len) {
}
char *pStart = &(*it);
while (&(*it) > pStart && (isEndOfBuffer(it, end) || IsLineEnd(*it) || IsSpaceOrNewLine(*it))) {
--it;
--len;
}
while (!isEndOfBuffer(it, end) && !IsLineEnd(*it) && !IsSpaceOrNewLine(*it)) {
++it;
++len;

View File

@@ -58,8 +58,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef GLTF2ASSET_H_INC
#define GLTF2ASSET_H_INC
//#if !defined(ASSIMP_BUILD_NO_GLTF_IMPORTER) && !defined(ASSIMP_BUILD_NO_GLTF2_IMPORTER)
#include <assimp/Exceptional.h>
#include <algorithm>
@@ -1283,6 +1281,4 @@ inline std::string getContextForErrorMessages(const std::string &id, const std::
// Include the implementation of the methods
#include "glTF2Asset.inl"
//#endif // ASSIMP_BUILD_NO_GLTF_IMPORTER
#endif // GLTF2ASSET_H_INC