Object not falling down when changing UserMeshCollision

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Object not falling down when changing UserMeshCollision

Postby Marc » Mon May 30, 2011 8:44 pm

Hi !

I have a UserMeshCollision. There is a large horizontal triangle. I put a sphere on top and add gravity to it. it falls on the triangle and gets to rest.

Now I remove that triangle, so the next time the collide callback gets called, that triangle won't be returned. But the sphere doens't fall down, it just rests in midair until I put a small force on it.

I guessed it has to do with auto sleep. So I tried

NewtonBodySetAutoSleep(body, 0);
NewtonBodySetFreezeState(body, 0);

(even in front of every NewtonUpdate) on the sphere,

but it's not helping. What could be wrong?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Object not falling down when changing UserMeshCollision

Postby Julio Jerez » Mon May 30, 2011 11:03 pm

my gueee is that the collision is no where you think it is.

enable the debug display.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Object not falling down when changing UserMeshCollision

Postby Marc » Wed Jun 01, 2011 6:41 pm

Hmm debug display. I tried to capture the geometry I create dynamically when my NewtonUserMeshCollisionCollideCallback collideCallback gets called. But surprisingly, in this moment, it doesn't get called. When I'm on the flat ground moving around, it gets called exactly once per NewtonUpdate. As soon as I stop moving and velocity gets equal 0, the callback doesn't get called anymore. How is this possible? I always apply a force in -Z direction, and the flat ground is the XY plane. So my sphere gets pushed inside the plane every frame, but without a collidecallback, how come it doesn't fall through the ground?

Just an idea: maybe Newton caches the dynamically created meshes by the callback for the next frame? If the position doesn't change, it uses the same again?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Object not falling down when changing UserMeshCollision

Postby JernejL » Thu Jun 02, 2011 3:26 am

For debug display julio meant rendering collision shapes with NewtonCollisionForEachPolygonDo

see here: http://www.newtondynamics.com/forum/vie ... 41&start=0
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Object not falling down when changing UserMeshCollision

Postby Marc » Thu Jun 02, 2011 5:04 am

I see.

But that's probably not giving much more insight. My point in my last post was: Newton doesn't ask me for my updated geometry. It can't know that I changed the Geometry, because it doesn't call my callback in this case. But why doesn't it do it?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Object not falling down when changing UserMeshCollision

Postby Julio Jerez » Thu Jun 02, 2011 8:59 am

Marc wrote:Just an idea: maybe Newton caches the dynamically created meshes by the callback for the next frame? If the position doesn't change, it uses the same again?


the is not internal mesk caching, the reason for the call to stop are:
1- the body is sleeping (make sur eteh body is active)
2- the AABB of you mesh is no what is should be, an they body do no overlap (see if teh on AABB overlap is call)
3- the body is smalled then the wold, (see fi teh body is ouzide teh work by settin teh on exit worl call back)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Object not falling down when changing UserMeshCollision

Postby Marc » Fri Jun 03, 2011 5:42 pm

Thank you Julio! I examined those points

1.
I put
Code: Select all
   NewtonBodySetAutoSleep(phys, 0);
   MNewtonBodyUnfreeze(phys);

in my code. Afterwards, I do
Code: Select all
   int freezestate = NewtonBodyGetFreezeState(phys);
   int autosleep = NewtonBodyGetAutoSleep(phys);
   int sleepstate = NewtonBodyGetSleepState(phys);

before every NewtonUpdate() and they all return 0. I'm not 100% sure which values should there be, but I guess all 0 means everything gets simulated. The issue persists with this setup. :(

2.
My user collision is spans from (0, 0, 0) - (1024, 1024, 1024), placed at (0, 0, 0). I call NewtonSetWorldSize() with an additonal border of 100. So it's
(-100, -100, -100, 1124, 1124, 1124) in size. My sphere is at (512, 512, 512), z radius is 0.9, x and y are 0.5, and falls down 10 in z direction before it hits the triangle.
I added the OnAABBOverlap callback. It gets called every frame, the whole time from the beginning, hitting the triangle, standing still and floating in the air
after removing the triangle. :(

3.
From the values from 2., I don't think there is a world leaving issue. I added the LeaveWorldCallback anyways just to make sure: It never gets called. :(


I'm not sure if that helps, but when the sphere is hovering and I call NewtonInvalidateCache() once, the hovering stops and the sphere falls down.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: Object not falling down when changing UserMeshCollision

Postby Julio Jerez » Fri Jun 03, 2011 8:03 pm

Is there a test demo?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Object not falling down when changing UserMeshCollision

Postby Marc » Sat Jun 04, 2011 4:52 am

Sort of. It's similar to my other game you debugged a few times. You can download it here http://dl.dropbox.com/u/103286/filehost/walkover2/walkover2_setup.exe.
You can easily reproduce the issue if you look downwards and click left. That'll remove a part of the terrain like in some popular mining game. When you did this once, you'll stand on a flat quad. Qait until you stand still completly, usually only takes a few seconds, then click again to remove more. => You'll hover in the air until you move around a bit.

I added some debug output. If you have a 2nd monitor, you can move the console window there and have a look while moving around:
Image
If a callback doesn't get called, that line won't appear.

As a note: The onfloor value gets set in NewtonContactProcessCallback, but it's also checked if the collision normal is upwards and the contact is somewhere near the feet and so on, so it's not an indicator to check if NewtonContactProcessCallback processed a collision.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron