convex cast problem

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

convex cast problem

Postby hamsterexplosion » Sat Jul 20, 2013 9:08 am

hi, everyone!

i'm trying to write my own character controller using convex cast. i cast player collision (cylinder) down to see if it hits the ground and store it in m_bInContact variable. here's the code (executed every frame):
Code: Select all
   m_bInContact = false;
   NewtonWorldConvexCastReturnInfo info[16];
   matrix m;
   NewtonBodyGetMatrix (getBody()->m_pNewtonBody, m);

   vec3 target = m.getPos();
   vec3 origin = target;
   origin.y += 0.01;
   m.setPos(origin);
   target.y -= 0.01;
   float param;
   int result = NewtonWorldConvexCast(gPhys.getWorld(), m, target, NewtonBodyGetCollision(getBody()->m_pNewtonBody), &param, getBody()->m_pNewtonBody, ConvexCastCallback, info, 16, 0);

   if (result != 0)
      m_bInContact = true;

it works absolutely ok with collision tree, but for dynamic bodies it looks unpredictable for me. for example, this body (made as convex hull) is being detected by the convex cast:
1.jpg
1.jpg (208.35 KiB) Viewed 4768 times


but if i scale down vertices of the same collision it is not detected:
2.JPG
2.JPG (191.67 KiB) Viewed 4768 times


player collision size is R=0,4064 H=1,778.

is there something i doing wrong?
User avatar
hamsterexplosion
 
Posts: 20
Joined: Thu Jul 11, 2013 11:54 am
Location: ukraine

Re: convex cast problem

Postby Julio Jerez » Sat Jul 20, 2013 10:32 am

question why don you use the player controller that comes with the engine?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: convex cast problem

Postby hamsterexplosion » Sun Jul 21, 2013 2:14 am

Julio Jerez wrote:question why don you use the player controller that comes with the engine?

it seems for me that it is not so good at interacting with dynamic bodies. and also i have a bunch of special things to do anyway, that are not implemented in CustomPlayerController.

what i did is created an upvector-constrainted dynamic body, cancelled all friction and elasticity and switching gravity on only when not m_bInContact. the velocity is clamped so it is not infinitely accelerated.
i tested a lot of methods, but this one gives best results when walking on slopes.

so what's wrong with my convex cast?
User avatar
hamsterexplosion
 
Posts: 20
Joined: Thu Jul 11, 2013 11:54 am
Location: ukraine

Re: convex cast problem

Postby Julio Jerez » Sun Jul 21, 2013 9:45 am

the convex cast works on all shapes with of without scale. including non uniform scale.
what version of newton are you using?

what do you mean the player controller is no good at interacting with dynamic bodies? I spent a great deal of effort manning to interact with other bodies.
plus that behavior can be customized.
can you give me an example of what you mean maybe it can be fixed?
what are those special things you want to do that that the current play does no do, maybe they can be implemented? directly or indirectly via call backs.

Has you tried that play controller in the latest version of core 310 or 311?

one of the thong that make these thong better is the conflagration of ideas from many users, they get streamlined and integrated into the app.
but if it is not used and not information is passed back them I always remain as a mediocre feature.

I encourage you to give a try to that controller and see if we can fix what you want to see in it rather than begging for scratch.
in the end your implementation will be very similar to what is there already but by them you will have spent lots of time.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: convex cast problem

Postby hamsterexplosion » Sun Jul 21, 2013 11:29 am

i'm currently on 2.32. as for 3.xx i see the word 'alpha', a lot of undocumented functions, and no backwards compatibility, so i'd stick at 2.xx for now.

besides, i'd suggest you to document new features as you add them, so people like me could try that and see if something is wrong or not. i think that could speed the development up. as for now to help you i should have study all the engine code to see what's going on in there and what are the new features for. the biggest reason why people use newton engine is to not getting involved to all that deep by themselves. i'm sure that's a lot of useful things in newton's source directory, but without full documentation and systematization they are barely helpful.

i really loved the old-fashioned 1.xx engine when all the user need was a library and a header, so learning that comes to learning api functions and callbacks, that were fully-documented. and i don't think that the physics engine should actualy implement such a game-specific functionality as character controller. what is think would be best if the engine could give the user everything he needs to implement that by his own. good example apps would be just enough.
User avatar
hamsterexplosion
 
Posts: 20
Joined: Thu Jul 11, 2013 11:54 am
Location: ukraine

Re: convex cast problem

Postby Julio Jerez » Sun Jul 21, 2013 12:49 pm

The thing is that game controller as well as vehicle are particular difficult to implement. This is why you need the experience of a person who really knows the detail that are involves on that.
I made the controller not just base of my knowledge of the physic library, it is also based of me 18 year+ experience on owing on the game industry as a programmer.

As for the engine being like version 1.00, you are asking for something that is difficult to keep. core 1.xx had a limited set of features, as functionality grows it is inevitable that the engine will also becomes bigger.
Newton core is still one file and one header, all of the higher functionality like custom joints, vehicles, player controlled, trigger managers, and here will be more, are all build on top of the newton.h file.
in core 310, there is now a high level dNewton class, that encapsulate newton as a cpp object oriented engine.
I am studying what automatic documentation toll to use fore documentation that class as well of the rest of the other class.

as for the Alpha word, that concept does no really apply to open source engine. I keep the world alpha for stable release but that because I always keep making improvement and bug fixes,
but the engine is quite polished.

Newton 310, is faster that Havok and PhysX 3.3 (as tested by even NVidia internal team in there PEERL tool) and is does that while being more accurate more stable and more bug free and about twice as many features that both
I have those test but I am forbidden by NDA form NVidia for releasing them.
I person form they team said he will make an article about comparison, but know who the operate I believe they will hold the result until the tweaked PhysX so that It Beta Newton in order no to make the look so embarrassed.

Please at least download core 3.10 see if at least does what you want.

as for core 2.xx we need to let that core rest. the solution if to more on to the newer version witch probably has that bug already fix.
moving form core 2.xx to core 3.xx sopudl takes no more than a day of work, and it is worth it.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: convex cast problem

Postby JoeJ » Sun Jul 21, 2013 2:56 pm

hamsterexplosion wrote:i'm currently on 2.32. as for 3.xx i see the word 'alpha', , so i'd stick at 2.xx for now.


That's exactly what everyone will think. I'd remove the 'alpha'.
Even newcomers may choose 2.xx, because it 'must be a more stable release that 3.xx'... which is wrong.

a lot of undocumented functions


I think there are only few things that are really outdated on wiki. But that's enough to make people think that 'a lot' is outdated.

Maybe Julio should add a new section to forum covering those newer things.
Only Julio could start a new thread if some user asks about a new thing, but further public discussion is allowed, like FAQ.
F.ex. a lot people asked for difference of dynamic and kinetic body creation, but answers are rare and hard to find in some out of topic thread.


and no backwards compatibility

For me it took only a hour to move from 2 to 3. You can use #ifdefs so you can go back.

hamsterexplosion wrote:so what's wrong with my convex cast?

No idea, i have not used convex cast yet. But for me, if i used scaled bodies, angular behaviour became incorrect so i avoid them for now.
I recreated my scene in newton demo sandbox, and there behaviour is correct. No clue what i do wrong.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: convex cast problem

Postby Julio Jerez » Sun Jul 21, 2013 3:04 pm

hamsterexplosion wrote:so what's wrong with my convex cast?

No idea, i have not used convex cast yet. But for me, if i used scaled bodies, angular behaviour became incorrect so i avoid them for now.
I recreated my scene in newton demo sandbox, and there behaviour is correct. No clue what i do wrong.


Joe can I have the recreation that you did in the sandbox, scale geometry should work properly at all time. If there is a malfunction there maybe you can tell me how to recreated it so that it can be fixed.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: convex cast problem

Postby JoeJ » Sun Jul 21, 2013 3:40 pm

The thread was this:
http://newtondynamics.com/forum/viewtopic.php?f=9&t=7551&hilit=scale

I was NOT able to reproduce in sandbox, so the bug should be on my side.
But i remember some other guy with a strange scaling problem.

Hamsterexplosion, can you update and see if convex cast is still wrong with 3.xx?
I remember Julio fixed a 'scaling twice'-bug somewhen, but i dont know if it was present in 2.xx.

If there really is a scaling bug in newton, i don't think that i alone can help to find it.
I could send exe, but that's some work and because there's nothing really wrong badly, i don't think it helps.
I think it's better to see if other people have problems too and don't worry for now.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: convex cast problem

Postby Julio Jerez » Sun Jul 21, 2013 5:50 pm

Joe, This important because if Scaling make a shape to behave incorrect physically, then scale is not really feature, and because a check box stuff.

as I remember there bug was relate to the inertia matrix for nor uniform scale being calculate wrong. but I fix that long time ago.

The way I test that is by making tow boxes with actual size and the other a unit box scaled to math the first one and throwing them on the scene.
the they should behave very similarly.
They will no be identical because the scale intrude some rounding off differences. But the behavior should be physically correct in both cases.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: convex cast problem

Postby hamsterexplosion » Mon Jul 22, 2013 12:57 am

what kind of 'scaling' do you mean? i just multiplyed vertex positions before passing them to NewtonCreateConvexHull.


p.s. i downloaded version 3.10 and gonna give it a try when i get to it.
User avatar
hamsterexplosion
 
Posts: 20
Joined: Thu Jul 11, 2013 11:54 am
Location: ukraine

Re: convex cast problem

Postby JoeJ » Mon Jul 22, 2013 3:00 am

as I remember there bug was relate to the inertia matrix for nor uniform scale being calculate wrong. but I fix that long time ago.


Yes i know that was before. I have had checked that both Sandbox and my app calulate correct and equal inertia values on body setup.
Also contact points are calculated correct for both. The difference was that in my app collisions resulted in too large rotational response,
and the scaled box tumbled around unaturally and took much longer to get to rest.
An explantation would be that inertia accidently gets scaled again at runtime under some unknown circumstance.

The test i used was similar to what you discribed, but i used cubes, so both inertia and my scale was uniform.
I'll update and repeat the test to see if it still happens, and if the error looks proportional to the scale...

hamsterexplosion wrote:what kind of 'scaling' do you mean? i just multiplyed vertex positions before passing them to NewtonCreateConvexHull.

Ah, so i got you wrong and you can ignore my stuff. Newton has scaling feature build in,
but if you prescale stuff yourself it is not in use and i'd assume that you have a visuals / physics mismatch?
Are you sure that collisions are correct on your scaled geometry so you can exclude that?
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: convex cast problem

Postby JoeJ » Mon Jul 22, 2013 3:47 am

I made a video:

http://www.share-online.biz/dl/GP6OUBQMHP

left box is original, center is scaled, right is reference.
scale factor is 0.1
If i use factor 0.9 error is not noticeable.

The error is hard to notice anyway but im 100% sure that is not present by recreating scene ind sandbox.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: convex cast problem

Postby hamsterexplosion » Sat Oct 26, 2013 9:16 am

okay, sorry for a delay, but i've finally ported my 2xx code to 311. and what i say is that my problem is still there. any guesses?

ps. and also i've noted that it can not always work with same collision. some times it's ok, and some times the cast fails. but still works 100% fine with collision tree
User avatar
hamsterexplosion
 
Posts: 20
Joined: Thu Jul 11, 2013 11:54 am
Location: ukraine

Re: convex cast problem

Postby Julio Jerez » Sat Oct 26, 2013 11:33 am

what is it that you are trying to do?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests