mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 11:43:49 +00:00
update assimp lib
This commit is contained in:
parent
03a348deb7
commit
d3f8fee74e
1725 changed files with 196314 additions and 62009 deletions
|
|
@ -2,7 +2,7 @@
|
|||
Open Asset Import Library (assimp)
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2006-2022, assimp team
|
||||
Copyright (c) 2006-2024, assimp team
|
||||
|
||||
All rights reserved.
|
||||
|
||||
|
|
@ -46,13 +46,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "ProcessHelper.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace Assimp;
|
||||
|
||||
EmbedTexturesProcess::EmbedTexturesProcess() = default;
|
||||
|
||||
EmbedTexturesProcess::~EmbedTexturesProcess() = default;
|
||||
|
||||
bool EmbedTexturesProcess::IsActive(unsigned int pFlags) const {
|
||||
return (pFlags & aiProcess_EmbedTextures) != 0;
|
||||
}
|
||||
|
|
@ -95,25 +92,47 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) {
|
|||
ASSIMP_LOG_INFO("EmbedTexturesProcess finished. Embedded ", embeddedTexturesCount, " textures." );
|
||||
}
|
||||
|
||||
std::string EmbedTexturesProcess::tryToFindValidPath(const std::string &imagePath) const
|
||||
{
|
||||
// Test path directly
|
||||
if (mIOHandler->Exists(imagePath)) {
|
||||
return imagePath;
|
||||
}
|
||||
ASSIMP_LOG_WARN("EmbedTexturesProcess: Cannot find image: ", imagePath, ". Will try to find it in root folder.");
|
||||
|
||||
// Test path in root path
|
||||
std::string testPath = mRootPath + imagePath;
|
||||
if (mIOHandler->Exists(testPath)) {
|
||||
return testPath;
|
||||
}
|
||||
|
||||
// Test path basename in root path
|
||||
testPath = mRootPath + imagePath.substr(imagePath.find_last_of("\\/") + 1u);
|
||||
if (mIOHandler->Exists(testPath)) {
|
||||
return testPath;
|
||||
}
|
||||
|
||||
// In unix systems, '\' is a valid file name character, but some files may use \ as a directory separator.
|
||||
// Try replacing '\' by '/'.
|
||||
if (mIOHandler->getOsSeparator() != '\\' && imagePath.find('\\') != std::string::npos) {
|
||||
ASSIMP_LOG_WARN("EmbedTexturesProcess: Cannot find image '", imagePath, "' in root folder. Will try replacing directory separators.");
|
||||
testPath = imagePath;
|
||||
std::replace(testPath.begin(), testPath.end(), '\\', mIOHandler->getOsSeparator());
|
||||
return tryToFindValidPath(testPath);
|
||||
}
|
||||
|
||||
ASSIMP_LOG_ERROR("EmbedTexturesProcess: Unable to embed texture: ", imagePath, ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
bool EmbedTexturesProcess::addTexture(aiScene *pScene, const std::string &path) const {
|
||||
std::streampos imageSize = 0;
|
||||
std::string imagePath = path;
|
||||
std::string imagePath = tryToFindValidPath(path);
|
||||
|
||||
// Test path directly
|
||||
if (!mIOHandler->Exists(imagePath)) {
|
||||
ASSIMP_LOG_WARN("EmbedTexturesProcess: Cannot find image: ", imagePath, ". Will try to find it in root folder.");
|
||||
|
||||
// Test path in root path
|
||||
imagePath = mRootPath + path;
|
||||
if (!mIOHandler->Exists(imagePath)) {
|
||||
// Test path basename in root path
|
||||
imagePath = mRootPath + path.substr(path.find_last_of("\\/") + 1u);
|
||||
if (!mIOHandler->Exists(imagePath)) {
|
||||
ASSIMP_LOG_ERROR("EmbedTexturesProcess: Unable to embed texture: ", path, ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (imagePath.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IOStream* pFile = mIOHandler->Open(imagePath);
|
||||
if (pFile == nullptr) {
|
||||
ASSIMP_LOG_ERROR("EmbedTexturesProcess: Unable to embed texture: ", path, ".");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue