fixed emply buffer stream write, removed some cast warnings.

This commit is contained in:
Marco Di Benedetto
2018-03-19 18:22:27 +01:00
parent 3390185270
commit 9d813a48b0
9 changed files with 57 additions and 57 deletions

View File

@@ -99,22 +99,22 @@ void EmbedTexturesProcess::Execute(aiScene* pScene) {
}
bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
uint32_t imageSize = 0;
std::string imagePath = path;
std::streampos imageSize = 0;
std::string imagePath = path;
// Test path directly
std::ifstream file(imagePath, std::ios::binary | std::ios::ate);
if ((imageSize = file.tellg()) == -1u) {
if ((imageSize = file.tellg()) == std::streampos(-1)) {
DefaultLogger::get()->warn("EmbedTexturesProcess: Cannot find image: " + imagePath + ". Will try to find it in root folder.");
// Test path in root path
imagePath = mRootPath + path;
file.open(imagePath, std::ios::binary | std::ios::ate);
if ((imageSize = file.tellg()) == -1u) {
if ((imageSize = file.tellg()) == std::streampos(-1)) {
// Test path basename in root path
imagePath = mRootPath + path.substr(path.find_last_of("\\/") + 1u);
file.open(imagePath, std::ios::binary | std::ios::ate);
if ((imageSize = file.tellg()) == -1u) {
if ((imageSize = file.tellg()) == std::streampos(-1)) {
DefaultLogger::get()->error("EmbedTexturesProcess: Unable to embed texture: " + path + ".");
return false;
}
@@ -134,7 +134,7 @@ bool EmbedTexturesProcess::addTexture(aiScene* pScene, std::string path) const {
// Add the new texture
auto pTexture = new aiTexture();
pTexture->mHeight = 0; // Means that this is still compressed
pTexture->mWidth = imageSize;
pTexture->mWidth = uint32_t(imageSize);
pTexture->pcData = imageContent;
auto extension = path.substr(path.find_last_of('.') + 1u);