Regression: raycasting bug problem with walls.

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 12:10 pm

This was a old bug that was solved around a year or so ago before, now it returned in the latest newton releases.
I just tested 2.25 and noticed it, then i used older dlls from 2.21, 2.22, 2.23 and 2.25 and they all have the same problem, i did not test 2.24 as i skipped testing that release.

The bug shows as improper raycast returns like this circle around the player - notice odd pattern around the edge of building.
Image

I prepared a demo to expose this bug, just run the program, all debug flags and rendering are already on and positioned on one place where the bug appears.

http://mathpudding.com/temp/TDC%20DEMO% ... 20test.rar

Let me know if you need me to do anything else to help solve this bug.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Sun Nov 14, 2010 12:31 pm

Yes I remember working on that.

in that image can you draw how the green light shoudl look like?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 12:42 pm

IT should go along the building wall, the newton debug geometry is rendered.

But just in case i made this image with red marking the proper path that should be traced:
Image
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Sun Nov 14, 2010 1:02 pm

I see, I paly it and I can see hwo the player can statyu in one place and I see the the casting.

Delfi it is possible that you buidl the demo with only the player? tha will simplify debugging a lot

and also is your world z up aligned?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 1:11 pm

Z is aligned as height yes, and the raycasts fall perfectly on flat walls with start and end coordinates on same Z / height.

I will build you a simplier demo.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 1:18 pm

Okay here is a updated exe, this only has ONE actor, and no cars, pedesterian or nothing else:
http://mathpudding.com/temp/tdc%20aloneactor.rar
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Sun Nov 14, 2010 1:50 pm

exclent and it happen riggh the at the start position.

I will chek it out now.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Sun Nov 14, 2010 3:15 pm

I manage to reproduce it one exact ray the generate the bug,
this is a wird bug, because it is not failling the cast as it was before,
instead it is reporting a hit with a face that is not there.

a way to check a bug is by pertubation teh data, and I race teh race parallel to teh floor and still report the false hit.
I need to figure out wha that is, it could be a serios bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 3:49 pm

Also a idea: delete the \data\maps\cache when you want the game to regenerate the map geometry, it stores it in serialized files (just incase if you need them re-generated while testing).
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Sun Nov 14, 2010 4:18 pm

Ha I fix it Delfi.

This bug was indtruduce when we were working on the convex optimization,
if you remember we made a modification to teh collsion tree buildes so that allow more strict faces to be consided convex.

when I did that the tolerance I was using for raycasting convex faces was rendered too big,
and the caster was considering a hit if a line hit a polygon close to an edge but outside the polygon.
now the faces are more correct an the tolernace became too large.
ideally it should be zero, but that will fail in faces sharing the same edge, I made the adjustment and now it is fine.
I will make a new buils and post it tonight, I have to go out now.
here is the ray cast function tha newton uses.

Code: Select all
dgFloat32 RayTest::PolygonIntersect (const dgVector& normal, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt32 indexCount) const
{
   _ASSERTE (m_p0.m_w == m_p1.m_w);

   dgFloat32 dist = normal % m_diff;
   if (dist < m_dirError) {

      dgInt32 stride = strideInBytes / sizeof (dgFloat32);

      dgVector v0 (&polygon[indexArray[indexCount - 1] * stride]);
      dgVector p0v0 (v0 - m_p0);
      dgFloat32 tOut = normal % p0v0;
      // this only work for convex polygons and for single side faces
      // walk the polygon around the edges and calculate the volume
      if ((tOut < dgFloat32 (0.0f)) && (tOut > dist)) {
         for (dgInt32 i = 0; i < indexCount; i ++) {
            dgInt32 i2 = indexArray[i] * stride;
            dgVector v1 (&polygon[i2]);
            dgVector p0v1 (v1 - m_p0);
            // calculate the volume formed by the line and the edge of the polygon
            dgFloat32 alpha = (m_diff * p0v1) % p0v0;
            // if a least one volume is negative it means the line crosses the polygon outside this edge and do not hit the face
            if (alpha < DG_RAY_TOL_ERROR) {
               return dgFloat32 (1.2f);
            }
            p0v0 = p0v1;
         }

         //the line is to the left of all the polygon edges,
         //then the intersetion is the the point we the line interset the plane of the polygon
         tOut = tOut / dist;
         _ASSERTE (tOut >= dgFloat32 (0.0f));
         _ASSERTE (tOut <= dgFloat32 (1.0f));
         return tOut;
      }
   }
   return dgFloat32 (1.2f);
}


DG_RAY_TOL_ERROR ws 0.01, now it is 0.001 and that seems to work fine now.

BTW the function is perhaps the fastest and most robust ray/polygon interceion you can fine anywhere,
in fact the optimized version in SSE is about 32 instructions in the inner loop but it does 4 edges per iteration for an average of 8 intructions per edge of a face.
the limitation is that it only works for convex single sided polygons.
This the reason why in Newton all collisions only works on single sided faces, it is because most function are like that.
as you can see, if the polygon was allowed to be double sided then the sign of the triple scalar product

dgFloat32 alpha = (m_diff * p0v1) % p0v0;

will have not meaning
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Sun Nov 14, 2010 4:27 pm

Cool, i will test with a new dll as soon as you have one ready, i will continue testing with the 2.25 i have for now.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Mon Nov 15, 2010 11:22 am

Ok delfi try 2.25 again please
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Mon Nov 15, 2010 1:51 pm

Delfi ignore that build, still has a problem,
I fixed already but I do not have time to load it to the download, I will do it tonight.
sorry about that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Regression: raycasting bug problem with walls.

Postby JernejL » Mon Nov 15, 2010 4:09 pm

ok, i will wait for updated dll.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Regression: raycasting bug problem with walls.

Postby Julio Jerez » Tue Nov 16, 2010 10:55 am

alright delfi, you can try 2.25 again

Delfi, I was paying the game a litle and I see that the are lot of vehicle trafic jams, is that normal?

also I see that that game really, realy stress the racast funtion, :mrgreen:
almost each actor shot a circle of ray around him at abut 10% or so separation, and ther are pleanty of actors.
how that works on low end systems?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 4 guests