Checking collisions with Rays doesn't take the ray length into account?

Checking collisions with Rays doesn’t take the ray length into account? I used ridiculously small ray to check for collisions in the proximity and I get results that are very far (distance). Of course I can filter them out, but this ray casting also slows my application down to a crawling speeds. And one thing I suspect that causes this is that the ray length perhaps isn’t taken into account. I’m not an expert on this, I don’t know does it make any difference at all to shoot smaller rays performance-wise…

What rays are you talking about? jME collision or bullet?

JME ones I think:

com.jme3.math.Ray ray = new com.jme3.math.Ray(start, start.subtract(inputRay.end.x, 0.25f, inputRay.end.y).normalizeLocal());
CollisionResults results = new CollisionResults();
((Node) world.getWorld().getChild(“Map”)).getChild(“Terrain”).collideWith(ray, results);

It doesn’t but effectively that wouldn’t do much. Although you see that the object is far away the engine doesn’t without looping through all objects and checking the bounding box of each at least.

I was prepared for that kind of answer. I think I can work around this. I’m trying to implement GDX-AI AI solution and it wants to shoot rays all over (Steering). I have just basically 2D tilemap and I can easily ask for location of walls etc. Even other creature locations for collision checking.

Yep. Most games actually check the locations first and then do ray tests from strategic positions (e.g. shoulders, feet, head) to check for occlusion.

The limit should be taken into account but it may only be done at the bounding shape level, I don’t remember. I have used it to limit my collisions before, though. I can’t recall the exact situation.

Perhaps my memory is bad or your scene has messed up bounding volumes.

Best way to visually view the bounding volumes is to save the scene and open it in the JME editor? It shows the blue box around the model, that is the bounding volume, right?

Oh, and I use BatchNodes, is that the problem… It creates a huge bounding volume in which my creatures dwell…?

Yep. That’s probably it. You shouldn’t batch really big scenes all together. Some intelligent partitioning is necessary for best picking performance.

I do partition them, 8x8 tile pages. Our maps are fairly small, 144x144 I think is max. I partition walls, roofs and floors separately, but indeed the walls might form bounding volumes that span across corridors…