-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Inventory image animation API second try #16538
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
Conversation
f06fffe to
ff95981
Compare
|
d75ed95 to
06a265a
Compare
|
Another big rebase, next time I will squash the commits to reduce rebase work. |
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'd like to propose a few changes:
0001-Use-AnimationInfo-for-simplicity.patch.tar.gz
Excerpt from the commit message:
- Moved 'ItemVisuals' to the source file (internal for 'ItemVisualsManager')
- Re-used 'AnimationInfo' with one tile: This makes it possible to use
one class/interface to contain as many textures as wanted. (generic) - Replaced 'OwnedAnimationInfo' with 'AnimationInfo' + 'freeFrames()' to
(hopefully) reduce complexity.
|
Thanks for the improvements. |
SmallJoker
left a comment
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.
LGTM aside from that. I find the animations very distracting, but it works.
|
|
||
| // Note: Also update core.protocol_versions in builtin when bumping | ||
| const u16 LATEST_PROTOCOL_VERSION = 50; | ||
| const u16 LATEST_PROTOCOL_VERSION = 51; |
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.
Design question to the dev team: Should we bump already, or in the 5.15.0-rc build?
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.
Typically people bump the protocol version because a network change requires it.
If this isn't the case here we could delay the bumping, but I don't see a strong reason to.
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 am mainly asking this in case there would be a second PR for 5.15.0 that also increases the version. I guess it does not matter. We could bump it multiple times per version.
Only send first frame texture names to old clients Replace image string by item image definition Bump protocol version 1. Moved 'ItemVisuals' to the source file (internal for 'ItemVisualsManager') 2. Re-used 'AnimationInfo' with one tile: This makes it possible to use one class/interface to contain as many textures as wanted. (generic) 3. Replaced 'OwnedAnimationInfo' with 'AnimationInfo' + 'freeFrames()' to (hopefully) reduce complexity. Co-authored-by: SmallJoker <[email protected]>
b2958d1 to
298a6c5
Compare
|
Rebased (and squashed beforehand). |
|
|
||
| ~ItemVisuals() | ||
| { | ||
| inventory_normal.freeFrames(); |
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.
wouldn't it be cleaner if ItemVisuals owned the frames ptr separately, so that AnimationInfo is always just a reference?
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.
This was the case before at some point, but with Krocks's suggestions it changed "to (hopefully) reduce complexity".
Though, it probably would be best to directly store it in ItemVisuals instead of allocating additional heap memory.
| -- 'chunksize' mapgen setting can be a vector, instead of a single number (5.15.0) | ||
| chunksize_vector = true, | ||
| -- Item definition fields `inventory_image`, `inventory_overlay`, `wield_image` | ||
| -- and `wield_overlay` accept a table containing animation definitions. (5.16.0) |
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.
5.15.0
| if (image.name.empty()) { | ||
| // no-op | ||
| } else if (image.animation.type == TileAnimationType::TAT_NONE) { | ||
| frames->push_back({0, tsrc->getTexture(image.name)}); |
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.
couldn't createAnimationFrames just handle the one-frame case?
| AnimationInfo *getInventoryOverlayAnimation(const ItemStack &item, Client *client) const; | ||
|
|
||
| // Get item mesh | ||
| // Once said to return nullptr if there is an inventory image, but this is wrong |
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.
line should be removed.
|
|
||
| std::vector<FrameSpec> createAnimationFrames(ITextureSource *tsrc, | ||
| const std::string &image_name, const TileAnimationParams &animation, | ||
| int &result_frame_length_ms) |
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 would move this to another file, but not sure where
| void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result) | ||
| void createItemMesh(Client *client, const ItemDefinition &def, | ||
| AnimationInfo &animation_normal, | ||
| AnimationInfo &animation_overlay, |
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.
const?
| extractTexture(f.tiledef_special[0], l0, tsrc), nullptr | ||
| ); | ||
| result->buffer_info.emplace_back(0, l0.has_color, l0.color); | ||
| mesh = getExtrudedMesh(l0.texture); |
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.
no, the extractTexture call is important and was needed for preparation for array textures.
(in the future) l0.texture may be an array texture, which isn't usable for the item mesh.
|
|
||
| // Modifies the texture name such that it only contains the first frame | ||
| // If the texture_size is know (client code), getTextureModifer should be used instead | ||
| void extractFirstFrame(std::string &name) const; |
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 would put a disclaimer here that this function is only for compatibility purposes with old clients.
Revision of #15979 (Can't reopen the old PR because of rebase force push.) Closes #4758
There are now 4 different animation definitions such that the overlay animations can be changed independently.Item image can now be a table
Animations can be changed via metadata (Json serialized and properly cached). ✨Removed for this PR
Problems (currently not planned to be resolved with this PR):
visual = "wielditem"andvisual = "item"objects (dropped items) is not animated.TileAnimationParamsback to Lua.To do
Ready for Review.
How to test
Start devtest and use
testitems:inventory_image_animationtestitems:inventory_image_animation_overlaytestitems:wield_image_animationtestitems:wield_image_animation_overlaytestitems:inventory_image_animation_meta(new, for metadata)Test compatibility with older versions, which only use the first frame.