Fix namespaces.

pull/5282/head^2
Kim Kulling 2023-11-11 21:13:47 +01:00 committed by Kim Kulling
parent 8cf2d6e588
commit 4535e37fc6
22 changed files with 121 additions and 98 deletions

View File

@ -52,9 +52,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cctype> #include <cctype>
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
static const unsigned int NotSet = 0xcdcdcdcd; static constexpr unsigned int NotSet = 0xcdcdcdcd;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Setup final material indices, generae a default material if necessary // Setup final material indices, generae a default material if necessary
@ -68,7 +68,7 @@ void Discreet3DSImporter::ReplaceDefaultMaterial() {
unsigned int idx(NotSet); unsigned int idx(NotSet);
for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) { for (unsigned int i = 0; i < mScene->mMaterials.size(); ++i) {
std::string s = mScene->mMaterials[i].mName; std::string s = mScene->mMaterials[i].mName;
for (char & it : s) { for (char &it : s) {
it = static_cast<char>(::tolower(static_cast<unsigned char>(it))); it = static_cast<char>(::tolower(static_cast<unsigned char>(it)));
} }
@ -805,4 +805,6 @@ void Discreet3DSImporter::ConvertScene(aiScene *pcOut) {
} }
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER #endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER

View File

@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team Copyright (c) 2006-2022, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -57,8 +56,7 @@ struct aiNode;
struct aiMaterial; struct aiMaterial;
struct aiMesh; struct aiMesh;
namespace Assimp namespace Assimp {
{
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/** /**
@ -88,7 +86,7 @@ private:
std::map<const aiNode*, aiMatrix4x4> trafos; std::map<const aiNode*, aiMatrix4x4> trafos;
typedef std::multimap<const aiNode*, unsigned int> MeshesByNodeMap; using MeshesByNodeMap = std::multimap<const aiNode*, unsigned int>;
MeshesByNodeMap meshes; MeshesByNodeMap meshes;
}; };

View File

@ -54,7 +54,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
using namespace Assimp; namespace Assimp {
static constexpr aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"Discreet 3DS Importer", "Discreet 3DS Importer",
@ -1335,4 +1335,6 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D *out, bool acceptPercent) {
(void)bGamma; (void)bGamma;
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER #endif // !! ASSIMP_BUILD_NO_3DS_IMPORTER

View File

@ -81,10 +81,6 @@ static constexpr aiImporterDesc desc = {
"3mf" "3mf"
}; };
D3MFImporter::D3MFImporter() = default;
D3MFImporter::~D3MFImporter() = default;
bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const { bool D3MFImporter::CanRead(const std::string &filename, IOSystem *pIOHandler, bool /*checkSig*/) const {
if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) { if (!ZipArchiveIOSystem::isZipArchive(pIOHandler, filename)) {
return false; return false;

View File

@ -56,10 +56,10 @@ namespace Assimp {
class D3MFImporter : public BaseImporter { class D3MFImporter : public BaseImporter {
public: public:
/// @brief The default class constructor. /// @brief The default class constructor.
D3MFImporter(); D3MFImporter() = default;
/// @brief The class destructor. /// @brief The class destructor.
~D3MFImporter() override; ~D3MFImporter() override = default;
/// @brief Performs the data format detection. /// @brief Performs the data format detection.
/// @param pFile The filename to check. /// @param pFile The filename to check.

View File

@ -68,7 +68,7 @@ using OpcPackageRelationshipPtr = std::shared_ptr<OpcPackageRelationship>;
class OpcPackageRelationshipReader { class OpcPackageRelationshipReader {
public: public:
OpcPackageRelationshipReader(XmlParser &parser) : OpcPackageRelationshipReader(XmlParser &parser) :
m_relationShips() { mRelations() {
XmlNode root = parser.getRootNode(); XmlNode root = parser.getRootNode();
ParseRootNode(root); ParseRootNode(root);
} }
@ -108,13 +108,13 @@ public:
relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string(); relPtr->type = currentNode.attribute(XmlTag::RELS_ATTRIB_TYPE).as_string();
relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string(); relPtr->target = currentNode.attribute(XmlTag::RELS_ATTRIB_TARGET).as_string();
if (validateRels(relPtr)) { if (validateRels(relPtr)) {
m_relationShips.push_back(relPtr); mRelations.push_back(relPtr);
} }
} }
} }
} }
std::vector<OpcPackageRelationshipPtr> m_relationShips; std::vector<OpcPackageRelationshipPtr> mRelations;
}; };
static bool IsEmbeddedTexture( const std::string &filename ) { static bool IsEmbeddedTexture( const std::string &filename ) {
@ -217,11 +217,11 @@ std::string D3MFOpcPackage::ReadPackageRootRelationship(IOStream *stream) {
OpcPackageRelationshipReader reader(xmlParser); OpcPackageRelationshipReader reader(xmlParser);
auto itr = std::find_if(reader.m_relationShips.begin(), reader.m_relationShips.end(), [](const OpcPackageRelationshipPtr &rel) { auto itr = std::find_if(reader.mRelations.begin(), reader.mRelations.end(), [](const OpcPackageRelationshipPtr &rel) {
return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE; return rel->type == XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE;
}); });
if (itr == reader.m_relationShips.end()) { if (itr == reader.mRelations.end()) {
throw DeadlyImportError("Cannot find ", XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE); throw DeadlyImportError("Cannot find ", XmlTag::PACKAGE_START_PART_RELATIONSHIP_TYPE);
} }

View File

@ -49,12 +49,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp { namespace Assimp {
namespace D3MF { namespace D3MF {
static const int IdNotSet = -1; static constexpr int IdNotSet = -1;
namespace { namespace {
static const size_t ColRGBA_Len = 9; static constexpr size_t ColRGBA_Len = 9;
static const size_t ColRGB_Len = 7; static constexpr size_t ColRGB_Len = 7;
// format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1) // format of the color string: #RRGGBBAA or #RRGGBB (3MF Core chapter 5.1.1)
bool validateColorString(const char *color) { bool validateColorString(const char *color) {

View File

@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
static constexpr aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"AC3D Importer", "AC3D Importer",
@ -862,4 +862,6 @@ void AC3DImporter::InternReadFile(const std::string &pFile,
} }
} }
} // namespace Assimp
#endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER #endif //!defined ASSIMP_BUILD_NO_AC_IMPORTER

View File

@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// utilities // utilities
#include <assimp/fast_atof.h> #include <assimp/fast_atof.h>
using namespace Assimp; namespace Assimp {
using namespace Assimp::ASE; using namespace Assimp::ASE;
static constexpr aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
@ -1262,6 +1262,8 @@ bool ASEImporter::GenerateNormals(ASE::Mesh &mesh) {
return false; return false;
} }
}
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER #endif // ASSIMP_BUILD_NO_3DS_IMPORTER
#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER #endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER

View File

@ -53,7 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/fast_atof.h> #include <assimp/fast_atof.h>
#include <assimp/DefaultLogger.hpp> #include <assimp/DefaultLogger.hpp>
using namespace Assimp; namespace Assimp {
using namespace Assimp::ASE; using namespace Assimp::ASE;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -1864,6 +1864,8 @@ void Parser::ParseLV4MeshLong(unsigned int &iOut) {
iOut = strtoul10(filePtr, &filePtr); iOut = strtoul10(filePtr, &filePtr);
} }
}
#endif // ASSIMP_BUILD_NO_3DS_IMPORTER #endif // ASSIMP_BUILD_NO_3DS_IMPORTER
#endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER #endif // !! ASSIMP_BUILD_NO_BASE_IMPORTER

View File

@ -59,7 +59,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
using namespace std; using namespace std;
static constexpr aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
@ -79,9 +79,9 @@ static constexpr aiImporterDesc desc = {
#pragma warning(disable : 4018) #pragma warning(disable : 4018)
#endif #endif
//#define DEBUG_B3D // #define DEBUG_B3D
template<typename T> template <typename T>
void DeleteAllBarePointers(std::vector<T> &x) { void DeleteAllBarePointers(std::vector<T> &x) {
for (auto p : x) { for (auto p : x) {
delete p; delete p;
@ -329,7 +329,7 @@ void B3DImporter::ReadBRUS() {
mat->AddProperty(&i, 1, AI_MATKEY_TWOSIDED); mat->AddProperty(&i, 1, AI_MATKEY_TWOSIDED);
} }
//Textures // Textures
for (int i = 0; i < n_texs; ++i) { for (int i = 0; i < n_texs; ++i) {
int texid = ReadInt(); int texid = ReadInt();
if (texid < -1 || (texid >= 0 && texid >= static_cast<int>(_textures.size()))) { if (texid < -1 || (texid >= 0 && texid >= static_cast<int>(_textures.size()))) {
@ -372,7 +372,7 @@ void B3DImporter::ReadVRTS() {
} }
if (_vflags & 2) { if (_vflags & 2) {
ReadQuat(); //skip v 4bytes... ReadQuat(); // skip v 4bytes...
} }
for (int j = 0; j < _tcsets; ++j) { for (int j = 0; j < _tcsets; ++j) {
@ -704,22 +704,22 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
} }
} }
//nodes // nodes
scene->mRootNode = _nodes[0]; scene->mRootNode = _nodes[0];
_nodes.clear(); // node ownership now belongs to scene _nodes.clear(); // node ownership now belongs to scene
//material // material
if (!_materials.size()) { if (!_materials.size()) {
_materials.emplace_back(std::unique_ptr<aiMaterial>(new aiMaterial)); _materials.emplace_back(std::unique_ptr<aiMaterial>(new aiMaterial));
} }
scene->mNumMaterials = static_cast<unsigned int>(_materials.size()); scene->mNumMaterials = static_cast<unsigned int>(_materials.size());
scene->mMaterials = unique_to_array(_materials); scene->mMaterials = unique_to_array(_materials);
//meshes // meshes
scene->mNumMeshes = static_cast<unsigned int>(_meshes.size()); scene->mNumMeshes = static_cast<unsigned int>(_meshes.size());
scene->mMeshes = unique_to_array(_meshes); scene->mMeshes = unique_to_array(_meshes);
//animations // animations
if (_animations.size() == 1 && _nodeAnims.size()) { if (_animations.size() == 1 && _nodeAnims.size()) {
aiAnimation *anim = _animations.back().get(); aiAnimation *anim = _animations.back().get();
@ -738,4 +738,6 @@ void B3DImporter::ReadBB3D(aiScene *scene) {
flip.Execute(scene); flip.Execute(scene);
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER #endif // !! ASSIMP_BUILD_NO_B3D_IMPORTER

View File

@ -55,7 +55,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <map> #include <map>
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
static constexpr aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
@ -73,8 +74,8 @@ static constexpr aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Aborts the file reading with an exception // Aborts the file reading with an exception
template<typename... T> template <typename... T>
AI_WONT_RETURN void BVHLoader::ThrowException(T&&... args) { AI_WONT_RETURN void BVHLoader::ThrowException(T &&...args) {
throw DeadlyImportError(mFileName, ":", mLine, " - ", args...); throw DeadlyImportError(mFileName, ":", mLine, " - ", args...);
} }
@ -426,7 +427,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
nodeAnim->mNodeName.Set(nodeName); nodeAnim->mNodeName.Set(nodeName);
std::map<BVHLoader::ChannelType, int> channelMap; std::map<BVHLoader::ChannelType, int> channelMap;
//Build map of channels // Build map of channels
for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) { for (unsigned int channel = 0; channel < node.mChannels.size(); ++channel) {
channelMap[node.mChannels[channel]] = channel; channelMap[node.mChannels[channel]] = channel;
} }
@ -441,7 +442,7 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
// Now compute all translations // Now compute all translations
for (BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel + 1)) { for (BVHLoader::ChannelType channel = Channel_PositionX; channel <= Channel_PositionZ; channel = (BVHLoader::ChannelType)(channel + 1)) {
//Find channel in node // Find channel in node
std::map<BVHLoader::ChannelType, int>::iterator mapIter = channelMap.find(channel); std::map<BVHLoader::ChannelType, int>::iterator mapIter = channelMap.find(channel);
if (mapIter == channelMap.end()) if (mapIter == channelMap.end())
@ -485,26 +486,23 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) { for (unsigned int fr = 0; fr < mAnimNumFrames; ++fr) {
aiMatrix4x4 temp; aiMatrix4x4 temp;
aiMatrix3x3 rotMatrix; aiMatrix3x3 rotMatrix;
for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++ channelIdx) { for (unsigned int channelIdx = 0; channelIdx < node.mChannels.size(); ++channelIdx) {
switch (node.mChannels[channelIdx]) { switch (node.mChannels[channelIdx]) {
case Channel_RotationX: case Channel_RotationX: {
{
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationX( angle, temp); rotMatrix *= aiMatrix3x3( temp); aiMatrix4x4::RotationX(angle, temp);
} rotMatrix *= aiMatrix3x3(temp);
break; } break;
case Channel_RotationY: case Channel_RotationY: {
{
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationY( angle, temp); rotMatrix *= aiMatrix3x3( temp); aiMatrix4x4::RotationY(angle, temp);
} rotMatrix *= aiMatrix3x3(temp);
break; } break;
case Channel_RotationZ: case Channel_RotationZ: {
{
const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f; const float angle = node.mChannelValues[fr * node.mChannels.size() + channelIdx] * float(AI_MATH_PI) / 180.0f;
aiMatrix4x4::RotationZ( angle, temp); rotMatrix *= aiMatrix3x3( temp); aiMatrix4x4::RotationZ(angle, temp);
} rotMatrix *= aiMatrix3x3(temp);
break; } break;
default: default:
break; break;
} }
@ -525,4 +523,6 @@ void BVHLoader::CreateAnimation(aiScene *pScene) {
} }
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER #endif // !! ASSIMP_BUILD_NO_BVH_IMPORTER

View File

@ -61,7 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
using namespace Assimp::COB; using namespace Assimp::COB;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
@ -1164,4 +1164,6 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist"); ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
} }
}
#endif // ASSIMP_BUILD_NO_COB_IMPORTER #endif // ASSIMP_BUILD_NO_COB_IMPORTER

View File

@ -64,9 +64,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define strtok_s strtok_r #define strtok_s strtok_r
#endif #endif
using namespace Assimp; namespace Assimp {
static const aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"Valve SMD Importer", "Valve SMD Importer",
"", "",
"", "",
@ -1077,4 +1077,6 @@ void SMDImporter::ParseVertex(const char* szCurrent,
SMDI_PARSE_RETURN; SMDI_PARSE_RETURN;
} }
}
#endif // !! ASSIMP_BUILD_NO_SMD_IMPORTER #endif // !! ASSIMP_BUILD_NO_SMD_IMPORTER

View File

@ -52,11 +52,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
namespace { namespace {
static const aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"Stereolithography (STL) Importer", "Stereolithography (STL) Importer",
"", "",
"", "",
@ -250,13 +250,13 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
sz += 5; // skip the "solid" sz += 5; // skip the "solid"
SkipSpaces(&sz); SkipSpaces(&sz);
const char *szMe = sz; const char *szMe = sz;
while (!::IsSpaceOrNewLine(*sz)) { while (!IsSpaceOrNewLine(*sz)) {
sz++; sz++;
} }
size_t temp = (size_t)(sz - szMe); size_t temp = (size_t)(sz - szMe);
// setup the name of the node // setup the name of the node
if ( temp ) { if (temp) {
if (temp >= MAXLEN) { if (temp >= MAXLEN) {
throw DeadlyImportError("STL: Node name too long"); throw DeadlyImportError("STL: Node name too long");
} }
@ -303,7 +303,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
normalBuffer.emplace_back(vn); normalBuffer.emplace_back(vn);
normalBuffer.emplace_back(vn); normalBuffer.emplace_back(vn);
} }
} else if (!strncmp(sz, "vertex", 6) && ::IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000 } else if (!strncmp(sz, "vertex", 6) && IsSpaceOrNewLine(*(sz + 6))) { // vertex 1.50000 1.50000 0.00000
if (faceVertexCounter >= 3) { if (faceVertexCounter >= 3) {
ASSIMP_LOG_ERROR("STL: a facet with more than 3 vertices has been found"); ASSIMP_LOG_ERROR("STL: a facet with more than 3 vertices has been found");
++sz; ++sz;
@ -325,14 +325,14 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
} else if (!::strncmp(sz, "endsolid", 8)) { } else if (!::strncmp(sz, "endsolid", 8)) {
do { do {
++sz; ++sz;
} while (!::IsLineEnd(*sz)); } while (!IsLineEnd(*sz));
SkipSpacesAndLineEnd(&sz); SkipSpacesAndLineEnd(&sz);
// finished! // finished!
break; break;
} else { // else skip the whole identifier } else { // else skip the whole identifier
do { do {
++sz; ++sz;
} while (!::IsSpaceOrNewLine(*sz)); } while (!IsSpaceOrNewLine(*sz));
} }
} }
@ -349,14 +349,14 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
throw DeadlyImportError("Normal buffer size does not match position buffer size"); throw DeadlyImportError("Normal buffer size does not match position buffer size");
} }
// only process positionbuffer when filled, else exception when accessing with index operator // only process position buffer when filled, else exception when accessing with index operator
// see line 353: only warning is triggered // see line 353: only warning is triggered
// see line 373(now): access to empty positionbuffer with index operator forced exception // see line 373(now): access to empty position buffer with index operator forced exception
if (!positionBuffer.empty()) { if (!positionBuffer.empty()) {
pMesh->mNumFaces = static_cast<unsigned int>(positionBuffer.size() / 3); pMesh->mNumFaces = static_cast<unsigned int>(positionBuffer.size() / 3);
pMesh->mNumVertices = static_cast<unsigned int>(positionBuffer.size()); pMesh->mNumVertices = static_cast<unsigned int>(positionBuffer.size());
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
for (size_t i=0; i<pMesh->mNumVertices; ++i ) { for (size_t i = 0; i < pMesh->mNumVertices; ++i) {
pMesh->mVertices[i].x = positionBuffer[i].x; pMesh->mVertices[i].x = positionBuffer[i].x;
pMesh->mVertices[i].y = positionBuffer[i].y; pMesh->mVertices[i].y = positionBuffer[i].y;
pMesh->mVertices[i].z = positionBuffer[i].z; pMesh->mVertices[i].z = positionBuffer[i].z;
@ -366,7 +366,7 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
// also only process normalBuffer when filled, else exception when accessing with index operator // also only process normalBuffer when filled, else exception when accessing with index operator
if (!normalBuffer.empty()) { if (!normalBuffer.empty()) {
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
for (size_t i=0; i<pMesh->mNumVertices; ++i ) { for (size_t i = 0; i < pMesh->mNumVertices; ++i) {
pMesh->mNormals[i].x = normalBuffer[i].x; pMesh->mNormals[i].x = normalBuffer[i].x;
pMesh->mNormals[i].y = normalBuffer[i].y; pMesh->mNormals[i].y = normalBuffer[i].y;
pMesh->mNormals[i].z = normalBuffer[i].z; pMesh->mNormals[i].z = normalBuffer[i].z;
@ -450,9 +450,8 @@ bool STLImporter::LoadBinaryFile() {
aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices]; aiVector3D *vp = pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; aiVector3D *vn = pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
typedef aiVector3t<float> aiVector3F; aiVector3f *theVec;
aiVector3F *theVec; aiVector3f theVec3F;
aiVector3F theVec3F;
for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) { for (unsigned int i = 0; i < pMesh->mNumFaces; ++i) {
// NOTE: Blender sometimes writes empty normals ... this is not // NOTE: Blender sometimes writes empty normals ... this is not
@ -460,8 +459,8 @@ bool STLImporter::LoadBinaryFile() {
// There's one normal for the face in the STL; use it three times // There's one normal for the face in the STL; use it three times
// for vertex normals // for vertex normals
theVec = (aiVector3F *)sz; theVec = (aiVector3f *)sz;
::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vn->x = theVec3F.x; vn->x = theVec3F.x;
vn->y = theVec3F.y; vn->y = theVec3F.y;
vn->z = theVec3F.z; vn->z = theVec3F.z;
@ -471,7 +470,7 @@ bool STLImporter::LoadBinaryFile() {
vn += 3; vn += 3;
// vertex 1 // vertex 1
::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x; vp->x = theVec3F.x;
vp->y = theVec3F.y; vp->y = theVec3F.y;
vp->z = theVec3F.z; vp->z = theVec3F.z;
@ -479,7 +478,7 @@ bool STLImporter::LoadBinaryFile() {
++vp; ++vp;
// vertex 2 // vertex 2
::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x; vp->x = theVec3F.x;
vp->y = theVec3F.y; vp->y = theVec3F.y;
vp->z = theVec3F.z; vp->z = theVec3F.z;
@ -487,7 +486,7 @@ bool STLImporter::LoadBinaryFile() {
++vp; ++vp;
// vertex 3 // vertex 3
::memcpy(&theVec3F, theVec, sizeof(aiVector3F)); ::memcpy(&theVec3F, theVec, sizeof(aiVector3f));
vp->x = theVec3F.x; vp->x = theVec3F.x;
vp->y = theVec3F.y; vp->y = theVec3F.y;
vp->z = theVec3F.z; vp->z = theVec3F.z;
@ -570,4 +569,6 @@ void STLImporter::pushMeshesToNode(std::vector<unsigned int> &meshIndices, aiNod
meshIndices.clear(); meshIndices.clear();
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_STL_IMPORTER #endif // !! ASSIMP_BUILD_NO_STL_IMPORTER

View File

@ -51,9 +51,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/IOSystem.hpp> #include <assimp/IOSystem.hpp>
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
using namespace Assimp; namespace Assimp {
static const aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"Terragen Heightmap Importer", "Terragen Heightmap Importer",
"", "",
"", "",
@ -73,10 +73,6 @@ TerragenImporter::TerragenImporter() :
// empty // empty
} }
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
TerragenImporter::~TerragenImporter() = default;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const { bool TerragenImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
@ -244,4 +240,6 @@ void TerragenImporter::InternReadFile(const std::string &pFile,
pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN; pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_TERRAGEN_IMPORTER #endif // !! ASSIMP_BUILD_NO_TERRAGEN_IMPORTER

View File

@ -73,7 +73,7 @@ namespace Assimp {
class TerragenImporter : public BaseImporter { class TerragenImporter : public BaseImporter {
public: public:
TerragenImporter(); TerragenImporter();
~TerragenImporter() override; ~TerragenImporter() override = default;
// ------------------------------------------------------------------- // -------------------------------------------------------------------
bool CanRead(const std::string &pFile, IOSystem *pIOHandler, bool CanRead(const std::string &pFile, IOSystem *pIOHandler,

View File

@ -63,7 +63,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cstdint> #include <cstdint>
#include <memory> #include <memory>
using namespace Assimp; namespace Assimp {
namespace Unreal { namespace Unreal {
@ -178,7 +178,7 @@ UnrealImporter::~UnrealImporter() = default;
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
bool UnrealImporter::CanRead(const std::string & filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const { bool UnrealImporter::CanRead(const std::string &filename, IOSystem * /*pIOHandler*/, bool /*checkSig*/) const {
return SimpleExtensionCheck(filename, "3d", "uc"); return SimpleExtensionCheck(filename, "3d", "uc");
} }
@ -336,12 +336,12 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
tempTextures.emplace_back(); tempTextures.emplace_back();
std::pair<std::string, std::string> &me = tempTextures.back(); std::pair<std::string, std::string> &me = tempTextures.back();
for (; !IsLineEnd(*data); ++data) { for (; !IsLineEnd(*data); ++data) {
if (!::ASSIMP_strincmp(data, "NAME=", 5)) { if (!ASSIMP_strincmp(data, "NAME=", 5)) {
const char *d = data += 5; const char *d = data += 5;
for (; !IsSpaceOrNewLine(*data); ++data) for (; !IsSpaceOrNewLine(*data); ++data)
; ;
me.first = std::string(d, (size_t)(data - d)); me.first = std::string(d, (size_t)(data - d));
} else if (!::ASSIMP_strincmp(data, "FILE=", 5)) { } else if (!ASSIMP_strincmp(data, "FILE=", 5)) {
const char *d = data += 5; const char *d = data += 5;
for (; !IsSpaceOrNewLine(*data); ++data) for (; !IsSpaceOrNewLine(*data); ++data)
; ;
@ -363,10 +363,10 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
std::pair<unsigned int, std::string> &me = textures.back(); std::pair<unsigned int, std::string> &me = textures.back();
for (; !IsLineEnd(*data); ++data) { for (; !IsLineEnd(*data); ++data) {
if (!::ASSIMP_strincmp(data, "NUM=", 4)) { if (!ASSIMP_strincmp(data, "NUM=", 4)) {
data += 4; data += 4;
me.first = strtoul10(data, &data); me.first = strtoul10(data, &data);
} else if (!::ASSIMP_strincmp(data, "TEXTURE=", 8)) { } else if (!ASSIMP_strincmp(data, "TEXTURE=", 8)) {
data += 8; data += 8;
const char *d = data; const char *d = data;
for (; !IsSpaceOrNewLine(*data); ++data) for (; !IsSpaceOrNewLine(*data); ++data)
@ -516,4 +516,6 @@ void UnrealImporter::InternReadFile(const std::string &pFile,
flipper.Execute(pScene); flipper.Execute(pScene);
} }
} // namespace Assimp
#endif // !! ASSIMP_BUILD_NO_3D_IMPORTER #endif // !! ASSIMP_BUILD_NO_3D_IMPORTER

View File

@ -61,7 +61,7 @@ namespace Assimp {
using namespace Assimp::Formatter; using namespace Assimp::Formatter;
static const aiImporterDesc desc = { static constexpr aiImporterDesc desc = {
"Direct3D XFile Importer", "Direct3D XFile Importer",
"", "",
"", "",

View File

@ -78,7 +78,7 @@ XGLImporter::XGLImporter() : mXmlParser(nullptr), m_scene(nullptr) {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
XGLImporter::~XGLImporter() { XGLImporter::~XGLImporter() {
delete mXmlParser; clear();
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -94,7 +94,8 @@ const aiImporterDesc *XGLImporter::GetInfo() const {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) { void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
#ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL clear();
#ifndef ASSIMP_BUILD_NO_COMPRESSED_XGL
std::vector<char> uncompressed; std::vector<char> uncompressed;
#endif #endif
@ -165,6 +166,13 @@ void XGLImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
scope.dismiss(); scope.dismiss();
} }
// ------------------------------------------------------------------------------------------------
void XGLImporter::clear() {
delete mXmlParser;
mXmlParser = nullptr;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) { void XGLImporter::ReadWorld(XmlNode &node, TempScope &scope) {
for (XmlNode &currentNode : node.children()) { for (XmlNode &currentNode : node.children()) {

View File

@ -81,6 +81,8 @@ public:
bool checkSig) const override; bool checkSig) const override;
protected: protected:
void clear();
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Return importer meta information. /** Return importer meta information.
* See #BaseImporter::GetInfo for the details */ * See #BaseImporter::GetInfo for the details */

View File

@ -151,6 +151,8 @@ public:
typedef aiVector3t<ai_real> aiVector3D; typedef aiVector3t<ai_real> aiVector3D;
typedef aiVector3t<float> aiVector3f;
typedef aiVector3t<double> aiVector3d;
#else #else