-
Notifications
You must be signed in to change notification settings - Fork 81
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
Resolve Max texture paths before exporting #1623
base: master
Are you sure you want to change the base?
Conversation
Max seems to save the original full file path to the texture image in its data, but happily resolves it against the current working directory when a file is opened in the editor. Except that it doesn't ever update the stored full file path, so when the PlasmaMax plugin asks for files it can get paths that don't exist. This is a problem because it tries to detect changes to textures based on modified times, and nonexistent files have nonexistent modified times, which can lead to the same image getting exported multiple times because PlasmaMax tries to treat each instance of it as a new texture. The Max SDK includes a function to resolve texture file paths, so we'll call that in a bunch of spots before we use the texture file path for anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'm comfortable with the idea of running this on the BitmapInfo itself because it may cause the max file to change on export. I'm a little wary of creating additional deltas. I think I would prefer to see the fix limited to places where the plugin code is trying to access the file system, which is really just in plBitmapCreator::ICreateTexture()
AFAICT. There is an overload of BMMGetFullFilename()
would be helpful for this. I left it in a suggestion - not for it to be applied there but as an example.
BMMGetFullFilename(&GetPBBitmap(index)->bi); | ||
_tcsncpy( destFilename, GetPBBitmap( index )->bi.Name(), maxLength ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BMMGetFullFilename(&GetPBBitmap(index)->bi); | |
_tcsncpy( destFilename, GetPBBitmap( index )->bi.Name(), maxLength ); | |
BMMGetFullFilename(GetPBBitmap( index )->bi.Name(), destFilename, maxLength); |
That is a good point about this causing the paths to change in the actual Max file and leading to unexpected git diffs! I'll try to get the string-based on hooked up in plBitmapConverter. IIRC the one thing we need to watch out for there is that it isn't available in older APIs (i.e., Max 7) and changed to take a length parameter in recent versions. |
😞 |
Max seems to save the original full file path to the texture image in its data, but happily resolves it against the current working directory when a file is opened in the editor. Except that it doesn't ever update the stored full file path, so when the PlasmaMax plugin asks for files it can get paths that don't exist. This is a problem because it tries to detect changes to textures based on modified times, and nonexistent files have nonexistent modified times, which can lead to the same image getting exported multiple times because PlasmaMax tries to treat each instance of it as a new texture.
The Max SDK includes a function to resolve texture file paths, so we'll call that in a bunch of spots before we use the texture file path for anything.