checkForCollisionSpherical for small sphere

Started by grog, April 08, 2013, 11:26:33 PM

Previous topic - Next topic

grog

I have a large mesh that I use for a level and multiple smaller meshes representing players that reside within it.  The players collide with each other and the map without issue, using a mix of ellipsoid and spherical checks.  I also have even smaller meshes that I was using for grenades, but the spherical collision detection is not working consistently for these unless I use a radius that is way too large.  Basically, using checkForCollisionSpherical with radius 0.5, sometimes the grenades collide with the walls/floor correctly, but other times they pass straight through without registering a collision.  The same things happens with ellipsoid collision at the same size. If I up the radius to 1, every collision is detected, but the result looks bad because the grenade reacts before it visually hits the wall and floats above the floor due to the too-large sphere. If I decrease the radius (say 0.3), no collisions are detected.

I tried checking the docs for some config settings that might help, but I don't see anything that obviously relates to this.  Playing with Config.collideOffset didn't seem to make a difference. I would appreciate any help/ideas.

EgonOlsen

For spherical collision detection, this might happen because the algorithm only takes start and end point into account. If the radius is small and the transition is large in comparison, neither might indicate a collision. However, this shouldn't be a problem when using ellipsoid collision detection...have to tried to subdivide the translation? How long is the translation vector? It might happen, that a rough check at the beginning of the collision detection fails if the radius is small compared to the translation's lenght, but i'm not sure...

grog

Ahh, that's good to know about the spherical algorithm. Makes sense now why it's not quite working for me.  Hmm, I might have to take another look at ellipsoid, or maybe I can subdivide the translation like you say.  Thanks much!

EgonOlsen

If sub-dividing helps, please let me know. I'll then look into a way to fix this problem in the engine itself.

grog

Ok, so I adjusted my method to subdivide the translation vector based on the radius of the sphere and make successive calls to checkForCollisionSpherical() until the entire desired movement length is reached.  So far, everything seems to be working perfectly.

EgonOlsen

I see...i'll have a look if i can find the reason for it to fail for larger translations in your case. I think it's one of the early-out optimizations that triggers where it shouldn't...

EgonOlsen

One short question: Can you post some values for your ellipsoid and your translation for a case where it doesn't work?

grog

#7
I just tried an older version of my code when I used the ellipsoid method to see if I could pull a specific movement vector when the collision didn't register.  My ellipsoid was a SimpleVector of (0.5, 0.5, 0.5), and the translation vector was (0.222294,-0.29999998,-1.4834371).  With these values, the grenade passed through a plane undetected.

Also failed for translations:
(-1.2741067,-0.29999998,-0.79161346)
(0.83904916,-0.29999998,-1.2433811)

Hope that is at all useful.  I can't really see any consistency between when it works and when it doesn't on my end.  Getting those values just consisted of randomly throwing grenades at different spots until one went through a wall, although once I found a spot all subsequent grenades do pass through undetected as well.