From f78194ef9bb14cf2b3b483fbd0fd1ea7861ed3b5 Mon Sep 17 00:00:00 2001 From: Gamemechanic Date: Sun, 23 Jun 2024 17:43:44 +0200 Subject: [PATCH] Optimize IsPointInAreaTriggerZone (#2689) --- src/game/Database/DBCStores.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/game/Database/DBCStores.cpp b/src/game/Database/DBCStores.cpp index 2fcea448a0c..c100d826ae6 100644 --- a/src/game/Database/DBCStores.cpp +++ b/src/game/Database/DBCStores.cpp @@ -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))