This project has moved and is read-only. For the latest updates, please go here.

LineSegmentGeomIntersect can make collision detection more accurate?

Mar 23, 2009 at 11:27 PM
Hi there!
Well, one of my projects is basically a bunch of bullets flying around, that means that sometimes i suffer with collision detection.
I guess i can use LineSegmentGeomIntersect to check if there is something in the way of the bullet but how can i use this information to help the collision detection?
I don't know if it's something easy to do, but nothing clear comes to my mind when i think about it...

Thank you for any help in advance!
Mar 24, 2009 at 12:07 AM
Edited Mar 24, 2009 at 12:08 AM
Hey bud
Im a bit unclear as to what you are trying to accomplish
Have them collide with other things more efficiently,
or check for collisions more efficiently?
 And could you elaborate on a situation in your game? I think i can help you out
Mar 24, 2009 at 12:23 AM
Basically i want to avoid tunneling. Like a fast bullet flying in direction of a thin wall, with LineSegmentGeomIntersect i can detect that the bullet will hit the wall, but i don't know how to tell that to the "collision detector".
Sorry, I don't have much time now but i'll try to post a sample as fast as i can...

Mar 24, 2009 at 1:26 AM
Well i believe what people do is they do not have collision response enabled.
I think it would go like this

foreach(Bullet a in Bullets)
foreach(Object b in walls)
a.Dispose( );

this would have it so that every single bullet that hits a wall will be disposed.

Are you trying to have them do something to the walls like knock stuff over?
If so then im not sure how to combat tunneling.
Mar 24, 2009 at 2:25 AM
That's the big question, how to combat tunneling.
I guess version 2.2 will solve it, but since we don't know when it'll be released i'm trying to find a "solution" myself...

Anyway, i made a project just to work on that, if i find something that helps i'll post it here, and thanks for the help!
Mar 24, 2009 at 8:32 PM
The only solutions that will combat tunneling right now are the ones described in the manual. It's really a limitation of the computer than a limitation of the physics engine. If you call Update() 1 million times in a second, this problem would not exist. :)

But... since that is not feasible in the near future, we need to have some workaround that can make the collision detection more accurate between fast moving objects. This solution is also called CCD (Continues Collision Detection) and uses time-of-impact to tell when collisions happen.
We are indeed going to implement this in FP 2.2, but it will take some time since we need some radical changes to the engine before we even can think about implementing CCD.

You could perhaps use line intersection to make tunneling happen less between bullets and thin walls. If you created a line in the bullet's path, you have the distance between the point of intersection and the bullet. If this distance is low, update the physics engine more often. I have not tried it and have no idea about the consequences, but it would not hurt to try it.
Mar 25, 2009 at 12:43 AM
Yeah you can add that to the manual, "Buy a faster computer!" hahah!

I am trying to do that line thing, the bullet "emitt" a line to see if there is somethin on the way. I check the path and i detec there is a body ahead, what should i do? What do you mean by "update the physics engine more often"? Call simulator.update more than once inside game.update?

I totally think the best solution will be implemented by you guys in version 2.2, but i can't wait! hahahah