-line is defined by 2 points
-plane is defined by 3 points
-removed all if's and returns

Code:
void Line_Plane_Intersection(VECTOR* RESULT, VECTOR* line_p0, VECTOR* line_p1, VECTOR* plane_p0, VECTOR* plane_p1, VECTOR* plane_p2)
{
	VECTOR line_indeps;
	VECTOR line_coefs;
	vec_set(line_indeps,line_p0);
	vec_set(line_coefs,line_p1);
	vec_sub(line_coefs,line_p0);
	VECTOR plane_N;
	vec_cross(plane_N,vec_diff(NULL,plane_p1,plane_p0),vec_diff(NULL,plane_p2,plane_p0));
	var plane_indep;
	VECTOR plane_coefs;
	plane_indep=-(plane_N.x*plane_p0.x)-(plane_N.y*plane_p0.y)-(plane_N.z*plane_p0.z);
	vec_set(plane_coefs,plane_N);
	vec_mul(line_indeps,plane_coefs);
	vec_mul(line_coefs,plane_coefs);
	var T;
	T=(-plane_indep-(line_indeps.x+line_indeps.y+line_indeps.z))/(line_coefs.x+line_coefs.y+line_coefs.z);
	RESULT.x=line_p0.x+T*(line_p1.x-line_p0.x);
	RESULT.y=line_p0.y+T*(line_p1.y-line_p0.y);
	RESULT.z=line_p0.z+T*(line_p1.z-line_p0.z);
}


Is this what you wanted?
This code is un-tested, but should work as my new function was based on this. (This was done on the bus and my mini-laptop cannot run 3DGS, I just use it to write code and test later at home)

EDIT: Keep in mind this assumes an infinite plane in all directions! If you want it specific to a tile I could modify it to limit the planes. (and if you are working with terrains I already have a more specific version for that too that I worked on some time ago)

Last edited by Carlos3DGS; 01/09/13 18:12.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1