-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Feature 2833 (rotated Wang tiles) #2912
Conversation
7923ffa
to
360df03
Compare
My current plan for supporting direct use after Wang tile edit would be to regenerate the virtual Wang tile entries whenever the tileset is saved to a file. @bjorn Would you require this before merging to master? |
@cpetig It should work without needing to save the tileset, but I have not yet gotten around to looking at your approach in detail and to consider alternatives. I'll look into this tomorrow. |
I know that derived (rotated) Wang variants are not recalculated whenever a Wang tile is edited. I thought that recalculating on save might be a reasonable compromise (only need to change a single function) instead of having to recalculate at every change. Currently the derived set is only calculated at Tileset load time (which will probably confuse users) |
I've replaced the generated WangTiles approach by iterating the variations on-demand and applying a small penalty to variations in order to keep the "rotate-for-variation" optional. It's slower (even twice as slow at the moment), but I still prefer it since it makes other things easier. Maybe we can still optimize the setting up of the variations a bit later. There's a few things still to be done before this can be merged:
I'll see if I can help with these things next week, but in the meantime any work or additional feedback is really appreciated! |
I still have trouble imagining a tile set where different rules apply to different Wang sets (i.e. I believe that if any image in a set supports vertical flipping (birds eye view typically) all images would allow this). And since the system prefers existing flipped/rotated-WangId tiles over flipping/rotating tiles I see no benefit of making the decision per Wang Set or even per tile. |
Eishiya convinced me that there is at least one user for per tile settings, see https://discordapp.com/channels/524610627545595904/524610627545595906/777201497770819635 . Also it seems that indeed 180° doesn't imply 90° is valid. |
@bjorn Is there a specific reason for defining trivial one statement get functions at the end of the header instead of embedding them inside the class? |
I try to figure out whether the rotation permission is a property of a WangTile or a Tile? I assume a WangTile corresponds to an entity which is edited in the Wang editor for one tile, so this would be the correct place to store the information. @bjorn Could you please confirm this understanding as correct? |
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.
@bjorn Is there a specific reason for defining trivial one statement get functions at the end of the header instead of embedding them inside the class?
Oh, I see it is done differently in WangTile and WangSet. So I assume there is no specific reason.
It just means I'm not feeling overly attached to having them in one place or another, since both have their advantages. The reason to put them outside of the class is simply to keep the class definition more readable.
I try to figure out whether the rotation permission is a property of a WangTile or a Tile? I assume a WangTile corresponds to an entity which is edited in the Wang editor for one tile, so this would be the correct place to store the information. @bjorn Could you please confirm this understanding as correct?
Yes, though when we're doing this per-WangTile there would need to be some way in the tileset editor to set up which tiles can be flipped in which way. Not sure what's the best approach for now.
I left some inline comments, though I saw you just pushed another change, which is not taken into account yet.
Dear @bjorn , I completed the code for per WangSet and per WangTile independent flip permissions. But to me it feels that (especially after implementing the undo/redo part per WangTile) overriding flip permissions for a WangTile should be a per Tile property. |
@cpetig Well, the way it's implemented now it indeed makes no sense for this stuff to be stored in the WangTile instead of the Tile. But in any case, I think you've done a great job adjusting this patch to the recent discussions. Let's take a short break. I will have time to take a detailed look into the patch again on Tuesday. |
@bjorn I tested the per tileset settings and would say that this could be ready (if necessary) for the next release if you hide the per tile flip properties (as they have no implemention yet and would only confuse users). The document/model/changedata classes will probably need some cleanup (especially when it comes to per tile properties). |
@cpetig Thanks for your hard work on this change and for your persistence as we try different approaches! As said, it may take until Tuesday for me to be able to get back to this change, but it's great to work together on this and I'm sure we'll manage to get this merged soon now. |
The following remaining things still need to be addressed:
|
Closes bjorn/tiled/mapeditor#2833
In my measurements this was unfortunately about twice as slow as working with generated WangTiles, but that's not too bad since it avoids the complexity of keeping them updated as we change WangIds of tiles or options related to which flips are allowed.
…and WangTiles Still unfinished work
…rotation properties
We don't need the variation_recipe array if we make the flags dynamic.
Also, associating just WangIds with tiles, removing most usage of the WangTile class, which could eventually be removed entirely. Large parts of the code have been commented out since they have not been adjusted yet to the other changes.
* Introduced Tileset::TransformationFlags to replace the 4 bools. * Changed the way the allowed transformations are stored in the TMX format to use a separate <transformations> element, since it's not nice to have a lot of attributes. * Removed the reading code that was there for compatibility, since the change is still work in progress. Shouldn't be much effort to adapt. * Fixed the on-demand recalculation of the WangId -> Cell association by comparing to the "last seen" translation flags of the tileset.
Needed changing due to WangSet API change away from using WangTile.
FYI: I rebased the branch on the current master for a start. |
… properties for now
I implemented JSON im+export and documented the file format changes (although the meaning of the bitset in the JSON file is not documented. Also I turned off the rotation properties for tiles, so that the incomplete feature is not accessible by/visible for users. I will go to bed now. PS: I get a warning that Q_FLAGS() is obselete and should be replaced by Q_FLAG() see https://doc.qt.io/qt-5/qobject-obsolete.html#Q_FLAGS |
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.
Thanks @cpetig, I'll finish up the rest. I've left some inline comments but I will resolve those as well.
Can be reintroduced when we add this feature in the future.
* Removed no longer supported hflip, vflip and dflip attributes on Wang tiles. Simplified WangTile class. * Re-enabled code in ChangeTileWangId based on new WangSet API. * Changed JSON format to not use bitflags for allowed transformations. * Removed Q_FLAGS use in Tileset, which makes no sense since the Tileset class has no QMetaObject. * Additional documentation updates.
* Removed comment about individual tile flipping preferences that doesn't apply for now. * Added forgotten copying of mLastSeenTranslationFlags. * Removed unused tileFlipPermissionChanged signal. * Removed unused OverrideTransformationFlagsProperty enum value. * Removed comment about penalty for flipped variations that no longer applies. * Removed unused icons.
Puh, I guess this change is almost ready for merging. I wonder if I'm doing something wrong that makes some changes take such a long time to finish, and to even finish them in a state that leaves more work to be done! One remaining thing that's nagging me right now, is that the option of whether to allow rotation essentially only allows a single 90-degree clockwise rotation. You need to allow flipping to enable 180 and 270 degree rotations as well. I wanted this flag to say "rotation" rather than "diagonal flip" because I think it's more intuitive and more useful, but I guess if only rotation is selected, it should really also include 180 and 270 degrees. Just need to find a way to work this into I also wonder a bit what should happen when "Rotate" and "Flip Horizontal" is allowed, but not "Flip Vertical". It makes no sense because Rotate180 + FlipHorizontal = FlipVertical. :S Any opinions welcome, @cpetig! |
If it's just 90-degree variation it's not very intuitive and rather less useful.
Also explains a little what they are for.
@cpetig Thanks for a nice collaboration! |
@bjorn Same to you! Thank you for programming, maintaining and offering this nice tool. |
Implementation of rotated Wang tiles. Introduces new icons for rotate-on-demand and rotate-for-variation. Implements saving and loading these properties to tile sets. Implements rotated virtual Wang tile generation on loading.
Closes #2833