Not rounded shapes (using DemoApplication class)

Post Reply
PORRAS
Posts: 15
Joined: Tue Oct 13, 2009 2:49 pm

Not rounded shapes (using DemoApplication class)

Post by PORRAS »

Hi, all.

I'm trying to modify one of the supplied demos to create a simple application.

For now, I only want to detect collisions, so I'm using the CollisionInterfaceDemo example.

I know that shapes are drawn using OpenGL through DemoApplication member functions. But, went I try to use a simple sphere or cylinder, I get an irregular one, I mean, without rounded shapes, very polygonal, with insufficient vertices. The result is similar when I use a convex hull with rounded edges.

Could you tell me how to change this setting or behaviour?

Does the collision detection algorithm takes into account this irregular drawn shape, or performs its calculations with a more rounded one?

Attached you can see a sample picture.

Thank you very much,
Francisco
Attachments
Cylinder¿¿¿.jpg
Cylinder¿¿¿.jpg (73.06 KiB) Viewed 3366 times
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Not rounded shapes (using DemoApplication class)

Post by mako90 »

Hi,
where did you get that mesh? Looks like it's been imported from some 3D program or created by points.
Have you used btCylinderShape for creating the shape?

BR.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Not rounded shapes (using DemoApplication class)

Post by Erwin Coumans »

This is just some basic approximation for demo rendering purposes, the collision detection uses the actual rounded shape for btCylinderShape.

Code: Select all

GL_ShapeDrawer::ShapeCache*		GL_ShapeDrawer::cache(btConvexShape* shape)
{
	ShapeCache*		sc=(ShapeCache*)shape->getUserPointer();
	if(!sc)
	{
		sc=new(btAlignedAlloc(sizeof(ShapeCache),16)) ShapeCache(shape);
		sc->m_shapehull.buildHull(shape->getMargin());
		m_shapecaches.push_back(sc);
The btShapeHull utility uses a rough approximation based on NUM_UNITSPHERE_POINTS, 42. You can add additional direction for better approximation, or add your own better rendering.
Thanks,
Erwin
Post Reply