Skip to main content
GameDev.net gamedev.net
🔒 Locked

Nevermind I trashed my code

Started by Cakey Jun 22, 2009 at 1:39 PM 0 replies 1.2k views
Original Post
Cakey
Cakey
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]
Cakey
Cakey
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)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.