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

[SM64] Sort Level Objects Alphabetically #336

Merged
merged 1 commit into from
May 31, 2024

Conversation

jesusyoshi54
Copy link
Collaborator

added sorting to object exports in sm64. Actors are sorted alphabetically. This will generally make it so the same type of object all export in a row since these will have names like: coin, coin.001, coin.002 etc.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Apr 21, 2024

Is there any reason whirlpools and mario starts don't have a separate list like specials, macros, puppy cam volumes, etc?

@jesusyoshi54
Copy link
Collaborator Author

jesusyoshi54 commented Apr 21, 2024

I don't believe there is any special reason, I think it just categorically was grouped as part of the area while objects felt deserving of their own separate lists. Probably because they won't be scrutinized as much.
It was this way in vanilla so kure probably copied that and it has carried over.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Apr 22, 2024

wait really? I checked the hacker implementation and they don't create any objects, ao I guess that's hacker specific? sorry about that aha, if that is the case then this looks perfect already, I will do a level export later today and then if everything is correct I will get this merged

@Lilaa3
Copy link
Collaborator

Lilaa3 commented Apr 22, 2024

It seems objects are getting sorted correctly by blender which I don´t remember being the case? In fact this pr broke correct order by putting capitalized names first, if the objective is to have the same types of objects be placed in order then why not sort by model and behavior and presets (for macros)
jesusyoshi54#3 here are my suggested changes/implementation, I wrote it a bit carelessly but it does get the job done perfectly

@jesusyoshi54
Copy link
Collaborator Author

wait really? I checked the hacker implementation and they don't create any objects, ao I guess that's hacker specific?

What I meant is for grouping. Mario start and whirlpools aren't objects, but they're chunked together in the same lists as objects in the area level script, so that's why I believe it was coded that way. There's no actual reason it has to be.

@jesusyoshi54
Copy link
Collaborator Author

jesusyoshi54 commented Apr 27, 2024

It seems objects are getting sorted correctly by blender which I don´t remember being the case? In fact this pr broke correct order by putting capitalized names first, if the objective is to have the same types of objects be placed in order then why not sort by model and behavior and presets (for macros)

The goal was to allow the user to sort the objects. I don't know if that is always by model or by behavior. I think the original reason this was brought up was due to some kaze thing where he needed stuff in a specific order.
I don't know what correct order I broke with this, could you explain that?

I also closed by accident I didn't know deleting a comment closed the PR lol

@jesusyoshi54 jesusyoshi54 reopened this Apr 27, 2024
@Lilaa3
Copy link
Collaborator

Lilaa3 commented Apr 27, 2024

at least in blender 4.1 it seems objects are getting sorted in the UI and in the actual data.
to answer your question (again) your code sorts differently, by capitalization and only then by alphabetic order which is confusing in my opinion.
In any case do you see any use for this where a sort by model, behavior and then just keeping the order that blender has isn't better? If someone wanted to use this for say batching, that would work out of the box. I'd say it makes a lot of sense to sort like that.
This PR might be needed for older blender versions tho, which I seem to remember, if you think model behavior sorting takes away control from the user I can accept that and the only change I'd like you to make then is updating the lambda to sort alphabetically like blender.

@jesusyoshi54
Copy link
Collaborator Author

jesusyoshi54 commented Apr 27, 2024

I'd prefer to sort by what the UI has, that's the most intuitive. I'll have to add an ignore case to the sort to fix it.
While I don't think it would be common to not sort by model, it can happen, and I would think it is worth allowing customized sorting for any specific weirdness users may want to do; something like a water diamond/water diamond init obj may be such a case.

@jesusyoshi54
Copy link
Collaborator Author

Ok from my testing on versions 3.2 and 3.6 of blender, the current method of sorting matches what the UI does. Only blender 4.0+ has an issue where it starts doing some wack stuff. I really have no clue what it really is doing since it doesn't match any sort of ordering I could tell from looking at the console.
image
You can see the order of the 1ups (denoted by name) does not match with what prints out in the console. I believe this is just the blender UI for 4.0 being wack.
image
Here I got an example of a M * string coming after a m * string, which really doesn't make sense.

@Lilaa3
Copy link
Collaborator

Lilaa3 commented May 12, 2024

I really tried understanding how this works but I'm having a really hard time understanding the blender source code

@Lilaa3
Copy link
Collaborator

Lilaa3 commented May 24, 2024

Ok from what I did understand the order in the UI isn't achieved with any form of conventional name sorting specifically, and we should not rely on the order of bpy.data.objects, your original implementation is consistent and that's good
I still think the behavior I was seeing was weird, if I two objects like "Blargg" and "amp", blaarg would come first from just the capitalization, is this that common and I'm just not used to seeing it? and does pre 4.0 blender also do it?

@jesusyoshi54
Copy link
Collaborator Author

your original implementation is consistent and that's good I still think the behavior I was seeing was weird, if I two objects like "Blargg" and "amp", blaarg would come first from just the capitalization, is this that common and I'm just not used to seeing it? and does pre 4.0 blender also do it?

My experience from 3.X is the order always matched string ordering. Capital letters First, then lowers, alphabetical order in those sets. It always did this as far as I'm aware, but maybe in some versions past 3.6 it didn't, but I don't use those. This is the same way python sorts strings.

@Lilaa3 Lilaa3 added the merge soon Will be merged in a few days at most if nothing else comes up label May 24, 2024
@Lilaa3 Lilaa3 merged commit a062be6 into Fast-64:main May 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge soon Will be merged in a few days at most if nothing else comes up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants