Does ray cast support collision on boundingbox?

Hi again

As i know jme ray cast check collision on mesh level but in my case checking on BoundVolume is enough for me.

does it support checking on BoundVolume of my spatial? (if not what do you think about adding this feature to it ?) or i should add an invisible box geometry on my model and do raycast on that box geom ?

From https://davidb.github.io/sandbox_wiki_jme/jme3/advanced/collision_and_intersection.html

An important restriction is that you can only collide geometry vs bounding volumes or rays. (This means for example that a must be of Type Node or Geometry and b respectively of Type BoundingBox, BoundingSphere or Ray.)

So I don’t believe that you can do a ray cast against a bounding volume.

Edit: You could also just try to do the collision. Worse case you’ll get an exception.

1 Like

Actually bounding volume vs. ray collisions are supported. It is only geometry vs. geometry collisions which are not supported.

1 Like

The code supports it at the BoundingVolume + ray level but if you mean can you make spatial.collideWith() just consider bounding volumes, then no. You will have to code that yourself by traversing the scene graph.

Edit: do note that collideWith() is already considering the bounding volume… it just then goes on to also check the mesh. So I suppose you could create your own Mesh subclass that didn’t do anything on the collideWith() but check bounding volume and then only use your Mesh instead of JMEs. Probably easier to just implement your own custom collision traversal.

2 Likes