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

Resolve Max texture paths before exporting #1623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpogue
Copy link
Member

@dpogue dpogue commented Nov 1, 2024

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.

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.
@dpogue dpogue added the Plugin label Nov 1, 2024
Copy link
Member

@Hoikas Hoikas left a 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.

Comment on lines +403 to 404
BMMGetFullFilename(&GetPBBitmap(index)->bi);
_tcsncpy( destFilename, GetPBBitmap( index )->bi.Name(), maxLength );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BMMGetFullFilename(&GetPBBitmap(index)->bi);
_tcsncpy( destFilename, GetPBBitmap( index )->bi.Name(), maxLength );
BMMGetFullFilename(GetPBBitmap( index )->bi.Name(), destFilename, maxLength);

@dpogue
Copy link
Member Author

dpogue commented Nov 3, 2024

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.

@Hoikas
Copy link
Member

Hoikas commented Nov 3, 2024

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.

😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants