update assimp to 6.0.5

This commit is contained in:
AzaezelX 2026-06-09 12:46:56 -05:00
parent 2d2eb57e2e
commit f5cf21cfeb
941 changed files with 22718 additions and 12240 deletions

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
Copyright (c) 2006-2026, assimp team
All rights reserved.
@ -45,8 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_COB_IMPORTER
#include "AssetLib/COB/COBLoader.h"
#include "AssetLib/COB/COBScene.h"
#include "COBLoader.h"
#include "COBScene.h"
#include "PostProcessing/ConvertToLHProcess.h"
#include <assimp/LineSplitter.h>
@ -62,6 +62,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
namespace Assimp {
using namespace Assimp::COB;
using namespace Assimp::Formatter;
@ -109,10 +110,29 @@ void COBImporter::SetupProperties(const Importer * /*pImp*/) {
}
// ------------------------------------------------------------------------------------------------
/*static*/ AI_WONT_RETURN void COBImporter::ThrowException(const std::string &msg) {
AI_WONT_RETURN void COBImporter::ThrowException(const std::string &msg) {
throw DeadlyImportError("COB: ", msg);
}
// ------------------------------------------------------------------------------------------------
static bool isValidASCIIHeader(const char *head) {
ai_assert(head != nullptr);
if (strncmp(head, "Caligari ", 9) != 0) {
COBImporter::ThrowException("Could not found magic id: `Caligari`");
}
if (strncmp(&head[9], "V00.", 4) != 0) {
COBImporter::ThrowException("Could not found Version tag: `V00.`");
}
ASSIMP_LOG_INFO("File format tag: ", std::string(head + 9, 6));
if (head[16] != 'L') {
COBImporter::ThrowException("File is big-endian, which is not supported");
}
return true;
}
// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
@ -126,19 +146,15 @@ void COBImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
std::unique_ptr<StreamReaderLE> stream(new StreamReaderLE(file));
// check header
char head[32];
stream->CopyAndAdvance(head, 32);
if (strncmp(head, "Caligari ", 9) != 0) {
ThrowException("Could not found magic id: `Caligari`");
}
ASSIMP_LOG_INFO("File format tag: ", std::string(head + 9, 6));
if (head[16] != 'L') {
ThrowException("File is big-endian, which is not supported");
}
static constexpr size_t HeaderSize = 32u;
char head[HeaderSize] = {};
stream->CopyAndAdvance(head, HeaderSize);
// load data into intermediate structures
if (head[15] == 'A') {
if (!isValidASCIIHeader(head)) {
ThrowException("Invalid ASCII file header");
}
ReadAsciiFile(scene, stream.get());
} else {
ReadBinaryFile(scene, stream.get());
@ -228,7 +244,7 @@ aiNode *COBImporter::BuildNodes(const Node &root, const Scene &scin, aiScene *fi
const Mesh &ndmesh = (const Mesh &)(root);
if (ndmesh.vertex_positions.size() && ndmesh.texture_coords.size()) {
typedef std::pair<const unsigned int, Mesh::FaceRefList> Entry;
using Entry = std::pair<const unsigned int, Mesh::FaceRefList>;
for (const Entry &reflist : ndmesh.temp_map) {
{ // create mesh
size_t n = 0;
@ -1170,6 +1186,6 @@ void COBImporter::ReadUnit_Binary(COB::Scene &out, StreamReaderLE &reader, const
ASSIMP_LOG_WARN("`Unit` chunk ", nfo.id, " is a child of ", nfo.parent_id, " which does not exist");
}
}
} // namespace Assimp
#endif // ASSIMP_BUILD_NO_COB_IMPORTER

View file

@ -2,8 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
Copyright (c) 2006-2026, assimp team
All rights reserved.
@ -73,7 +72,7 @@ namespace COB {
*
* Currently relatively limited, loads only ASCII files and needs more test coverage. */
// -------------------------------------------------------------------------------------------
class COBImporter : public BaseImporter {
class COBImporter final : public BaseImporter {
public:
COBImporter() = default;
~COBImporter() override = default;
@ -82,6 +81,10 @@ public:
bool CanRead(const std::string &pFile, IOSystem *pIOHandler,
bool checkSig) const override;
// -------------------------------------------------------------------
/** Prepend 'COB: ' and throw msg.*/
AI_WONT_RETURN static void ThrowException(const std::string &msg) AI_WONT_RETURN_SUFFIX;
protected:
// --------------------
const aiImporterDesc *GetInfo() const override;
@ -94,10 +97,6 @@ protected:
IOSystem *pIOHandler) override;
private:
// -------------------------------------------------------------------
/** Prepend 'COB: ' and throw msg.*/
AI_WONT_RETURN static void ThrowException(const std::string &msg) AI_WONT_RETURN_SUFFIX;
// -------------------------------------------------------------------
/** @brief Read from an ascii scene/object file
* @param out Receives output data.
@ -149,4 +148,5 @@ private:
}; // !class COBImporter
} // end of namespace Assimp
#endif // AI_UNREALIMPORTER_H_INC

View file

@ -2,7 +2,7 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
Copyright (c) 2006-2024, assimp team
Copyright (c) 2006-2026, assimp team
All rights reserved.
@ -52,68 +52,66 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <deque>
#include <map>
namespace Assimp {
namespace COB {
namespace Assimp::COB {
// ------------------
/** Represents a single vertex index in a face */
struct VertexIndex
{
struct VertexIndex {
// intentionally uninitialized
unsigned int pos_idx,uv_idx;
};
// ------------------
/** COB Face data structure */
struct Face
{
struct Face {
// intentionally uninitialized
unsigned int material, flags;
unsigned int material;
unsigned int flags;
std::vector<VertexIndex> indices;
};
// ------------------
/** COB chunk header information */
const unsigned int NO_SIZE = UINT_MAX;
constexpr unsigned int NO_SIZE = UINT_MAX;
struct ChunkInfo
{
ChunkInfo ()
: id (0)
, parent_id (0)
, version (0)
, size (NO_SIZE)
{}
struct ChunkInfo {
ChunkInfo() = default;
virtual ~ChunkInfo() = default;
// Id of this chunk, unique within file
unsigned int id;
unsigned int id{ 0 };
// and the corresponding parent
unsigned int parent_id;
unsigned int parent_id{ 0 };
// version. v1.23 becomes 123
unsigned int version;
unsigned int version{ 0 };
// chunk size in bytes, only relevant for binary files
// NO_SIZE is also valid.
unsigned int size;
unsigned int size{NO_SIZE};
};
// ------------------
/** A node in the scenegraph */
struct Node : public ChunkInfo
{
struct Node : ChunkInfo {
enum Type {
TYPE_MESH,TYPE_GROUP,TYPE_LIGHT,TYPE_CAMERA,TYPE_BONE
TYPE_INVALID = -1,
TYPE_MESH = 0,
TYPE_GROUP,
TYPE_LIGHT,
TYPE_CAMERA,
TYPE_BONE,
TYPE_COUNT
};
virtual ~Node() = default;
Node(Type type) : type(type), unit_scale(1.f){}
~Node() override = default;
explicit Node(Type type) : type(type), unit_scale(1.f){}
Type type;
// used during resolving
typedef std::deque<const Node*> ChildList;
using ChildList = std::deque<const Node*> ;
mutable ChildList temp_children;
// unique name
@ -128,8 +126,7 @@ struct Node : public ChunkInfo
// ------------------
/** COB Mesh data structure */
struct Mesh : public Node
{
struct Mesh final : Node {
using ChunkInfo::operator=;
enum DrawFlags {
SOLID = 0x1,
@ -162,107 +159,118 @@ struct Mesh : public Node
// ------------------
/** COB Group data structure */
struct Group : public Node
{
struct Group final : Node {
using ChunkInfo::operator=;
Group() : Node(TYPE_GROUP) {}
Group() : Node(TYPE_GROUP) {
// empty
}
};
// ------------------
/** COB Bone data structure */
struct Bone : public Node
{
struct Bone final : Node {
using ChunkInfo::operator=;
Bone() : Node(TYPE_BONE) {}
Bone() : Node(TYPE_BONE) {
// empty
}
};
// ------------------
/** COB Light data structure */
struct Light : public Node
{
struct Light final : Node {
enum LightType {
SPOT,LOCAL,INFINITE
SPOT,
LOCAL,
INFINITE
};
using ChunkInfo::operator=;
Light() : Node(TYPE_LIGHT),angle(),inner_angle(),ltype(SPOT) {}
Light() : Node(TYPE_LIGHT), ltype() {
// empty
}
aiColor3D color;
float angle,inner_angle;
float angle{ 0.0f };
float inner_angle{ 0.0f };
LightType ltype;
LightType ltype{SPOT};
};
// ------------------
/** COB Camera data structure */
struct Camera : public Node
{
struct Camera final : Node {
using ChunkInfo::operator=;
Camera() : Node(TYPE_CAMERA) {}
Camera() : Node(TYPE_CAMERA) {
// empty
}
};
// ------------------
/** COB Texture data structure */
struct Texture
{
struct Texture {
std::string path;
aiUVTransform transform;
};
// ------------------
/** COB Material data structure */
struct Material : ChunkInfo
{
struct Material : ChunkInfo {
using ChunkInfo::operator=;
enum Shader {
FLAT,PHONG,METAL
FLAT,
PHONG,
METAL
};
enum AutoFacet {
FACETED,AUTOFACETED,SMOOTH
FACETED,
AUTOFACETED,
SMOOTH
};
Material() : alpha(),exp(),ior(),ka(),ks(1.f),
matnum(UINT_MAX),
shader(FLAT),autofacet(FACETED),
autofacet_angle()
{}
Material() : shader(FLAT) {
// empty
}
std::string type;
aiColor3D rgb;
float alpha, exp, ior,ka,ks;
unsigned int matnum;
float alpha{ 0.0f };
float exp{ 0.0f };
float ior{ 0.0f };
float ka{ 0.0f };
float ks{ 1.0f };
unsigned int matnum{ UINT_MAX };
Shader shader;
AutoFacet autofacet;
float autofacet_angle;
AutoFacet autofacet{FACETED};
float autofacet_angle{ 0.0f };
std::shared_ptr<Texture> tex_env,tex_bump,tex_color;
};
// ------------------
/** Embedded bitmap, for instance for the thumbnail image */
struct Bitmap : ChunkInfo
{
Bitmap() : orig_size() {}
struct BitmapHeader
{
struct Bitmap : ChunkInfo {
Bitmap() = default;
struct BitmapHeader {
// empty
};
BitmapHeader head;
size_t orig_size;
size_t orig_size{ 0u };
std::vector<char> buff_zipped;
};
typedef std::deque< std::shared_ptr<Node> > NodeList;
typedef std::vector< Material > MaterialList;
using NodeList = std::deque< std::shared_ptr<Node>>;
using MaterialList = std::vector< Material >;
// ------------------
/** Represents a master COB scene, even if we loaded just a single COB file */
struct Scene
{
struct Scene {
NodeList nodes;
MaterialList materials;
@ -270,7 +278,6 @@ struct Scene
Bitmap thumbnail;
};
} // end COB
} // end Assimp
} // end Assimp::COB
#endif
#endif // INCLUDED_AI_COB_SCENE_H