Bounding sphere collision with mesh?

I see the engine supports basic collision using bounding box/sphere of models. Is there a way to use a bounding sphere to test collision against a more complicated shape such a mesh ? I want to get an accurate collision of when the sphere touches the any area of the geometry not just the bounding box/sphere.

I looked through the tutorials on the sdk but it only shows box/sphere. The wiki has this topic but it’s down :frowning:

Not without involving the physics engine… and even then there will be limitations on the type of physics object for the mesh side.

Actually, I think I might have implemented bounding sphere to mesh collision. You can try it.

@pspeed Do you have a link to any examples ?

Currently I have resorted to using a ray cast only collision detection system to simulate my physics. I’m just having to many issues with the bullet library. However this method sometimes fails when used on complicated shapes.

What happens when you try to collideWith() using a bounding sphere?

I’ve been using intersects instead of collide with. I’m working directly with the geometry instead of nodes.

Example code

public boolean intersects(Geometry geometry){
   if (gameManager.getGeometry("Cube1").getModelBound().intersects(geometry.getModelBound())) {
       return true;
   } else {
       return false;


Even if I create sphere and add it to the node then test it against the model bounds it by default creates a bounding box and uses that for detection. I’ll try playing with collideWith later and see what I come up with.

Well, this will obviously never intersect the actual mesh because it never involves the actual mesh.

So, yeah, if you want mesh collision then you should at least collide with something with a mesh involved.

this works but uses the box bounds.

public boolean intersects(Spatial spatial){
   if (gameManager.physicsManager.collisionNode.getWorldBound().intersects(spatial.getWorldBound())) {
       return true;
   } else {
       return false;


The geometry.getMesh also only has a function for returning a bounding box.

…well of course it is.

“This code I have that is specifically using the bounds is only using the bounds”

Yes… but I don’t understand why you are stuck on bounding boxes when you don’t want to use bounding boxes.

Why are you not just using collideWith() which would actually collide with the mesh… since you seem to want to collide with the mesh.

I was using the collidewith originally and it was always returning a false positive that’s when I realized I was using the it on the spatials world bounds and not the geometry bounds. I changed it the geometry and it worked.