Skip to content

Commit

Permalink
Optimize IsPointInAreaTriggerZone (#2689)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gamemechanicwow authored Jun 23, 2024
1 parent a1cd3ab commit f78194e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/game/Database/DBCStores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,12 @@ bool IsPointInAreaTriggerZone(AreaTriggerEntry const* atEntry, uint32 mapid, flo
float playerBoxDistX = x - atEntry->x;
float playerBoxDistY = y - atEntry->y;

float rotPlayerX = float(atEntry->x + playerBoxDistX * cosVal - playerBoxDistY * sinVal);
float rotPlayerY = float(atEntry->y + playerBoxDistY * cosVal + playerBoxDistX * sinVal);
float dx = float(playerBoxDistX * cosVal - playerBoxDistY * sinVal);
float dy = float(playerBoxDistY * cosVal + playerBoxDistX * sinVal);

// box edges are parallel to coordiante axis, so we can treat every dimension independently :D
float dz = z - atEntry->z;
float dx = rotPlayerX - atEntry->x;
float dy = rotPlayerY - atEntry->y;

if ((fabs(dx) > atEntry->box_x / 2 + delta) ||
(fabs(dy) > atEntry->box_y / 2 + delta) ||
(fabs(dz) > atEntry->box_z / 2 + delta))
Expand Down

1 comment on commit f78194e

@jianggn
Copy link

Choose a reason for hiding this comment

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


Please sign in to comment.