[added] experimental intersect.bounce_off (needs to be verified)

This commit is contained in:
Max Cahill 2021-04-13 15:39:36 +10:00
parent ab0839430a
commit bfad0baba9

View File

@ -418,4 +418,15 @@ function intersect.point_in_poly(point, poly)
return wn ~= 0 return wn ~= 0
end end
--resolution helpers
--bounce a velocity off of a normal (modifying velocity)
local _bounce_temp = vec2()
function intersect.bounce_off(velocity, normal)
_bounce_temp:vset(velocity)
velocity:vreji(normal)
velocity:vsubi(_bounce_temp:vsubi(velocity))
return velocity
end
return intersect return intersect