Question about prefilter - prefilter bug!

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Question about prefilter - prefilter bug!

Postby Executor » Mon Jun 28, 2010 5:47 am

When i use raycast, sometimes execute filter for object, but not execute prefilter. Why?
For example in prefilter i write always return 0, but cast passed.
This bag or i not understand how prefilter work?

P.S. Newton 2.11 and 2.22.
Last edited by Executor on Wed Jun 30, 2010 6:38 am, edited 1 time in total.
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter

Postby Julio Jerez » Mon Jun 28, 2010 6:56 am

prefilter is for deciding if a body will be cast or not. it does not stop the casting.
if you return 1 and then you will get a cal to the filter, 0 will pass that body as if it was transparent to the ray.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about prefilter

Postby Executor » Mon Jun 28, 2010 7:17 am

prefilter always return 0, but cast passed. because prefilter not execute, executed only filter.

for example:

1) have 2 objects: obj0, obj1
2) do raycast:

NewtonWorldRayCast(world, beginPoint, endPoint, rayCastFilter, NULL, rayCastPrefilter);

Code: Select all
static unsigned RayCastPrefilter (const NewtonBody* body,  const NewtonCollision* collision, void* userData)
{
   return 0;
}


Code: Select all
static dFloat RayCastFilter (const NewtonBody* body, const dFloat* normal, int collisionID, void* userData, dFloat intersetParam)
{
   ...
   return intersetParam;
}


3) Result:
call NewtonWorldRayCast();
call RayCastFilter() for obj1; (why!?!? where prefilter for obj1???)
call RayCastPreFilter() for obj0;
cast passed! (wrong!)

I think, it must be so:
call NewtonWorldRayCast();
call RayCastPreFilter() for obj1; (ok!)
call RayCastPreFilter() for obj0;
cast not passed! (ok!)

May be it will be better if i'll make a minimal example which will show the problem?
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter

Postby Julio Jerez » Mon Jun 28, 2010 1:23 pm

if you have obj0 and obj1 and you call ray cast with prefilete teh result will be.
Code: Select all
RayCastprefilter fo rteh first object.
if prefiler ==1 ) {
      RayCast thet object.
     if ( Ray hit the body an dteh ray can possible hit secudn body) {
           if (Rayprefiler secund body) {
                if ( Ray hit the body and the ray can possible hit secudn body) {
                      //and so on.
                }
           }
     }
else {
       if (Rayprefiler secund body) {
               if ( Ray hit the body and the ray can possible hit secudn body) {
                     //and so on.
               }
 }



Ray prefielter is not a ray aabb test, it si a teats again poietcal ray hit of bodei who leav in same cell of of the mutigrid.
you will never get a RayFilter with out a prefiler,
The test may calify is they is a bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about prefilter

Postby Executor » Tue Jun 29, 2010 4:17 am

This bug occurs only with compound (count >= 1) objects.
I take Tutorial 104 example, and add some funcs show bug.

Code: Select all
static unsigned MyRayCastPrefilter (const NewtonBody* body,  const NewtonCollision* collision, void* userData)
{
   return 0; // Always zero - never executed MyRayCastFilter
}

static dFloat MyRayCastFilter (const NewtonBody* body, const dFloat* normal, int collisionID, void* userData, dFloat intersetParam)
{
   // If cast passed, set position of box to (0,5,0)
   dMatrix matrix (GetIdentityMatrix());
   matrix.m_posit = dVector(0, 5, 0, 1);
   NewtonBodySetMatrix(body, &matrix[0][0]);
   return intersetParam;
}


SOURCE AND BINARY --> http://exec.mentalx.org/RayCastBug.zip

Press P for raycast and youll see how execute MyRayCastFilter for two compound objects.
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter

Postby Julio Jerez » Tue Jun 29, 2010 11:09 am

I do no knwo what teh demo does, I see 4 boxes and when I hit P one box disapare and anothe goes up in the air.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about prefilter

Postby Executor » Wed Jun 30, 2010 2:18 am

Julio Jerez wrote:I do no knwo what teh demo does, I see 4 boxes and when I hit P one box disapare and anothe goes up in the air.


This is bug. Boxes should never be in the air.
See code - it show bug. Code is simple.
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter - prefilter bug!

Postby Julio Jerez » Wed Jun 30, 2010 8:47 am

where is the box suppost to go when you hit the key?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Question about prefilter - prefilter bug!

Postby Executor » Wed Jun 30, 2010 2:36 pm

When raycast filter executes, then object, which passed raycast, moves in position (0,5,0) in the air.
Two boxes which compound, passed raycast and both of them moves in one position. It seems that it's one box, but actualy it's two boxes in one position.
It does not matter, that raycast filter doing, I simple show, that filter executes, though it must not, because prefilter always returns zero.

Code contains many tutorial code. I only added a creation of boxes and raycast. You may see in code that filter never execute and it's correct for not compound objects. But filter executes for compound objects. I guess it's bug of Newton. In correct variant, when you press P key, then boxes should stay on their original position.
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter - prefilter bug!

Postby Executor » Fri Jul 02, 2010 3:03 am

Did you watch my code?
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter - prefilter bug!

Postby Executor » Tue Jul 06, 2010 1:11 am

Bug fixed in 2.23
Thanks.
Executor
 
Posts: 25
Joined: Fri Sep 04, 2009 7:01 am

Re: Question about prefilter - prefilter bug!

Postby Carli » Tue Jul 06, 2010 3:20 am

I'm interested in this bugfix, too.

Would you please release a linux version?
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron