Skip to content

refactor(basetype): Make isInRegion consistent across Region types - #3428

Merged
xezon merged 2 commits into
TheSuperHackers:mainfrom
stephanmeesters:refactor/isInRegion
Oct 5, 2026
Merged

xezon merged 2 commits into
TheSuperHackers:mainfrom
stephanmeesters:refactor/isInRegion

Conversation

@stephanmeesters

@stephanmeesters stephanmeesters commented Oct 5, 2026 •

Copy link
Copy Markdown
  • All four region types (IRegion2D, Region2D, IRegion3D, Region3D) now have the same isInRegion overloads: separate values, a point, and a whole region.
  • Every check uses <=, so points on the edge count as inside.
  • isInRegionNoZ is gone. The 3D types take a 2D point instead, and callers convert with asCoord2D(). Inlines completely.

AI was used.

@coderabbitai

This comment was marked as spam.

@stephanmeesters stephanmeesters added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Refactor Edits the code with insignificant behavior changes, is never user facing labels Oct 5, 2026
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Refactors region boundary-check API across game logic.

The PR appears safe to merge; both earlier edge findings are addressed.

What we checked:

  • Map checks might use height: No. asCoord2D() copies only x and y, and the selected Region3D overload checks only those values.
Summary

This PR gives the four region types matching isInRegion overloads and replaces isInRegionNoZ calls with 2D points. The latest change restores strict edge checks, addressing both earlier findings.

  • Existing map checks keep their x/y behavior.
  • Points on a region edge are excluded, contrary to the PR description.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Position["3D position"] --> Convert["asCoord2D()"]
  Convert --> Check["Region3D::isInRegion(Coord2D)"]
  Check --> Result["Strict x/y edge check"]
Loading

Reviews (2) · Last reviewed commit: "Revert from <= to <"

Comment thread GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
Comment thread Core/Libraries/Include/Lib/Region2D.h Outdated
@stephanmeesters

Copy link
Copy Markdown
Author

Perhaps I'll add a set of isInRegionInclusive variants for the <= case

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Makes sense for the current users. It is strange that they did not choose <= to begin with. It is especially apparent on floating points.

A difference of 0.0 means it is not inside, but 0.000001 means it is inside. But for integers that threshold is 1, which is much further away.

Having an inclusive one makes sense, because that covers the default use case for region inclusion checks. Imo the current isInRegion should be the exception, not the norm.

@xezon
xezon merged commit 171894d into TheSuperHackers:main Oct 5, 2026
25 checks passed
@stephanmeesters
stephanmeesters deleted the refactor/isInRegion branch October 5, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants