Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around not-found textures. #1635

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions Sources/MaxPlugin/MaxConvert/plBitmapCreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,23 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l
// Texture reuse optimization
if( texture )
{
WIN32_FILE_ATTRIBUTE_DATA fileAttrib;
GetFileAttributesExW(bd->fileName.WideString().data(), GetFileExInfoStandard, &fileAttrib);
FILETIME &fileTime = fileAttrib.ftLastWriteTime;
WIN32_FILE_ATTRIBUTE_DATA fileAttrib{};
if (GetFileAttributesExW(bd->fileName.WideString().data(), GetFileExInfoStandard, &fileAttrib) != FALSE)
{
FILETIME &fileTime = fileAttrib.ftLastWriteTime;

// If this texture has been modified since the last export, delete the old version but reuse the key
if (!texture->IsSameModifiedTime(fileTime.dwLowDateTime, fileTime.dwHighDateTime))
// If this texture has been modified since the last export, delete the old version but reuse the key
if (!texture->IsSameModifiedTime(fileTime.dwLowDateTime, fileTime.dwHighDateTime))
{
DeleteExportedBitmap( texture->GetKey() );
texture = nullptr;
key = nullptr;
}
}
else
{
DeleteExportedBitmap( texture->GetKey() );
texture = nullptr;
key = nullptr;
// Well, this really sucks. We couldn't tell what the modify time is, so just pretend all is well (but assert in Debug mode)
hsAssert(0, ST::format("Couldn't get bitmap '{}' modify time: {}", bd->fileName, hsCOMError(hsLastWin32Error, GetLastError()).c_str()));
}
}

Expand Down Expand Up @@ -644,10 +651,17 @@ plBitmap *plBitmapCreator::ICreateTexture( plBitmapData *bd, const plLocation &l
}

// Texture reuse optimization
WIN32_FILE_ATTRIBUTE_DATA fileAttrib;
GetFileAttributesExW(bd->fileName.WideString().data(), GetFileExInfoStandard, &fileAttrib);
FILETIME &fileTime = fileAttrib.ftLastWriteTime;
texture->SetModifiedTime(fileTime.dwLowDateTime, fileTime.dwHighDateTime);
WIN32_FILE_ATTRIBUTE_DATA fileAttrib{};
if (GetFileAttributesExW(bd->fileName.WideString().data(), GetFileExInfoStandard, &fileAttrib) != FALSE)
{
FILETIME &fileTime = fileAttrib.ftLastWriteTime;
texture->SetModifiedTime(fileTime.dwLowDateTime, fileTime.dwHighDateTime);
}
else
{
// Well, this really sucks. We couldn't tell what the modify time is, so just pretend all is well (but assert in Debug mode)
hsAssert(0, ST::format("Couldn't set bitmap '{}' modify time: {}", bd->fileName, hsCOMError(hsLastWin32Error, GetLastError()).c_str()));
}

// Add to our list of created textures and ref, since we have a hold of them
IAddBitmap( texture );
Expand Down