Multiple Floating Point Traps

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Multiple Floating Point Traps

Postby Julio Jerez » Wed Nov 20, 2019 5:49 pm

Ok few things.
1- the video of the game is really cool :D

Lax wrote:Would It help, if I would create a debug mode package executables for you?
[/code]
yes that will help, the assert of the explosion is debug could not be a good sign. and my guess the only thing keeping working is the, the fallback when the matrix becomes ill condition.
What also does not work is setting:

Lax wrote:to true, so that the joints will collide with each other in the ragdoll. As soon as I set the collision state to true, and joints are created, the player will vanish immediately because of nan values.

that should always work and the code
Code: Select all
Ogre::Vector3 omega = body->getOmega();
      Ogre::Real mag2 = omega.dotProduct(omega);
      if (mag2 > (50.0f * 50.0f))
      {
         omega = omega.normalise() * 50.0f;
         body->setOmega(omega);
      }


should be very rareally execute, that's like a emergency space valve is should not be a feature.
My guess is that you mos have joint with more than 6dof or something like than that of making singular submatrices.
the fact that you get is going is not tell my that is right, there most be some error if you are getting those large numbers.
the is one of the thong that late version of the engine is going four, no more baby sitting that hide bad physics setting.
anyway if you can prepare a repro that I can check out, I may be able to help you out better.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby JernejL » Thu Nov 21, 2019 4:31 am

In my experience messing with omega by setting it directly generally results in strange results.
It works better if you apply changes that affect omega via force/torque calls.

It would be great to have something that would calculate force needed to apply to achieve a specific omega :)
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Multiple Floating Point Traps

Postby Lax » Thu Nov 21, 2019 5:24 pm

Hi,

1- the video of the game is really cool

Thanks for your feedback :D

should be very rareally execute, that's like a emergency space valve is should not be a feature.

That is really strange.

I created a debug package with the corresponding pdb files and I enabled the omage clamp code in the move callbacks:

http://www.lukas-kalinowski.com/Homepage/wp-content/uploads/GameDevelopment_Debug2.7z

In order to start the application:
- Go to the folder "../bin/Debug"
- Start NOWA_Design_d.exe
- Configure Ogre: No Fullscreen, the remaining parameters are ok (ogre.cfg)
- Load from recent scenes "Level4.scene"
- When loaded click the "Play" Button
- Player can be controlled via "wasd" and Jump with "space". In order to switch to ragdoll mode, press "T".
- The assert occurs e.g. when player jumps and in air "T" is pressed to switch to ragdoll mode.

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Multiple Floating Point Traps

Postby Julio Jerez » Thu Nov 21, 2019 5:47 pm

ok good, I can't do it during the week.
I will get tonight bu I will check over the weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sat Nov 23, 2019 1:35 pm

ok I have thsi going now and I see many problems with it.

Is I go over I was expecting all the objects to be contacting by a plane joint but tha is not the case, instead I see up vectors, hinged and ball and socket joint that are all in conflict.
the onle reason it works in release is that the assert are comple out but the velocity and accelration is huge well outside the dynamic range of a float. the onle reason is running Is because the penalties are keeping form exploding.

you nee to go back to basics.
The fist part is call you tell me hwo you are keeping all you object on the plane.
I did no see any plane joint. That is step one, get all bodies constrain by a plane joint.

step tow is to make two 2d joint, basically a set of joint that do not constrain the plane of motion
but that onel acc on the x, y and angle.
the can be done with the 3dof

do you want to do that?
can you show me the code where you set the joints. some is really incorrect there.
all you joint must be top 3 dof, but I see joint with even more than 6 which is wrong even
for a 3d scene.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sat Nov 23, 2019 2:00 pm

I see you are using joint dCustomUpVector, is many objects is you are using to constraint the object to the plane, that's a huge mistake.

the joint that you should be using is
Code: Select all
dCustomPlane (const dVector& pivot, const dVector& normal, NewtonBody* const child);


where pivot, is the point on the center of mass of the body, assuming it aligned to the plan of motion.
and normal is the direction perpendicular to the plane of motion.
this joint must be attached to every dynamics body in your scene.
to force the body motion to the plane.

the will make the scene a 2d scene in which each body will have three degrees of freedom,
x, y and rotation on the plane.

then I can make you a set of 2d joints that you can uses to make your ragdolls and player.
for what I can see you onle need two joints. these joint only have 3 dof at must

this should not be too complex, but is the only way I can see tha is can be fixed.
there is not bug to fix the set up is fundamentally incorrect at its root. teh assert you are getting is teh engine telling you that there are lot of ill form mass matrices because the engine does not know is a 2d scene.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Lax » Sun Nov 24, 2019 8:51 am

Oh so many issues :oops:

The fist part is call you tell me hwo you are keeping all you object on the plane.
I did no see any plane joint. That is step one, get all bodies constrain by a plane joint.


I faked the 2D plane joint, because, at the time, I started to write the 2.5 Jump n run. There was no plane joint ported to OgreNewt. So basically in my update function, I set each z-velocity to zero.

At best I check the plane joint again, if it will work!

then I can make you a set of 2d joints that you can uses to make your ragdolls and player.
for what I can see you onle need two joints. these joint only have 3 dof at must

That would be great! Indeed, I need 3 joints: Also the double hinge. I experimented with double hinge for upper arm joint, and it does work better as with ball and socket and i can use spring damper functionality.

of ill form mass matrices because the engine does not know is a 2d scene.

Oh ok..., thats new to me. So It means, when I create a physics body with the plane joint, the mass matrix will be different?

Is I go over I was expecting all the objects to be contacting by a plane joint but tha is not the case, instead I see up vectors, hinged and ball and socket joint that are all in conflict.

The up vector is used for each player and enemy, to prevent fall over. The ball and socket I use for upper arm of the ragdoll, is this wrong?
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sun Nov 24, 2019 10:38 am

There was no plane joint ported to OgreNewt. So basically in my update function, I set each z-velocity to zero.

yes that's but we have it for some time now and this is the correct way to do what you want.

in fact for all you object that live in flat land, the Plane Joint is the only joint allowed.
all othe sould be subclassed from that one an only dPlaneJoint base class.

later I will make you an 2d upvector and a 2d hinge and I with posted here. so tha you take and use in you code.
That should be all you nee for your game.

so to summarize, your fiert step are this.

1-comment out all you code that is using any kind of joints, all of it.
In fact so confident I am that you can jsut delete it, but do no do that keep for reference for what you do next.

2- to every dynamic object (object that non zero mass) assign a plane joint at creation time.
the joint can be a member of your class so that you have handy.

3-at this stage your game should be almost fully working, but there will be not player or not ragdoll.
but not weird physics behavior like explosion or warnings in debug mode.

4- when I post the 2dupvector, for each player in your game, you delete the plane joint and attach an 2d up vector. This will make your player work and interact nicely with everything since the 2dupvector is also an plane joint that constraint the plane angle.

5- now your entire game should run as is doing now but there will be not ragdoll yet.
after the game is running smooth without weird behavior, you move to add rag doll.

6-to make a rag doll, for each body that will be part of the ragdoll you do as follows.
delete the plane joint for all on them except for the root body.
this is for each child of a parent node below the root of teh doll,
delete the plane joint that force the body to move in the plane and replace
it with a 2d hinge joint that will allow the child only rotation relative to it parent.
since the parent will still be constrained to the plane of the scene, then all children will also be constrained to the plane of the scene.

those step should provide with the most accurate, stable and faster scene that you will get using newton, and sould no be that much work to get in fact is should be far simpler than
how you are doing I now. How you are doing it now should not even work at all.
the more I move Newton to correctness the more the ill form configuration will be exposed.

this was why the LDLt transformation blue up, because is not tolerant of ill condition matrices.

I am glad and grateful it blue up because, in a physics system there are legitimate reason why a matrix can be ill condition and still legal and that was my be mistake, so I get to correct that.

The point I am making is that if a Matrix is ill condition, then it can be substituted with a pseudo matrix by a trick called regularization, but that can only be done using Cholesky.
since I was using cholesky before, your game was working but is was because the solver was constantly repairing that mass matrix, hence hiding the problems.
The regularization trick should be an extreme rare citation that sould only happens when configuration have difficult loops, this is not your case.

anyway I hope the guidelines above help you to get the game going,
and later today I will write the two joints that you need for teh rest.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Lax » Sun Nov 24, 2019 3:14 pm

Hi julio,

thank you so much for your time and for the discovery of the issues!
I will follow your instructions.

I now tested the dCustomPlane joint, but it does not work as expected.
I tested with a simple case body, like:

I used the case body's current position

Code: Select all
dCustomPlane(caseBodyPosition, Vector3(0,0,1),caseBody, 0)


But the case will fall through the floor. I did not use a parent body, because I would like to have the whole world as parent.
When I debug the code, in SubmitConstraints, there is an assert:

Code: Select all
dAssert(0);


which stops the application.

But maybe I wait, til you made some adaptations...
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sun Nov 24, 2019 3:45 pm

there was an assert there yes, but is was removed when I start to make the a flatland demo.
find these asserts is a common thing in newton.

try sync to latest I added a new demo that does step 1 and 2 of the guidelines I stated before.
1-comment out all you code that is using any kind of joints, all of it.
In fact so confident I am that you can jsut delete it, but do no do that keep for reference for what you do next.
2- to every dynamic object (object that non zero mass) assign a plane joint at creation time.
the joint can be a member of your class so that you have handy.


please just sync and tell me if this is along the line you expect.

I will now move to step 3 and 4, adding the upright 2d joint. to make a capsules translate by not rotate those will act as your players proxies.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sun Nov 24, 2019 4:13 pm

ok if you sync again now you can have the upright joint which is subclassed from the plane joint.
the will be step 3 and 4 of teh guide lines.
assuming my interpretation of what yo seek is correct, this showed be what you need to get player and almost 85% of you game going. adding the player was less tha 1 dozen line of code.

what is left is the ragdoll, which is just making a 2d hinge joint subclass for the plane.

I am no making a complex ragdoll since that take a lot of work whi is not relevant, instead I will make teh joint and connect few long boxes to a center box, and I hope this is sufficient for you to go from there.
any other joint you need to can derive yourself, just like the hinge and upright in teh demo.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Julio Jerez » Sun Nov 24, 2019 5:07 pm

al right I now added the final step and mini ragdoll, that I think is enough to show hwo to go about
the entire thong is far less than 300 line of code
and I beleive is has all you need to make robust fast and very acurate.

this will fix all those other weird behavior that you reported form time to time and that since wrong but some how are accepted as how physic should be. sloppy and terrible,
but to me that not the point of a physic library.

anyway after you sync and test the demo let us knwo if you get problem understanding it.

edit:
the plane2d hinge does no has limits, and the moment, but that is quiet trivial to add.
in fact it should have limits and some dry friction so that you ragdoll look much nicer.

this could be a good practice for you, but if you get problems let me know.
it really is very eassy for people who understand how the Newton engine works
but I consider that my biggest failure.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Julio Jerez » Mon Nov 25, 2019 2:22 pm

one last comment.
I was going to add joint limits to the plane 2d joint, but I realized that this joint is not necessary. In fact any non root level node could use any joint.

This should be a good news for you, because your can preserve your rag doll code without much change. just get rid of all the z velocity and position resetting and should be fine.

so the rules I stated at the beginning, reduces to just one.

any Root level body the moves in a 2d plane, should be constrained to the plane by a dCustomPlane or a sub class of dCustomPlane joint.

this will let your rag doll to have some kind of 2.5 motion by simple using the regular joint, and again the only condition is the the root should be fixed to the plane by a dCustomPlane

I hope this is what you need and simply the changes.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Multiple Floating Point Traps

Postby Lax » Tue Dec 10, 2019 3:57 pm

Hi Julio,

now I had time to test everything and it indeed does now work correctly. I followed your last instruction.
Thanks a lot for the guidance!

Best Regards
Lax
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

Re: Multiple Floating Point Traps

Postby Lax » Tue Dec 17, 2019 4:50 pm

Ah damn it. I made a lot of tests and now. When the player collides with the enemy, the player or the enemy will be pushed a bit away in z-direction, so that after keeping colliding for some short time, they will pass each other and never collide. This behavior ruins my game mechanics.

In my old approach, I set the velocity z to zero each time, forcing newton todo nothing with this coordinate.

Similiar behavior I also need for ai path movement etc. I need to deactivate physics a bit, so that my enemies can behave correctly.

Do you have an idea, how this can be accomplished?
Please support SecondEarthTechnicBase built of Lego bricks for Lego ideas: https://ideas.lego.com/projects/81b9bd17-5ff5-40a0-ac6f-44b97b79be62
Image
Lax
 
Posts: 165
Joined: Sat Jan 08, 2011 8:24 am

PreviousNext

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 4 guests

cron