Jump to content
  • Advertisement
Sign in to follow this  

Nevermind I trashed my code

This topic is 3318 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm making a quad-tree. So essentially I am flattening the Camera Frustum(to the X/Z axis), and testing to see if it holds a bunch of squares or intersects them. The faster the routine the better. If it helps at all my square is a true square(equal length and width). edit: It's recently come to my attention that a trapezoid is just one truncated triangle. Thanks IRC haha. So now I just need to figure out how to test is a square is in a triangle. [Edited by - Cakey on June 22, 2009 5:22:54 PM]

Share this post

Link to post
Share on other sites
Is it going to be significantly slow to test every single point? With a method such as:

private bool isPointInTriangle(Vector2 Point, Vector2 A, Vector2 B, Vector2 C){
float Orientation1 = Orientation(A, B, Point),
Orientation2 = Orientation(B, C, Point),
Orientation3 = Orientation(C, A, Point);
if(Orientation1 == Orientation2 && Orientation2 == Orientation3)
{return true;}
else{return false;}

private int Orientation(Vector2 Begin, Vector2 End, Vector2 Point){
//Linear determinant
float Orin = (End.X - Begin.X) * (Point.Y - Begin.Y) - (Point.X - Begin.X) * (End.Y - Begin.Y);
if (Orin > 0.0){return 1;} //Orientation to the right
else if (Orin < 0.0) {return -1;} //Orientation to the left
else{return 0;} //Orientation is middle bound

(Also I dunno if that code is right I have yet to test it)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!