multiple tree collision issues

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: multiple tree collision issues

Postby Julio Jerez » Wed Mar 20, 2019 12:22 pm

I do not know what else to say or do, trying to find a problem that as far as I know for not exist or is difficult to reproduce. But you are are saying that is just the opposite, that it fail every time.
And we are testing the same repro case.

If you see a red dot at everyy point you point and click, that's the demonstration that is working. Other than that I am at lost.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby Julio Jerez » Wed Mar 20, 2019 1:50 pm

collerblade wrote:im away from home again, so i cant compile c++ right now. So i cant test, but i belive you that there isnt any error on your side.
But the question is: why isnt working for me? What kind of newton call can i do legaly to produce this behaviour? Only newtonraycast prefilter. And i dont using that. So what the heck could happen here?

I do not know how you are using it.
look a class dMousePickClass in file ..\applications\demosSandbox\sdkDemos\toolBox\PhysicsUtils.cpp
and how is used by function
NewtonBody* MousePickBody (NewtonWorld* const nWorld, const dVector& origin, const dVector& end, dFloat& paramterOut, dVector& positionOut, dVector& normalOut)
is very easy to see how it work.

but I though we where taking about the same data failing in both you application and in the newton sandbox. I am still unclear as to how an where the bug is happening.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby collerblade » Tue Mar 26, 2019 4:23 am

hi again,
i think i figured out. So i give you some pseudo code.
Using this example raycast works without any problem:
Code: Select all
collision=createTreeCollision(....);
nbody=NewtonCreateDynamicBody(nworld,collision,identity);
NewtonBodySetMassProperties(nbody,mass,NewtonBodyGetCollision(nbody));
NewtonBodySetUserData(nbody,this);
NewtonBodySetForceAndTorqueCallback(nbody,forceAndTorqueCB);
NewtonBodySetTransformCallback(nbody,transformCB);
NewtonBodySetMatrix(nbody, someTransform);


And this is what i done, and this does NOT work with raycast:
Code: Select all
nbody=NewtonCreateDynamicBody(nworld,null,identity);
NewtonBodySetUserData(nbody,this);
NewtonBodySetForceAndTorqueCallback(nbody,forceAndTorqueCB);
NewtonBodySetTransformCallback(nbody,transformCB);
NewtonBodySetMatrix(nbody, someTransform);
...
collision=createTreeCollision(....);
NewtonBodySetCollision(nbody, collision);
NewtonBodySetMassProperties(nbody,mass,NewtonBodyGetCollision(nbody));


Of cource:
- mass is zero
- createTreeCollision uses the [NewtonCreateTreeCollision, NewtonTreeCollisionAddFace, NewtonTreeCollisionEndBuild] trio. With or without optimalization (no different in result)
- While creating the body: insted of null i tried NewtonCreateNull() as well. Also has no effect.

Seems to me that changing collision to tree collision is buggy for some reason.
My situation is: that i dont know the collision while creating the body, it is only gets known later. Also in my api i allow to change the collision any time. A made that assumption that NewtonBodySetCollision can be called anywhere. Even for static collisions. Isnt that true? Is there any restrictions?
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: multiple tree collision issues

Postby Julio Jerez » Tue Mar 26, 2019 5:22 am

Creating a body with null collision is fine, null collision can't be ray cast, because they are no added to the broad phase, changing Collison is perfectly ok and should work.
Are you saying that if you create a body with a null collision and them changing it to a collision tree is what cause the ray cast to fail?
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby Julio Jerez » Tue Mar 26, 2019 10:17 am

ah yes I was able reproduced the bug
I commited a test case that reproduce it, the fix is not quite trivial so I will do it tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby collerblade » Tue Mar 26, 2019 3:45 pm

thank you
not urgent to me, couse im away from home again (untill the weekend)
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: multiple tree collision issues

Postby Julio Jerez » Tue Mar 26, 2019 3:45 pm

ok this is now fixed, is was a side effect of the broad phase optimization.
before the broad phase did a lot of work that now is assumed unchanged from frame to frame.
changed a collision shape from null to something else need to override the sleep state of the body by calling update broaphasee after the operation
Code: Select all
void NewtonBodySetCollision(const NewtonBody* const bodyPtr, const NewtonCollisi
   dgBody* const body = (dgBody *)bodyPtr;
   dgCollisionInstance* const collision = (dgCollisionInstance*) collisionPtr;
   body->AttachCollision (collision);
   body->UpdateCollisionMatrix(dgFloat32(0.0f), 0);
}


what is funny is that this bug was there for changing scale, since that function does the update Collision matrix, by set collision shape never did, I guess that change collision shape did it internally but after the optimization, it bloke and I never realized.

Anyway of you sync it would be fine now.
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby collerblade » Wed Mar 27, 2019 2:17 pm

wonderful,
i will test it on the weekend.
Sorry for the slow progress
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: multiple tree collision issues

Postby collerblade » Sat Mar 30, 2019 2:08 am

unfortunately, it doesnt fixed the issue for me.
I downloaded the latest master build. Compiled it and nothing changed.
The issue is exacly the same. When i change the collision to tree collison after the body creation, i loose the raycast.
I tested the x64/dll build.
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Re: multiple tree collision issues

Postby Julio Jerez » Sat Mar 30, 2019 8:52 am

oh sorry for forget to commit the change in the broad phase that fixed the bug,

It is in now, please check again
Julio Jerez
Moderator
Moderator
 
Posts: 10989
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: multiple tree collision issues

Postby collerblade » Sun Mar 31, 2019 4:36 am

yeah, it is working perfectly.
Thanks for the fix.
collerblade
 
Posts: 88
Joined: Mon Apr 05, 2010 12:09 pm

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests