line of sight finding

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2579 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2008-09-14 01:08:50 +00:00
parent b9fb8522ab
commit 7e238e849f
2 changed files with 12 additions and 0 deletions
+11
View File
@@ -59,6 +59,17 @@ float raycube(const vec &o, const vec &ray, vec &surface)
return dist;
}
bool raycubelos(const vec &from, const vec &to, float margin)
{
vec dir(to);
dir.sub(from);
float limit = dir.magnitude();
dir.mul(1.0f/limit);
vec surface;
float dist = raycube(from, dir, surface);
return dist > max(limit - margin, 0.0f);
}
physent *hitplayer = NULL;
bool plcollide(physent *d, physent *o, float &headspace, float &hi, float &lo) // collide with physent