Merge pull request #3248 from assimp/issue_3165
closes https://github.com/assimp/assimp/issues/3165: fix gcc build.pull/3284/head
commit
f776cc8008
|
@ -5,8 +5,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,
|
||||
|
@ -101,11 +99,13 @@ static bool IsAsciiSTL(const char *buffer, unsigned int fileSize) {
|
|||
|
||||
const char *bufferEnd = buffer + fileSize;
|
||||
|
||||
if (!SkipSpaces(&buffer))
|
||||
if (!SkipSpaces(&buffer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (buffer + 5 >= bufferEnd)
|
||||
if (buffer + 5 >= bufferEnd) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isASCII(strncmp(buffer, "solid", 5) == 0);
|
||||
if (isASCII) {
|
||||
|
@ -370,13 +370,21 @@ void STLImporter::LoadASCIIFile(aiNode *root) {
|
|||
pMesh->mNumFaces = static_cast<unsigned int>(positionBuffer.size() / 3);
|
||||
pMesh->mNumVertices = static_cast<unsigned int>(positionBuffer.size());
|
||||
pMesh->mVertices = new aiVector3D[pMesh->mNumVertices];
|
||||
memcpy(pMesh->mVertices, &positionBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D));
|
||||
for (size_t i=0; i<pMesh->mNumVertices; ++i ) {
|
||||
pMesh->mVertices[i].x = positionBuffer[i].x;
|
||||
pMesh->mVertices[i].y = positionBuffer[i].y;
|
||||
pMesh->mVertices[i].z = positionBuffer[i].z;
|
||||
}
|
||||
positionBuffer.clear();
|
||||
}
|
||||
// also only process normalBuffer when filled, else exception when accessing with index operator
|
||||
if (!normalBuffer.empty()) {
|
||||
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
|
||||
memcpy(pMesh->mNormals, &normalBuffer[0].x, pMesh->mNumVertices * sizeof(aiVector3D));
|
||||
for (size_t i=0; i<pMesh->mNumVertices; ++i ) {
|
||||
pMesh->mNormals[i].x = normalBuffer[i].x;
|
||||
pMesh->mNormals[i].y = normalBuffer[i].y;
|
||||
pMesh->mNormals[i].z = normalBuffer[i].z;
|
||||
}
|
||||
normalBuffer.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
@ -61,12 +60,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <algorithm>
|
||||
#include <stdexcept>
|
||||
|
||||
#ifndef RAPIDJSON_HAS_STDSTRING
|
||||
#define RAPIDJSON_HAS_STDSTRING 1
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
#endif
|
||||
|
||||
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
|
||||
#define RAPIDJSON_NOMEMBERITERATORCLASS
|
||||
#endif
|
||||
|
||||
#include <rapidjson/rapidjson.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/error/en.h>
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
# include <memory>
|
||||
# include <assimp/DefaultIOSystem.h>
|
||||
|
|
|
@ -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,
|
||||
|
@ -63,12 +62,27 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef RAPIDJSON_HAS_STDSTRING
|
||||
#define RAPIDJSON_HAS_STDSTRING 1
|
||||
#endif
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
#endif
|
||||
|
||||
#ifndef RAPIDJSON_NOMEMBERITERATORCLASS
|
||||
#define RAPIDJSON_NOMEMBERITERATORCLASS
|
||||
#endif
|
||||
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/error/en.h>
|
||||
#include <rapidjson/rapidjson.h>
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#ifdef ASSIMP_API
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/DefaultIOSystem.h>
|
||||
|
|
|
@ -66,6 +66,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
namespace Assimp {
|
||||
|
||||
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Add a prefix to a string
|
||||
inline
|
||||
|
@ -75,7 +80,7 @@ void PrefixString(aiString& string,const char* prefix, unsigned int len) {
|
|||
return;
|
||||
|
||||
if (len+string.length>=MAXLEN-1) {
|
||||
ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long");
|
||||
ASSIMP_LOG_VERBOSE_DEBUG("Can't add an unique prefix because the string is too long");
|
||||
ai_assert(false);
|
||||
return;
|
||||
}
|
||||
|
@ -98,8 +103,9 @@ void SceneCombiner::AddNodeHashes(aiNode* node, std::set<unsigned int>& hashes)
|
|||
}
|
||||
|
||||
// Process all children recursively
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i)
|
||||
for (unsigned int i = 0; i < node->mNumChildren;++i) {
|
||||
AddNodeHashes(node->mChildren[i],hashes);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
@ -1074,12 +1080,14 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) {
|
|||
GetArrayCopy( dest->mBitangents, dest->mNumVertices );
|
||||
|
||||
unsigned int n = 0;
|
||||
while (dest->HasTextureCoords(n))
|
||||
GetArrayCopy( dest->mTextureCoords[n++], dest->mNumVertices );
|
||||
while (dest->HasTextureCoords(n)) {
|
||||
GetArrayCopy( dest->mTextureCoords[n++], dest->mNumVertices );
|
||||
}
|
||||
|
||||
n = 0;
|
||||
while (dest->HasVertexColors(n))
|
||||
GetArrayCopy( dest->mColors[n++], dest->mNumVertices );
|
||||
while (dest->HasVertexColors(n)) {
|
||||
GetArrayCopy( dest->mColors[n++], dest->mNumVertices );
|
||||
}
|
||||
|
||||
// make a deep copy of all bones
|
||||
CopyPtrArray(dest->mBones,dest->mBones,dest->mNumBones);
|
||||
|
@ -1341,5 +1349,9 @@ void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src) {
|
|||
}
|
||||
}
|
||||
|
||||
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
} // Namespace Assimp
|
||||
|
||||
|
|
|
@ -210,20 +210,16 @@ BinFloat ToBinary(const ai_real &pValue) {
|
|||
// See http://en.wikipedia.org/wiki/Signed_number_representations.
|
||||
|
||||
// Two's complement?
|
||||
bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000));
|
||||
bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000));
|
||||
bool SignedMagnitude = ((-42 == (42 | (-0))) && (binValue & 0x80000000));
|
||||
const bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000));
|
||||
const bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000));
|
||||
|
||||
if (DefaultValue)
|
||||
return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue;
|
||||
// One's complement?
|
||||
else if (OneComplement)
|
||||
return BinFloat(-0) - binValue;
|
||||
// Sign-magnitude?
|
||||
else if (SignedMagnitude) // -0 = 1000... binary
|
||||
return binValue;
|
||||
else
|
||||
return binValue;
|
||||
// Sign-magnitude? -0 = 1000... binary
|
||||
return binValue;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -17,6 +17,11 @@
|
|||
|
||||
/*! \file document.h */
|
||||
|
||||
#if (__GNUC__ >= 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wclass-memaccess"
|
||||
#endif
|
||||
|
||||
#include "reader.h"
|
||||
#include "internal/meta.h"
|
||||
#include "internal/strfunc.h"
|
||||
|
@ -2610,4 +2615,8 @@ private:
|
|||
RAPIDJSON_NAMESPACE_END
|
||||
RAPIDJSON_DIAG_POP
|
||||
|
||||
#if (__GNUC__ == 8 && __GNUC_MINOR__ >= 0)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#endif // RAPIDJSON_DOCUMENT_H_
|
||||
|
|
|
@ -106,8 +106,10 @@ void utFindInvalidDataProcess::TearDown() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
TEST_F(utFindInvalidDataProcess, testStepNegativeResult) {
|
||||
::memset(mMesh->mNormals, 0, mMesh->mNumVertices * sizeof(aiVector3D));
|
||||
::memset(mMesh->mBitangents, 0, mMesh->mNumVertices * sizeof(aiVector3D));
|
||||
for ( size_t i=0; i<mMesh->mNumVertices; ++i ) {
|
||||
mMesh->mNormals[i].x = mMesh->mNormals[i].y = mMesh->mNormals[i].z =0;
|
||||
mMesh->mBitangents[i].x = mMesh->mBitangents[i].y = mMesh->mBitangents[i].z = 0;
|
||||
}
|
||||
|
||||
mMesh->mTextureCoords[2][455] = aiVector3D(std::numeric_limits<float>::quiet_NaN());
|
||||
|
||||
|
|
Loading…
Reference in New Issue