Update Assimp from 5.2.3 to 5.2.5

This commit is contained in:
Bloodknight 2022-10-02 19:02:49 +01:00
parent ea7ca63301
commit 16f3710058
379 changed files with 14469 additions and 47175 deletions

View file

@ -131,7 +131,7 @@ void X3DExporter::AttrHelper_Color3ToAttrList(std::list<SAttribute> &pList, cons
if (pValue == pDefaultValue) return;
AttrHelper_Col3DArrToString(&pValue, 1, tstr);
pList.push_back({ pName, tstr });
pList.emplace_back( pName, tstr );
}
void X3DExporter::AttrHelper_FloatToAttrList(std::list<SAttribute> &pList, const string &pName, const float pValue, const float pDefaultValue) {
@ -140,7 +140,7 @@ void X3DExporter::AttrHelper_FloatToAttrList(std::list<SAttribute> &pList, const
if (pValue == pDefaultValue) return;
AttrHelper_FloatToString(pValue, tstr);
pList.push_back({ pName, tstr });
pList.emplace_back( pName, tstr );
}
void X3DExporter::NodeHelper_OpenNode(const string &pNodeName, const size_t pTabLevel, const bool pEmptyElement, const list<SAttribute> &pAttrList) {
@ -186,7 +186,7 @@ void X3DExporter::Export_Node(const aiNode *pNode, const size_t pTabLevel) {
if (CheckAndExport_Light(*pNode, pTabLevel)) return;
// Check if need DEF.
if (pNode->mName.length) attr_list.push_back({ "DEF", pNode->mName.C_Str() });
if (pNode->mName.length) attr_list.emplace_back( "DEF", pNode->mName.C_Str() );
// Check if need <Transformation> node against <Group>.
if (!pNode->mTransformation.IsIdentity()) {
@ -213,13 +213,13 @@ void X3DExporter::Export_Node(const aiNode *pNode, const size_t pTabLevel) {
pNode->mTransformation.Decompose(scale, rotate_axis, rotate_angle, translate);
// Check if values different from default
if ((rotate_angle != 0) && (rotate_axis.Length() > 0))
attr_list.push_back({ "rotation", Rotation2String(rotate_axis, rotate_angle) });
attr_list.emplace_back( "rotation", Rotation2String(rotate_axis, rotate_angle) );
if (!scale.Equal({ 1.0, 1.0, 1.0 })) {
attr_list.push_back({ "scale", Vector2String(scale) });
attr_list.emplace_back( "scale", Vector2String(scale) );
}
if (translate.Length() > 0) {
attr_list.push_back({ "translation", Vector2String(translate) });
attr_list.emplace_back( "translation", Vector2String(translate) );
}
}
@ -284,7 +284,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
// Check if mesh already defined early.
if (mDEF_Map_Mesh.find(pIdxMesh) != mDEF_Map_Mesh.end()) {
// Mesh already defined, just refer to it
attr_list.push_back({ "USE", mDEF_Map_Mesh.at(pIdxMesh) });
attr_list.emplace_back( "USE", mDEF_Map_Mesh.at(pIdxMesh) );
NodeHelper_OpenNode(NodeName_Shape, pTabLevel, true, attr_list);
return;
@ -293,7 +293,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
string mesh_name(mesh.mName.C_Str() + string("_IDX_") + to_string(pIdxMesh)); // Create mesh name
// Define mesh name.
attr_list.push_back({ "DEF", mesh_name });
attr_list.emplace_back( "DEF", mesh_name );
mDEF_Map_Mesh[pIdxMesh] = mesh_name;
//
@ -327,7 +327,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
// remove last space symbol.
coordIndex.resize(coordIndex.length() - 1);
attr_list.push_back({ "coordIndex", coordIndex });
attr_list.emplace_back( "coordIndex", coordIndex );
// create node
NodeHelper_OpenNode(NodeName_IFS, pTabLevel + 1, false, attr_list);
attr_list.clear();
@ -336,14 +336,14 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
// Export <Coordinate>
AttrHelper_Vec3DArrToString(mesh.mVertices, mesh.mNumVertices, attr_value);
attr_list.push_back({ "point", attr_value });
attr_list.emplace_back( "point", attr_value );
NodeHelper_OpenNode("Coordinate", pTabLevel + 2, true, attr_list);
attr_list.clear();
// Export <ColorRGBA>
if (mesh.HasVertexColors(0)) {
AttrHelper_Col4DArrToString(mesh.mColors[0], mesh.mNumVertices, attr_value);
attr_list.push_back({ "color", attr_value });
attr_list.emplace_back( "color", attr_value );
NodeHelper_OpenNode("ColorRGBA", pTabLevel + 2, true, attr_list);
attr_list.clear();
}
@ -351,7 +351,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
// Export <TextureCoordinate>
if (mesh.HasTextureCoords(0)) {
AttrHelper_Vec3DAsVec2fArrToString(mesh.mTextureCoords[0], mesh.mNumVertices, attr_value);
attr_list.push_back({ "point", attr_value });
attr_list.emplace_back( "point", attr_value );
NodeHelper_OpenNode("TextureCoordinate", pTabLevel + 2, true, attr_list);
attr_list.clear();
}
@ -359,7 +359,7 @@ void X3DExporter::Export_Mesh(const size_t pIdxMesh, const size_t pTabLevel) {
// Export <Normal>
if (mesh.HasNormals()) {
AttrHelper_Vec3DArrToString(mesh.mNormals, mesh.mNumVertices, attr_value);
attr_list.push_back({ "vector", attr_value });
attr_list.emplace_back( "vector", attr_value );
NodeHelper_OpenNode("Normal", pTabLevel + 2, true, attr_list);
attr_list.clear();
}
@ -380,7 +380,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
// Check if material already defined early.
if (mDEF_Map_Material.find(pIdxMaterial) != mDEF_Map_Material.end()) {
// Material already defined, just refer to it
attr_list.push_back({ "USE", mDEF_Map_Material.at(pIdxMaterial) });
attr_list.emplace_back( "USE", mDEF_Map_Material.at(pIdxMaterial) );
NodeHelper_OpenNode(NodeName_A, pTabLevel, true, attr_list);
return;
@ -392,7 +392,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
if (material.Get(AI_MATKEY_NAME, ai_mat_name) == AI_SUCCESS) material_name.insert(0, ai_mat_name.C_Str());
// Define material name.
attr_list.push_back({ "DEF", material_name });
attr_list.emplace_back( "DEF", material_name );
mDEF_Map_Material[pIdxMaterial] = material_name;
//
@ -410,7 +410,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
if (aiColor3D(pAttrValue.r, pAttrValue.g, pAttrValue.b) != pAttrDefaultValue) {
AttrHelper_Col4DArrToString(&pAttrValue, 1, tstr);
attr_list.push_back({ pAttrName, tstr });
attr_list.emplace_back( pAttrName, tstr );
}
};
@ -462,7 +462,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
//
{
auto RepeatToAttrList = [&](const string &pAttrName, const bool pAttrValue) {
if (!pAttrValue) attr_list.push_back({ pAttrName, "false" });
if (!pAttrValue) attr_list.emplace_back( pAttrName, "false" );
};
bool tvalb;
@ -473,7 +473,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
if (strncmp(tstring.C_Str(), AI_EMBEDDED_TEXNAME_PREFIX, strlen(AI_EMBEDDED_TEXNAME_PREFIX)) == 0)
LogError("Embedded texture is not supported");
else
attr_list.push_back({ "url", string("\"") + tstring.C_Str() + "\"" });
attr_list.emplace_back( "url", string("\"") + tstring.C_Str() + "\"" );
}
// repeatS="true" SFBool
@ -495,7 +495,7 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
if (pAttrValue != pAttrDefaultValue) {
AttrHelper_Vec2DArrToString(&pAttrValue, 1, tstr);
attr_list.push_back({ pAttrName, tstr });
attr_list.emplace_back( pAttrName, tstr );
}
};
@ -520,40 +520,40 @@ void X3DExporter::Export_Material(const size_t pIdxMaterial, const size_t pTabLe
void X3DExporter::Export_MetadataBoolean(const aiString &pKey, const bool pValue, const size_t pTabLevel) {
list<SAttribute> attr_list;
attr_list.push_back({ "name", pKey.C_Str() });
attr_list.push_back({ "value", pValue ? "true" : "false" });
attr_list.emplace_back( "name", pKey.C_Str() );
attr_list.emplace_back( "value", pValue ? "true" : "false" );
NodeHelper_OpenNode("MetadataBoolean", pTabLevel, true, attr_list);
}
void X3DExporter::Export_MetadataDouble(const aiString &pKey, const double pValue, const size_t pTabLevel) {
list<SAttribute> attr_list;
attr_list.push_back({ "name", pKey.C_Str() });
attr_list.push_back({ "value", to_string(pValue) });
attr_list.emplace_back( "name", pKey.C_Str() );
attr_list.emplace_back( "value", to_string(pValue) );
NodeHelper_OpenNode("MetadataDouble", pTabLevel, true, attr_list);
}
void X3DExporter::Export_MetadataFloat(const aiString &pKey, const float pValue, const size_t pTabLevel) {
list<SAttribute> attr_list;
attr_list.push_back({ "name", pKey.C_Str() });
attr_list.push_back({ "value", to_string(pValue) });
attr_list.emplace_back( "name", pKey.C_Str() );
attr_list.emplace_back( "value", to_string(pValue) );
NodeHelper_OpenNode("MetadataFloat", pTabLevel, true, attr_list);
}
void X3DExporter::Export_MetadataInteger(const aiString &pKey, const int32_t pValue, const size_t pTabLevel) {
list<SAttribute> attr_list;
attr_list.push_back({ "name", pKey.C_Str() });
attr_list.push_back({ "value", to_string(pValue) });
attr_list.emplace_back( "name", pKey.C_Str() );
attr_list.emplace_back( "value", to_string(pValue) );
NodeHelper_OpenNode("MetadataInteger", pTabLevel, true, attr_list);
}
void X3DExporter::Export_MetadataString(const aiString &pKey, const aiString &pValue, const size_t pTabLevel) {
list<SAttribute> attr_list;
attr_list.push_back({ "name", pKey.C_Str() });
attr_list.push_back({ "value", pValue.C_Str() });
attr_list.emplace_back( "name", pKey.C_Str() );
attr_list.emplace_back( "value", pValue.C_Str() );
NodeHelper_OpenNode("MetadataString", pTabLevel, true, attr_list);
}
@ -565,7 +565,7 @@ bool X3DExporter::CheckAndExport_Light(const aiNode &pNode, const size_t pTabLev
if (pAttrValue != pAttrDefaultValue) {
AttrHelper_Vec3DArrToString(&pAttrValue, 1, tstr);
attr_list.push_back({ pAttrName, tstr });
attr_list.emplace_back( pAttrName, tstr );
}
};
@ -590,8 +590,8 @@ bool X3DExporter::CheckAndExport_Light(const aiNode &pNode, const size_t pTabLev
aiMatrix4x4 trafo_mat = Matrix_GlobalToCurrent(pNode).Inverse();
attr_list.push_back({ "DEF", light.mName.C_Str() });
attr_list.push_back({ "global", "true" }); // "false" is not supported.
attr_list.emplace_back( "DEF", light.mName.C_Str() );
attr_list.emplace_back( "global", "true" ); // "false" is not supported.
// ambientIntensity="0" SFFloat [inputOutput]
AttrHelper_FloatToAttrList(attr_list, "ambientIntensity", aiVector3D(light.mColorAmbient.r, light.mColorAmbient.g, light.mColorAmbient.b).Length(), 0);
// color="1 1 1" SFColor [inputOutput]
@ -648,10 +648,10 @@ X3DExporter::X3DExporter(const char *pFileName, IOSystem *pIOSystem, const aiSce
XML_Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
XML_Write("<!DOCTYPE X3D PUBLIC \"ISO//Web3D//DTD X3D 3.3//EN\" \"http://www.web3d.org/specifications/x3d-3.3.dtd\">\n");
// Root node
attr_list.push_back({ "profile", "Interchange" });
attr_list.push_back({ "version", "3.3" });
attr_list.push_back({ "xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance" });
attr_list.push_back({ "xsd:noNamespaceSchemaLocation", "http://www.web3d.org/specifications/x3d-3.3.xsd" });
attr_list.emplace_back( "profile", "Interchange" );
attr_list.emplace_back( "version", "3.3" );
attr_list.emplace_back( "xmlns:xsd", "http://www.w3.org/2001/XMLSchema-instance" );
attr_list.emplace_back( "xsd:noNamespaceSchemaLocation", "http://www.web3d.org/specifications/x3d-3.3.xsd" );
NodeHelper_OpenNode("X3D", 0, false, attr_list);
attr_list.clear();
// <head>: meta data.

View file

@ -241,7 +241,7 @@ public:
/// \fn ~X3DExporter()
/// Default destructor.
~X3DExporter() {}
~X3DExporter() = default;
}; // class X3DExporter

View file

@ -193,7 +193,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::list<aiColor3D> &pColors,
// create RGBA array from RGB.
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it)
tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1));
tcol.emplace_back((*it).r, (*it).g, (*it).b, 1);
// call existing function for adding RGBA colors
add_color(pMesh, tcol, pColorPerVertex);
@ -238,7 +238,7 @@ void X3DGeoHelper::add_color(aiMesh &pMesh, const std::vector<int32_t> &pCoordId
// create RGBA array from RGB.
for (std::list<aiColor3D>::const_iterator it = pColors.begin(); it != pColors.end(); ++it) {
tcol.push_back(aiColor4D((*it).r, (*it).g, (*it).b, 1));
tcol.emplace_back((*it).r, (*it).g, (*it).b, 1);
}
// call existing function for adding RGBA colors
@ -440,7 +440,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::vector<int32_t> &pCoo
// copy list to array because we are need indexed access to normals.
texcoord_arr_copy.reserve(pTexCoords.size());
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
texcoord_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0));
texcoord_arr_copy.emplace_back((*it).x, (*it).y, 0);
}
if (pTexCoordIdx.size() > 0) {
@ -480,7 +480,7 @@ void X3DGeoHelper::add_tex_coord(aiMesh &pMesh, const std::list<aiVector2D> &pTe
// copy list to array because we are need convert aiVector2D to aiVector3D and also get indexed access as a bonus.
tc_arr_copy.reserve(pTexCoords.size());
for (std::list<aiVector2D>::const_iterator it = pTexCoords.begin(); it != pTexCoords.end(); ++it) {
tc_arr_copy.push_back(aiVector3D((*it).x, (*it).y, 0));
tc_arr_copy.emplace_back((*it).x, (*it).y, 0);
}
// copy texture coordinates to mesh

View file

@ -333,7 +333,7 @@ void X3DImporter::readHead(XmlNode &node) {
}
mScene->mMetaData = aiMetadata::Alloc(static_cast<unsigned int>(metaArray.size()));
unsigned int i = 0;
for (auto currentMeta : metaArray) {
for (const auto& currentMeta : metaArray) {
mScene->mMetaData->Set(i, currentMeta.name, aiString(currentMeta.value));
++i;
}
@ -477,9 +477,6 @@ void X3DImporter::ParseHelper_Node_Exit() {
// check if we can walk up.
if (mNodeElementCur != nullptr) {
mNodeElementCur = mNodeElementCur->Parent;
} else {
int i = 0;
++i;
}
}

View file

@ -270,7 +270,7 @@ public:
void Clear();
private:
X3DNodeElementBase *MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE);
X3DNodeElementBase *MACRO_USE_CHECKANDAPPLY(XmlNode &node, const std::string &pDEF, const std::string &pUSE, X3DElemType pType, X3DNodeElementBase *pNE);
bool isNodeEmpty(XmlNode &node);
void checkNodeMustBeEmpty(XmlNode &node);
void skipUnsupportedNode(const std::string &pParentNodeName, XmlNode &node);

View file

@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2019, assimp team
Copyright (c) 2006-2022, assimp team
All rights reserved.
@ -152,7 +151,7 @@ void X3DImporter::readArcClose2D(XmlNode &node) {
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
if ((closureType == "PIE") || (closureType == "\"PIE\""))
vlist.push_back(aiVector3D(0, 0, 0)); // center point - first radial line
vlist.emplace_back(0, 0, 0); // center point - first radial line
else if ((closureType != "CHORD") && (closureType != "\"CHORD\""))
Throw_IncorrectAttrValue("ArcClose2D", "closureType");
@ -262,22 +261,25 @@ void X3DImporter::readDisk2D(XmlNode &node) {
//
// create quad list from two point lists
//
if (tlist_i.size() < 2) throw DeadlyImportError("Disk2D. Not enough points for creating quad list."); // tlist_i and tlist_o has equal size.
if (tlist_i.size() < 2) {
// tlist_i and tlist_o has equal size.
throw DeadlyImportError("Disk2D. Not enough points for creating quad list.");
}
// add all quads except last
for (std::list<aiVector3D>::iterator it_i = tlist_i.begin(), it_o = tlist_o.begin(); it_i != tlist_i.end();) {
// do not forget - CCW direction
vlist.push_back(*it_i++); // 1st point
vlist.push_back(*it_o++); // 2nd point
vlist.push_back(*it_o); // 3rd point
vlist.push_back(*it_i); // 4th point
vlist.emplace_back(*it_i++); // 1st point
vlist.emplace_back(*it_o++); // 2nd point
vlist.emplace_back(*it_o); // 3rd point
vlist.emplace_back(*it_i); // 4th point
}
// add last quad
vlist.push_back(*tlist_i.end()); // 1st point
vlist.push_back(*tlist_o.end()); // 2nd point
vlist.push_back(*tlist_o.begin()); // 3rd point
vlist.push_back(*tlist_o.begin()); // 4th point
vlist.emplace_back(tlist_i.back()); // 1st point
vlist.emplace_back(tlist_o.back()); // 2nd point
vlist.emplace_back(tlist_o.front()); // 3rd point
vlist.emplace_back(tlist_i.front()); // 4th point
((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
}
@ -321,7 +323,7 @@ void X3DImporter::readPolyline2D(XmlNode &node) {
// convert vec2 to vec3
for (std::list<aiVector2D>::iterator it2 = lineSegments.begin(); it2 != lineSegments.end(); ++it2)
tlist.push_back(aiVector3D(it2->x, it2->y, 0));
tlist.emplace_back(it2->x, it2->y, 0);
// convert point set to line set
X3DGeoHelper::extend_point_to_line(tlist, ((X3DNodeElementGeometry2D *)ne)->Vertices);
@ -359,7 +361,7 @@ void X3DImporter::readPolypoint2D(XmlNode &node) {
// convert vec2 to vec3
for (std::list<aiVector2D>::iterator it2 = point.begin(); it2 != point.end(); ++it2) {
((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0));
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0);
}
((X3DNodeElementGeometry2D *)ne)->NumIndices = 1;
@ -403,10 +405,10 @@ void X3DImporter::readRectangle2D(XmlNode &node) {
float y2 = size.y / 2.0f;
std::list<aiVector3D> &vlist = ((X3DNodeElementGeometry2D *)ne)->Vertices; // just short alias.
vlist.push_back(aiVector3D(x2, y1, 0)); // 1st point
vlist.push_back(aiVector3D(x2, y2, 0)); // 2nd point
vlist.push_back(aiVector3D(x1, y2, 0)); // 3rd point
vlist.push_back(aiVector3D(x1, y1, 0)); // 4th point
vlist.emplace_back(x2, y1, 0); // 1st point
vlist.emplace_back(x2, y2, 0); // 2nd point
vlist.emplace_back(x1, y2, 0); // 3rd point
vlist.emplace_back(x1, y1, 0); // 4th point
((X3DNodeElementGeometry2D *)ne)->Solid = solid;
((X3DNodeElementGeometry2D *)ne)->NumIndices = 4;
// check for X3DMetadataObject childs.
@ -447,7 +449,7 @@ void X3DImporter::readTriangleSet2D(XmlNode &node) {
// convert vec2 to vec3
for (std::list<aiVector2D>::iterator it2 = vertices.begin(); it2 != vertices.end(); ++it2) {
((X3DNodeElementGeometry2D *)ne)->Vertices.push_back(aiVector3D(it2->x, it2->y, 0));
((X3DNodeElementGeometry2D *)ne)->Vertices.emplace_back(it2->x, it2->y, 0);
}
((X3DNodeElementGeometry2D *)ne)->Solid = solid;

View file

@ -59,7 +59,7 @@ namespace Assimp {
/// \param [in] pUSE - string holding "USE" value.
/// \param [in] pType - type of element to find.
/// \param [out] pNE - pointer to found node element.
inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, std::string pDEF, std::string pUSE, X3DElemType pType, X3DNodeElementBase *pNE) {
inline X3DNodeElementBase *X3DImporter::MACRO_USE_CHECKANDAPPLY(XmlNode &node, const std::string &pDEF, const std::string &pUSE, X3DElemType pType, X3DNodeElementBase *pNE) {
checkNodeMustBeEmpty(node);
if (!pDEF.empty())
Assimp::Throw_DEF_And_USE(node.name());