Created
July 10, 2012 11:53
-
-
Save FeepingCreature/3082877 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WorldObject[auto~] inRect(vec2f a, b) { | |
auto world-center = vec3f(0), world-radius = 1; | |
auto center = cam.apply(world-center).xy; | |
float radius; | |
using glModelviewMatrix { | |
cam.unrotate; | |
auto offset = cam.apply(world-center + world-radius * vec3f.X).xy - center; | |
radius = |offset|; | |
} | |
auto aspect = vec2f(1, 1/cam.aspect); | |
if (overlaps_rect_circle(a*aspect, b*aspect, center*aspect, radius)) { | |
WorldObject[auto~] res; res ~= this; return res; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment