Update Assimp to v5.4.1

#2727
This commit is contained in:
Wojtek Figat
2024-07-02 09:59:30 +02:00
parent ec510425a1
commit a79fb237e5
10 changed files with 75 additions and 104 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -57,9 +57,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iomanip>
#if defined(_MSC_VER) && !defined(__clang__)
# define AI_SIZEFMT "%Iu"
#define AI_SIZEFMT "%Iu"
#else
# define AI_SIZEFMT "%zu"
#define AI_SIZEFMT "%zu"
#endif
// ---------------------------------------------------------------------------------
@@ -99,9 +99,9 @@ inline int ai_snprintf(char *outBuf, size_t size, const char *format, ...) {
}
#elif defined(__MINGW32__)
# define ai_snprintf __mingw_snprintf
#define ai_snprintf __mingw_snprintf
#else
# define ai_snprintf snprintf
#define ai_snprintf snprintf
#endif
// ---------------------------------------------------------------------------------
@@ -185,7 +185,6 @@ AI_FORCE_INLINE std::string ai_rgba2hex(int r, int g, int b, int a, bool with_he
// ---------------------------------------------------------------------------------
/// @brief Performs a trim from start (in place)
/// @param s string to trim.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE void ai_trim_left(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
@@ -196,6 +195,7 @@ AI_FORCE_INLINE void ai_trim_left(std::string &s) {
/// @brief Performs a trim from end (in place).
/// @param s string to trim.
// ---------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE void ai_trim_right(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
@@ -214,10 +214,6 @@ AI_FORCE_INLINE std::string ai_trim(std::string &s) {
return out;
}
// ---------------------------------------------------------------------------------
/// @brief Performs a to lower operation onto on single character.
/// @param in The character
/// @return the character as lower-case.
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE char_t ai_tolower(char_t in) {
@@ -237,10 +233,6 @@ AI_FORCE_INLINE std::string ai_tolower(const std::string &in) {
return out;
}
// ---------------------------------------------------------------------------------
/// @brief Performs a to upper operation onto on single character.
/// @param in The character
/// @return the character as upper-case.
// ---------------------------------------------------------------------------------
template <class char_t>
AI_FORCE_INLINE char_t ai_toupper(char_t in) {
@@ -251,7 +243,6 @@ AI_FORCE_INLINE char_t ai_toupper(char_t in) {
/// @brief Performs a ToLower-operation and return the upper-case string.
/// @param in The incoming string.
/// @return The string as uppercase.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
std::string out(in);
std::transform(out.begin(), out.end(), out.begin(), [](char c) { return ai_toupper(c); });
@@ -264,7 +255,6 @@ AI_FORCE_INLINE std::string ai_str_toupper(const std::string &in) {
/// @param in The incoming string.
/// @param placeholder Placeholder character, default is a question mark.
/// @return The string, with all non-printable characters replaced.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char placeholder = '?') {
std::string out(in);
std::transform(out.begin(), out.end(), out.begin(), [placeholder] (unsigned char c) {
@@ -281,9 +271,9 @@ AI_FORCE_INLINE std::string ai_str_toprintable(const std::string &in, char place
/// @param placeholder Placeholder character, default is a question mark.
/// @return The string, with all non-printable characters replaced. Will return an
/// empty string if in is null or len is <= 0.
// ---------------------------------------------------------------------------------
AI_FORCE_INLINE std::string ai_str_toprintable(const char *in, int len, char placeholder = '?') {
return (in && len > 0) ? ai_str_toprintable(std::string(in, len), placeholder) : std::string();
}
#endif // INCLUDED_AI_STRINGUTILS_H

View File

@@ -43,7 +43,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define INCLUDED_AI_IRRXML_WRAPPER
#include <assimp/ai_assert.h>
#include <assimp/StringUtils.h>
#include <assimp/DefaultLogger.hpp>
#include "BaseImporter.h"
@@ -448,7 +447,6 @@ inline bool TXmlParser<TNodeType>::getValueAsString(XmlNode &node, std::string &
}
text = node.text().as_string();
text = ai_trim(text);
return true;
}

View File

@@ -150,7 +150,7 @@ inline uint8_t HexOctetToDecimal(const char* in) {
// ------------------------------------------------------------------------------------
// signed variant of strtoul10
// ------------------------------------------------------------------------------------
inline int strtol10( const char* in, const char** out = 0) {
inline int strtol10( const char* in, const char** out=0) {
bool inv = (*in=='-');
if ( inv || *in == '+' ) {
++in;
@@ -158,7 +158,7 @@ inline int strtol10( const char* in, const char** out = 0) {
int value = strtoul10(in,out);
if (inv) {
if (value < INT_MAX && value > INT_MIN) {
if (value < INT_MAX) {
value = -value;
} else {
ASSIMP_LOG_WARN( "Converting the string \"", in, "\" into an inverted value resulted in overflow." );

View File

@@ -334,12 +334,7 @@ enum aiTextureType {
#define AI_TEXTURE_TYPE_MAX aiTextureType_TRANSMISSION
// -------------------------------------------------------------------------------
/**
* @brief Get a string for a given aiTextureType
*
* @param in The texture type
* @return The description string for the texture type.
*/
// Get a string for a given aiTextureType
ASSIMP_API const char *aiTextureTypeToString(enum aiTextureType in);
// ---------------------------------------------------------------------------
@@ -430,8 +425,7 @@ enum aiShadingMode {
};
// ---------------------------------------------------------------------------
/**
* @brief Defines some mixed flags for a particular texture.
/** @brief Defines some mixed flags for a particular texture.
*
* Usually you'll instruct your cg artists how textures have to look like ...
* and how they will be processed in your application. However, if you use
@@ -470,8 +464,7 @@ enum aiTextureFlags {
};
// ---------------------------------------------------------------------------
/**
* @brief Defines alpha-blend flags.
/** @brief Defines alpha-blend flags.
*
* If you're familiar with OpenGL or D3D, these flags aren't new to you.
* They define *how* the final color value of a pixel is computed, basing
@@ -515,8 +508,7 @@ enum aiBlendMode {
#include "./Compiler/pushpack1.h"
// ---------------------------------------------------------------------------
/**
* @brief Defines how an UV channel is transformed.
/** @brief Defines how an UV channel is transformed.
*
* This is just a helper structure for the #AI_MATKEY_UVTRANSFORM key.
* See its documentation for more details.
@@ -560,8 +552,8 @@ struct aiUVTransform {
//! @cond AI_DOX_INCLUDE_INTERNAL
// ---------------------------------------------------------------------------
/**
* @brief A very primitive RTTI system for the contents of material properties.
/** @brief A very primitive RTTI system for the contents of material
* properties.
*/
enum aiPropertyTypeInfo {
/** Array of single-precision (32 Bit) floats
@@ -706,14 +698,7 @@ struct aiMaterial
#ifdef __cplusplus
public:
/**
* @brief The class constructor.
*/
aiMaterial();
/**
* @brief The class destructor.
*/
~aiMaterial();
// -------------------------------------------------------------------
@@ -1031,7 +1016,7 @@ extern "C" {
// Clearcoat
// ---------
// Clearcoat layer intensity. 0.0 = none (disabled)
#define AI_MATKEY_CLEARCOAT_FACTOR "$mat.clearcoat.factor", 0, 0
#define AI_MATKEY_CLEARCOAT_FACTOR "$mat.clearcoat.factor", 0, 0
#define AI_MATKEY_CLEARCOAT_ROUGHNESS_FACTOR "$mat.clearcoat.roughnessFactor", 0, 0
#define AI_MATKEY_CLEARCOAT_TEXTURE aiTextureType_CLEARCOAT, 0
#define AI_MATKEY_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_CLEARCOAT, 1
@@ -1061,23 +1046,23 @@ extern "C" {
// Emissive
// --------
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
#define AI_MATKEY_USE_EMISSIVE_MAP "$mat.useEmissiveMap", 0, 0
#define AI_MATKEY_EMISSIVE_INTENSITY "$mat.emissiveIntensity", 0, 0
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
#define AI_MATKEY_USE_AO_MAP "$mat.useAOMap", 0, 0
// ---------------------------------------------------------------------------
// Pure key names for all texture-related properties
//! @cond MATS_DOC_FULL
#define _AI_MATKEY_TEXTURE_BASE "$tex.file"
#define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
#define _AI_MATKEY_TEXOP_BASE "$tex.op"
#define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
#define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
#define _AI_MATKEY_TEXTURE_BASE "$tex.file"
#define _AI_MATKEY_UVWSRC_BASE "$tex.uvwsrc"
#define _AI_MATKEY_TEXOP_BASE "$tex.op"
#define _AI_MATKEY_MAPPING_BASE "$tex.mapping"
#define _AI_MATKEY_TEXBLEND_BASE "$tex.blend"
#define _AI_MATKEY_MAPPINGMODE_U_BASE "$tex.mapmodeu"
#define _AI_MATKEY_MAPPINGMODE_V_BASE "$tex.mapmodev"
#define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
#define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
#define _AI_MATKEY_TEXMAP_AXIS_BASE "$tex.mapaxis"
#define _AI_MATKEY_UVTRANSFORM_BASE "$tex.uvtrafo"
#define _AI_MATKEY_TEXFLAGS_BASE "$tex.flags"
//! @endcond
// ---------------------------------------------------------------------------

View File

@@ -141,28 +141,25 @@ struct ASSIMP_API aiNode {
/** Destructor */
~aiNode();
/**
* @brief Searches for a node with a specific name, beginning at this
/** Searches for a node with a specific name, beginning at this
* nodes. Normally you will call this method on the root node
* of the scene.
*
* @param name Name to search for
* @return nullptr or a valid Node if the search was successful.
*/
inline const aiNode* FindNode(const aiString& name) const {
inline
const aiNode* FindNode(const aiString& name) const {
return FindNode(name.data);
}
inline aiNode* FindNode(const aiString& name) {
inline
aiNode* FindNode(const aiString& name) {
return FindNode(name.data);
}
/**
* @brief Will search for a node described by its name.
* @param[in] name The name for the node to look for.
* @return Pointer showing to the node or nullptr if not found.
*/
const aiNode* FindNode(const char* name) const;
aiNode* FindNode(const char* name);
/**
@@ -243,7 +240,8 @@ struct ASSIMP_API aiNode {
* delete a given scene on your own.
*/
// -------------------------------------------------------------------------------
struct ASSIMP_API aiScene {
struct aiScene
{
/** Any combination of the AI_SCENE_FLAGS_XXX flags. By default
* this value is 0, no flags are set. Most applications will
* want to reject all scenes with the AI_SCENE_FLAGS_INCOMPLETE
@@ -357,10 +355,10 @@ struct ASSIMP_API aiScene {
#ifdef __cplusplus
//! Default constructor - set everything to 0/nullptr
aiScene();
ASSIMP_API aiScene();
//! Destructor
~aiScene();
ASSIMP_API ~aiScene();
//! Check whether the scene contains meshes
//! Unless no special scene flags are set this will always be true.

View File

@@ -118,9 +118,9 @@ extern "C" {
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */
#ifdef __cplusplus
static const size_t AI_MAXLEN = 1024;
static const size_t MAXLEN = 1024;
#else
#define AI_MAXLEN 1024
#define MAXLEN 1024
#endif
// ----------------------------------------------------------------------------------
@@ -243,8 +243,7 @@ struct aiColor3D {
}; // !struct aiColor3D
// ----------------------------------------------------------------------------------
/**
* @brief Represents an UTF-8 string, zero byte terminated.
/** Represents an UTF-8 string, zero byte terminated.
*
* The character set of an aiString is explicitly defined to be UTF-8. This Unicode
* transformation was chosen in the belief that most strings in 3d files are limited
@@ -261,40 +260,42 @@ struct aiColor3D {
* UTF-8 strings to their working character set (i.e. MBCS, WideChar).
*
* We use this representation instead of std::string to be C-compatible. The
* (binary) length of such a string is limited to AI_MAXLEN characters (including the
* (binary) length of such a string is limited to MAXLEN characters (including the
* the terminating zero).
*/
*/
struct aiString {
#ifdef __cplusplus
/** Default constructor, the string is set to have zero length */
aiString() AI_NO_EXCEPT :
length(0), data{'\0'} {
aiString() AI_NO_EXCEPT
: length(0) {
data[0] = '\0';
#ifdef ASSIMP_BUILD_DEBUG
// Debug build: overwrite the string on its full length with ESC (27)
memset(data + 1, 27, AI_MAXLEN - 1);
memset(data + 1, 27, MAXLEN - 1);
#endif
}
/** Copy constructor */
aiString(const aiString &rOther) :
length(rOther.length), data{'\0'} {
length(rOther.length) {
// Crop the string to the maximum length
length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
length = length >= MAXLEN ? MAXLEN - 1 : length;
memcpy(data, rOther.data, length);
data[length] = '\0';
}
/** Constructor from std::string */
explicit aiString(const std::string &pString) :
length((ai_uint32)pString.length()), data{'\0'} {
length = length >= AI_MAXLEN ? AI_MAXLEN - 1 : length;
length((ai_uint32)pString.length()) {
length = length >= MAXLEN ? MAXLEN - 1 : length;
memcpy(data, pString.c_str(), length);
data[length] = '\0';
}
/** Copy a std::string to the aiString */
void Set(const std::string &pString) {
if (pString.length() > AI_MAXLEN - 1) {
if (pString.length() > MAXLEN - 1) {
return;
}
length = (ai_uint32)pString.length();
@@ -305,8 +306,8 @@ struct aiString {
/** Copy a const char* to the aiString */
void Set(const char *sz) {
ai_int32 len = (ai_uint32)::strlen(sz);
if (len > static_cast<ai_int32>(AI_MAXLEN - 1)) {
len = static_cast<ai_int32>(AI_MAXLEN - 1);
if (len > (ai_int32)MAXLEN - 1) {
len = (ai_int32) MAXLEN - 1;
}
length = len;
memcpy(data, sz, len);
@@ -320,8 +321,8 @@ struct aiString {
}
length = rOther.length;
if (length > (AI_MAXLEN - 1)) {
length = static_cast<ai_int32>(AI_MAXLEN - 1);
if (length >(MAXLEN - 1)) {
length = (ai_int32) MAXLEN - 1;
}
memcpy(data, rOther.data, length);
@@ -343,24 +344,21 @@ struct aiString {
/** Comparison operator */
bool operator==(const aiString &other) const {
if (length == other.length) {
return memcmp(data, other.data, length) == 0;
}
return false;
return (length == other.length && 0 == memcmp(data, other.data, length));
}
/** Inverse comparison operator */
bool operator!=(const aiString &other) const {
return !(*this == other);
return (length != other.length || 0 != memcmp(data, other.data, length));
}
/** Append a string to the string */
void Append(const char *app) {
const ai_uint32 len = static_cast<ai_uint32>(::strlen(app));
const ai_uint32 len = (ai_uint32)::strlen(app);
if (!len) {
return;
}
if (length + len >= AI_MAXLEN) {
if (length + len >= MAXLEN) {
return;
}
@@ -375,7 +373,7 @@ struct aiString {
#ifdef ASSIMP_BUILD_DEBUG
// Debug build: overwrite the string on its full length with ESC (27)
memset(data + 1, 27, AI_MAXLEN - 1);
memset(data + 1, 27, MAXLEN - 1);
#endif
}
@@ -391,8 +389,8 @@ struct aiString {
* the number of bytes from the beginning of the string to its end.*/
ai_uint32 length;
/** String buffer. Size limit is AI_MAXLEN */
char data[AI_MAXLEN];
/** String buffer. Size limit is MAXLEN */
char data[MAXLEN];
}; // !struct aiString
// ----------------------------------------------------------------------------------
@@ -530,7 +528,7 @@ struct aiMemoryInfo {
*/
struct aiBuffer {
const char *data; ///< Begin poiner
const char *end; ///< End pointer
const char *end; ///< End pointer
#ifdef __cplusplus
/// @brief The class constructor.

View File

@@ -87,8 +87,7 @@ namespace Flax.Deps.Dependencies
var globalConfig = string.Join(" ", configs);
// Get the source
CloneGitRepoFast(root, "https://github.com/assimp/assimp.git");
GitCheckout(root, "master", "adff2f388a23f2192738470b094bb3197feb8ada");
CloneGitRepoSingleBranch(root, "https://github.com/assimp/assimp.git", "master", "10df90ec144179f97803a382e4f07c0570665864");
foreach (var platform in options.Platforms)
{
@@ -105,10 +104,9 @@ namespace Flax.Deps.Dependencies
// Build for Windows
File.Delete(Path.Combine(root, "CMakeCache.txt"));
foreach (var architecture in new[] { TargetArchitecture.x64, TargetArchitecture.ARM64 })
{
var buildDir = Path.Combine(root, "build-" + architecture.ToString());
var buildDir = Path.Combine(root, "build-" + architecture);
var solutionPath = Path.Combine(buildDir, "Assimp.sln");
SetupDirectory(buildDir, true);
RunCmake(root, platform, architecture, $"-B\"{buildDir}\" -DLIBRARY_SUFFIX=-vc140-md -DUSE_STATIC_CRT=OFF " + globalConfig);

View File

@@ -68,10 +68,14 @@ namespace Flax.Deps
/// <param name="options">The options.</param>
/// <param name="platform">The target platform.</param>
/// <param name="architecture">The target architecture.</param>
/// <param name="createIfMissing">Auto-create directory if it's missing.</param>
/// <returns>The absolute path to the deps folder for the given platform and architecture configuration.</returns>
public static string GetThirdPartyFolder(BuildOptions options, TargetPlatform platform, TargetArchitecture architecture)
public static string GetThirdPartyFolder(BuildOptions options, TargetPlatform platform, TargetArchitecture architecture, bool createIfMissing = true)
{
return Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "ThirdParty", architecture.ToString());
var path = Path.Combine(options.PlatformsFolder, platform.ToString(), "Binaries", "ThirdParty", architecture.ToString());
if (createIfMissing && !Directory.Exists(path))
Directory.CreateDirectory(path);
return path;
}
/// <summary>