Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Explosion
PostPosted: Mon May 31, 2010 12:16 pm 
Offline

Joined: Tue Sep 26, 2006 1:10 pm
Posts: 79
Hi,

I'm wondering about explosion effects and their implementation. I found this thread (http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=2683&hilit=explosion) about the topic but I'd still like to bring this up again.
How do you guys do explosions?
Here is a way I thought about:
1. Find all affected objects, for example by using a ghostshape
2. Trace rays from the center of the explosion to 1 or many sample points of the affected objects, if the ray hits a static/kinematic object the corresponding sample is not affected by the explosion

That way you have basic occlusion and by using a few samples per object (10 or so?) you could have effects like stuff spinning because it was hit (only) at a corner.

What do you think?


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Mon May 31, 2010 2:33 pm 
Offline

Joined: Fri May 30, 2008 2:51 am
Posts: 508
Location: Ossining, New York
Ah I remember that thread... good times... I still haven't implemented explosions in my game but they're on the todo list, will probably do it by the end of summer.

The problem I see with using a ghost shape (as opposed to a direct collision query which is slower) is that it has to exist in the scene for a while before the explosion. So if you know there's going to be an explosion at a particular point some frames in advance then that's OK. But for an instantaneous explosion I don't know if it would work. Erwin?


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Tue Jun 01, 2010 1:35 pm 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 456
sparkprime wrote:
The problem I see with using a ghost shape (as opposed to a direct collision query which is slower) is that it has to exist in the scene for a while before the explosion. So if you know there's going to be an explosion at a particular point some frames in advance then that's OK. But for an instantaneous explosion I don't know if it would work.

I, in an old post, wrote:
What is the difference between using a ghostObject/pairCachingGhostObject and using aabbTest/contactTest queries?
(I suppose that ghost objects have their manifold points refreshed automatically every physic frame by Bullet, even if the user don't need to use them that often, and contact queries must be used "on the fly". Is it correct?)

Erwin, as an answer, wrote:
The most important difference is that aabbTest/contactTest has to calculate the overlapping AABB's and contact information from scratch, while the btGhostObject approach is incremental (it only computes changes). So if there are a lot of objects in the world, and you can keep a btGhostObject in a given location for a longer period of time, it could be more efficient. In other words, it doesn't make sense to insert a btGhostObject only a single frame, or moving it around a lot, in that case a aabbTest/contactTest is more suitable.

The difference might be not so big anymore, because Bullet uses the btDbvtBroadphase for a fast O(log n) search. Also the btAxisSweep3 uses this optional dynamic btDbvt acceleration stucture by default (as long as you don't disable the 'disableRaycastAccelerator')


So probably we can use aabbTest/contactTest queries instead of ghost objects.


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Wed Jun 02, 2010 9:58 am 
Offline

Joined: Tue Sep 26, 2006 1:10 pm
Posts: 79
Flix wrote:
So probably we can use aabbTest/contactTest queries instead of ghost objects.

Sounds good. But what exactly do those aabbTest/contactTest queries mean? Is there an interface for them or do you implement them yourself?


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Thu Jun 03, 2010 10:27 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 456
B_old wrote:
But what exactly do those aabbTest/contactTest queries mean? Is there an interface for them or do you implement them yourself?


Please read this post for further info (I didn't try it myself at the moment):
http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=5147&p=18791&hilit=contactTest#p18791


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Wed Jun 09, 2010 7:33 am 
Offline

Joined: Tue Sep 26, 2006 1:10 pm
Posts: 79
Thanks for the link.
But what do you do if the radius of your explosion can be arbitrary?


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Thu Jun 10, 2010 10:07 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 456
B_old wrote:
But what do you do if the radius of your explosion can be arbitrary?


Why you're asking it ?
If you want to use a contact test, but don't want to create a different collision shape each time, you can probaly use setLocalScaling() many times on the same sphere collision shape.

P.S. As I wrote before, I've never used the "contactTest" feature myself (at the moment), but I've found another post about it here: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4424&p=17423&hilit=contactTest#p17423, and I've discovered that it's used in the Bullet "collisionInterfaceDemo" too.


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Thu Jun 10, 2010 11:35 am 
Offline

Joined: Tue Sep 26, 2006 1:10 pm
Posts: 79
Flix wrote:
Why you're asking it ?
If you want to use a contact test, but don't want to create a different collision shape each time, you can probaly use setLocalScaling() many times on the same sphere collision shape.

I'm asking because I wasn't aware of the setLocalScaling() method.
I'll have to find some more info on this, because right now I'm wondering if this can be used to only have 1 instance of every CollisionShape. Right now I have a CollisionShape for every scale I use.

Thanks for the answers and links, they are very helpful for me!


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Fri Jun 11, 2010 12:10 am 
Offline

Joined: Fri May 30, 2008 2:51 am
Posts: 508
Location: Ossining, New York
You can create a sphere on the stack, no need to worry about it.


Top
 Profile  
 
 Post subject: Re: Explosion
PostPosted: Fri Jun 11, 2010 11:55 am 
Offline

Joined: Tue Sep 26, 2006 1:10 pm
Posts: 79
sparkprime wrote:
You can create a sphere on the stack, no need to worry about it.

Somehow that never occurred to me, but it sounds like a good solution.

Do you know whether the callback for testCollision() will provide all contact-points with a certain object grouped together? In other words, if I receive a contact-point for one object and then for another, can I assume that no other contact-points for the first object will follow?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 14 guests


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

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group