Collision Hulls, Primitives or

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Collision Hulls, Primitives or

Postby Spek » Sat Feb 28, 2009 10:38 am

Hi,

I'm making an editor to define objects for my game. One of the parts is composing a collision hull. So far I make them out of primitive shapes (boxes, cylinders, cubes, and so on). Its quite some work to create the collision hulls though, so I was thinking about using Newton's convex hull / "point cloud".

I know these shapes are slower than a simple primitives, but:
- Are they still slower than, let's say, 4 primitives together for 1 object?
- Although I do have a big world with lots of objects, only a relative small number (~50 at max) of objects has active physics. Others are freezed. So would it be that bad for the performance at all?

Another thing I'm a little bit worried about is the memory usage. It sounds logical that a point cloud takes more memory. That's not a problem, as long as objects share their resource. I mean, if I create thousand tables that all use the same collision hull, I should be able to share it right? I create the table collider only once, but I'm not sure what Newton does with all the bodies that make use of the same collider. I guess Newton let's it bodies refer to a collider, so sharing shouldn't be a problem. But I thought I just ask.

Greetings,
Rick
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: Collision Hulls, Primitives or

Postby Julio Jerez » Sat Feb 28, 2009 3:43 pm

Spek wrote:I know these shapes are slower than a simple primitives

actaully this si not true, ull are faster than any o fteh smoth primitive liek cylider, and cone,
but teh smoth primitive are extact smoth surfaces.
O box is a litle bit faster than a big hull but that's only because a big hull have more points, a hull of 8 point is just as fast as a Box.
you can safaly use the hulls.
in fact if you use say 12, or 16 size cylinder mane of hull they are faster that teh perfect smoth cylidrican hull.
The rule is use what you need for the job.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Collision Hulls, Primitives or

Postby Spek » Sat Feb 28, 2009 4:00 pm

Really? That's good news :) I thought primitive shapes would be faster, but it seems the point count is all what matters. I thought I read something different in the Newton Wiki, but I could be wrong.

As for my other question, does bodies that use convex hulls take more memory, or is it just the same as any other type of object?

Thanks,
Rick
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: Collision Hulls, Primitives or

Postby Julio Jerez » Sat Feb 28, 2009 5:32 pm

In the earlier time of newton the exact primitives were faster than the convex hulls, but in 2.0 and up the convxe hull is very optimized and it faster that the exact primitves if you keep the point cloud relativatly small, say under 200 points.
If you make a very complex conve xlike trying to make a smooth cylinder by poligonazing an exact cylinder to a point cloud, say to 100 size polyhedrum, then the exact cylinder is by far better.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Collision Hulls, Primitives or

Postby Spek » Sun Mar 01, 2009 5:05 am

Thanks for the info! I'll go for the convex hulls then. If I remember right, Newton simplifies the point clouds itself. That is fine for most of the objects, but stuff like tables or chairs that have 'pegs' will have their empty spaces filled. That's not a big problem for my physics, but Í also like to use the Newton raycasting functions for bullets for example. It would be a little bit strange to hit a table while the bullet is flying between the pegs. Is there a way to make the hull more precise, or should I stick with primitive box shapes in this case? I could also model the pegs and the table desk as 5 boxes apart and connect them with joints...

By the way, what version is 2.0? I have SDK 1.53 (2006).

Greetings
Spek
 
Posts: 66
Joined: Sat Oct 04, 2008 8:54 am

Re: Collision Hulls, Primitives or

Postby agi_shi » Sun Mar 01, 2009 10:07 am

Spek wrote:Thanks for the info! I'll go for the convex hulls then. If I remember right, Newton simplifies the point clouds itself.

It doesn't simplify it (well, 2.0 has some simplification tolerance, but that's different).
That is fine for most of the objects, but stuff like tables or chairs that have 'pegs' will have their empty spaces filled.

What happens is that a point cloud is just that, a cloud. You can wrap tinfoil around all the points, but you can't make the same table shape without knowing the order of the points to make triangles. Catch my drift?
That's not a big problem for my physics, but Í also like to use the Newton raycasting functions for bullets for example. It would be a little bit strange to hit a table while the bullet is flying between the pegs. Is there a way to make the hull more precise, or should I stick with primitive box shapes in this case? I could also model the pegs and the table desk as 5 boxes apart and connect them with joints...

What you want here is NewtonCreateCompoundCollision(). Basically, you make several convex hulls/primitives, put them into an array, and then create a compound collision out of them. A table could use a top and 4 legs to create a compound collision that both behaves realistically and raycasts don't just hit in open space.
By the way, what version is 2.0? I have SDK 1.53 (2006).

Greetings

2.0 is the newest. Go to the sticky (in general discussion) and grab the latest SDK. There are so many improvements and good things I recommend you do it ASAP. There are some slight usage changes, mostly in the API, but they're easily to migrate over.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 51 guests