Interactable: allow specifying arbitrary 2D polygon for mouse interaction#21574
Merged
abcdefg30 merged 2 commits intoSep 20, 2024
Merged
Conversation
543ca2d to
58a10f3
Compare
RoosterDragon
approved these changes
Sep 11, 2024
RoosterDragon
left a comment
Member
There was a problem hiding this comment.
Seems like a nice addition to me, and RenderMouseBounds is a lightweight addon so seems worth keeping for debugging utility.
Contributor
|
if i look at the example graphics, it seems to me it migh be nicer to draw 3d bounding box around a building. i.e. letting a selection/bounding box be part of the graphics of a building. |
abcdefg30
previously approved these changes
Sep 19, 2024
abcdefg30
left a comment
Member
There was a problem hiding this comment.
Lgtm otherwise. Can you remove the testcase?
58a10f3 to
24d3ccb
Compare
…ble/Selectable trait
24d3ccb to
5069f5b
Compare
abcdefg30
approved these changes
Sep 20, 2024
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Interactabletrait does not allow specifying non-rectangular region as mouse bounds...... despite
MouseoverBounds()method inIMouseBoundsinterface returningPolygon:PR description
This PR allows specifying arbitrary 2D polygon for mouse interaction that will be used instead of
Bounds(or bounds generated usingIAutoMouseBoundstrait):Example in RA
This is how a (bit contrived) test case could look like in RA:
(here only Refinery has polygon mouse bounds, the rest of the buildings use normal rectangle)
I also added a debug trait
RenderMouseBoundsfor use by modders in order to tweak the polygon, since the mouse bounds are not visible unlike the selection box. It's not essential for the PR, so I can remove it, if required.More background (and a real use case)
In OpenE2140 we have a small issue with the mouse bounds for Refinery and Mine buildings. Both have conveyor belt on one entire tile, which "sticks" out of the main part of each building. The problem is that it's not possible to target the cell right below the conveyor belt:
With
Interactableallowing to define polygon (in addition to normal rectangle), we can solve this issue very elegantly:Actually this is how the mouse interaction works in the original Earth 2140: