Floating objects

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 5:48 pm

I am not sure how that was working or if you change but you are calling
void NewtonBodyApplyImpulsePair with a zero impulse one every object every frame.
    > newton_d.dll!dgBody::ApplyImpulsePair(const dgVector & linearImpulseIn, const dgVector & angularImpulseIn, float timestep) Line 698 C++
    newton_d.dll!NewtonBodyApplyImpulsePair(const NewtonBody * const bodyPtr, float * const linearImpulse, float * const angularImpulse, float timestep) Line 6244 C++
    MyGame.debug.exe!00c19fd1() Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for MyGame.debug.exe]

that function wakes up a body, but because it does not apply any state change so what happens is the the body is send to the solver and the solver apply a contact force that set the velocity to 0.0001 m/s
and integrate the body for one frame. The velocity change is below the sleep threshold so the body goes to sleep again, but is wakes up by the call to NewtonBodyApplyImpulsePair with zero impulse.
Basically you are using NewtonBodyApplyImpulsePair to manipulate the body.
In general NewtonBodyApplyImpulsePair is used to apply some non zero impulse, calling it to do something else, I do not know what the result is.
what is it that you are trying to do by calling Set Matrix or apply impulse?

anyway I added a check that if the impulse is zero, not to wake up the body, and that fix the problem. I could not test the first demo since the later overrode the first.
Sync and try again. see if that fixes the bug.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Sat Apr 06, 2019 7:05 pm

This is very strange. When I remove the call to ApplyImpulsePair that does fix the simpler box demo.

However, the bug remains when the player jumps onto the box. The box body ID is 2.

New download here:
https://www.leadwerks.com/files/physicstest2.zip
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 7:17 pm

I do not see it happening to that demo, I try few time but seems fine.
edit: I try some more and I can push the box around over the floor, and jump on top as many time as I wnat and the bug does not happens.
did you sync like I said before?
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Sat Apr 06, 2019 7:26 pm

This is how you trigger it:
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 7:36 pm

Did you sync, to that last committed version?
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Sat Apr 06, 2019 7:38 pm

No, I just removed the AddImpulse call. I will try that now.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 7:46 pm

The second problem happen with apply impulse.

The first problem is related to a change that was made few month ago to support sleep for the parallel solver.
Somehow that change made small island to state sleep but continue to be integrated.
If the body having that residual velocity was integrated one frame and go to sleep just to be wake up again. The fix that was suppose to correct the problem, did not work because the call to impulse.

Please sync and try the commit that is suppose to fix it all issues.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Sat Apr 06, 2019 7:48 pm

Hmmmm, with your latest code I have not been able to create the problem yet. I will continue to test but it looks fixed. Your explanation makes sense given the behavior.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby JoshKlint » Sun Apr 07, 2019 2:00 pm

Unfortunately I am still seeing the problematic behavior:
https://www.leadwerks.com/files/physicstest2.zip

It is harder to produce, but still happens very easily. Jump on top of the box and walk around a little or rotate and it will start rising.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sun Apr 07, 2019 2:32 pm

what I do not understand is why I never saw that bug before,
I know very few people are using Newton these days, but I know for a fact that
I and Dave use it regularly and tested the solver changes exhaustively and that bug never happened.
some how you manage to get a body that is in sleep state bypass the solver and get integrated with a residual velocity.
anyway I will check it tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Sun Apr 07, 2019 2:41 pm

You have 30,000 users with my engine. :)
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Mon Apr 08, 2019 11:00 am

you are going to have to make a video to show me how I can make it happens, I played a few minute and It could no make is happen at all.
in fact the pathway in code where that could happens is no called.
basically is would have to call the solver for a body with a contact that was no refreshed. and thsi is no longer happening.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Tue Apr 09, 2019 12:09 am

JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Tue Apr 09, 2019 10:20 am

no sure why you do that but you keep calling these functions that activate the body when not change is applied on them.
    > newton_d.dll!dgBody::SetSleepState(bool state) Line 558 C++
    newton_d.dll!NewtonBodySetSleepState(const NewtonBody * const bodyPtr, int state) Line 5900 C++
    MyGame.debug.exe!00c29fea() Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for MyGame.debug.exe]
    MyGame.debug.exe!00c243e9() Unknown
    MyGame.debug.exe!011abea2() Unknown

I know the engine should deal with that but these problem happen because some how by simple waking up a body when no action is applied, the body is integrated by one frame to put to sleep again.
In newton bodies goes to sleep in one frame, so the transition from when the body was last integrated and put to sleep tells the collsion that since the body is sleeping no contact calculation need to be performed.
but since the body is awaken the solver say not the body must be integrated and it keeps moving.
in most case the solve find the zero velocity and acceleration and the bodies goes to equilibrium in one frame but in your case when the player touches the box, you apply impulse or velocity, of first you were teleporting.
These actions are ok when the do any of the body state, but when the do no any of the body state whey, they simple tell the solve integrate this body.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby Julio Jerez » Tue Apr 09, 2019 10:43 am

actually that doe no fixed. the problem. basically it come down that calling
NewtonBodySetSleepState to wake up a body tha was sleeping by do change the body state causes the body to be integrated by the solver.

becaus ethe solve now check body to be at rest not for comple islands,
I am reverting that change
I have to think how to fix this, I have to leave for work now I continue later.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron