Merge branch 'master' of https://github.com/assimp/assimp into implementation_warning_fix
# Conflicts: # code/AMFImporter_Postprocess.cpp # code/FBXConverter.cpp # code/IFCLoader.cpp # code/NDOLoader.cpp # code/glTFAsset.inl
This commit is contained in:
@@ -336,25 +336,21 @@ auto texmap_is_equal = [](const CAMFImporter_NodeElement_TexMap* pTexMap1, const
|
||||
} while(pInputList.size() > 0);
|
||||
}
|
||||
|
||||
void AMFImporter::Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& pMetadataList, aiNode& pSceneNode) const
|
||||
void AMFImporter::Postprocess_AddMetadata(const std::list<CAMFImporter_NodeElement_Metadata*>& metadataList, aiNode& sceneNode) const
|
||||
{
|
||||
if(pMetadataList.size() > 0)
|
||||
if ( !metadataList.empty() )
|
||||
{
|
||||
if(pSceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
|
||||
if(sceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
|
||||
|
||||
// copy collected metadata to output node.
|
||||
pSceneNode.mMetaData = new aiMetadata();
|
||||
pSceneNode.mMetaData->mNumProperties = static_cast<unsigned int>(pMetadataList.size());
|
||||
pSceneNode.mMetaData->mKeys = new aiString[pSceneNode.mMetaData->mNumProperties];
|
||||
pSceneNode.mMetaData->mValues = new aiMetadataEntry[pSceneNode.mMetaData->mNumProperties];
|
||||
sceneNode.mMetaData = aiMetadata::Alloc( static_cast<unsigned int>(metadataList.size()) );
|
||||
size_t meta_idx( 0 );
|
||||
|
||||
size_t meta_idx = 0;
|
||||
|
||||
for(const CAMFImporter_NodeElement_Metadata& metadata: pMetadataList)
|
||||
for(const CAMFImporter_NodeElement_Metadata& metadata: metadataList)
|
||||
{
|
||||
pSceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata.Type, metadata.Value.c_str());
|
||||
sceneNode.mMetaData->Set(static_cast<unsigned int>(meta_idx++), metadata.Type, aiString(metadata.Value));
|
||||
}
|
||||
}// if(pMetadataList.size() > 0)
|
||||
}// if(!metadataList.empty())
|
||||
}
|
||||
|
||||
void AMFImporter::Postprocess_BuildNodeAndObject(const CAMFImporter_NodeElement_Object& pNodeElement, std::list<aiMesh*>& pMeshList, aiNode** pSceneNode)
|
||||
|
||||
@@ -56,7 +56,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -461,29 +460,32 @@ void BaseImporter::TextFileToBuffer(IOStream* stream,
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
namespace Assimp
|
||||
{
|
||||
namespace Assimp {
|
||||
// Represents an import request
|
||||
struct LoadRequest
|
||||
{
|
||||
struct LoadRequest {
|
||||
LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id)
|
||||
: file(_file), flags(_flags), refCnt(1),scene(NULL), loaded(false), id(_id)
|
||||
{
|
||||
if (_map)
|
||||
: file(_file)
|
||||
, flags(_flags)
|
||||
, refCnt(1)
|
||||
, scene(NULL)
|
||||
, loaded(false)
|
||||
, id(_id) {
|
||||
if ( _map ) {
|
||||
map = *_map;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string file;
|
||||
unsigned int flags;
|
||||
unsigned int refCnt;
|
||||
aiScene* scene;
|
||||
bool loaded;
|
||||
BatchLoader::PropertyMap map;
|
||||
unsigned int id;
|
||||
|
||||
bool operator== (const std::string& f) const {
|
||||
bool operator== ( const std::string& f ) const {
|
||||
return file == f;
|
||||
}
|
||||
|
||||
const std::string file;
|
||||
unsigned int flags;
|
||||
unsigned int refCnt;
|
||||
aiScene *scene;
|
||||
bool loaded;
|
||||
BatchLoader::PropertyMap map;
|
||||
unsigned int id;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,8 @@ BlenderImporter::~BlenderImporter()
|
||||
delete modifier_cache;
|
||||
}
|
||||
|
||||
static const char* Tokens[] = { "BLENDER" };
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Returns whether the class can handle the format of the given file.
|
||||
bool BlenderImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
|
||||
@@ -117,8 +119,7 @@ bool BlenderImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, b
|
||||
|
||||
else if ((!extension.length() || checkSig) && pIOHandler) {
|
||||
// note: this won't catch compressed files
|
||||
const char* tokens[] = {"BLENDER"};
|
||||
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
|
||||
return SearchFileHeaderForToken(pIOHandler,pFile, Tokens,1);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -172,7 +173,7 @@ void BlenderImporter::InternReadFile( const std::string& pFile,
|
||||
|
||||
char magic[8] = {0};
|
||||
stream->Read(magic,7,1);
|
||||
if (strcmp(magic,"BLENDER")) {
|
||||
if (strcmp(magic, Tokens[0] )) {
|
||||
// Check for presence of the gzip header. If yes, assume it is a
|
||||
// compressed blend file and try uncompressing it, else fail. This is to
|
||||
// avoid uncompressing random files which our loader might end up with.
|
||||
@@ -347,8 +348,9 @@ void BlenderImporter::ConvertBlendFile(aiScene* out, const Scene& in,const FileD
|
||||
if (cur->object) {
|
||||
if(!cur->object->parent) {
|
||||
no_parents.push_back(cur->object.get());
|
||||
} else {
|
||||
conv.objects.insert( cur->object.get() );
|
||||
}
|
||||
else conv.objects.insert(cur->object.get());
|
||||
}
|
||||
}
|
||||
for (std::shared_ptr<Base> cur = in.basact; cur; cur = cur->next) {
|
||||
@@ -431,8 +433,9 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M
|
||||
// so we can extract the file extension from it.
|
||||
const size_t nlen = strlen( img->name );
|
||||
const char* s = img->name+nlen, *e = s;
|
||||
|
||||
while (s >= img->name && *s != '.')--s;
|
||||
while ( s >= img->name && *s != '.' ) {
|
||||
--s;
|
||||
}
|
||||
|
||||
tex->achFormatHint[0] = s+1>e ? '\0' : ::tolower( s[1] );
|
||||
tex->achFormatHint[1] = s+2>e ? '\0' : ::tolower( s[2] );
|
||||
@@ -449,8 +452,7 @@ void BlenderImporter::ResolveImage(aiMaterial* out, const Material* mat, const M
|
||||
tex->pcData = reinterpret_cast<aiTexel*>(ch);
|
||||
|
||||
LogInfo("Reading embedded texture, original file was "+std::string(img->name));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
name = aiString( img->name );
|
||||
}
|
||||
|
||||
|
||||
@@ -805,5 +805,5 @@ void DNA::RegisterConverters() {
|
||||
converters["Image"] = DNA::FactoryPair( &Structure::Allocate<Image>, &Structure::Convert<Image> );
|
||||
}
|
||||
|
||||
|
||||
#endif // ASSIMP_BUILD_NO_BLEND_IMPORTER
|
||||
|
||||
|
||||
@@ -1075,10 +1075,7 @@ void Converter::SetupNodeMetadata( const Model& model, aiNode& nd )
|
||||
|
||||
// create metadata on node
|
||||
std::size_t numStaticMetaData = 2;
|
||||
aiMetadata* data = new aiMetadata();
|
||||
data->mNumProperties = static_cast<unsigned int>(unparsedProperties.size() + numStaticMetaData);
|
||||
data->mKeys = new aiString[ data->mNumProperties ]();
|
||||
data->mValues = new aiMetadataEntry[ data->mNumProperties ]();
|
||||
aiMetadata* data = aiMetadata::Alloc( static_cast<unsigned int>(unparsedProperties.size() + numStaticMetaData) );
|
||||
nd.mMetaData = data;
|
||||
int index = 0;
|
||||
|
||||
@@ -1089,22 +1086,22 @@ void Converter::SetupNodeMetadata( const Model& model, aiNode& nd )
|
||||
|
||||
// add unparsed properties to the node's metadata
|
||||
for( const DirectPropertyMap::value_type& prop : unparsedProperties ) {
|
||||
|
||||
// Interpret the property as a concrete type
|
||||
if ( const TypedProperty<bool>* interpreted = prop.second->As<TypedProperty<bool> >() )
|
||||
if ( const TypedProperty<bool>* interpreted = prop.second->As<TypedProperty<bool> >() ) {
|
||||
data->Set( index++, prop.first, interpreted->Value() );
|
||||
else if ( const TypedProperty<int>* interpreted = prop.second->As<TypedProperty<int> >() )
|
||||
} else if ( const TypedProperty<int>* interpreted = prop.second->As<TypedProperty<int> >() ) {
|
||||
data->Set( index++, prop.first, interpreted->Value() );
|
||||
else if ( const TypedProperty<uint64_t>* interpreted = prop.second->As<TypedProperty<uint64_t> >() )
|
||||
} else if ( const TypedProperty<uint64_t>* interpreted = prop.second->As<TypedProperty<uint64_t> >() ) {
|
||||
data->Set( index++, prop.first, interpreted->Value() );
|
||||
else if ( const TypedProperty<float>* interpreted = prop.second->As<TypedProperty<float> >() )
|
||||
} else if ( const TypedProperty<float>* interpreted = prop.second->As<TypedProperty<float> >() ) {
|
||||
data->Set( index++, prop.first, interpreted->Value() );
|
||||
else if ( const TypedProperty<std::string>* interpreted = prop.second->As<TypedProperty<std::string> >() )
|
||||
} else if ( const TypedProperty<std::string>* interpreted = prop.second->As<TypedProperty<std::string> >() ) {
|
||||
data->Set( index++, prop.first, aiString( interpreted->Value() ) );
|
||||
else if ( const TypedProperty<aiVector3D>* interpreted = prop.second->As<TypedProperty<aiVector3D> >() )
|
||||
} else if ( const TypedProperty<aiVector3D>* interpreted = prop.second->As<TypedProperty<aiVector3D> >() ) {
|
||||
data->Set( index++, prop.first, interpreted->Value() );
|
||||
else
|
||||
assert( false );
|
||||
} else {
|
||||
ai_assert( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1394,9 +1391,9 @@ unsigned int Converter::ConvertMeshMultiMaterial( const MeshGeometry& mesh, cons
|
||||
// allocate tangents, binormals.
|
||||
const std::vector<aiVector3D>& tangents = mesh.GetTangents();
|
||||
const std::vector<aiVector3D>* binormals = &mesh.GetBinormals();
|
||||
std::vector<aiVector3D> tempBinormals;
|
||||
|
||||
if ( tangents.size() ) {
|
||||
std::vector<aiVector3D> tempBinormals;
|
||||
if ( !binormals->size() ) {
|
||||
if ( normals.size() ) {
|
||||
// XXX this computes the binormals for the entire mesh, not only
|
||||
|
||||
@@ -127,8 +127,7 @@ void HMPImporter::InternReadFile( const std::string& pFile,
|
||||
throw DeadlyImportError( "HMP File is too small.");
|
||||
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector<uint8_t> buffer(fileSize);
|
||||
mBuffer = &buffer[0];
|
||||
mBuffer = new uint8_t[fileSize];
|
||||
file->Read( (void*)mBuffer, 1, fileSize);
|
||||
iFileSize = (unsigned int)fileSize;
|
||||
|
||||
@@ -174,7 +173,9 @@ void HMPImporter::InternReadFile( const std::string& pFile,
|
||||
// Set the AI_SCENE_FLAGS_TERRAIN bit
|
||||
pScene->mFlags |= AI_SCENE_FLAGS_TERRAIN;
|
||||
|
||||
// File buffer destructs automatically now
|
||||
delete[] mBuffer;
|
||||
mBuffer= nullptr;
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -449,11 +450,13 @@ void HMPImporter::ReadFirstSkin(unsigned int iNumSkins, const unsigned char* szC
|
||||
|
||||
// read the type of the skin ...
|
||||
// sometimes we need to skip 12 bytes here, I don't know why ...
|
||||
uint32_t iType = *((uint32_t*)szCursor);szCursor += sizeof(uint32_t);
|
||||
uint32_t iType = *((uint32_t*)szCursor);
|
||||
szCursor += sizeof(uint32_t);
|
||||
if (0 == iType)
|
||||
{
|
||||
szCursor += sizeof(uint32_t) * 2;
|
||||
iType = *((uint32_t*)szCursor);szCursor += sizeof(uint32_t);
|
||||
iType = *((uint32_t*)szCursor);
|
||||
szCursor += sizeof(uint32_t);
|
||||
if (!iType)
|
||||
throw DeadlyImportError("Unable to read HMP7 skin chunk");
|
||||
|
||||
|
||||
@@ -707,15 +707,11 @@ aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el, Conversion
|
||||
}
|
||||
|
||||
if (!properties.empty()) {
|
||||
aiMetadata* data = new aiMetadata();
|
||||
data->mNumProperties = static_cast<unsigned int>(properties.size());
|
||||
data->mKeys = new aiString[data->mNumProperties]();
|
||||
data->mValues = new aiMetadataEntry[data->mNumProperties]();
|
||||
|
||||
unsigned int index = 0;
|
||||
for(const Metadata::value_type& kv : properties)
|
||||
data->Set(index++, kv.first, aiString(kv.second));
|
||||
|
||||
aiMetadata* data = aiMetadata::Alloc( static_cast<unsigned int>(properties.size()) );
|
||||
unsigned int index( 0 );
|
||||
for ( const Metadata::value_type& kv : properties ) {
|
||||
data->Set( index++, kv.first, aiString( kv.second ) );
|
||||
}
|
||||
nd->mMetaData = data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,14 +269,15 @@ void IRRImporter::CopyMaterial(std::vector<aiMaterial*>& materials,
|
||||
if (UINT_MAX == defMatIdx)
|
||||
{
|
||||
defMatIdx = (unsigned int)materials.size();
|
||||
aiMaterial* mat = new aiMaterial();
|
||||
//TODO: add this materials to someone?
|
||||
/*aiMaterial* mat = new aiMaterial();
|
||||
|
||||
aiString s;
|
||||
s.Set(AI_DEFAULT_MATERIAL_NAME);
|
||||
mat->AddProperty(&s,AI_MATKEY_NAME);
|
||||
|
||||
aiColor3D c(0.6f,0.6f,0.6f);
|
||||
mat->AddProperty(&c,1,AI_MATKEY_COLOR_DIFFUSE);
|
||||
mat->AddProperty(&c,1,AI_MATKEY_COLOR_DIFFUSE);*/
|
||||
}
|
||||
mesh->mMaterialIndex = defMatIdx;
|
||||
return;
|
||||
|
||||
@@ -116,14 +116,18 @@ const aiImporterDesc* IRRMeshImporter::GetInfo () const
|
||||
return &desc;
|
||||
}
|
||||
|
||||
static void releaseMaterial( aiMaterial *mat ) {
|
||||
delete mat;
|
||||
mat = nullptr;
|
||||
static void releaseMaterial( aiMaterial **mat ) {
|
||||
if(*mat!= nullptr) {
|
||||
delete *mat;
|
||||
*mat = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void releaseMesh( aiMesh *mesh ) {
|
||||
delete mesh;
|
||||
mesh = nullptr;
|
||||
static void releaseMesh( aiMesh **mesh ) {
|
||||
if (*mesh != nullptr){
|
||||
delete *mesh;
|
||||
*mesh = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
@@ -148,8 +152,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
meshes.reserve(5);
|
||||
|
||||
// temporary data - current mesh buffer
|
||||
aiMaterial* curMat = NULL;
|
||||
aiMesh* curMesh = NULL;
|
||||
aiMaterial* curMat = nullptr;
|
||||
aiMesh* curMesh = nullptr;
|
||||
unsigned int curMatFlags = 0;
|
||||
|
||||
std::vector<aiVector3D> curVertices,curNormals,curTangents,curBitangents;
|
||||
@@ -170,14 +174,14 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
// end of previous buffer. A material and a mesh should be there
|
||||
if ( !curMat || !curMesh) {
|
||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||
releaseMaterial( curMat );
|
||||
releaseMesh( curMesh );
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
} else {
|
||||
materials.push_back(curMat);
|
||||
meshes.push_back(curMesh);
|
||||
}
|
||||
curMat = NULL;
|
||||
curMesh = NULL;
|
||||
curMat = nullptr;
|
||||
curMesh = nullptr;
|
||||
|
||||
curVertices.clear();
|
||||
curColors.clear();
|
||||
@@ -192,7 +196,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
if (!ASSIMP_stricmp(reader->getNodeName(),"material")) {
|
||||
if (curMat) {
|
||||
DefaultLogger::get()->warn("IRRMESH: Only one material description per buffer, please");
|
||||
releaseMaterial( curMat );
|
||||
releaseMaterial( &curMat );
|
||||
}
|
||||
curMat = ParseMaterial(curMatFlags);
|
||||
}
|
||||
@@ -204,8 +208,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
// This is possible ... remove the mesh from the list and skip further reading
|
||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero vertices");
|
||||
|
||||
releaseMaterial( curMat );
|
||||
releaseMesh( curMesh );
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
textMeaning = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -248,7 +252,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
vertexFormat = 2;
|
||||
}
|
||||
else if (ASSIMP_stricmp("standard", t)) {
|
||||
releaseMaterial( curMat );
|
||||
releaseMaterial( &curMat );
|
||||
DefaultLogger::get()->warn("IRRMESH: Unknown vertex format");
|
||||
}
|
||||
else vertexFormat = 0;
|
||||
@@ -256,7 +260,7 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
}
|
||||
else if (!ASSIMP_stricmp(reader->getNodeName(),"indices")) {
|
||||
if (curVertices.empty() && curMat) {
|
||||
releaseMaterial( curMat );
|
||||
releaseMaterial( &curMat );
|
||||
throw DeadlyImportError("IRRMESH: indices must come after vertices");
|
||||
}
|
||||
|
||||
@@ -272,10 +276,10 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
DefaultLogger::get()->warn("IRRMESH: Found mesh with zero indices");
|
||||
|
||||
// mesh - away
|
||||
releaseMesh( curMesh );
|
||||
releaseMesh( &curMesh );
|
||||
|
||||
// material - away
|
||||
releaseMaterial( curMat );
|
||||
releaseMaterial( &curMat );
|
||||
|
||||
textMeaning = 0;
|
||||
continue;
|
||||
@@ -487,8 +491,8 @@ void IRRMeshImporter::InternReadFile( const std::string& pFile,
|
||||
if (curMat || curMesh) {
|
||||
if ( !curMat || !curMesh) {
|
||||
DefaultLogger::get()->error("IRRMESH: A buffer must contain a mesh and a material");
|
||||
releaseMaterial( curMat );
|
||||
releaseMesh( curMesh );
|
||||
releaseMaterial( &curMat );
|
||||
releaseMesh( &curMesh );
|
||||
}
|
||||
else {
|
||||
materials.push_back(curMat);
|
||||
|
||||
@@ -1058,8 +1058,6 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
||||
LWO::PointList& pointList = mCurLayer->mTempPoints;
|
||||
LWO::ReferrerList& refList = mCurLayer->mPointReferrers;
|
||||
|
||||
float temp[4];
|
||||
|
||||
const unsigned int numPoints = (unsigned int)pointList.size();
|
||||
const unsigned int numFaces = (unsigned int)list.size();
|
||||
|
||||
@@ -1123,10 +1121,12 @@ void LWOImporter::LoadLWO2VertexMap(unsigned int length, bool perPoly)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<float[]> temp(new float[type]);
|
||||
for (unsigned int l = 0; l < type;++l)
|
||||
temp[l] = GetF4();
|
||||
|
||||
DoRecursiveVMAPAssignment(base,type,idx, temp);
|
||||
DoRecursiveVMAPAssignment(base,type,idx, temp.get());
|
||||
mFileBuffer += diff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,8 +172,7 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||
}
|
||||
|
||||
// Allocate storage and copy the contents of the file to a memory buffer
|
||||
std::vector<unsigned char> buffer(iFileSize+1);
|
||||
mBuffer = &buffer[0];
|
||||
mBuffer =new unsigned char[iFileSize+1];
|
||||
file->Read( (void*)mBuffer, 1, iFileSize);
|
||||
|
||||
// Append a binary zero to the end of the buffer.
|
||||
@@ -239,7 +238,8 @@ void MDLImporter::InternReadFile( const std::string& pFile,
|
||||
0.f,0.f,1.f,0.f,0.f,-1.f,0.f,0.f,0.f,0.f,0.f,1.f);
|
||||
|
||||
// delete the file buffer and cleanup
|
||||
AI_DEBUG_INVALIDATE_PTR(mBuffer);
|
||||
delete [] mBuffer;
|
||||
mBuffer= nullptr;
|
||||
AI_DEBUG_INVALIDATE_PTR(pIOHandler);
|
||||
AI_DEBUG_INVALIDATE_PTR(pScene);
|
||||
}
|
||||
@@ -1557,7 +1557,7 @@ void MDLImporter::InternReadFile_3DGS_MDL7( )
|
||||
} else {
|
||||
pcNode->mName.length = ::strlen(szBuffer);
|
||||
}
|
||||
::strcpy(pcNode->mName.data,szBuffer);
|
||||
::strncpy(pcNode->mName.data,szBuffer,MAXLEN-1);
|
||||
++p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||
unsigned int iWidth,
|
||||
unsigned int iHeight)
|
||||
{
|
||||
aiTexture* pcNew = NULL;
|
||||
aiTexture* pcNew = nullptr;
|
||||
|
||||
// get the type of the skin
|
||||
unsigned int iMasked = (unsigned int)(iType & 0xF);
|
||||
@@ -522,7 +522,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||
memcpy(pcNew->pcData,szCurrent,pcNew->mWidth);
|
||||
szCurrent += iWidth;
|
||||
}
|
||||
if (0x7 == iMasked)
|
||||
else if (0x7 == iMasked)
|
||||
{
|
||||
// ***** REFERENCE TO EXTERNAL FILE *****
|
||||
if (1 != iHeight)
|
||||
@@ -546,6 +546,9 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
|
||||
else if (iMasked || !iType || (iType && iWidth && iHeight))
|
||||
{
|
||||
// ***** STANDARD COLOR TEXTURE *****
|
||||
if(pcNew!= nullptr)
|
||||
delete pcNew;
|
||||
|
||||
pcNew = new aiTexture();
|
||||
if (!iHeight || !iWidth)
|
||||
{
|
||||
|
||||
@@ -168,6 +168,8 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// build output vertex weights
|
||||
for (unsigned int i = 0;i < pcMesh->mNumBones;++i)
|
||||
{
|
||||
@@ -177,11 +179,11 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh)
|
||||
aiVertexWeight *weightToCopy = &( newWeights[i][0] );
|
||||
memcpy(pcMesh->mBones[i]->mWeights, weightToCopy,
|
||||
sizeof(aiVertexWeight) * newWeights[i].size());
|
||||
delete[] newWeights;
|
||||
} else {
|
||||
pcMesh->mBones[i]->mWeights = NULL;
|
||||
}
|
||||
}
|
||||
delete[] newWeights;
|
||||
|
||||
// delete the old members
|
||||
delete[] pcMesh->mVertices;
|
||||
|
||||
@@ -257,7 +257,8 @@ void NDOImporter::InternReadFile( const std::string& pFile,
|
||||
}
|
||||
|
||||
aiMesh* mesh = new aiMesh();
|
||||
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces=static_cast<unsigned int>(face_table.size())];
|
||||
mesh->mNumFaces=static_cast<unsigned int>(face_table.size());
|
||||
aiFace* faces = mesh->mFaces = new aiFace[mesh->mNumFaces];
|
||||
|
||||
vertices.clear();
|
||||
vertices.reserve(4 * face_table.size()); // arbitrarily chosen
|
||||
@@ -298,7 +299,8 @@ void NDOImporter::InternReadFile( const std::string& pFile,
|
||||
pScene->mMeshes[pScene->mNumMeshes] = mesh;
|
||||
|
||||
(nd->mMeshes = new unsigned int[nd->mNumMeshes=1])[0]=pScene->mNumMeshes++;
|
||||
}
|
||||
}else
|
||||
delete mesh;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -451,6 +451,7 @@ void ObjFileParser::getFace( aiPrimitiveType type ) {
|
||||
DefaultLogger::get()->error("Obj: Ignoring empty face");
|
||||
// skip line and clean up
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
delete face;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -901,11 +901,8 @@ void SIBImporter::InternReadFile(const std::string& pFile,
|
||||
// Mark instanced objects as being so.
|
||||
if (n >= firstInst)
|
||||
{
|
||||
node->mMetaData = new aiMetadata;
|
||||
node->mMetaData->mNumProperties = 1;
|
||||
node->mMetaData->mKeys = new aiString[1];
|
||||
node->mMetaData->mValues = new aiMetadataEntry[1];
|
||||
node->mMetaData->Set(0, "IsInstance", true);
|
||||
node->mMetaData = aiMetadata::Alloc( 1 );
|
||||
node->mMetaData->Set( 0, "IsInstance", true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -641,7 +641,7 @@ void SMDImporter::ComputeAbsoluteBoneTransformations()
|
||||
bone.mOffsetMatrix.Inverse();
|
||||
}
|
||||
}
|
||||
|
||||
\
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// create output materials
|
||||
void SMDImporter::CreateOutputMaterials()
|
||||
@@ -660,7 +660,7 @@ void SMDImporter::CreateOutputMaterials()
|
||||
|
||||
if (aszTextures[iMat].length())
|
||||
{
|
||||
::strcpy(szName.data, aszTextures[iMat].c_str() );
|
||||
::strncpy(szName.data, aszTextures[iMat].c_str(),MAXLEN-1);
|
||||
szName.length = aszTextures[iMat].length();
|
||||
pcMat->AddProperty(&szName,AI_MATKEY_TEXTURE_DIFFUSE(0));
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ void STLImporter::LoadASCIIFile()
|
||||
}
|
||||
else pScene->mRootNode->mName.Set("<STL_ASCII>");
|
||||
|
||||
unsigned int faceVertexCounter = 0;
|
||||
unsigned int faceVertexCounter = 3;
|
||||
for ( ;; )
|
||||
{
|
||||
// go to the next token
|
||||
|
||||
@@ -43,11 +43,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
// possible as new fields are added to assimp structures.
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** @file Implements Assimp::SceneCombiner. This is a smart utility
|
||||
* class that combines multiple scenes, meshes, ... into one. Currently
|
||||
* these utilities are used by the IRR and LWS loaders and the
|
||||
* OptimizeGraph step.
|
||||
*/
|
||||
/**
|
||||
* @file Implements Assimp::SceneCombiner. This is a smart utility
|
||||
* class that combines multiple scenes, meshes, ... into one. Currently
|
||||
* these utilities are used by the IRR and LWS loaders and the
|
||||
* OptimizeGraph step.
|
||||
*/
|
||||
// ----------------------------------------------------------------------------
|
||||
#include "SceneCombiner.h"
|
||||
#include "StringUtils.h"
|
||||
@@ -59,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <stdio.h>
|
||||
#include "ScenePrivate.h"
|
||||
|
||||
namespace Assimp {
|
||||
namespace Assimp {
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Add a prefix to a string
|
||||
@@ -198,8 +199,9 @@ void SceneCombiner::MergeScenes(aiScene** _dest,std::vector<aiScene*>& src,
|
||||
void SceneCombiner::AttachToGraph (aiNode* attach, std::vector<NodeAttachmentInfo>& srcList)
|
||||
{
|
||||
unsigned int cnt;
|
||||
for (cnt = 0; cnt < attach->mNumChildren;++cnt)
|
||||
AttachToGraph(attach->mChildren[cnt],srcList);
|
||||
for ( cnt = 0; cnt < attach->mNumChildren; ++cnt ) {
|
||||
AttachToGraph( attach->mChildren[ cnt ], srcList );
|
||||
}
|
||||
|
||||
cnt = 0;
|
||||
for (std::vector<NodeAttachmentInfo>::iterator it = srcList.begin();
|
||||
@@ -1219,13 +1221,12 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void SceneCombiner::Copy (aiMetadata** _dest, const aiMetadata* src)
|
||||
void SceneCombiner::Copy(aiMetadata** _dest, const aiMetadata* src)
|
||||
{
|
||||
ai_assert(NULL != _dest && NULL != src);
|
||||
ai_assert( NULL != _dest );
|
||||
ai_assert( NULL != src);
|
||||
|
||||
aiMetadata* dest = *_dest = new aiMetadata();
|
||||
dest->mNumProperties = src->mNumProperties;
|
||||
dest->mKeys = new aiString[src->mNumProperties];
|
||||
aiMetadata* dest = *_dest = aiMetadata::Alloc( src->mNumProperties );
|
||||
std::copy(src->mKeys, src->mKeys + src->mNumProperties, dest->mKeys);
|
||||
|
||||
dest->mValues = new aiMetadataEntry[src->mNumProperties];
|
||||
|
||||
@@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "SpatialSort.h"
|
||||
#include "ProcessHelper.h"
|
||||
#include "Vertex.h"
|
||||
#include <assimp/ai_assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Assimp;
|
||||
@@ -55,9 +56,7 @@ void mydummy() {}
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
class CatmullClarkSubdivider : public Subdivider
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void Subdivide (aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input);
|
||||
void Subdivide (aiMesh** smesh, size_t nmesh,
|
||||
aiMesh** out, unsigned int num, bool discard_input);
|
||||
@@ -74,8 +73,6 @@ public:
|
||||
unsigned int ref;
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef std::vector<unsigned int> UIntVector;
|
||||
typedef std::map<uint64_t,Edge> EdgeMap;
|
||||
|
||||
@@ -99,7 +96,6 @@ public:
|
||||
unsigned int eh_tmp0__, eh_tmp1__;
|
||||
|
||||
private:
|
||||
|
||||
void InternSubdivide (const aiMesh* const * smesh,
|
||||
size_t nmesh,aiMesh** out, unsigned int num);
|
||||
};
|
||||
@@ -128,7 +124,8 @@ void CatmullClarkSubdivider::Subdivide (
|
||||
bool discard_input
|
||||
)
|
||||
{
|
||||
assert(mesh != out);
|
||||
ai_assert(mesh != out);
|
||||
|
||||
Subdivide(&mesh,1,&out,num,discard_input);
|
||||
}
|
||||
|
||||
@@ -142,12 +139,12 @@ void CatmullClarkSubdivider::Subdivide (
|
||||
bool discard_input
|
||||
)
|
||||
{
|
||||
ai_assert(NULL != smesh && NULL != out);
|
||||
ai_assert( NULL != smesh );
|
||||
ai_assert( NULL != out );
|
||||
|
||||
// course, both regions may not overlap
|
||||
assert(smesh<out || smesh+nmesh>out+nmesh);
|
||||
ai_assert(smesh<out || smesh+nmesh>out+nmesh);
|
||||
if (!num) {
|
||||
|
||||
// No subdivision at all. Need to copy all the meshes .. argh.
|
||||
if (discard_input) {
|
||||
for (size_t s = 0; s < nmesh; ++s) {
|
||||
|
||||
@@ -1480,10 +1480,11 @@ void X3DImporter::ParseNode_Head()
|
||||
XML_CheckNode_MustBeEmpty();
|
||||
|
||||
// adding metadata from <head> as MetaString from <Scene>
|
||||
CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur);
|
||||
bool added( false );
|
||||
CX3DImporter_NodeElement_MetaString* ms = new CX3DImporter_NodeElement_MetaString(NodeElement_Cur);
|
||||
|
||||
ms->Name = mReader->getAttributeValueSafe("name");
|
||||
// name can not be empty
|
||||
// name must not be empty
|
||||
if(!ms->Name.empty())
|
||||
{
|
||||
ms->Value.push_back(mReader->getAttributeValueSafe("content"));
|
||||
@@ -1491,8 +1492,13 @@ void X3DImporter::ParseNode_Head()
|
||||
if ( NodeElement_Cur != nullptr )
|
||||
{
|
||||
NodeElement_Cur->Child.push_back( ms );
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
// if an error has occurred, release instance
|
||||
if ( !added ) {
|
||||
delete ms;
|
||||
}
|
||||
}// if(XML_CheckNode_NameEqual("meta"))
|
||||
}// if(mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
||||
else if(mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
||||
|
||||
@@ -130,37 +130,35 @@ public:
|
||||
public:
|
||||
|
||||
std::string ID;///< ID of the element. Can be empty. In X3D synonym for "ID" attribute.
|
||||
CX3DImporter_NodeElement* Parent;///< Parrent element. If nullptr then this node is root.
|
||||
CX3DImporter_NodeElement* Parent;///< Parent element. If nullptr then this node is root.
|
||||
std::list<CX3DImporter_NodeElement*> Child;///< Child elements.
|
||||
|
||||
/***********************************************/
|
||||
/****************** Functions ******************/
|
||||
/***********************************************/
|
||||
|
||||
private:
|
||||
/// @brief The destructor, virtual.
|
||||
virtual ~CX3DImporter_NodeElement() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/// \fn CX3DImporter_NodeElement(const CX3DImporter_NodeElement& pNodeElement)
|
||||
private:
|
||||
/// Disabled copy constructor.
|
||||
CX3DImporter_NodeElement(const CX3DImporter_NodeElement& pNodeElement);
|
||||
|
||||
/// \fn CX3DImporter_NodeElement& operator=(const CX3DImporter_NodeElement& pNodeElement)
|
||||
/// Disabled assign operator.
|
||||
CX3DImporter_NodeElement& operator=(const CX3DImporter_NodeElement& pNodeElement);
|
||||
|
||||
/// \fn CX3DImporter_NodeElement()
|
||||
/// Disabled default constructor.
|
||||
CX3DImporter_NodeElement();
|
||||
|
||||
protected:
|
||||
|
||||
/// \fn CX3DImporter_NodeElement(const EType pType, CX3DImporter_NodeElement* pParent)
|
||||
/// In constructor inheritor must set element type.
|
||||
/// \param [in] pType - element type.
|
||||
/// \param [in] pParent - parent element.
|
||||
CX3DImporter_NodeElement(const EType pType, CX3DImporter_NodeElement* pParent)
|
||||
: Type(pType), Parent(pParent)
|
||||
{}
|
||||
|
||||
};// class IX3DImporter_NodeElement
|
||||
|
||||
/// \class CX3DImporter_NodeElement_Group
|
||||
|
||||
@@ -758,15 +758,14 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN
|
||||
size_t meta_idx;
|
||||
|
||||
PostprocessHelper_CollectMetadata(pNodeElement, meta_list);// find metadata in current node element.
|
||||
if(meta_list.size() > 0)
|
||||
if ( !meta_list.empty() )
|
||||
{
|
||||
if(pSceneNode.mMetaData != nullptr) throw DeadlyImportError("Postprocess. MetaData member in node are not nullptr. Something went wrong.");
|
||||
if ( pSceneNode.mMetaData != nullptr ) {
|
||||
throw DeadlyImportError( "Postprocess. MetaData member in node are not nullptr. Something went wrong." );
|
||||
}
|
||||
|
||||
// copy collected metadata to output node.
|
||||
pSceneNode.mMetaData = new aiMetadata();
|
||||
pSceneNode.mMetaData->mNumProperties = meta_list.size();
|
||||
pSceneNode.mMetaData->mKeys = new aiString[pSceneNode.mMetaData->mNumProperties];
|
||||
pSceneNode.mMetaData->mValues = new aiMetadataEntry[pSceneNode.mMetaData->mNumProperties];
|
||||
// copy collected metadata to output node.
|
||||
pSceneNode.mMetaData = aiMetadata::Alloc( meta_list.size() );
|
||||
meta_idx = 0;
|
||||
for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++, meta_idx++)
|
||||
{
|
||||
@@ -808,7 +807,7 @@ void X3DImporter::Postprocess_CollectMetadata(const CX3DImporter_NodeElement& pN
|
||||
throw DeadlyImportError("Postprocess. Unknown metadata type.");
|
||||
}// if((*it)->Type == CX3DImporter_NodeElement::ENET_Meta*) else
|
||||
}// for(std::list<CX3DImporter_NodeElement*>::const_iterator it = meta_list.begin(); it != meta_list.end(); it++)
|
||||
}// if(meta_list.size() > 0)
|
||||
}// if( !meta_list.empty() )
|
||||
}
|
||||
|
||||
}// namespace Assimp
|
||||
|
||||
@@ -513,7 +513,7 @@ std::string XFileExporter::toXFileString(aiString &name)
|
||||
return str;
|
||||
}
|
||||
|
||||
void XFileExporter::writePath(aiString path)
|
||||
void XFileExporter::writePath(const aiString &path)
|
||||
{
|
||||
std::string str = std::string(path.C_Str());
|
||||
BaseImporter::ConvertUTF8toISO8859_1(str);
|
||||
|
||||
@@ -107,7 +107,7 @@ protected:
|
||||
const ExportProperties* mProperties;
|
||||
|
||||
/// write a path
|
||||
void writePath(aiString path);
|
||||
void writePath(const aiString &path);
|
||||
|
||||
/// The IOSystem for output
|
||||
IOSystem* mIOSystem;
|
||||
|
||||
@@ -744,6 +744,10 @@ namespace glTF
|
||||
SExtension(const EType pType)
|
||||
: Type(pType)
|
||||
{}
|
||||
|
||||
virtual ~SExtension() {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
|
||||
@@ -765,8 +769,13 @@ namespace glTF
|
||||
/// \fn SCompression_Open3DGC
|
||||
/// Constructor.
|
||||
SCompression_Open3DGC()
|
||||
: SExtension(Compression_Open3DGC)
|
||||
{}
|
||||
: SExtension(Compression_Open3DGC) {
|
||||
// empty
|
||||
}
|
||||
|
||||
virtual ~SCompression_Open3DGC() {
|
||||
// empty
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1005,6 +1005,12 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||
size_t tval = ifs.GetNIntAttribute(static_cast<unsigned long>(idx));
|
||||
switch( ifs.GetIntAttributeType(static_cast<unsigned long>(idx) ) )
|
||||
{
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_UNKOWN:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_JOINT_ID:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX_BUFFER_ID:
|
||||
break;
|
||||
|
||||
default:
|
||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(static_cast<unsigned long>(idx))));
|
||||
}
|
||||
@@ -1049,10 +1055,14 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
for(size_t idx = 0, idx_end = size_intattr.size(); idx < idx_end; idx++)
|
||||
{
|
||||
switch(ifs.GetIntAttributeType(static_cast<unsigned long>(idx)))
|
||||
{
|
||||
for(size_t idx = 0, idx_end = size_intattr.size(); idx < idx_end; idx++) {
|
||||
switch(ifs.GetIntAttributeType(static_cast<unsigned int>(idx))) {
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_UNKOWN:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_JOINT_ID:
|
||||
case o3dgc::O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX_BUFFER_ID:
|
||||
break;
|
||||
|
||||
// ifs.SetIntAttribute(idx, (long* const)(decoded_data + get_buf_offset(primitives[0].attributes.joint)));
|
||||
default:
|
||||
throw DeadlyImportError("GLTF: Open3DGC. Unsupported type of int attribute: " + to_string(ifs.GetIntAttributeType(static_cast<unsigned long>(idx))));
|
||||
@@ -1062,7 +1072,9 @@ Ref<Buffer> buf = pAsset_Root.buffers.Get(pCompression_Open3DGC.Buffer);
|
||||
//
|
||||
// Decode data
|
||||
//
|
||||
if(decoder.DecodePayload(ifs, bstream) != o3dgc::O3DGC_OK) throw DeadlyImportError("GLTF: can not decode Open3DGC data.");
|
||||
if ( decoder.DecodePayload( ifs, bstream ) != o3dgc::O3DGC_OK ) {
|
||||
throw DeadlyImportError( "GLTF: can not decode Open3DGC data." );
|
||||
}
|
||||
|
||||
// Set encoded region for "buffer".
|
||||
buf->EncodedRegion_Mark(pCompression_Open3DGC.Offset, pCompression_Open3DGC.Count, decoded_data, decoded_data_size, id);
|
||||
|
||||
@@ -37,9 +37,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef ASSIMP_BUILD_NO_EXPORT
|
||||
#ifndef ASSIMP_BUILD_NO_GLTF_EXPORTER
|
||||
|
||||
@@ -94,8 +91,6 @@ namespace Assimp {
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
|
||||
|
||||
glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiScene* pScene,
|
||||
const ExportProperties* pProperties, bool isBinary)
|
||||
: mFilename(filename)
|
||||
@@ -418,17 +413,18 @@ Ref<Node> FindSkeletonRootJoint(Ref<Skin>& skinRef)
|
||||
return parentNodeRef;
|
||||
}
|
||||
|
||||
void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref<Mesh>& meshRef, Ref<Buffer>& bufferRef, Ref<Skin>& skinRef, std::vector<aiMatrix4x4>& inverseBindMatricesData)
|
||||
void ExportSkin(Asset& mAsset, const aiMesh* aimesh, Ref<Mesh>& meshRef, Ref<Buffer>& bufferRef, Ref<Skin>& skinRef, std::vector<aiMatrix4x4>& inverseBindMatricesData)
|
||||
{
|
||||
if (aim->mNumBones < 1) {
|
||||
if (aimesh->mNumBones < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the vertex joint and weight data.
|
||||
vec4* vertexJointData = new vec4[aim->mNumVertices];
|
||||
vec4* vertexWeightData = new vec4[aim->mNumVertices];
|
||||
int* jointsPerVertex = new int[aim->mNumVertices];
|
||||
for (size_t i = 0; i < aim->mNumVertices; ++i) {
|
||||
const size_t NumVerts( aimesh->mNumVertices );
|
||||
vec4* vertexJointData = new vec4[ NumVerts ];
|
||||
vec4* vertexWeightData = new vec4[ NumVerts ];
|
||||
int* jointsPerVertex = new int[ NumVerts ];
|
||||
for (size_t i = 0; i < NumVerts; ++i) {
|
||||
jointsPerVertex[i] = 0;
|
||||
for (size_t j = 0; j < 4; ++j) {
|
||||
vertexJointData[i][j] = 0;
|
||||
@@ -436,8 +432,8 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref<Mesh>& meshRef, Ref<Buffer
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int idx_bone = 0; idx_bone < aim->mNumBones; ++idx_bone) {
|
||||
const aiBone* aib = aim->mBones[idx_bone];
|
||||
for (unsigned int idx_bone = 0; idx_bone < aimesh->mNumBones; ++idx_bone) {
|
||||
const aiBone* aib = aimesh->mBones[idx_bone];
|
||||
|
||||
// aib->mName =====> skinRef->jointNames
|
||||
// Find the node with id = mName.
|
||||
@@ -469,7 +465,9 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref<Mesh>& meshRef, Ref<Buffer
|
||||
float vertWeight = aib->mWeights[idx_weights].mWeight;
|
||||
|
||||
// A vertex can only have at most four joint weights. Ignore all others.
|
||||
if (jointsPerVertex[vertexId] > 3) { continue; }
|
||||
if (jointsPerVertex[vertexId] > 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;
|
||||
vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
|
||||
@@ -480,11 +478,18 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref<Mesh>& meshRef, Ref<Buffer
|
||||
} // End: for-loop mNumMeshes
|
||||
|
||||
Mesh::Primitive& p = meshRef->primitives.back();
|
||||
Ref<Accessor> vertexJointAccessor = ExportData(mAsset, skinRef->id, bufferRef, aim->mNumVertices, vertexJointData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if (vertexJointAccessor) p.attributes.joint.push_back(vertexJointAccessor);
|
||||
Ref<Accessor> vertexJointAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices, vertexJointData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if ( vertexJointAccessor ) {
|
||||
p.attributes.joint.push_back( vertexJointAccessor );
|
||||
}
|
||||
|
||||
Ref<Accessor> vertexWeightAccessor = ExportData(mAsset, skinRef->id, bufferRef, aim->mNumVertices, vertexWeightData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if (vertexWeightAccessor) p.attributes.weight.push_back(vertexWeightAccessor);
|
||||
Ref<Accessor> vertexWeightAccessor = ExportData(mAsset, skinRef->id, bufferRef, aimesh->mNumVertices, vertexWeightData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if ( vertexWeightAccessor ) {
|
||||
p.attributes.weight.push_back( vertexWeightAccessor );
|
||||
}
|
||||
delete[] jointsPerVertex;
|
||||
delete[] vertexWeightData;
|
||||
delete[] vertexJointData;
|
||||
}
|
||||
|
||||
void glTFExporter::ExportMeshes()
|
||||
@@ -864,7 +869,10 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
|
||||
}
|
||||
|
||||
Ref<Accessor> tranAccessor = ExportData(mAsset, animId, buffer, nodeChannel->mNumPositionKeys, translationData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
if (tranAccessor) animRef->Parameters.translation = tranAccessor;
|
||||
if ( tranAccessor ) {
|
||||
animRef->Parameters.translation = tranAccessor;
|
||||
}
|
||||
delete[] translationData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
@@ -876,7 +884,10 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
|
||||
}
|
||||
|
||||
Ref<Accessor> scaleAccessor = ExportData(mAsset, animId, buffer, nodeChannel->mNumScalingKeys, scaleData, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||
if (scaleAccessor) animRef->Parameters.scale = scaleAccessor;
|
||||
if ( scaleAccessor ) {
|
||||
animRef->Parameters.scale = scaleAccessor;
|
||||
}
|
||||
delete[] scaleData;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
@@ -891,7 +902,10 @@ inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animati
|
||||
}
|
||||
|
||||
Ref<Accessor> rotAccessor = ExportData(mAsset, animId, buffer, nodeChannel->mNumRotationKeys, rotationData, AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT);
|
||||
if (rotAccessor) animRef->Parameters.rotation = rotAccessor;
|
||||
if ( rotAccessor ) {
|
||||
animRef->Parameters.rotation = rotAccessor;
|
||||
}
|
||||
delete[] rotationData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user