fixed a bug that caused the object picking to be very inaccurate

This commit is contained in:
codeimp 2008-12-04 21:37:44 +00:00
parent 4b81abdb17
commit 136413d29a
2 changed files with 3 additions and 2 deletions

View file

@ -115,7 +115,7 @@ namespace CodeImp.DoomBuilder.Geometry
float div = (y4 - y3) * (v2.x - v1.x) - (x4 - x3) * (v2.y - v1.y);
// Can this be tested?
if((div > 0.000001f) || (div < -0.000001f))
if(div != 0.0f)
{
// Calculate the intersection distance from the line
u_line = ((x4 - x3) * (v1.y - y3) - (y4 - y3) * (v1.x - x3)) / div;

View file

@ -454,6 +454,7 @@ namespace CodeImp.DoomBuilder.VisualModes
{
VisualPickResult result = new VisualPickResult();
Line2D ray2d = new Line2D(from, to);
Vector3D delta = to - from;
// Setup no result
result.geometry = null;
@ -495,7 +496,7 @@ namespace CodeImp.DoomBuilder.VisualModes
float side = ld.SideOfLine(ray2d.v1);
// Calculate intersection point
Vector3D intersect = from + to * u;
Vector3D intersect = from + delta * u;
// We must add the sectors of both sides of the line
// If we wouldn't, then aiming at a sector that is just within range