Skip to content

Commit cd454d0

Browse files
committed
refactor: Improve logic readability
1 parent e1dece7 commit cd454d0

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,8 +1419,8 @@ void InGameUI::handleBuildPlacements( void )
14191419
// while using force attack mode for convenience.
14201420
if (isInForceAttackMode())
14211421
{
1422-
const Real snapRadians = PI / 4.0f;
1423-
angle = floor((angle / snapRadians) + 0.5f) * snapRadians;
1422+
const Real snapRadians = DEG_TO_RADF(45);
1423+
angle = WWMath::Round(angle / snapRadians) * snapRadians;
14241424
}
14251425
} // end if
14261426

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,8 +1474,8 @@ void InGameUI::handleBuildPlacements( void )
14741474
// while using force attack mode for convenience.
14751475
if (isInForceAttackMode())
14761476
{
1477-
const Real snapRadians = PI / 4.0f;
1478-
angle = floor((angle / snapRadians) + 0.5f) * snapRadians;
1477+
const Real snapRadians = DEG_TO_RADF(45);
1478+
angle = WWMath::Round(angle / snapRadians) * snapRadians;
14791479
}
14801480
} // end if
14811481

0 commit comments

Comments
 (0)