Skip to content

Instantly share code, notes, and snippets.

@warriordog
Created November 13, 2014 22:31
Show Gist options
  • Save warriordog/ca8ab4a2bf8f4ea6f908 to your computer and use it in GitHub Desktop.
Save warriordog/ca8ab4a2bf8f4ea6f908 to your computer and use it in GitHub Desktop.
(Cheating at) sorting the corners in an AABB by physical location
private void sortCorners() {
//corner1 and corner2 are Vec3is. corner1 is the bottom left corner of the AABB, corner2 is the top right corner.
int corner1X = corner1.x;
int corner2X = corner2.x;
if (corner1X > corner2X) {
corner1.x = corner2X;
corner2.x = corner1X;
}
int corner1Y = corner1.y;
int corner2Y = corner2.y;
if (corner1Y > corner2Y) {
corner1.y = corner2Y;
corner2.y = corner1Y;
}
int corner1Z = corner1.z;
int corner2Z = corner2.z;
if (corner1Z > corner2Z) {
corner1.z = corner2Z;
corner2.z = corner1Z;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment