Player and other bodies interaction

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Player and other bodies interaction

Postby Crashy » Tue Dec 16, 2014 3:22 am

Hi,

I've just upgraded to the last version of Newton and Ogre newt, and I first need to thank anybody who worked on it, it's awesome !

I'm trying to make player controllers interact with other dynamic bodies (and later with other players), but I'm having some issues.
Reading this topic, it seems that it should work : viewtopic.php?f=9&t=7637&p=52581&hilit=player+interaction#p52581

Here is my basic setup:
My player is 2 meters high, it's mass is 100 kg, outer radius is 0.5 and inner radius 0.3, the stair step is 0.1.
The sample dynamic body I've made is a cube of 1*1*1 meters with a 1kg weight.

Using this setup, when the player collides the cube this one doesn't react to the player collisions.

If I change the player height to something bigger (ie: 10 meters), then the cube reacts to the player interactions, but the player also climbs on it sometimes, which is not what I want.
Same thing if I keep the height to 2meters but change the step height to 0.8 or more.

it seems the only way to make the other bodies react is to have them collide with the lower part of the players collision (the supportShape in the code).

Is there something I'm missing?

Thanks.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Crashy » Tue Apr 28, 2015 7:58 am

Hi,

I've made some more test about this issue.

When modifying the player controller sample from the newton samples by adding a simple box in the scene, everything is working as it should: the player pushes the box.

However, this is not working in my sample.

I'm using OgreNewt, so it is a dNewtonPlayer that is used instead of a "raw" CustomPlayerController.

In my case, the player doesn't "pushes" the box, but is sometimes climbing it (even if the box size is much greater than the stair step) and then the box reacts to the contact.

I've got some troubles understanding all the dNewton stuff, which seems to be a kind of high level wrapper to the core library, but maybe something is wrong with the dNewtonPlayer implementation, but I can't see what, as it is just wrapping the body and the collisions to a dKinematicBody and dCollisions.

The player setup is the same as in the first post, and player axis are : up : 0 1 0, direction 0 0 -1
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Julio Jerez » Tue Apr 28, 2015 8:55 am

There may be something with the the dCustomPlayer, last time I tried to use Ogre, I could not get it to work, I do not know what is going on with the Ogre engine, but they make it harder and harder for people to use it. After you download it, you need to go and find dozen of libraries each one with complex build proccess, why don't they do just like Unreal wich is orders of magnitud more complex and yet you get everything in one download?

I like the Ogre engine, but it should not be tha difficult to use it. Specially now that they have a tough competition for high end engine developers with budgets of tens of million dollars a year in engine developt,ment alone. Unreal is now openesource, and my guess is that soon Unity, crisis, and Valve will follow suit.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player and other bodies interaction

Postby Crashy » Tue Apr 28, 2015 9:38 am

I understand your point of view. We are building our own engine based on Ogre and other open source libraries (such as Newton of course, lua, and a few other stuff).

We will release it as open source and one of the main goal we have is to have the less complicated build system for this kind of engine.
A part from the boost dependency which is too big to be included in our repo, everything is a one click command line build on both windows and linux.

About the dCustomPlayer, is there a way to test it independently ?

I'll maybe try to modify the newton advancedcontroller demo to use dNewton stuff instead of the lower level newton calls, but it may take some time.

I hardly see what could be wrong though, as all the contact resulting forces are done in the core library, aren't they ? So as the dNewton library is more or less a wrapper, this shouldn't change anything at all.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Crashy » Tue Apr 28, 2015 2:36 pm

I've plugged the debugger to show the player collisions, and they're fine.

Two test:
The first with a inner radius of 0.3 and an outer radius of 0.5.
The objects with a box shaped collision don't react to the player at all.
Spherical collisions are reacting but only when the player climbs them.
big_radius.jpg
big_radius.jpg (110.03 KiB) Viewed 7957 times

The second one with a inner radius of 0.3 and a outer radius of 0.1 so that the capsule shape is inside the convex cast shape.
With that setup, everything is reacting as it should: all objects are reacting when colliding the player.
small_radius.jpg
small_radius.jpg (67.35 KiB) Viewed 7957 times


So it seems the problem is related to the capsule shape :?
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Julio Jerez » Tue Apr 28, 2015 10:42 pm

It looks as if the dimentions are all screwed up, the center cylider should be thinner,
the innner radios should always be much smalled than the outer radio, the outer radio corresponds to the capsule. The player inner cilynder is colliding with the box and that is not suppose to happens, That may need a bug I may need some clamping to prevent that.
Are you synced to the last version of newton?

if you are cna you get the player controller and see if you can recrate the same thing in the demo.
for the most part the controller is almost the same, so it soeu be simpel to recreate thet cate in the basci player controller.
the is is a matter to just get the last version of the engine compiling in Ogre.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player and other bodies interaction

Postby Crashy » Wed Apr 29, 2015 2:16 am

Yes I'm up to date.

I've tested it in the newton sample, it's possible to have an outer radius smaller than the inner radius. But there is an assert in debug mode.

But I think I've found the catch:
-Inverted the order of the collision shapes in the player collision:
Code: Select all
NewtonCompoundCollisionAddSubCollision (playerShape, bodyCapsule);
NewtonCompoundCollisionAddSubCollision (playerShape, supportShape);

-With an inner radius of 0.2 and lower, and an outer radius of 0.5, the player pushes the objects
-With an inner radius of 0.3 and an outer radius of 0.5, the player doesn't push the objects.

So it seems that the inner radius must be very small, not only smaller than the outer radius. This is ok for me, I may clamp values so that the inner radius always stay below a percentage of the outer radius.

Thanks for your help.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Julio Jerez » Wed Apr 29, 2015 8:55 am

Crashy wrote:-With an inner radius of 0.2 and lower, and an outer radius of 0.5, the player pushes the objects
-With an inner radius of 0.3 and an outer radius of 0.5, the player doesn't push the objects.

that does not sound right, the tow radios woudl be on the same scale, it may be a bug.
There few thing I need to check in the controller.
this and changing of the player origin.
Do yo get it going now?

I am out until the 10 of next most.
I iwll checl taht ouyt as soon as I get back.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player and other bodies interaction

Postby Crashy » Wed Apr 29, 2015 9:31 am

This is ok for me now.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Julio Jerez » Mon May 11, 2015 9:43 am

Crashy wrote:-With an inner radius of 0.2 and lower, and an outer radius of 0.5, the player pushes the objects
-With an inner radius of 0.3 and an outer radius of 0.5, the player doesn't push the objects.

I just tested this and It seems to work in the current version, are you sure you have the latest version?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Player and other bodies interaction

Postby Crashy » Tue May 19, 2015 12:04 pm

Yes, 100% sure . However, as I said, this is now working when inverting the two sub collisions so it's fine for me.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: Player and other bodies interaction

Postby Crashy » Thu Dec 03, 2015 9:28 am

Hi, I'm back with this issue again !

In fact my fix was not working in all cases, as it is impossible to walk on stairs with it.

So I reverted back, updated my newton source, and made some tests.

As before, I cannot move a dynamic body by pushing it with my character, and while debugging I've reached this line, in dgCollisionConvex.cpp, line 3058:
Code: Select all
dgFloat32 penetration = minkHull.m_normal % ((minkHull.m_q - minkHull.m_p).CompProduct4(scale)) - proxy.m_skinThickness;

This penetration calculation is used to tell if the contact is active or not. In most (99%) of cases, the penetration is >0 so the contact is never activated. But sometimes, it's <0 and my player controller moves the dynamic body.

By changing this line to
Code: Select all
dgFloat32 penetration = -0.1
the player controller always moves the dynamic body.

This leads me to think the restraining distance used in CustomPlayerController::PostUpdate avoids my player to actually "touch" the dynamic body and as a result the penetration is always > 0

If I change the code in post update to substract restraining distance instead of adding it (line 369 in CustomPlayerControllerManager.cpp), everything works fine and the player pushes the dynamic body as it should.

I know this is not a proper fix, but maybe you could give me a hint to fix this issue ?

Otherwise, I still don't see any difference between my player controller initialization code and the one provided with the demos.

Thanks.
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron