update assimp lib

This commit is contained in:
marauder2k7 2024-12-09 20:22:47 +00:00
parent 03a348deb7
commit d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -260,7 +260,7 @@ public:
VEC4,
MAT2,
MAT3,
MAT4
MAT4
};
inline static Value FromString(const char *str) {
@ -288,8 +288,8 @@ private:
};
template <int N>
struct data {
static const Info infos[NUM_VALUES];
struct data {
static const Info infos[NUM_VALUES];
};
};
@ -297,11 +297,11 @@ private:
template <int N>
const AttribType::Info AttribType::data<N>::infos[AttribType::NUM_VALUES] = {
{ "SCALAR", 1 },
{ "VEC2", 2 },
{ "VEC3", 3 },
{ "VEC4", 4 },
{ "MAT2", 4 },
{ "MAT3", 9 },
{ "VEC2", 2 },
{ "VEC3", 3 },
{ "VEC4", 4 },
{ "MAT2", 4 },
{ "MAT3", 9 },
{ "MAT4", 16 }
};
@ -374,7 +374,7 @@ struct Accessor : public Object {
}
inline bool IsValid() const {
return data != 0;
return data != nullptr;
}
};
@ -513,21 +513,22 @@ struct Camera : public Object {
};
Type type;
struct Perspective {
float aspectRatio; //!<The floating - point aspect ratio of the field of view. (0 = undefined = use the canvas one)
float yfov; //!<The floating - point vertical field of view in radians. (required)
float zfar; //!<The floating - point distance to the far clipping plane. (required)
float znear; //!< The floating - point distance to the near clipping plane. (required)
};
struct Ortographic {
float xmag; //! The floating-point horizontal magnification of the view. (required)
float ymag; //! The floating-point vertical magnification of the view. (required)
float zfar; //! The floating-point distance to the far clipping plane. (required)
float znear; //! The floating-point distance to the near clipping plane. (required)
};
union {
struct {
float aspectRatio; //!<The floating - point aspect ratio of the field of view. (0 = undefined = use the canvas one)
float yfov; //!<The floating - point vertical field of view in radians. (required)
float zfar; //!<The floating - point distance to the far clipping plane. (required)
float znear; //!< The floating - point distance to the near clipping plane. (required)
} perspective;
struct {
float xmag; //! The floating-point horizontal magnification of the view. (required)
float ymag; //! The floating-point vertical magnification of the view. (required)
float zfar; //! The floating-point distance to the far clipping plane. (required)
float znear; //! The floating-point distance to the near clipping plane. (required)
} ortographic;
struct Perspective perspective;
struct Ortographic ortographic;
};
Camera() = default;
@ -629,9 +630,7 @@ struct Mesh : public Object {
SExtension(const EType pType) :
Type(pType) {}
virtual ~SExtension() {
// empty
}
virtual ~SExtension() = default;
};
#ifdef ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC
@ -657,9 +656,7 @@ struct Mesh : public Object {
// empty
}
virtual ~SCompression_Open3DGC() {
// empty
}
virtual ~SCompression_Open3DGC() = default;
};
#endif
@ -873,7 +870,7 @@ class LazyDict : public LazyDictBase {
Ref<T> Add(T *obj);
public:
LazyDict(Asset &asset, const char *dictId, const char *extId = 0);
LazyDict(Asset &asset, const char *dictId, const char *extId = nullptr);
~LazyDict();
Ref<T> Get(const char *id);
@ -970,17 +967,17 @@ public:
Ref<Scene> scene;
public:
Asset(IOSystem *io = 0) :
mIOSystem(io),
asset(),
accessors(*this, "accessors"),
animations(*this, "animations"),
buffers(*this, "buffers"),
bufferViews(*this, "bufferViews"),
cameras(*this, "cameras"),
images(*this, "images"),
materials(*this, "materials"),
meshes(*this, "meshes"),
Asset(IOSystem *io = nullptr) :
mIOSystem(io),
asset(),
accessors(*this, "accessors"),
animations(*this, "animations"),
buffers(*this, "buffers"),
bufferViews(*this, "bufferViews"),
cameras(*this, "cameras"),
images(*this, "images"),
materials(*this, "materials"),
meshes(*this, "meshes"),
nodes(*this, "nodes"),
samplers(*this, "samplers"),
scenes(*this, "scenes"),

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -68,7 +68,7 @@ using namespace glTFCommon;
template <class T>
inline LazyDict<T>::LazyDict(Asset &asset, const char *dictId, const char *extId) :
mDictId(dictId), mExtId(extId), mDict(0), mAsset(asset) {
mDictId(dictId), mExtId(extId), mDict(nullptr), mAsset(asset) {
asset.mDicts.push_back(this); // register to the list of dictionaries
}
@ -81,7 +81,7 @@ inline LazyDict<T>::~LazyDict() {
template <class T>
inline void LazyDict<T>::AttachToDocument(Document &doc) {
Value *container = 0;
Value *container = nullptr;
if (mExtId) {
if (Value *exts = FindObject(doc, "extensions")) {
@ -98,7 +98,7 @@ inline void LazyDict<T>::AttachToDocument(Document &doc) {
template <class T>
inline void LazyDict<T>::DetachFromDocument() {
mDict = 0;
mDict = nullptr;
}
template <class T>
@ -194,7 +194,7 @@ inline void Buffer::Read(Value &obj, Asset &r) {
glTFCommon::Util::DataURI dataURI;
if (ParseDataURI(uri, it->GetStringLength(), dataURI)) {
if (dataURI.base64) {
uint8_t *data = 0;
uint8_t *data = nullptr;
this->byteLength = Base64::Decode(dataURI.data, dataURI.dataLength, data);
this->mData.reset(data, std::default_delete<uint8_t[]>());
@ -383,9 +383,9 @@ inline unsigned int Accessor::GetElementSize() {
}
inline uint8_t *Accessor::GetPointer() {
if (!bufferView || !bufferView->buffer) return 0;
if (!bufferView || !bufferView->buffer) return nullptr;
uint8_t *basePtr = bufferView->buffer->GetPointer();
if (!basePtr) return 0;
if (!basePtr) return nullptr;
size_t offset = byteOffset + bufferView->byteOffset;
@ -698,7 +698,7 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
// and WEIGHT.Attribute semantics can be of the form[semantic]_[set_index], e.g., TEXCOORD_0, TEXCOORD_1, etc.
int undPos = 0;
Mesh::AccessorList *vec = 0;
Mesh::AccessorList *vec = nullptr;
if (GetAttribVector(prim, attr, vec, undPos)) {
size_t idx = (attr[undPos] == '_') ? atoi(attr + undPos + 1) : 0;
if ((*vec).size() <= idx) (*vec).resize(idx + 1);

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -525,7 +525,7 @@ namespace glTF {
{
std::unique_ptr<IOStream> jsonOutFile(mAsset.OpenFile(path, "wt", true));
if (jsonOutFile == 0) {
if (jsonOutFile == nullptr) {
throw DeadlyExportError("Could not open output file: " + std::string(path));
}
@ -548,7 +548,7 @@ namespace glTF {
std::unique_ptr<IOStream> binOutFile(mAsset.OpenFile(binPath, "wb", true));
if (binOutFile == 0) {
if (binOutFile == nullptr) {
throw DeadlyExportError("Could not open output file: " + binPath);
}
@ -564,7 +564,7 @@ namespace glTF {
{
std::unique_ptr<IOStream> outfile(mAsset.OpenFile(path, "wb", true));
if (outfile == 0) {
if (outfile == nullptr) {
throw DeadlyExportError("Could not open output file: " + std::string(path));
}

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -259,7 +259,7 @@ class Ref {
public:
Ref() :
vector(0),
vector(nullptr),
index(0) {}
Ref(std::vector<T *> &vec, unsigned int idx) :
vector(&vec),
@ -495,22 +495,22 @@ inline Value *FindExtension(Value &val, const char *extensionId) {
inline Value *FindString(Value &val, const char *id) {
Value::MemberIterator it = val.FindMember(id);
return (it != val.MemberEnd() && it->value.IsString()) ? &it->value : 0;
return (it != val.MemberEnd() && it->value.IsString()) ? &it->value : nullptr;
}
inline Value *FindObject(Value &val, const char *id) {
Value::MemberIterator it = val.FindMember(id);
return (it != val.MemberEnd() && it->value.IsObject()) ? &it->value : 0;
return (it != val.MemberEnd() && it->value.IsObject()) ? &it->value : nullptr;
}
inline Value *FindArray(Value &val, const char *id) {
Value::MemberIterator it = val.FindMember(id);
return (it != val.MemberEnd() && it->value.IsArray()) ? &it->value : 0;
return (it != val.MemberEnd() && it->value.IsArray()) ? &it->value : nullptr;
}
inline Value *FindNumber(Value &val, const char *id) {
Value::MemberIterator it = val.FindMember(id);
return (it != val.MemberEnd() && it->value.IsNumber()) ? &it->value : 0;
return (it != val.MemberEnd() && it->value.IsNumber()) ? &it->value : nullptr;
}
} // namespace glTFCommon

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp>
#include <assimp/material.h>
#include <assimp/scene.h>
#include <assimp/config.h>
// Header files, standard library.
#include <memory>
@ -111,7 +112,11 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc
mScene.reset(sceneCopy_tmp);
mAsset.reset( new glTF::Asset( pIOSystem ) );
mAsset = std::make_shared<glTF::Asset>(pIOSystem);
configEpsilon = mProperties->GetPropertyFloat(
AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON,
(ai_real)AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT);
if (isBinary) {
mAsset->SetAsBinary();
@ -322,7 +327,7 @@ void glTFExporter::GetTexSampler(const aiMaterial* mat, glTF::TexProperty& prop)
prop.texture->sampler->minFilter = SamplerMinFilter_Linear;
}
void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& prop,
void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& prop,
const char* propName, int type, int idx, aiTextureType tt) {
aiString tex;
aiColor4D col;
@ -370,9 +375,9 @@ void glTFExporter::GetMatColorOrTex(const aiMaterial* mat, glTF::TexProperty& pr
}
if (mat->Get(propName, type, idx, col) == AI_SUCCESS) {
prop.color[0] = col.r;
prop.color[0] = col.r;
prop.color[1] = col.g;
prop.color[2] = col.b;
prop.color[2] = col.b;
prop.color[3] = col.a;
}
}
@ -824,7 +829,7 @@ unsigned int glTFExporter::ExportNodeHierarchy(const aiNode* n)
{
Ref<Node> node = mAsset->nodes.Create(mAsset->FindUniqueID(n->mName.C_Str(), "node"));
if (!n->mTransformation.IsIdentity()) {
if (!n->mTransformation.IsIdentity(configEpsilon)) {
node->matrix.isPresent = true;
CopyValue(n->mTransformation, node->matrix.value);
}
@ -851,7 +856,7 @@ unsigned int glTFExporter::ExportNode(const aiNode* n, Ref<Node>& parent)
node->parent = parent;
if (!n->mTransformation.IsIdentity()) {
if (!n->mTransformation.IsIdentity(configEpsilon)) {
node->matrix.isPresent = true;
CopyValue(n->mTransformation, node->matrix.value);
}

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/material.h>
#include <assimp/types.h>
#include <assimp/defs.h>
#include <map>
#include <memory>
@ -98,6 +99,8 @@ private:
std::vector<unsigned char> mBodyData;
ai_real configEpsilon;
void WriteBinaryData(IOStream *outfile, std::size_t sceneLength);
void GetTexSampler(const aiMaterial *mat, glTF::TexProperty &prop);

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.
@ -62,11 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using namespace Assimp;
using namespace glTF;
//
// glTFImporter
//
static const aiImporterDesc desc = {
static constexpr aiImporterDesc desc = {
"glTF Importer",
"",
"",
@ -80,7 +76,7 @@ static const aiImporterDesc desc = {
};
glTFImporter::glTFImporter() :
BaseImporter(), meshOffsets(), embeddedTexIdxs(), mScene(nullptr) {
mScene(nullptr) {
// empty
}
@ -93,7 +89,10 @@ const aiImporterDesc *glTFImporter::GetInfo() const {
bool glTFImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /* checkSig */) const {
glTF::Asset asset(pIOHandler);
try {
asset.Load(pFile, GetExtension(pFile) == "glb");
asset.Load(pFile,
CheckMagicToken(
pIOHandler, pFile, AI_GLB_MAGIC_NUMBER, 1, 0,
static_cast<unsigned int>(strlen(AI_GLB_MAGIC_NUMBER))));
return asset.asset;
} catch (...) {
return false;
@ -110,7 +109,7 @@ inline void SetMaterialColorProperty(std::vector<int> &embeddedTexIdxs, Asset &
if (texIdx != -1) { // embedded
// setup texture reference string (copied from ColladaLoader::FindFilenameForEffectTexture)
uri.data[0] = '*';
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, MAXLEN - 1, texIdx);
uri.length = 1 + ASSIMP_itoa10(uri.data + 1, AI_MAXLEN - 1, texIdx);
}
mat->AddProperty(&uri, _AI_MATKEY_TEXTURE_BASE, texType, 0);
@ -243,7 +242,7 @@ void glTFImporter::ImportMeshes(glTF::Asset &r) {
if (mesh.primitives.size() > 1) {
ai_uint32 &len = aim->mName.length;
aim->mName.data[len] = '-';
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(MAXLEN - len - 1), p);
len += 1 + ASSIMP_itoa10(aim->mName.data + len + 1, unsigned(AI_MAXLEN - len - 1), p);
}
switch (prim.mode) {
@ -283,7 +282,7 @@ void glTFImporter::ImportMeshes(glTF::Asset &r) {
}
}
aiFace *faces = 0;
aiFace *faces = nullptr;
unsigned int nFaces = 0;
if (prim.indices) {
@ -632,8 +631,9 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset &r) {
numEmbeddedTexs += 1;
}
if (numEmbeddedTexs == 0)
if (numEmbeddedTexs == 0) {
return;
}
mScene->mTextures = new aiTexture *[numEmbeddedTexs];
@ -658,11 +658,13 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset &r) {
if (!img.mimeType.empty()) {
const char *ext = strchr(img.mimeType.c_str(), '/') + 1;
if (ext) {
if (strcmp(ext, "jpeg") == 0) ext = "jpg";
if (strncmp(ext, "jpeg", 4) == 0) {
ext = "jpg";
}
size_t len = strlen(ext);
const size_t len = strlen(ext);
if (len <= 3) {
strcpy(tex->achFormatHint, ext);
strncpy(tex->achFormatHint, ext, len);
}
}
}
@ -697,7 +699,10 @@ void glTFImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOS
// read the asset file
glTF::Asset asset(pIOHandler);
asset.Load(pFile, GetExtension(pFile) == "glb");
asset.Load(pFile,
CheckMagicToken(
pIOHandler, pFile, AI_GLB_MAGIC_NUMBER, 1, 0,
static_cast<unsigned int>(strlen(AI_GLB_MAGIC_NUMBER))));
//
// Copy the data out

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2022, assimp team
Copyright (c) 2006-2024, assimp team
All rights reserved.