# Physics Simulation Forum

 All times are UTC

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: dilating/expanding a shape in a single directionPosted: Tue Apr 10, 2012 2:31 pm

Joined: Fri Apr 18, 2008 2:20 pm
Posts: 154
Hi,

I am not sure how I could solve the following problem.

I have two shapes:
- a box shape
- a convex decomposition shape (using ConvexBuilder)

Basically, I want to test wether the box shape (shown in blue) collide with the convex decomposition shape (shown in black below) + some dilatation in front of the object (shown in red).

I don't need the collision points or any information other than a boolean (collide or not).

I am not sure how I can handle this. I thought I could use btCollisionWorld::convexSweepTest(), however, this method does perform the test on the whole world, not between two shapes.

I have also tried to find a solution using btGjkPairDetector::getClosestPoints(), but I couldn't find any way to achieve this.

Any help would be appreciated !

Thanks.
Greg

Last edited by gjaegy on Thu Apr 12, 2012 6:34 am, edited 1 time in total.

Top

 Posted: Wed Apr 11, 2012 12:53 pm

Joined: Fri Apr 18, 2008 2:20 pm
Posts: 154
Maybe there is no way to achieve this ?

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Thu Apr 12, 2012 10:20 am

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 347
gjaegy wrote:
I want to test wether the box shape (shown in blue) collide with the convex decomposition shape (shown in black below) + some dilatation in front of the object (shown in red).
I don't need the collision points or any information other than a boolean (collide or not).

I've never used btCollisionWorld::convexSweepTest() so far, but I think it can probably be customized (with collision masks or custom 'needsCollision' like methods) to reduce the perfomance penalty of testing against the whole world. The problem is that your shape is NOT convex, so I don't think you can't use this method with compound shapes.

You can use btCollisionWorld::contactPairTest:
Code:
///contactTest performs a discrete collision test between two collision objects and calls the resultCallback if overlap if detected.
///it reports one or more contact points (including the one with deepest penetration)
void   btCollisionWorld::contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback);
It should be possible to create the 'moved' btCollisionObject on the stack easily with just its btCollisionShape and a world transform (it doesn't need to be added to the world).
The problem in this case is that it will work in the case of the image you've attached, but in the general case it won't work as expected, because you need an 'enlarged' collision shape of the plane to do the test, and I don't think it's easy to create it on the fly (you could try scaling (a 'static' copy of the) the btCompoundShape and adjust its position accordingly, but I don't think that btCompoundShape::setLocalScaling(...) is reliable enough...(I usually avoid using it)).

So in short I think a good solution to your problem would be something like a btCollisionWorld::compoundShapeSweepPairTest(), but it does not exist in Bullet as far as I know

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Thu Apr 12, 2012 2:07 pm

Joined: Fri Apr 18, 2008 2:20 pm
Posts: 154
Flix,

thanks a lot for your answer, really appreciated (I mean, the fact that you've answered, not your answer saying there is no solution ).

I guess I will have to let my customer know, there is no way to achieve what he asks for

Thanks once again.

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Sat Apr 14, 2012 8:58 am

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 347
gjaegy wrote:
there is no way to achieve what he asks for
Still, if the sweep-test can be replaced by a collision test with a constant scaled version of the plane (i.e. the enlargement is the same at each test) I would try creating (and caching) a scaled version of the plane (better doing that manually, without using btCompoundShape::setLocalScaling(...): also using an accurate "ad-hoc" sweep-test-like shape would be better) and using btCollisionWorld::contactPairTest(...).
If this is not the case you could approximate the plane shape with a convex shape and use a proper btCollisionWorld::convexSweepTest().

However it all depends on the program you're making .

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Mon Apr 16, 2012 6:46 am

Joined: Fri Apr 18, 2008 2:20 pm
Posts: 154
I forgot to mention that the dilatation is in the direction of the aircraft move... Hence fully dynamic, not sure I can affort rebuilding the convex shape decomposition process each frame...

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Wed Apr 18, 2012 1:12 pm

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 347
gjaegy wrote:
I forgot to mention that the dilatation is in the direction of the aircraft move... Hence fully dynamic, not sure I can affort rebuilding the convex shape decomposition process each frame...
No, you shouldn't do that... anyway if the dilatation is constant at each simulation step (but I guess it should depend on the plane speed) you could reuse the same dilatated shape, position it correctly through a new btRigidBody (not added to the world, it can be cached or built on the stack each time) and perform a contactPairTest between the body and the blue box in your image.

Alternatively (if the dilatation is not constant) you can perform multiple convex sweep tests each step (one per each child shape of your plane compound shape) and get an accurate result.
However it would be much easier and fast, to perform a single convex sweep test with the convex hull shape of the plane (a btConvexHullShape made with all the vertices of the plane mesh),even if the result shouldn't be so accurate.

Top

 Post subject: Re: dilating/expanding a shape in a single directionPosted: Wed Apr 18, 2012 1:29 pm

Joined: Fri Apr 18, 2008 2:20 pm
Posts: 154
Yes, the dilatation changes according to the speed of the aircraft.

Interesting Flix, thanks for that !

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ BULLET PHYSICS LIBRARY USERS    General Bullet Physics Support and Feedback    Release Announcements    Applications, Games, Demos or Movies using Bullet PHYSICS AUTHORING TOOLS, SERIALIZATION AND STANDARDS    Physics authoring tools, serialization, standards and related topics RESEARCH AND DEVELOPMENT IN COLLISION DETECTION & PHYSICS. Don't post Bullet support questions here!    Research and development discussion about Collision Detection and Physics Simulation    Links, Papers, Libraries, Demos, Movies, Comparisons       Non-technical forum and license/patent discussion    Career Opportunities