Debugging freeze state

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Debugging freeze state

Postby Cannos » Tue Jun 01, 2010 2:59 pm

I need some tips on debugging freeze state. I am setting some bodies to frozen and non-collidable (by setting their material group to one I've set up that does not collide with any other group). I am not applying any forces to these bodies, but somehow they are becoming unfrozen. Any idea what might be unfreezing them?
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: Debugging freeze state

Postby Cannos » Fri Sep 03, 2010 5:17 pm

I worked around some freeze state issues a while ago, but I'm looking at this again. Here are 2 of the issues I'm seeing:

1) According to the wiki, frozen bodies do not have callbacks called, but I am seeing the applyForceAndTorque callback called on frozen bodies. I had to add at a check for freeze state and early exit from the callback to keep gravity from being applied to frozen bodies.

2) Invalidating cache seems to unfreeze bodies. Refreezing bodies after invalidating cache doesn't seem to work, something is preventing them from being frozen, or they are becoming unfrozen.

I'm sure I may be doing something wrong, so I wanted to see what behavior I should expect from frozen bodies and what I should check if the above behavior is unexpected. Thanks.
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: Debugging freeze state

Postby Julio Jerez » Fri Sep 03, 2010 5:31 pm

In 2.0 all bodies get Force and Torue callback.
This is a Tradeoff between simplicity and and performance.
1.53 keeps two lists, one for sleeping bodies and one for active bodies, but this makes the logic too complex when mutitreading, since a body can touch a slepping body
and it will be very hard to update that body if it was on another thread, plus it is too later since the solve will not knwo the external forces acting on that body.

In 2.0 calling applyforce on all bodies solve the problems since bodies can be activated without having to know if they are in contact with other bodies.
a body is activated if the net force is different than zero. as a side bonus the engine is easier for the end user, since they can use force a torque as a beat for the engine.

Invalidate Cache does activate objects yes, but they go to sleep when they reach equlibrium.
a body will become unfrozzen if it collide with other body, or if the forces acting on it are different than zero,
you migh be confuce because you are getting force callback on frozen bodies.

say for example you have a box resting on the floor. the box is frozen, but you keep getting force callback.
when you apply gravity, the engine sees that the gravity added to the resting forces add to zero, and preserve the sleeeping state of the body.
The body does not participate on any more calculation unless is touched by other body and it gets pulled into the solver.
if you apply a force different than gravity, then the force do not add to zero, and the body is activated and sent to the solver for integration
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Debugging freeze state

Postby Cannos » Fri Sep 03, 2010 6:25 pm

Okay, that makes sense. I was thinking I could use the freeze state to not apply gravity, for instance. I will continue to use my own flag to do that. Thanks for the information!
Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm

Re: Debugging freeze state

Postby JernejL » Sat Sep 04, 2010 12:48 pm

Cannos wrote:I worked around some freeze state issues a while ago, but I'm looking at this again. Here are 2 of the issues I'm seeing:

1) According to the wiki, frozen bodies do not have callbacks called, but I am seeing the applyForceAndTorque callback called on frozen bodies.



Where did you read that? i thought i corrected this on all places..
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Debugging freeze state

Postby Cannos » Sat Sep 04, 2010 9:03 pm

Cannos
 
Posts: 129
Joined: Thu Mar 04, 2010 5:41 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 154 guests

cron