more openddl-fixes

pull/3478/head
Kim Kulling 2020-10-26 21:35:44 +01:00
parent 57e691e28e
commit 7e1a8f09c5
3 changed files with 621 additions and 623 deletions

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
@ -45,13 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "PostProcessing/MakeVerboseFormat.h"
#include <assimp/DefaultIOSystem.h>
#include <assimp/DefaultLogger.hpp>
#include <assimp/StringComparison.h>
#include <assimp/DefaultLogger.hpp>
#include <openddlparser/OpenDDLParser.h>
#include <assimp/scene.h>
#include <assimp/ai_assert.h>
#include <assimp/importerdesc.h>
#include <assimp/scene.h>
#include <openddlparser/OpenDDLParser.h>
#include <vector>
@ -218,18 +217,15 @@ static void propId2StdString( Property *prop, std::string &name, std::string &ke
#else
name = prop->m_key->m_buffer;
#endif
if ( Value::ddl_string == prop->m_value->m_type ) {
if (Value::ValueType::ddl_string == prop->m_value->m_type) {
key = prop->m_value->getString();
}
}
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::VertexContainer::VertexContainer()
: m_numColors( 0 )
, m_colors( nullptr )
, m_numUVComps()
, m_textureCoords() {
OpenGEXImporter::VertexContainer::VertexContainer() :
m_numColors(0), m_colors(nullptr), m_numUVComps(), m_textureCoords() {
// empty
}
@ -243,10 +239,10 @@ OpenGEXImporter::VertexContainer::~VertexContainer() {
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::RefInfo::RefInfo( aiNode *node, Type type, std::vector<std::string> &names )
: m_node( node )
, m_type( type )
, m_Names( names ) {
OpenGEXImporter::RefInfo::RefInfo(aiNode *node, Type type, std::vector<std::string> &names) :
m_node(node),
m_type(type),
m_Names(names) {
// empty
}
@ -256,26 +252,26 @@ OpenGEXImporter::RefInfo::~RefInfo() {
}
//------------------------------------------------------------------------------------------------
OpenGEXImporter::OpenGEXImporter()
: m_root( nullptr )
, m_nodeChildMap()
, m_meshCache()
, m_mesh2refMap()
, m_material2refMap()
, m_ctx( nullptr )
, m_metrics()
, m_currentNode( nullptr )
, m_currentVertices()
, m_currentMesh( nullptr )
, m_currentMaterial( nullptr )
, m_currentLight( nullptr )
, m_currentCamera( nullptr )
, m_tokenType( Grammar::NoneType )
, m_materialCache()
, m_cameraCache()
, m_lightCache()
, m_nodeStack()
, m_unresolvedRefStack() {
OpenGEXImporter::OpenGEXImporter() :
m_root(nullptr),
m_nodeChildMap(),
m_meshCache(),
m_mesh2refMap(),
m_material2refMap(),
m_ctx(nullptr),
m_metrics(),
m_currentNode(nullptr),
m_currentVertices(),
m_currentMesh(nullptr),
m_currentMaterial(nullptr),
m_currentLight(nullptr),
m_currentCamera(nullptr),
m_tokenType(Grammar::NoneType),
m_materialCache(),
m_cameraCache(),
m_lightCache(),
m_nodeStack(),
m_unresolvedRefStack() {
// empty
}
@ -443,17 +439,17 @@ void OpenGEXImporter::handleMetricNode( DDLNode *node, aiScene * /*pScene*/ ) {
Property *prop(node->getProperties());
while (nullptr != prop) {
if (nullptr != prop->m_key) {
if( Value::ddl_string == prop->m_value->m_type ) {
if (Value::ValueType::ddl_string == prop->m_value->m_type) {
std::string valName((char *)prop->m_value->m_data);
int type(Grammar::isValidMetricType(valName.c_str()));
if (Grammar::NoneType != type) {
Value *val(node->getValue());
if (nullptr != val) {
if( Value::ddl_float == val->m_type ) {
if (Value::ValueType::ddl_float == val->m_type) {
m_metrics[type].m_floatValue = val->getFloat();
} else if( Value::ddl_int32 == val->m_type ) {
} else if (Value::ValueType::ddl_int32 == val->m_type) {
m_metrics[type].m_intValue = val->getInt32();
} else if( Value::ddl_string == val->m_type ) {
} else if (Value::ValueType::ddl_string == val->m_type) {
m_metrics[type].m_stringValue = std::string(val->getString());
} else {
throw DeadlyImportError("OpenGEX: invalid data type for Metric node.");
@ -475,14 +471,13 @@ void OpenGEXImporter::handleNameNode( DDLNode *node, aiScene * /*pScene*/ ) {
Value *val(node->getValue());
if (nullptr != val) {
if( Value::ddl_string != val->m_type ) {
if (Value::ValueType::ddl_string != val->m_type) {
throw DeadlyImportError("OpenGEX: invalid data type for value in node name.");
return;
}
const std::string name(val->getString());
if( m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken
|| m_tokenType == Grammar::CameraNodeToken ) {
if (m_tokenType == Grammar::GeometryNodeToken || m_tokenType == Grammar::LightNodeToken || m_tokenType == Grammar::CameraNodeToken) {
m_currentNode->mName.Set(name.c_str());
} else if (m_tokenType == Grammar::MaterialToken) {
aiString aiName;

View File

@ -100,7 +100,7 @@ static bool isUnsignedIntegerType(Value::ValueType integerType) {
}
static DDLNode *createDDLNode(Text *id, OpenDDLParser *parser) {
if (nullptr == id || nullptr == parser) {
if (nullptr == id || nullptr == parser || id->m_buffer == nullptr) {
return nullptr;
}
@ -543,6 +543,9 @@ char *OpenDDLParser::parseIdentifier(char *in, char *end, Text **id) {
// ignore blanks
in = lookForNextToken(in, end);
if (in == end) {
return in;
}
// staring with a number is forbidden
if (isNumeric<const char>(*in)) {
@ -861,7 +864,7 @@ char *OpenDDLParser::parseProperty(char *in, char *end, Property **prop) {
}
in = lookForNextToken(in, end);
Text *id(nullptr);
Text *id = nullptr;
in = parseIdentifier(in, end, &id);
if (nullptr != id) {
in = lookForNextToken(in, end);

View File

@ -48,7 +48,7 @@ using namespace Assimp;
class utOpenGEXImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
bool importerTest() override {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0);
return nullptr != scene;