Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub get_collisions_for_aabb
- {
- my ($self, $aabb) = @_;
- return () if !defined $self->{root_aabb};
- $self->{root_aabb}->get_collisions_for_aabb_rec($aabb);
- }
- # And in Game::Collisions::AABB:
- sub get_collisions_for_aabb_rec
- {
- my ($node, $target) = @_;
- $node && $node != $target
- && $node->[_MAX_X] >= $target->[_X] && $node->[_X] <= $target->[_MAX_X]
- && $node->[_MAX_Y] >= $target->[_Y] && $node->[_Y] <= $target->[_MAX_Y]
- ? ( $node->[_LEFT_NODE] || $node->[_RIGHT_NODE]
- ? ( get_collisions_for_aabb_rec($node->[_LEFT_NODE], $target),
- get_collisions_for_aabb_rec($node->[_RIGHT_NODE], $target) )
- : [ $node, $target ]
- )
- : ()
- }
Advertisement
Add Comment
Please, Sign In to add comment