You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add coordinate min/max and region intersection helpers
✨ Enhancement🕐 20-40 Minutes
AI Description
• Adds component-wise min/max helpers to integer and floating-point 2D/3D coordinates.
• Adds mutating intersection operations to all 2D and 3D region variants.
• Replaces duplicated window and pathfinding bounds-clamping logic with shared helpers.
Diagram
classDiagram
class Coord2D {
+min(other)
+max(other)
}
class ICoord2D {
+min(other)
+max(other)
}
class Region2D {
+intersect(other)
}
class IRegion2D {
+intersect(other)
}
class Coord3D {
+min(other)
+max(other)
}
class ICoord3D {
+min(other)
+max(other)
}
class Region3D {
+intersect(other)
}
class IRegion3D {
+intersect(other)
}
Region2D *-- Coord2D : bounds
IRegion2D *-- ICoord2D : bounds
Region3D *-- Coord3D : bounds
IRegion3D *-- ICoord3D : bounds
Loading
High-Level Assessment
The following are alternative approaches to this PR:
1. Non-mutating free functions
➕ Make value transformation explicit at call sites
➕ Allow source bounds to remain unchanged
➕ Can return a new region suitable for expression composition
➖ Require additional assignments or temporary objects
➖ Do not match the existing mutable POD-style APIs
➖ Produce greater call-site churn for this legacy codebase
2. Templated coordinate and region types
➕ Eliminate duplication between integer and floating-point variants
➕ Centralize dimension-independent min, max, and intersection behavior
➖ Greatly expands the scope and compatibility risk
➖ Could disrupt serialization, ABI assumptions, or legacy call sites
➖ Provides limited immediate benefit for this focused refactor
Recommendation: Keep the PR's mutating member-function approach because it fits the existing region and coordinate design and cleanly replaces repeated clamping logic. A templated redesign could reduce duplication but should be a separate, compatibility-focused change; tests for overlapping and disjoint regions would strengthen the current approach.
Files changed (3) +106 / -76
Enhancement (1) +98 / -12
BaseType.hAdd coordinate min/max and region intersection APIs+98/-12
Add coordinate min/max and region intersection APIs
• Adds mutating component-wise 'min' and 'max' methods to all 2D and 3D integer and floating-point coordinate types. Adds 'intersect' to corresponding region types and reuses coordinate helpers when constructing 3D bounds from points.
GameWindow.cppNormalize window bounds with coordinate min/max helpers+3/-20
Normalize window bounds with coordinate min/max helpers
• Replaces manual axis-by-axis endpoint swapping with the new component-wise coordinate operations while preserving the original lower endpoint for the upper-bound calculation.
AIPathfind.cppUse shared bounds clipping in pathfinding+5/-44
Use shared bounds clipping in pathfinding
• Replaces repeated coordinate clamps with 'min' and region 'intersect' operations during zone calculation, zone modification, and object-footprint classification. This centralizes two-dimensional bounds clipping behavior.
This PR adds reusable coordinate projection, component-wise bound updates, and region intersection/union helpers, then replaces equivalent manual coordinate and bounds operations throughout the engine and both game variants.
Adds asCoord2D/asICoord2D, updateMin/updateMax, and intersectWith/uniteWith helpers.
Refactors pathfinding, bridge, polygon, AI, prison-yard, rendering, and WorldBuilder calculations to use the helpers.
Renames the newly introduced integer-coordinate projection helper from getXY to asICoord2D and updates all callers.
The previous macro-collision thread is resolved; the current API uses updateMin and updateMax rather than member names min and max.
Confidence Score: 5/5
The PR appears safe to merge, with no outstanding correctness, security, or repository-rule issue identified.
The latest change only renames ICoord3D::getXY() to asICoord2D() and updates both existing callers; no stale calls remain, and the calls match the IRegion2D::uniteWith(const ICoord2D&) overload. The previous macro-collision finding was manually resolved and the implicated min/max member names are no longer present.
Important Files Changed
Filename
Overview
Core/Libraries/Include/Lib/BaseType.h
Introduces coordinate projection and component-wise region utility methods; the latest helper rename is consistently applied.
stephanmeesters
added
Gen
Relates to Generals
ZH
Relates to Zero Hour
Refactor
Edits the code with insignificant behavior changes, is never user facing
Minor
Severity: Minor < Major < Critical < Blocker
labels
Sep 8, 2026
stephanmeesters
changed the title
refactor(basetype): Add intersect and min/max functions to Region and Coord types
refactor(basetype): Add utility functions to Region and Coord types
Sep 10, 2026
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
GenRelates to GeneralsMinorSeverity: Minor < Major < Critical < BlockerRefactorEdits the code with insignificant behavior changes, is never user facingZHRelates to Zero Hour
3 participants
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.
Split off from #3245 where an intersect function was needed for
IRegion2D.In the current PR we implement
intersectWithanduniteWithfunctions forIRegion3D,IRegion2D,Region3DandRegion2DupdateMinandupdateMaxfunctions forICoord3D,ICoord2D,Coord3DandCoord2DasCoord2DandasICoord2Dfunctions forCoord3DandICoord3Drespectively.AI was used to implement this, every line was checked.