Merge branch 'master' into utf-issue
commit
5f832c9a44
|
@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "FBXUtil.h"
|
||||
#include <assimp/defs.h>
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <assimp/Exceptional.h>
|
||||
#include <assimp/ByteSwapper.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
|
|
|
@ -185,7 +185,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
|
|||
size_t total = 0;
|
||||
int read = 0;
|
||||
do {
|
||||
int bufferSize = fileInfo.uncompressed_size < INT16_MAX ? fileInfo.uncompressed_size : INT16_MAX;
|
||||
unsigned bufferSize = fileInfo.uncompressed_size < INT16_MAX ? static_cast<unsigned>(fileInfo.uncompressed_size) : INT16_MAX;
|
||||
void *buffer = malloc(bufferSize);
|
||||
read = unzReadCurrentFile(zip, buffer, bufferSize);
|
||||
if (read > 0) {
|
||||
|
|
|
@ -1372,7 +1372,7 @@ std::vector<IfcVector2> GetContourInPlane2D(const std::shared_ptr<TempMesh>& mes
|
|||
const std::vector<IfcVector3>& va = mesh->mVerts;
|
||||
if(va.size() <= 2) {
|
||||
std::stringstream msg;
|
||||
msg << "Skipping: Only " << va.size() << " verticies in opening mesh.";
|
||||
msg << "Skipping: Only " << va.size() << " vertices in opening mesh.";
|
||||
IFCImporter::LogDebug(msg.str().c_str());
|
||||
ok = false;
|
||||
return contour;
|
||||
|
|
|
@ -575,8 +575,8 @@ void SetupMapping(aiMaterial *mat, aiTextureMapping mode, const aiVector3D &axis
|
|||
m->mSemantic = prop->mSemantic;
|
||||
m->mType = aiPTI_Float;
|
||||
|
||||
m->mDataLength = 12;
|
||||
m->mData = new char[12];
|
||||
m->mDataLength = sizeof(aiVector3D);
|
||||
m->mData = new char[m->mDataLength];
|
||||
*((aiVector3D *)m->mData) = axis;
|
||||
p.push_back(m);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <cctype>
|
||||
#include <memory>
|
||||
|
||||
using namespace Assimp;
|
||||
namespace Assimp {
|
||||
|
||||
using namespace Assimp::Formatter;
|
||||
|
||||
static const aiImporterDesc desc = {
|
||||
|
@ -73,10 +74,6 @@ static const aiImporterDesc desc = {
|
|||
"x"
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructor to be privately used by Importer
|
||||
XFileImporter::XFileImporter() = default;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool XFileImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||
|
@ -124,8 +121,7 @@ void XFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, I
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Constructs the return data structure out of the imported data.
|
||||
void XFileImporter::CreateDataRepresentationFromImport( aiScene* pScene, XFile::Scene* pData)
|
||||
{
|
||||
void XFileImporter::CreateDataRepresentationFromImport(aiScene *pScene, XFile::Scene *pData) {
|
||||
// Read the global materials first so that meshes referring to them can find them later
|
||||
ConvertMaterials(pScene, pData->mGlobalMaterials);
|
||||
|
||||
|
@ -315,8 +311,8 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
|||
// collect vertex data for indices of this face
|
||||
for (unsigned int d = 0; d < df.mNumIndices; ++d) {
|
||||
df.mIndices[d] = newIndex;
|
||||
const unsigned int newIdx( pf.mIndices[ d ] );
|
||||
if ( newIdx > sourceMesh->mPositions.size() ) {
|
||||
const unsigned int newIdx = pf.mIndices[d];
|
||||
if (newIdx >= sourceMesh->mPositions.size()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -328,9 +324,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
|||
if (mesh->HasNormals()) {
|
||||
if (sourceMesh->mNormFaces[f].mIndices.size() > d) {
|
||||
const size_t idx(sourceMesh->mNormFaces[f].mIndices[d]);
|
||||
if (idx < sourceMesh->mNormals.size()) {
|
||||
mesh->mNormals[newIndex] = sourceMesh->mNormals[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// texture coord sets
|
||||
for (unsigned int e = 0; e < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++e) {
|
||||
|
@ -361,8 +359,11 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
|
|||
// set up a vertex-linear array of the weights for quick searching if a bone influences a vertex
|
||||
std::vector<ai_real> oldWeights(sourceMesh->mPositions.size(), 0.0);
|
||||
for (unsigned int d = 0; d < obone.mWeights.size(); ++d) {
|
||||
const unsigned int boneIdx = obone.mWeights[d].mVertex;
|
||||
if (boneIdx < obone.mWeights.size()) {
|
||||
oldWeights[obone.mWeights[d].mVertex] = obone.mWeights[d].mWeight;
|
||||
}
|
||||
}
|
||||
|
||||
// collect all vertex weights that influence a vertex in the new mesh
|
||||
std::vector<aiVertexWeight> newWeights;
|
||||
|
@ -451,8 +452,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
|
|||
nanim->mChannels[b] = nbone;
|
||||
|
||||
// key-frames are given as combined transformation matrix keys
|
||||
if( !bone->mTrafoKeys.empty() )
|
||||
{
|
||||
if (!bone->mTrafoKeys.empty()) {
|
||||
nbone->mNumPositionKeys = (unsigned int)bone->mTrafoKeys.size();
|
||||
nbone->mPositionKeys = new aiVectorKey[nbone->mNumPositionKeys];
|
||||
nbone->mNumRotationKeys = (unsigned int)bone->mTrafoKeys.size();
|
||||
|
@ -538,8 +538,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
|
|||
}
|
||||
|
||||
// store all converted animations in the scene
|
||||
if( newAnims.size() > 0)
|
||||
{
|
||||
if (newAnims.size() > 0) {
|
||||
pScene->mNumAnimations = (unsigned int)newAnims.size();
|
||||
pScene->mAnimations = new aiAnimation *[pScene->mNumAnimations];
|
||||
for (unsigned int a = 0; a < newAnims.size(); a++)
|
||||
|
@ -549,8 +548,7 @@ void XFileImporter::CreateAnimations( aiScene* pScene, const XFile::Scene* pData
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Converts all materials in the given array and stores them in the scene's material list.
|
||||
void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Material>& pMaterials)
|
||||
{
|
||||
void XFileImporter::ConvertMaterials(aiScene *pScene, std::vector<XFile::Material> &pMaterials) {
|
||||
// count the non-referrer materials in the array
|
||||
unsigned int numNewMaterials(0);
|
||||
for (unsigned int a = 0; a < pMaterials.size(); ++a) {
|
||||
|
@ -599,8 +597,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
|||
// Shading model: hard-coded to PHONG, there is no such information in an XFile
|
||||
// FIX (aramis): If the specular exponent is 0, use gouraud shading. This is a bugfix
|
||||
// for some models in the SDK (e.g. good old tiny.x)
|
||||
int shadeMode = (int)oldMat.mSpecularExponent == 0.0f
|
||||
? aiShadingMode_Gouraud : aiShadingMode_Phong;
|
||||
int shadeMode = (int)oldMat.mSpecularExponent == 0.0f ? aiShadingMode_Gouraud : aiShadingMode_Phong;
|
||||
|
||||
mat->AddProperty<int>(&shadeMode, 1, AI_MATKEY_SHADING_MODEL);
|
||||
// material colours
|
||||
|
@ -611,7 +608,6 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
|||
mat->AddProperty(&oldMat.mSpecular, 1, AI_MATKEY_COLOR_SPECULAR);
|
||||
mat->AddProperty(&oldMat.mSpecularExponent, 1, AI_MATKEY_SHININESS);
|
||||
|
||||
|
||||
// texture, if there is one
|
||||
if (1 == oldMat.mTextures.size()) {
|
||||
const XFile::TexEntry &otex = oldMat.mTextures.back();
|
||||
|
@ -679,4 +675,6 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace Assimp
|
||||
|
||||
#endif // !! ASSIMP_BUILD_NO_X_IMPORTER
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace XFile {
|
|||
*/
|
||||
class XFileImporter : public BaseImporter {
|
||||
public:
|
||||
XFileImporter();
|
||||
XFileImporter() = default;
|
||||
~XFileImporter() override = default;
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
@ -1380,7 +1380,12 @@ ENDIF()
|
|||
IF(NOT ASSIMP_HUNTER_ENABLED)
|
||||
if (UNZIP_FOUND)
|
||||
INCLUDE_DIRECTORIES(${UNZIP_INCLUDE_DIRS})
|
||||
# TODO if cmake required version has been updated to >3.12.0, collapse this to the second case only
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
|
||||
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LIBRARIES})
|
||||
else()
|
||||
TARGET_LINK_LIBRARIES(assimp ${UNZIP_LINK_LIBRARIES})
|
||||
endif()
|
||||
else ()
|
||||
INCLUDE_DIRECTORIES("../")
|
||||
endif ()
|
||||
|
|
|
@ -290,12 +290,6 @@ void PretransformVertices::ComputeAbsoluteTransform(aiNode *pcNode) {
|
|||
}
|
||||
}
|
||||
|
||||
static void normalizeVectorArray(aiVector3D *vectorArrayIn, aiVector3D *vectorArrayOut, size_t numVectors) {
|
||||
for (size_t i=0; i<numVectors; ++i) {
|
||||
vectorArrayOut[i] = vectorArrayIn[i].Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Apply the node transformation to a mesh
|
||||
void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat) const {
|
||||
|
@ -322,8 +316,11 @@ void PretransformVertices::ApplyTransform(aiMesh *mesh, const aiMatrix4x4 &mat)
|
|||
const aiMatrix3x3 m = aiMatrix3x3(mat).Inverse().Transpose();
|
||||
|
||||
if (mesh->HasNormals()) {
|
||||
normalizeVectorArray(mesh->mNormals, mesh->mNormals, mesh->mNumVertices);
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||
mesh->mNormals[i] = (m * mesh->mNormals[i]).Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
if (mesh->HasTangentsAndBitangents()) {
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
|
||||
mesh->mTangents[i] = (m * mesh->mTangents[i]).Normalize();
|
||||
|
|
|
@ -59,6 +59,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <assimp/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <unordered_set>
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
@ -872,11 +874,15 @@ struct aiMesh {
|
|||
|
||||
// DO NOT REMOVE THIS ADDITIONAL CHECK
|
||||
if (mNumBones && mBones) {
|
||||
std::unordered_set<const aiBone *> bones;
|
||||
for (unsigned int a = 0; a < mNumBones; a++) {
|
||||
if (mBones[a]) {
|
||||
delete mBones[a];
|
||||
bones.insert(mBones[a]);
|
||||
}
|
||||
}
|
||||
for (const aiBone *bone: bones) {
|
||||
delete bone;
|
||||
}
|
||||
delete[] mBones;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
class BlendImportAreaLight : public ::testing::Test {
|
||||
public:
|
||||
BlendImportAreaLight() :
|
||||
im(nullptr) {}
|
||||
~BlendImportAreaLight() override = default;
|
||||
void SetUp() override {
|
||||
im = new Assimp::Importer();
|
||||
}
|
||||
|
|
|
@ -48,11 +48,14 @@ using namespace ::Assimp;
|
|||
|
||||
class BlenderWorkTest : public ::testing::Test {
|
||||
public:
|
||||
virtual void SetUp() {
|
||||
BlenderWorkTest() : im(nullptr) {}
|
||||
~BlenderWorkTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
im = new Assimp::Importer();
|
||||
}
|
||||
|
||||
virtual void TearDown() {
|
||||
void TearDown() override {
|
||||
delete im;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue