Merge branch 'master' into patch-1
commit
0a1535647a
|
@ -34,6 +34,7 @@
|
|||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#----------------------------------------------------------------------
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0012 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
|
||||
SET(CMAKE_POLICY_DEFAULT_CMP0092 NEW)
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
|
|||
result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
|
||||
result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
|
||||
|
@ -66,7 +66,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
|
|||
ToCamelCase(val.first);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() {
|
||||
static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();
|
||||
|
|
|
@ -375,6 +375,11 @@ bool ReadScope(TokenList& output_tokens, const char* input, const char*& cursor,
|
|||
|
||||
// now come the individual properties
|
||||
const char* begin_cursor = cursor;
|
||||
|
||||
if ((begin_cursor + prop_length) > end) {
|
||||
TokenizeError("property length out of bounds reading length ", input, cursor);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < prop_count; ++i) {
|
||||
ReadData(sbeg, send, input, cursor, begin_cursor + prop_length);
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
#include <iomanip>
|
||||
|
||||
// Header files, Assimp
|
||||
|
@ -331,7 +332,10 @@ inline void Buffer::Read(Value &obj, Asset &r) {
|
|||
}
|
||||
} else { // Local file
|
||||
if (byteLength > 0) {
|
||||
std::string dir = !r.mCurrentAssetDir.empty() ? (r.mCurrentAssetDir) : "";
|
||||
std::string dir = !r.mCurrentAssetDir.empty() ? (
|
||||
r.mCurrentAssetDir.back() == '/' ?
|
||||
r.mCurrentAssetDir : r.mCurrentAssetDir + '/'
|
||||
) : "";
|
||||
|
||||
IOStream *file = r.OpenFile(dir + uri, "rb");
|
||||
if (file) {
|
||||
|
@ -1276,7 +1280,9 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) {
|
|||
|
||||
/*int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
|
||||
if (pos != int(std::string::npos)) mCurrentAssetDir = pFile.substr(0, pos + 1);*/
|
||||
if (0 != strncmp(pFile.c_str(), AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH)) {
|
||||
mCurrentAssetDir = getCurrentAssetDir(pFile);
|
||||
}
|
||||
|
||||
shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true));
|
||||
if (!stream) {
|
||||
|
|
|
@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/StringUtils.h>
|
||||
#include <assimp/DefaultLogger.hpp>
|
||||
#include <assimp/MemoryIOWrapper.h>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
|
@ -400,7 +401,10 @@ inline void Buffer::Read(Value &obj, Asset &r) {
|
|||
}
|
||||
} else { // Local file
|
||||
if (byteLength > 0) {
|
||||
std::string dir = !r.mCurrentAssetDir.empty() ? (r.mCurrentAssetDir) : "";
|
||||
std::string dir = !r.mCurrentAssetDir.empty() ? (
|
||||
r.mCurrentAssetDir.back() == '/' ?
|
||||
r.mCurrentAssetDir : r.mCurrentAssetDir + '/'
|
||||
) : "";
|
||||
|
||||
IOStream *file = r.OpenFile(dir + uri, "rb");
|
||||
if (file) {
|
||||
|
@ -1590,7 +1594,9 @@ inline void Asset::Load(const std::string &pFile, bool isBinary) {
|
|||
/*int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
|
||||
if (pos != int(std::string::npos)) */
|
||||
|
||||
if (0 != strncmp(pFile.c_str(), AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH)) {
|
||||
mCurrentAssetDir = glTFCommon::getCurrentAssetDir(pFile);
|
||||
}
|
||||
|
||||
shared_ptr<IOStream> stream(OpenFile(pFile.c_str(), "rb", true));
|
||||
if (!stream) {
|
||||
|
|
|
@ -229,6 +229,7 @@ inline void SetMaterialTextureProperty(std::vector<int> &embeddedTexIdxs, Asset
|
|||
static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, Material &mat) {
|
||||
aiMaterial *aimat = new aiMaterial();
|
||||
|
||||
try {
|
||||
if (!mat.name.empty()) {
|
||||
aiString str(mat.name);
|
||||
|
||||
|
@ -282,6 +283,10 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
|
|||
}
|
||||
|
||||
return aimat;
|
||||
} catch (...) {
|
||||
delete aimat;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void glTF2Importer::ImportMaterials(glTF2::Asset &r) {
|
||||
|
@ -291,6 +296,7 @@ void glTF2Importer::ImportMaterials(glTF2::Asset &r) {
|
|||
|
||||
mScene->mNumMaterials = numImportedMaterials + 1;
|
||||
mScene->mMaterials = new aiMaterial *[mScene->mNumMaterials];
|
||||
std::fill(mScene->mMaterials, mScene->mMaterials + mScene->mNumMaterials, nullptr);
|
||||
mScene->mMaterials[numImportedMaterials] = ImportMaterial(embeddedTexIdxs, r, defaultMaterial);
|
||||
|
||||
for (unsigned int i = 0; i < numImportedMaterials; ++i) {
|
||||
|
@ -452,6 +458,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
if (targets.size() > 0) {
|
||||
aim->mNumAnimMeshes = (unsigned int)targets.size();
|
||||
aim->mAnimMeshes = new aiAnimMesh *[aim->mNumAnimMeshes];
|
||||
std::fill(aim->mAnimMeshes, aim->mAnimMeshes + aim->mNumAnimMeshes, nullptr);
|
||||
for (size_t i = 0; i < targets.size(); i++) {
|
||||
bool needPositions = targets[i].position.size() > 0;
|
||||
bool needNormals = targets[i].normal.size() > 0;
|
||||
|
@ -510,7 +517,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
|
|||
size_t count = prim.indices->count;
|
||||
|
||||
Accessor::Indexer data = prim.indices->GetIndexer();
|
||||
ai_assert(data.IsValid());
|
||||
if (!data.IsValid()) {
|
||||
throw DeadlyImportError("GLTF: Invalid accessor without data in mesh ", getContextForErrorMessages(mesh.id, mesh.name));
|
||||
}
|
||||
|
||||
switch (prim.mode) {
|
||||
case PrimitiveMode_POINTS: {
|
||||
|
@ -699,6 +708,7 @@ void glTF2Importer::ImportCameras(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_DEBUG_F("Importing ", numCameras, " cameras");
|
||||
mScene->mNumCameras = numCameras;
|
||||
mScene->mCameras = new aiCamera *[numCameras];
|
||||
std::fill(mScene->mCameras, mScene->mCameras + numCameras, nullptr);
|
||||
|
||||
for (size_t i = 0; i < numCameras; ++i) {
|
||||
Camera &cam = r.cameras[i];
|
||||
|
@ -735,6 +745,7 @@ void glTF2Importer::ImportLights(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_DEBUG_F("Importing ", numLights, " lights");
|
||||
mScene->mNumLights = numLights;
|
||||
mScene->mLights = new aiLight *[numLights];
|
||||
std::fill(mScene->mLights, mScene->mLights + numLights, nullptr);
|
||||
|
||||
for (size_t i = 0; i < numLights; ++i) {
|
||||
Light &light = r.lights[i];
|
||||
|
@ -898,9 +909,11 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
|||
|
||||
aiNode *ainode = new aiNode(GetNodeName(node));
|
||||
|
||||
try {
|
||||
if (!node.children.empty()) {
|
||||
ainode->mNumChildren = unsigned(node.children.size());
|
||||
ainode->mChildren = new aiNode *[ainode->mNumChildren];
|
||||
std::fill(ainode->mChildren, ainode->mChildren + ainode->mNumChildren, nullptr);
|
||||
|
||||
for (unsigned int i = 0; i < ainode->mNumChildren; ++i) {
|
||||
aiNode *child = ImportNode(pScene, r, meshOffsets, node.children[i]);
|
||||
|
@ -938,6 +951,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
|||
|
||||
mesh->mNumBones = static_cast<unsigned int>(numBones);
|
||||
mesh->mBones = new aiBone *[mesh->mNumBones];
|
||||
std::fill(mesh->mBones, mesh->mBones + mesh->mNumBones, nullptr);
|
||||
|
||||
// GLTF and Assimp choose to store bone weights differently.
|
||||
// GLTF has each vertex specify which bones influence the vertex.
|
||||
|
@ -1021,6 +1035,10 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
|||
}
|
||||
|
||||
return ainode;
|
||||
} catch (...) {
|
||||
delete ainode;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
||||
|
@ -1036,14 +1054,16 @@ void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
|||
if (numRootNodes == 1) { // a single root node: use it
|
||||
mScene->mRootNode = ImportNode(mScene, r, meshOffsets, rootNodes[0]);
|
||||
} else if (numRootNodes > 1) { // more than one root node: create a fake root
|
||||
aiNode *root = new aiNode("ROOT");
|
||||
aiNode *root = mScene->mRootNode = new aiNode("ROOT");
|
||||
|
||||
root->mChildren = new aiNode *[numRootNodes];
|
||||
std::fill(root->mChildren, root->mChildren + numRootNodes, nullptr);
|
||||
|
||||
for (unsigned int i = 0; i < numRootNodes; ++i) {
|
||||
aiNode *node = ImportNode(mScene, r, meshOffsets, rootNodes[i]);
|
||||
node->mParent = root;
|
||||
root->mChildren[root->mNumChildren++] = node;
|
||||
}
|
||||
mScene->mRootNode = root;
|
||||
} else {
|
||||
mScene->mRootNode = new aiNode("ROOT");
|
||||
}
|
||||
|
@ -1066,6 +1086,8 @@ struct AnimationSamplers {
|
|||
|
||||
aiNodeAnim *CreateNodeAnim(glTF2::Asset&, Node &node, AnimationSamplers &samplers) {
|
||||
aiNodeAnim *anim = new aiNodeAnim();
|
||||
|
||||
try {
|
||||
anim->mNodeName = GetNodeName(node);
|
||||
|
||||
static const float kMillisecondsFromSeconds = 1000.f;
|
||||
|
@ -1147,10 +1169,16 @@ aiNodeAnim *CreateNodeAnim(glTF2::Asset&, Node &node, AnimationSamplers &sampler
|
|||
}
|
||||
|
||||
return anim;
|
||||
} catch (...) {
|
||||
delete anim;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
aiMeshMorphAnim *CreateMeshMorphAnim(glTF2::Asset&, Node &node, AnimationSamplers &samplers) {
|
||||
aiMeshMorphAnim *anim = new aiMeshMorphAnim();
|
||||
|
||||
try {
|
||||
anim->mName = GetNodeName(node);
|
||||
|
||||
static const float kMillisecondsFromSeconds = 1000.f;
|
||||
|
@ -1186,13 +1214,17 @@ aiMeshMorphAnim *CreateMeshMorphAnim(glTF2::Asset&, Node &node, AnimationSampler
|
|||
}
|
||||
|
||||
return anim;
|
||||
} catch (...) {
|
||||
delete anim;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<unsigned int, AnimationSamplers> GatherSamplers(Animation &anim) {
|
||||
std::unordered_map<unsigned int, AnimationSamplers> samplers;
|
||||
for (unsigned int c = 0; c < anim.channels.size(); ++c) {
|
||||
Animation::Channel &channel = anim.channels[c];
|
||||
if (channel.sampler >= static_cast<int>(anim.samplers.size())) {
|
||||
if (channel.sampler < 0 || channel.sampler >= static_cast<int>(anim.samplers.size())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1224,10 +1256,13 @@ void glTF2Importer::ImportAnimations(glTF2::Asset &r) {
|
|||
}
|
||||
|
||||
mScene->mAnimations = new aiAnimation *[numAnimations];
|
||||
std::fill(mScene->mAnimations, mScene->mAnimations + numAnimations, nullptr);
|
||||
|
||||
for (unsigned int i = 0; i < numAnimations; ++i) {
|
||||
aiAnimation *ai_anim = mScene->mAnimations[i] = new aiAnimation();
|
||||
|
||||
Animation &anim = r.animations[i];
|
||||
|
||||
aiAnimation *ai_anim = new aiAnimation();
|
||||
ai_anim->mName = anim.name;
|
||||
ai_anim->mDuration = 0;
|
||||
ai_anim->mTicksPerSecond = 0;
|
||||
|
@ -1249,6 +1284,7 @@ void glTF2Importer::ImportAnimations(glTF2::Asset &r) {
|
|||
ai_anim->mNumChannels = numChannels;
|
||||
if (ai_anim->mNumChannels > 0) {
|
||||
ai_anim->mChannels = new aiNodeAnim *[ai_anim->mNumChannels];
|
||||
std::fill(ai_anim->mChannels, ai_anim->mChannels + ai_anim->mNumChannels, nullptr);
|
||||
int j = 0;
|
||||
for (auto &iter : samplers) {
|
||||
if ((nullptr != iter.second.rotation) || (nullptr != iter.second.scale) || (nullptr != iter.second.translation)) {
|
||||
|
@ -1261,6 +1297,7 @@ void glTF2Importer::ImportAnimations(glTF2::Asset &r) {
|
|||
ai_anim->mNumMorphMeshChannels = numMorphMeshChannels;
|
||||
if (ai_anim->mNumMorphMeshChannels > 0) {
|
||||
ai_anim->mMorphMeshChannels = new aiMeshMorphAnim *[ai_anim->mNumMorphMeshChannels];
|
||||
std::fill(ai_anim->mMorphMeshChannels, ai_anim->mMorphMeshChannels + ai_anim->mNumMorphMeshChannels, nullptr);
|
||||
int j = 0;
|
||||
for (auto &iter : samplers) {
|
||||
if (nullptr != iter.second.weight) {
|
||||
|
@ -1312,8 +1349,6 @@ void glTF2Importer::ImportAnimations(glTF2::Asset &r) {
|
|||
|
||||
ai_anim->mDuration = maxDuration;
|
||||
ai_anim->mTicksPerSecond = 1000.0;
|
||||
|
||||
mScene->mAnimations[i] = ai_anim;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1333,6 +1368,7 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
ASSIMP_LOG_DEBUG_F("Importing ", numEmbeddedTexs, " embedded textures");
|
||||
|
||||
mScene->mTextures = new aiTexture *[numEmbeddedTexs];
|
||||
std::fill(mScene->mTextures, mScene->mTextures + numEmbeddedTexs, nullptr);
|
||||
|
||||
// Add the embedded textures
|
||||
for (size_t i = 0; i < r.images.Size(); ++i) {
|
||||
|
|
|
@ -1015,7 +1015,7 @@ ENDIF()
|
|||
# RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
|
||||
# has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
|
||||
FIND_PACKAGE(RT QUIET)
|
||||
IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR MSVC))
|
||||
IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR WIN32))
|
||||
SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
|
||||
ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
|
||||
ELSE ()
|
||||
|
|
|
@ -183,9 +183,10 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::vector<aiScene *> &src, un
|
|||
*_dest = src[0];
|
||||
return;
|
||||
}
|
||||
if (*_dest)
|
||||
if (*_dest) {
|
||||
(*_dest)->~aiScene();
|
||||
else
|
||||
new (*_dest) aiScene();
|
||||
} else
|
||||
*_dest = new aiScene();
|
||||
|
||||
// Create a dummy scene to serve as master for the others
|
||||
|
|
|
@ -146,7 +146,7 @@ int IOSystem2Unzip::testerror(voidpf /*opaque*/, voidpf /*stream*/) {
|
|||
zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
|
||||
zlib_filefunc_def mapping;
|
||||
|
||||
#ifdef ASSIMP_USE_HUNTER
|
||||
#if defined (ASSIMP_USE_HUNTER) || defined (__MINGW32__) // GH#3144
|
||||
mapping.zopen_file = (open_file_func)open;
|
||||
mapping.zread_file = (read_file_func)read;
|
||||
mapping.zwrite_file = (write_file_func)write;
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace o3dgc
|
|||
m_data[2] = rhs.m_data[2];
|
||||
}
|
||||
template <typename T>
|
||||
inline Vec3<T>::~Vec3(void){};
|
||||
inline Vec3<T>::~Vec3(void){}
|
||||
|
||||
template <typename T>
|
||||
inline Vec3<T>::Vec3() {}
|
||||
|
@ -308,7 +308,7 @@ namespace o3dgc
|
|||
m_data[1] = rhs.m_data[1];
|
||||
}
|
||||
template <typename T>
|
||||
inline Vec2<T>::~Vec2(void){};
|
||||
inline Vec2<T>::~Vec2(void){}
|
||||
|
||||
template <typename T>
|
||||
inline Vec2<T>::Vec2() {}
|
||||
|
|
|
@ -763,7 +763,7 @@ void cleanup()
|
|||
|
||||
if (g_hWnd)
|
||||
KillGLWindow();
|
||||
};
|
||||
}
|
||||
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, // Handles for this Window
|
||||
UINT uMsg, // Message for this Window
|
||||
|
|
|
@ -161,4 +161,4 @@ int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld) {
|
|||
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2143,7 +2143,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
|
|||
}
|
||||
return FALSE;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
using namespace AssimpView;
|
||||
|
||||
|
|
Loading…
Reference in New Issue