check if line starts inside cylinder

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5111 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2010-05-30 06:18:15 +00:00
parent 5841dd13e0
commit 8e2cb151ba
+6 -1
View File
@@ -233,7 +233,7 @@ static inline bool intersectcylinder(const vec &from, const vec &to, const vec &
float offset = md + dist*nd;
if(offset < 0)
{
if(nd < 0) return false;
if(nd <= 0) return false;
dist = -md / nd;
if(k + dist*(2*mn + dist*nn) > 0) return false;
}
@@ -243,6 +243,11 @@ static inline bool intersectcylinder(const vec &from, const vec &to, const vec &
dist = (dd - md) / nd;
if(k + dd - 2*md + dist*(2*(mn-nd) + dist*nn) > 0) return false;
}
else if(c <= 0)
{
dist = 0;
return true;
}
return dist >= 0 && dist <= 1;
}