Merge branch 'master' into issue_2182

pull/2535/head
Kim Kulling 2019-07-09 19:45:40 +02:00 committed by GitHub
commit a01302dd4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 76 additions and 25 deletions

View File

@ -331,7 +331,7 @@ ADD_ASSIMP_EXPORTER( ASSBIN
Assbin/AssbinExporter.cpp
)
ADD_ASSIMP_IMPORTER( ASSXML
ADD_ASSIMP_EXPORTER( ASSXML
Assxml/AssxmlExporter.h
Assxml/AssxmlExporter.cpp
)

View File

@ -99,7 +99,7 @@ ColladaExporter::ColladaExporter( const aiScene* pScene, IOSystem* pIOSystem, co
, mFile(file) {
// make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") );
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
mScene = pScene;
mSceneOwned = false;

View File

@ -323,10 +323,8 @@ void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
aiString aistr;
aistr.Set(value_char);
metadata.emplace(camel_key_str, aistr);
TestClosing(key_str.c_str());
}
else
SkipElement();
TestClosing(key_str.c_str());
}
else
SkipElement();

View File

@ -590,10 +590,12 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
// Find an worker class which can handle the file
BaseImporter* imp = NULL;
SetPropertyInteger("importerIndex", -1);
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, false)) {
imp = pimpl->mImporter[a];
SetPropertyInteger("importerIndex", a);
break;
}
}
@ -606,6 +608,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) {
imp = pimpl->mImporter[a];
SetPropertyInteger("importerIndex", a);
break;
}
}

View File

@ -1255,7 +1255,7 @@ namespace Assimp {
// mapping from output indices to DOM indexing, needed to resolve weights
std::vector<unsigned int> reverseMapping;
std::map<unsigned int, unsigned int> translateIndexMap;
if (process_weights) {
reverseMapping.resize(count_vertices);
}
@ -1363,6 +1363,7 @@ namespace Assimp {
if (reverseMapping.size()) {
reverseMapping[cursor] = in_cursor;
translateIndexMap[in_cursor] = cursor;
}
out_mesh->mVertices[cursor] = vertices[in_cursor];
@ -1394,6 +1395,39 @@ namespace Assimp {
ConvertWeights(out_mesh, model, mesh, node_global_transform, index, &reverseMapping);
}
std::vector<aiAnimMesh*> animMeshes;
for (const BlendShape* blendShape : mesh.GetBlendShapes()) {
for (const BlendShapeChannel* blendShapeChannel : blendShape->BlendShapeChannels()) {
const std::vector<const ShapeGeometry*>& shapeGeometries = blendShapeChannel->GetShapeGeometries();
for (size_t i = 0; i < shapeGeometries.size(); i++) {
aiAnimMesh* animMesh = aiCreateAnimMesh(out_mesh);
const ShapeGeometry* shapeGeometry = shapeGeometries.at(i);
const std::vector<aiVector3D>& vertices = shapeGeometry->GetVertices();
const std::vector<aiVector3D>& normals = shapeGeometry->GetNormals();
const std::vector<unsigned int>& indices = shapeGeometry->GetIndices();
animMesh->mName.Set(FixAnimMeshName(shapeGeometry->Name()));
for (size_t j = 0; j < indices.size(); j++) {
unsigned int index = indices.at(j);
aiVector3D vertex = vertices.at(j);
aiVector3D normal = normals.at(j);
unsigned int count = 0;
const unsigned int* outIndices = mesh.ToOutputVertexIndex(index, count);
for (unsigned int k = 0; k < count; k++) {
unsigned int index = translateIndexMap[outIndices[k]];
animMesh->mVertices[index] += vertex;
if (animMesh->mNormals != nullptr) {
animMesh->mNormals[index] += normal;
animMesh->mNormals[index].NormalizeSafe();
}
}
}
animMesh->mWeight = shapeGeometries.size() > 1 ? blendShapeChannel->DeformPercent() / 100.0f : 1.0f;
animMeshes.push_back(animMesh);
}
}
}
return static_cast<unsigned int>(meshes.size() - 1);
}
@ -1642,7 +1676,7 @@ namespace Assimp {
out_tex->pcData = reinterpret_cast<aiTexel*>(const_cast<Video&>(video).RelinquishContent());
// try to extract a hint from the file extension
const std::string& filename = video.FileName().empty() ? video.RelativeFilename() : video.FileName();
const std::string& filename = video.RelativeFilename().empty() ? video.FileName() : video.RelativeFilename();
std::string ext = BaseImporter::GetExtension(filename);
if (ext == "jpeg") {
@ -1653,7 +1687,7 @@ namespace Assimp {
memcpy(out_tex->achFormatHint, ext.c_str(), ext.size());
}
out_tex->mFilename.Set(video.FileName().c_str());
out_tex->mFilename.Set(filename.c_str());
return static_cast<unsigned int>(textures.size() - 1);
}

View File

@ -1328,6 +1328,7 @@ void LWOImporter::LoadLWO2File()
bool skip = false;
LE_NCONST uint8_t* const end = mFileBuffer + fileSize;
unsigned int iUnnamed = 0;
while (true)
{
if (mFileBuffer + sizeof(IFF::ChunkHeader) > end)break;
@ -1339,7 +1340,6 @@ void LWOImporter::LoadLWO2File()
break;
}
uint8_t* const next = mFileBuffer+head.length;
unsigned int iUnnamed = 0;
if(!head.length) {
mFileBuffer = next;

View File

@ -126,9 +126,9 @@ ObjExporter::ObjExporter(const char* _filename, const aiScene* pScene, bool noMt
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
mOutputMat.imbue(l);
mOutputMat.precision(16);
mOutputMat.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
WriteGeometryFile(noMtl);
if ( !noMtl ) {

View File

@ -111,7 +111,7 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
unsigned int faces = 0u, vertices = 0u, components = 0u;
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {

View File

@ -111,7 +111,7 @@ STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool expo
// make sure that all formatting happens using the standard, C locale and not the user's current locale
const std::locale& l = std::locale("C");
mOutput.imbue(l);
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
if (binary) {
char buf[80] = {0} ;
buf[0] = 'A'; buf[1] = 's'; buf[2] = 's'; buf[3] = 'i'; buf[4] = 'm'; buf[5] = 'p';

View File

@ -143,15 +143,15 @@ namespace {
// ------------------------------------------------------------------------------------------------
// Constructor for a specific scene to export
StepExporter::StepExporter(const aiScene* pScene, IOSystem* pIOSystem, const std::string& path,
const std::string& file, const ExportProperties* pProperties):
mProperties(pProperties),mIOSystem(pIOSystem),mFile(file), mPath(path),
mScene(pScene), endstr(";\n") {
CollectTrafos(pScene->mRootNode, trafos);
CollectMeshes(pScene->mRootNode, meshes);
const std::string& file, const ExportProperties* pProperties) :
mProperties(pProperties), mIOSystem(pIOSystem), mFile(file), mPath(path),
mScene(pScene), endstr(";\n") {
CollectTrafos(pScene->mRootNode, trafos);
CollectMeshes(pScene->mRootNode, meshes);
// make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") );
mOutput.precision(16);
mOutput.imbue(std::locale("C"));
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// start writing
WriteFile();
@ -166,7 +166,7 @@ void StepExporter::WriteFile()
mOutput.setf(std::ios::fixed);
// precision for double
// see http://stackoverflow.com/questions/554063/how-do-i-print-a-double-value-with-full-precision-using-cout
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// standard color
aiColor4D fColor;

View File

@ -113,7 +113,7 @@ XFileExporter::XFileExporter(const aiScene* pScene, IOSystem* pIOSystem, const s
{
// make sure that all formatting happens using the standard, C locale and not the user's current locale
mOutput.imbue( std::locale("C") );
mOutput.precision(16);
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION);
// start writing
WriteFile();
@ -134,7 +134,7 @@ void XFileExporter::WriteFile()
{
// note, that all realnumber values must be comma separated in x files
mOutput.setf(std::ios::fixed);
mOutput.precision(16); // precision for double
mOutput.precision(ASSIMP_AI_REAL_TEXT_PRECISION); // precision for ai_real
// entry of writing the file
WriteHeader();

View File

@ -142,7 +142,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @brief Specifies the maximum angle that may be between two vertex tangents
* that their tangents and bi-tangents are smoothed.
*
* This applies to the CalcTangentSpace-Step. The angle is specified
* This applies to the CalcTangentSpace-Step. TFvhe angle is specified
* in degrees. The maximum value is 175.
* Property type: float. Default value: 45 degrees
*/

View File

@ -241,10 +241,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
typedef double ai_real;
typedef signed long long int ai_int;
typedef unsigned long long int ai_uint;
#ifndef ASSIMP_AI_REAL_TEXT_PRECISION
#define ASSIMP_AI_REAL_TEXT_PRECISION 16
#endif // ASSIMP_AI_REAL_TEXT_PRECISION
#else // ASSIMP_DOUBLE_PRECISION
typedef float ai_real;
typedef signed int ai_int;
typedef unsigned int ai_uint;
#ifndef ASSIMP_AI_REAL_TEXT_PRECISION
#define ASSIMP_AI_REAL_TEXT_PRECISION 8
#endif // ASSIMP_AI_REAL_TEXT_PRECISION
#endif // ASSIMP_DOUBLE_PRECISION
//////////////////////////////////////////////////////////////////////////

View File

@ -161,7 +161,14 @@ struct aiColor3D
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
/** Component-wise comparison */
aiColor3D &operator=(const aiColor3D &o) {
r = o.r;
g = o.g;
b = o.b;
return *this;
}
/** Component-wise comparison */
// TODO: add epsilon?
bool operator == (const aiColor3D& other) const
{return r == other.r && g == other.g && b == other.b;}

View File

@ -274,6 +274,8 @@ def hasattr_silent(object, name):
"""
try:
if not object:
return False
return hasattr(object, name)
except AttributeError:
return False

View File

@ -241,6 +241,7 @@ TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {
aiString path;
aiTextureMapMode modes[2];
EXPECT_EQ(aiReturn_SUCCESS, mat->GetTexture(aiTextureType_DIFFUSE, 0, &path, nullptr, nullptr, nullptr, nullptr, modes));
ASSERT_STREQ(path.C_Str(), "..\\..\\..\\Desktop\\uv_test.png");
ASSERT_EQ(1, scene->mNumTextures);
ASSERT_TRUE(scene->mTextures[0]->pcData);