Floating objects

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Floating objects

Postby JoshKlint » Thu Apr 04, 2019 7:10 pm

When my player stands on an object, a force is applied to the object he is standing on.

It seems that the NewtonApplyForceAndTorque callback is always being called, even when the object is asleep.

It seems that the object starts floating up for no apparent reason.


https://www.leadwerks.com/community/top ... g-objects/
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Thu Apr 04, 2019 7:18 pm

force and torque is called on all objects sleep or no sleep.
I had never seen a bug like that.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Thu Apr 04, 2019 7:55 pm

It is very strange behavior. If I shoot or bump into the box it wakes it up and "cures" the problem, making it instantly drop back down to the ground.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Thu Apr 04, 2019 8:08 pm

I do not know what could that be, make a test repro.

the only this that can make something like that is if a contact of manipulated and make penetration the body in callback and the repulsive velocity penalty try to pus the penetration out.
but the engine can't do that contact are all in global space.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Thu Apr 04, 2019 8:36 pm

https://www.leadwerks.com/files/physicstest.zip

Walk to the crate. Jump onto it (space key jumps). The crate will start rising, and keep rising until you shoot it or bump into it to "wake" it up.

Escape key will open the game menu, freeing the mouse movement.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Dave Gravel » Thu Apr 04, 2019 9:10 pm

It look like the player produce bad velocity and it is transfered to the object. Take a look in your player controller and try to find any place where the velocity is apply or modified. Surely something wrong happen with the vel somewhere.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 690
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Floating objects

Postby JoshKlint » Fri Apr 05, 2019 12:23 am

That doesn't make sense. Gravity should be pulling those objects down.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Dave Gravel » Fri Apr 05, 2019 12:42 am

If the velocity restitution from the player is over the gravity value and mass it can float on air no ?
I'm not so sure why it seen to stay locked at this floating value, Maybe a wrong callback assignment.
Edited:
Maybe retake a look around the callback ApplyForceAndTorque and how it is assigned to the objects.
Maybe i'm wrong, but it look like when the player is in collision with the object the object is assigned to a other callback.
And it look like the old callback is not reassigned correctly after the collision with the player.
It is just what it look like for me, sorry if it don't help.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://www.facebook.com/dave.gravel1
http://orionx3d.googlepages.com/
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 690
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Re: Floating objects

Postby JernejL » Fri Apr 05, 2019 6:50 am

I'm not sure which newton you used previously, but i think since newton 2 force and torque callback is called for each frame regardless of body sleep and this is correct.
I think this was changed during transition from 1.8 or some really old version. This way you don't have to wake up bodies anymore.

The bug itself looks like definetly a related to character controller, probably something to do with how you apply force on objects under characters that is not reset properly.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1442
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Floating objects

Postby Julio Jerez » Fri Apr 05, 2019 9:07 am

Untitled.png
Untitled.png (12.97 KiB) Viewed 719 times

that function was changed to this NewtonConvexCollisionCalculateBuoyancyVolume
which does not assume anythong it onle compute the volume and center of mass of the part under the plane. the user can use it any way they want. buoyancy is one effect.

you need to sync I can't debug the dll.
Julio Jerez
Moderator
Moderator
 
Posts: 10954
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Floating objects

Postby JoshKlint » Fri Apr 05, 2019 3:41 pm

I updated Newton to the latest and re-uploaded. Same link:
https://www.leadwerks.com/files/physicstest.zip
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 11:12 am

the body move up because when you jump on it you are calling NewtonBodySetMatrix and it keep doing even after you step out. you have somethong wrong on the logic
but the question is why you expecity call set matrix on a body that is suppost to move by gravity.

Code: Select all
    newton_d.dll!dgBody::SetMatrix(const dgMatrix & matrix) Line 219   C++
    newton_d.dll!dgBody::SetMatrixResetSleep(const dgMatrix & matrix) Line 234   C++
    newton_d.dll!dgDynamicBody::SetMatrixResetSleep(const dgMatrix & matrix) Line 186   C++
>   newton_d.dll!NewtonBodySetMatrix(const NewtonBody * const bodyPtr, const float * const matrixPtr) Line 4843   C++
    MyGame.debug.exe!00ba0964()   Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for MyGame.debug.exe]   


the is probably the worse thing that can be done.
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 2:31 pm

Are you sure it is the box that is being called on? There are a lot of other dummy objects in the scene that have no collision or mass.
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Re: Floating objects

Postby Julio Jerez » Sat Apr 06, 2019 2:41 pm

It is the box yes, because the function set matrix
Is not called by the engine update, is called by the user, and in the test is called whe the player come in contact with the box.
The box is body I'd 4, you can verify by calling the function get body is.
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 3:05 pm

I created a new version that removes the player and just continually adds a small force to the box. The box slowly floats up into the air:
https://www.leadwerks.com/files/physicstest.zip
JoshKlint
 
Posts: 74
Joined: Sun Dec 10, 2017 8:03 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests