What exactly does Convex Cast return?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

What exactly does Convex Cast return?

Postby Marc » Fri Jul 06, 2012 6:30 pm

When I cast the upper shape through a world with two larger bodies like below:

Image

Will I get
0. contacts for both larger bodies or
1. just for the upper one because the upper one stops the shape before it could reach the lower one
?

Also, what's the difference between NewtonWorldConvexCastReturnInfo::m_normal and NewtonWorldConvexCastReturnInfo::m_normalOnHitPoint ?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby pHySiQuE » Fri Jul 06, 2012 9:19 pm

It should record all collisions.

I think the normalonhitpoint is the normal of the hit surface, which isn't always the same as the normal of the collision.

Note that Newton 3 presently is not reliable with convex casts against collision trees.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: What exactly does Convex Cast return?

Postby Marc » Fri Jul 06, 2012 9:26 pm

pHySiQuE wrote:It should record all collisions.

Hmm, what are all collisions? For example, in the case from above, is it option 0 or option 1 ?

pHySiQuE wrote:I think the normalonhitpoint is the normal of the hit surface, which isn't always the same as the normal of the collision.

Can you define the two? Or can you give an example when they are not equal?

pHySiQuE wrote:Note that Newton 3 presently is not reliable with convex casts against collision trees.

I'm still on 2xx.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby pHySiQuE » Fri Jul 06, 2012 9:29 pm

Marc wrote:
pHySiQuE wrote:It should record all collisions.

Hmm, what are all collisions? For example, in the case from above, is it option 0 or option 1 ?

Both. If you're doing anything fancy, loop through all results and find the closest collision that occurs.

pHySiQuE wrote:I think the normalonhitpoint is the normal of the hit surface, which isn't always the same as the normal of the collision.

Can you define the two? Or can you give an example when they are not equal?

If you run into a wall at an angle, the collision normal will not be the same as the direction the wall faces.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: What exactly does Convex Cast return?

Postby Julio Jerez » Sat Jul 07, 2012 12:06 am

NewtonWorldConvexCastReturnInfo::m_normal is teh normal forme by teh mutual tangen of teh tow collisding shape at teh point of impast

and NewtonWorldConvexCastReturnInfo::m_normalOnHitPoint in teh nmorla of teh hit point at the point of impact

example say you can a sp[ager again a polygon, if teh spher hi on teh flat area, them m_normal and m_normalOnHitPoint are the same becaus ethe tangent of botth suiface are the same
however if the shape hit teh polygon in and edge or a vertex, tehn the norlam is teh norla that on teh suface of the sphere, but m_normalOnHitPoint teh norla on the plane
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What exactly does Convex Cast return?

Postby Marc » Sat Jul 07, 2012 8:46 am

Hmm ok. Thanks for clarifying on the normals.

I experience something I still can't explain though. I have this situation:

Image

For some reason, I get contact A with the correct normals, but I get contact B with some normals I can't explain. I would the contact normals of B point upwards - but they don't. Note: the normals of B are correct if the box is not there. But if it is there like that, I get different normals for B. Does the existence of contact A have an impact on contact B ?

[edit]
I'm not sure if it makes a difference or not, but it might actually be more like this:

Image

The slope is a static body and the big box is dynamic, but rests there. If the big box and the slope touch like this, will I get contact B?
[/edit]
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby Julio Jerez » Sat Jul 07, 2012 9:09 am

if the litle box is casted in the direction of the arrow, and box A is in the way, them you you only get contact betwinn box A and the litle box.
that is what the definition of convex cast means. If this is not how it is working then they is a bug.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What exactly does Convex Cast return?

Postby Marc » Sat Jul 07, 2012 10:21 am

Ok so just to make sure: The convex cast is different from the raycast. With the raycast I can get B as well, depending on the value I return in my callback function.

What I still don't get: The convex cast does not always just return one contact. In this case from above, what additional contacts will be returned besides A? If it doesn't report all contacts like the raycast can and it does not only report the first contact, what are the others?
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby pHySiQuE » Sat Jul 07, 2012 11:41 am

Julio Jerez wrote:if the litle box is casted in the direction of the arrow, and box A is in the way, them you you only get contact betwinn box A and the litle box.
that is what the definition of convex cast means. If this is not how it is working then they is a bug.

My mistake.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: What exactly does Convex Cast return?

Postby Marc » Sat Jul 07, 2012 11:58 am

Julio Jerez wrote:if the litle box is casted in the direction of the arrow, and box A is in the way, them you you only get contact betwinn box A and the litle box.
that is what the definition of convex cast means. If this is not how it is working then they is a bug.

Ah I just wanted to clarify I'm not saying something is wrong or buggy with newton. I just want to understand what to expect from the convexcast so I can predict what I'll get from it in certain situations (ignoring any current potential bugs).

I think what I experience is what Julio describes: I get contact A but I don't get contact B. The thing I'm still wondering about is, I get 3-5 contacts when I move around a bit, but never 1. What are those additional contacts? When the convex cast "casts" the small box downwards, it hits the large box and creates contact A, what happens from there on? Or does it work completely different and I'm thinking wrong? (And actually, I'm not sure if that matters, but the large box is a large box while the small box is a cylinder from the side.)
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby Julio Jerez » Sat Jul 07, 2012 1:31 pm

when to convex shape interset the intersetion point define a plane.
depene of the deatore of eth shape the first cone is contact you will get:
a single vertex/vertex, vertex/edge, or vertex/face , (for a conic shape like a sphere of a capsule)

or and edge/face or face face (for shape with hard edges like boxes) in this case the colliding in more that one place.
ex twp boxes colliding face to face. all teh contact fall in the same plane
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What exactly does Convex Cast return?

Postby Marc » Sat Jul 07, 2012 7:27 pm

Julio Jerez wrote:all teh contact fall in the same plane

Ah, I think now I have an idea of what it returns. Thanks.

Is there a way to make it behave like the raycast? I could repeatedly call it and build a list of hit body and filter them until I hit nothing - but that's probably inefficient. [edit]Thinking a bit about it, I guess this hack/workaround does not necessarily have to work if the bodies are shaped appropriately. :( [/edit]
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby Julio Jerez » Sat Jul 07, 2012 8:04 pm

but the convest cats does works like a ray cast. the paremter t is the time at wich the contact happens. you cna use that just liek you use a ray cast. I do it many time.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: What exactly does Convex Cast return?

Postby Marc » Sat Jul 07, 2012 9:38 pm

Julio Jerez wrote:but the convest cats does works like a ray cast. the paremter t is the time at wich the contact happens. you cna use that just like you use a ray cast. I do it many time.

Hmm. How can I use t so that I can get contact B as well then?

At http://newtondynamics.com/wiki/index.php5?title=NewtonWorldRayCast it says:

An all body ray cast can be easily implemented by having the filter function always returning 1.0, and copying each rigid body into an array of pointers.

But there is no such callback for the convexcast? The convexcast only has the NewtonWorldRayPrefilterCallback, while the raycast has NewtonWorldRayPrefilterCallback and NewtonWorldRayFilterCallback and the later one allows to return values from 0.0 to 1.0, where a value of 1.0 results in an all body ray cast. Is it possible to do that with the convex cast as well?
Last edited by Marc on Sat Jul 07, 2012 9:44 pm, edited 1 time in total.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: What exactly does Convex Cast return?

Postby Julio Jerez » Sat Jul 07, 2012 9:42 pm

Because it is a convex cast, it will find the first body along teh trajectory that his the casting shape.
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 1 guest

cron