[opengex] Direct OpenDDLParser log messages to assimp logger

Also filter unprintable characters. Addresses second part of #3862.
pull/3881/head
Jason C 2021-05-04 03:32:49 -04:00 committed by Jason C
parent 558457e5bf
commit f8609c2c2d
1 changed files with 14 additions and 0 deletions

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultIOSystem.h>
#include <assimp/StringComparison.h>
#include <assimp/StringUtils.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/ai_assert.h>
@ -223,6 +224,18 @@ static void propId2StdString(Property *prop, std::string &name, std::string &key
}
}
//------------------------------------------------------------------------------------------------
static void logDDLParserMessage (LogSeverity severity, const std::string &rawmsg) {
std::string msg = ai_str_toprintable(rawmsg);
switch (severity) {
case ddl_debug_msg: ASSIMP_LOG_DEBUG(msg); break;
case ddl_info_msg: ASSIMP_LOG_INFO(msg); break;
case ddl_warn_msg: ASSIMP_LOG_WARN(msg); break;
case ddl_error_msg: ASSIMP_LOG_ERROR(msg); break;
default: ASSIMP_LOG_VERBOSE_DEBUG(msg); break;
}
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::VertexContainer::VertexContainer() :
m_numColors(0), m_colors(nullptr), m_numUVComps(), m_textureCoords() {
@ -306,6 +319,7 @@ void OpenGEXImporter::InternReadFile(const std::string &filename, aiScene *pScen
pIOHandler->Close(file);
OpenDDLParser myParser;
myParser.setLogCallback(&logDDLParserMessage);
myParser.setBuffer(&buffer[0], buffer.size());
bool success(myParser.parse());
if (success) {