Skip to content

Commit

Permalink
Fix quadtree AABB issue (#6782)
Browse files Browse the repository at this point in the history
# About the pull request

Quadtree AABB testing now correctly uses the Y bounds to test if the Y
coordinate is in range.

<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game

Bug bad. Shouldn't use the X coordinate to determine if you're in bounds
of the Y coordinate. Fortunate that so many things are squares that it
didn't cause an issue.
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
fix: sounds & motion detectors should be more reliable
/:cl:
  • Loading branch information
Doubleumc committed Jul 23, 2024
1 parent dfc7c71 commit 6957045
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion code/datums/quadtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

/// Returns TRUE if this shape's bounding box intersects the provided shape's bounding box, otherwise FALSE. Generally faster than a full intersection test.
/datum/shape/proc/intersects_aabb(datum/shape/aabb)
return (abs(src.center_x - aabb.center_x) <= (src.bounds_x + aabb.bounds_x) * 0.5) && (abs(src.center_y - aabb.center_y) <= (src.bounds_x + aabb.bounds_x) * 0.5)
return (abs(src.center_x - aabb.center_x) <= (src.bounds_x + aabb.bounds_x) * 0.5) && (abs(src.center_y - aabb.center_y) <= (src.bounds_y + aabb.bounds_y) * 0.5)

/// Returns TRUE if this shape intersects the provided rectangle shape, otherwise FALSE.
/datum/shape/proc/intersects_rect(datum/shape/rectangle/rect)
Expand Down

0 comments on commit 6957045

Please sign in to comment.