Skip to content

Commit 0228421

Browse files
authored
feat(input): Add ability to snap building rotation to 45 degree angles (#1472)
Is accessible while holding the force-attack modifier key (CTRL)
1 parent f478360 commit 0228421

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

Core/Libraries/Source/WWVegas/WWMath/wwmath.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ static WWINLINE float Atan2(float y,float x) { return static_cast<float>(atan2(
143143
static WWINLINE float Sign(float val);
144144
static WWINLINE float Ceil(float val) { return ceilf(val); }
145145
static WWINLINE float Floor(float val) { return floorf(val); }
146+
static WWINLINE float Round(float val) { return floorf(val + 0.5f); }
146147
static WWINLINE bool Fast_Is_Float_Positive(const float & val);
147148
static WWINLINE bool Is_Power_Of_2(const unsigned int val);
148149

Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,13 @@ void InGameUI::handleBuildPlacements( void )
14151415
v.y = worldEnd.y - worldStart.y;
14161416
angle = v.toAngle();
14171417

1418+
// TheSuperHackers @tweak Stubbjax 04/08/2025 Snap angle to nearest 45 degrees
1419+
// while using force attack mode for convenience.
1420+
if (isInForceAttackMode())
1421+
{
1422+
const Real snapRadians = DEG_TO_RADF(45);
1423+
angle = WWMath::Round(angle / snapRadians) * snapRadians;
1424+
}
14181425
} // end if
14191426

14201427
} // end if

GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1470,6 +1470,13 @@ void InGameUI::handleBuildPlacements( void )
14701470
v.y = worldEnd.y - worldStart.y;
14711471
angle = v.toAngle();
14721472

1473+
// TheSuperHackers @tweak Stubbjax 04/08/2025 Snap angle to nearest 45 degrees
1474+
// while using force attack mode for convenience.
1475+
if (isInForceAttackMode())
1476+
{
1477+
const Real snapRadians = DEG_TO_RADF(45);
1478+
angle = WWMath::Round(angle / snapRadians) * snapRadians;
1479+
}
14731480
} // end if
14741481

14751482
} // end if

0 commit comments

Comments
 (0)