What can bullet return about collisions?

inferno
Posts: 5
Joined: Wed Nov 27, 2013 1:53 am

What can bullet return about collisions?

Post by inferno »

Hello, my name is Pat and I've started using Bullet in my engine. In regards to the rigid body physics simulation and BSP it does an exceptionally good job and I have had no issues with it so far. I am using JBullet which is based off of Bullet 2.72.

I actually want to move all my projectile/point physics over to bullet as well and phase out my own BSP/collision libraries because they are so much slower. The problem is that I honestly don't know what all Bullet can do in this regard. Basically I can just give you guys a list of things that I NEED to be able to do in order to move all my physics to bullet and I'm hoping you could point me in the right direction to implement it.

Player Physics :
- I use a convex sweep test to determine if the player is on the ground by doing the sweep test down about 3 inches. If it hits something the player is standing on "something". The problem is that I need to know what the normal of the triangle is in order to determine if it's too steep to stand on. Currently you can stand on an 80 degree angle because I don't know how to get the normal of the triangle that I hit in the convex sweep test.
- I'd also like to be able to determine the "force" of an impact when the player hits something. This is simply so I can apply damage to the player if they hit a wall going 50 kmh or jump off a cliff.

Projectiles & Point Physics :
- For hitscan and projectile weapons all I need is the ability to do a line collision, and have the collision test return the normal of the triangle it hit and a reference to the object so I can tell if it's part of the static BSP or a RigidBody or a Player.
- For point physics and particles I can do them the same way as projectiles or I can do them with bullet physics objects if there a good way to do them like that.

No Colliding or "Phasing" collisions:
- I would also like to know if it's possible to have objects in the same simulation not interact. Specifically so I can have stuff like weapons that are laying on the ground and can be pushed around by explosions but NOT collide with players. I'd hate to accidentally kick a weapon across the room while trying to walk over and pick it up. I also have many other uses for such a feature involving hitscan/projectile hit detection.
- A good example of this is in the Gmod there is a tool that just makes 2 objects no longer collide with each other. That is basically what I'm looking for :P

That's about it. I really appreciate any one who bothered to read all that. Any help is much appreciated. :)
xexuxjy
Posts: 225
Joined: Wed Jan 07, 2009 11:43 am
Location: London

Re: What can bullet return about collisions?

Post by xexuxjy »

Hi Pat,

I'm pretty sure bullet will do all that you need - though using JBullet means that some of the newer things may not be available.

in terrms of your questions - the various CollisionWorld raycast methods should return information about both contact point and contact normal so you should be able to determine your movement based on that. (that should be true for your player and hitscan tests)
Not sure on best way for the the force of impact stuff - i added some fall / height based damage to a simple platform game I did and what I had there was a method of storing off the players velocity on the previous frame and comparing to the current frame, if the Y component had dropped from a large value to zero then I applied some damage to the player.

No colliding tests - 2 options here - you can make use of collision masks on your collision objects which provide a very quick way of checking if two objects should interact with each other. The other option is to have a custome overlap filter callback on the pair cache - you can then put your own rules in place for wether the 2 objects should interact.

Hope this helps.
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: What can bullet return about collisions?

Post by MaxDZ8 »

Some minor issues.
  1. Do not consider "collisions with triangles" for real. You might do that now, but in general, collision doesn't happen anymore at triangle level believe it or not. The triangle count has been growing faster than processing power on CPU and until GPU collision isn't viable, you cannot use modern graphics assets for collision;
  2. Do not use Bullet for particles, unless the particle count is extremely low. Particle simulation is often GPU-accelerated due to the typically high amount of type-coherent primitives to move;
  3. If your collisions are gameplay-dependant as you described, then you cannot use collision masks for real as they are supposed to be set only when the object is added to the world and I'm not sure how changing them would affect the simulation. I don't suggest to use collision callbacks either as the potential to disrupt instruction execution efficiency is immense. In my case, pooling the manifolds (I'm not even using ghost objects!) deferring validity filtering to a later time has proven to be very viable.
inferno
Posts: 5
Joined: Wed Nov 27, 2013 1:53 am

Re: What can bullet return about collisions?

Post by inferno »

xexuxjy wrote:Hi Pat,

I'm pretty sure bullet will do all that you need - though using JBullet means that some of the newer things may not be available.

in terrms of your questions - the various CollisionWorld raycast methods should return information about both contact point and contact normal so you should be able to determine your movement based on that. (that should be true for your player and hitscan tests)
Not sure on best way for the the force of impact stuff - i added some fall / height based damage to a simple platform game I did and what I had there was a method of storing off the players velocity on the previous frame and comparing to the current frame, if the Y component had dropped from a large value to zero then I applied some damage to the player.

No colliding tests - 2 options here - you can make use of collision masks on your collision objects which provide a very quick way of checking if two objects should interact with each other. The other option is to have a custome overlap filter callback on the pair cache - you can then put your own rules in place for wether the 2 objects should interact.

Hope this helps.
Thanks for the info. I'll begin looking into it more when I have the time.
MaxDZ8 wrote:Some minor issues.
  1. Do not consider "collisions with triangles" for real. You might do that now, but in general, collision doesn't happen anymore at triangle level believe it or not. The triangle count has been growing faster than processing power on CPU and until GPU collision isn't viable, you cannot use modern graphics assets for collision;
  2. Do not use Bullet for particles, unless the particle count is extremely low. Particle simulation is often GPU-accelerated due to the typically high amount of type-coherent primitives to move;
  3. If your collisions are gameplay-dependant as you described, then you cannot use collision masks for real as they are supposed to be set only when the object is added to the world and I'm not sure how changing them would affect the simulation. I don't suggest to use collision callbacks either as the potential to disrupt instruction execution efficiency is immense. In my case, pooling the manifolds (I'm not even using ghost objects!) deferring validity filtering to a later time has proven to be very viable.
I have separate models for collision and rendering. The collision one has a much lower triangle count. I also use primitive shapes when I can, this isn't always viable though.
How "low" are we talking about on particle counts? 10? 100? 1000?
Objects should have there collision masks set when they are instantiated and then never change if I understand the system correctly. I don't know much about collision call backs. Is there a good resource on it?