Commit Graph

36 Commits

Author SHA1 Message Date
Max Cahill
19bb169e55 fixed intersect.balance_from_mass crashing with nil/false mass 2024-03-07 11:39:44 +11:00
Max Cahill
2c6b5bd2ea rephrase empty if to make the silly linter happy 2023-08-10 16:35:42 +10:00
Max Cahill
8c1e51b057 optimised line line collision a little, could still use some more love :) 2023-08-10 16:26:17 +10:00
Max Cahill
ff2ab5f1aa fixed intersect relying on assert being exported 2023-03-16 12:14:51 +11:00
Max Cahill
07fbbe6247 fixed issue with line routines on certain inputs 2023-03-14 13:04:00 +11:00
Max Cahill
ba7a7b5500 fixed intersection tests with zero radius shapes (treated as points generally) 2022-12-08 13:36:29 +11:00
Max Cahill
84d4e39622 clarified position/halfsize for aabbs and provided conversion functions from xywh to pos/hs representation
closes #60
2022-10-24 15:18:28 +11:00
Max Cahill
05f86e2cc1 fixed wrong degenerate direction checked in intersect.line_line_collide 2022-03-29 17:56:02 +11:00
David Briscoe
0c193d7901 lint: Don't assign values that will never be used
No bugs here, but giving an initial value can hide cases where we fail
to set a value. Use an assert instead so we can see errors if we change
and break this code.

Except break_next which goes out of scope after it's assigned (I guess
it used to be outside the loop).
2022-03-03 10:17:35 -08:00
David Briscoe
5118cc42bb lint: Fix mismatched arguments in circle_aabb
Fix bug where circle_aabb_overlap wouldn't have the same results as
aabb_circle_overlap.

b_hs was unused, but the function we call expects a_hs as the first
argument. Looks like this circle_aabb_overlap is just flipping
the arguments to aabb_circle_overlap (and for circle_aabb_collide), so
it should match arguments.

Not sure what hs means. Box size?
2022-03-03 10:17:35 -08:00
Max Cahill
c0847e1955 fixed intersect.bounce_off bouncing if the velocity was already going away from the normal 2022-01-20 17:37:40 +11:00
Max Cahill
5df717fe6d used mathx for clamp01 in intersect
fixes #45
2021-11-23 10:25:09 +11:00
Westerbly Snaydley
271d079bbb Fix intersect depending on exported mathx 2021-10-24 18:32:14 -05:00
Sheepolution
95269b3362
Fix parameter/argument name mismatch 2021-10-19 03:04:55 +02:00
Max Cahill
a61a8a8618 added reversed-order methods for intersect (some missing) 2021-07-23 14:34:47 +10:00
Max Cahill
f835dd6e66 vec2 api finalisation and testing, updating intersect to new api 2021-07-23 14:15:30 +10:00
Max Cahill
4cea23e2e8 reworked intersect.lua - accepting that continuous collision is out of scope, reworking docs 2021-07-20 16:20:15 +10:00
Max Cahill
fe135c533b More pooled storage for intersect.lua 2021-06-29 14:43:55 +10:00
Max Cahill
af919da379 Fixed intersect.lua line functions not all working properly with un-exported batteries 2021-06-17 11:29:14 +10:00
Max Cahill
0bc9ccb17b Merge branch 'feature/minmax-vector-ops-and-aabb-collisions' 2021-06-08 11:53:09 +10:00
Max Cahill
a92a0c0351 Reworked aabb vs point and circle methods 2021-06-08 11:51:18 +10:00
Max Cahill
2d06ec7b9c [fixed] intersect.line_circle_overlap bug 2021-05-13 16:13:30 +10:00
Max Cahill
80c44f3436 [added] intersect.line_circle_overlap for checking boolean overlap circles vs lines 2021-05-13 12:24:45 +10:00
Max Cahill
af961ab2b8 [added] intersect.balance_from_mass which gets a normalised balance factor from two mass inputs, and treats <=0 or infinite or nil masses as static bodies 2021-05-11 15:47:48 +10:00
Aweptimum
b5d3707939 Added aabb_circle_collide routine, modify aabb_point_collide
If circle center within aabb, calls aabb_point collide. Then, adds to the msv the difference between the closest point on the aabb to the circle and the closest point on circle to closest point on the aabb.

It failed when the circle center was exactly on the aabb edges, so COLLIDE_EPS was added to the apo_normal in aabb_point_collide to force the point off the edge. As such, the "nudge" section was removed. This should definitely be reviewed.
2021-05-10 12:29:37 -04:00
Aweptimum
06ca04bde7 Added aabb_circle_overlap
When the distance between the circle's center and the closest point on the aabb is less than the circle radius, returns true.
2021-05-10 11:55:51 -04:00
Aweptimum
bfee65762e Added helper function for aabb_circle routines
Clamps point coords to the dimensions of an aabb to get the nearest point on the aabb. Returns two integers to avoid garbage.
2021-05-10 11:55:00 -04:00
Aweptimum
9d1e563796 Added aabb_point_collide()
Pushes point out along minimum axis. Nudges it out with COLLIDE_EPS added to the msv.
2021-05-10 11:53:40 -04:00
Max Cahill
c840bd01a5 [added] more intersection/resolution helpers 2021-04-14 13:32:14 +10:00
Max Cahill
bfad0baba9 [added] experimental intersect.bounce_off (needs to be verified) 2021-04-13 15:39:36 +10:00
Max Cahill
ab0839430a [fixed] broken intersect.circle_circle_collide result 2021-04-13 15:38:52 +10:00
Max Cahill
f6a2c9834f [added] nearest_point_on_line 2020-04-16 17:17:53 +10:00
Max Cahill
02568f8f08 [modified] intersect.lua imports vec2 unconditionally rather than attempting to use the global 2020-04-07 13:51:13 +10:00
Max Cahill
c7d96461cf [added] intersect.point_in_poly and required plumbing 2020-04-01 19:28:22 +11:00
Max Cahill
ad2fc71e7a [fixed] non-global compatible 2020-03-15 21:22:22 +11:00
Max Cahill
2f470cf7c7 initial commit 2020-01-29 14:26:28 +11:00