Quad Ray collision

I don’t know if it’s on purpose or if it’s a bug, but if you try to do a collision check between a Quad and a Ray (with the ray pointing to the quad), the ray will always collide, regardless of the value of ray.limit.
If you want to test it, try:

    public void simpleInitApp() {
        cam.setLocation(new Vector3f(2.5f, 2.5f, 10));
        cam.lookAt(new Vector3f(2.5f, 2.5f, 0), Vector3f.UNIT_Y);
        Node scenario = new Node("Scenario");
        Geometry geoQuad = new Geometry("GeoQuad", new Quad(5, 5));
        Material matQuad = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        matQuad.setColor("Color", ColorRGBA.Blue);
        inputManager.addMapping("Check collision", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
        inputManager.addListener(new ActionListener() {
            public void onAction(String name, boolean isPressed, float tpf) {
                if (name.equals("Check collision") && !isPressed) {
                    CollisionResults results = new CollisionResults();
                    Ray ray = new Ray(cam.getLocation(), cam.getDirection());
                    ray.limit = 1;//This value makes no difference
                    scenario.collideWith(ray, results);
                    for (int i = 0; i < results.size(); i++) {
                        System.out.println("Collided with: "+results.getCollision(i).getGeometry().getName());
                    //Draw the ray to see what it looks like
                    if (rootNode.getChild("Debug Node") != null)
                        rootNode.detachChildNamed("Debug Node");
                    Node debugNode = new Node("Debug Node");
                    Geometry geoRay = new Geometry("GeoRay", 
                            new Line(ray.origin, ray.origin.add(ray.direction.mult(ray.limit))));
                    Material matRay = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
                    matRay.setColor("Color", ColorRGBA.Green);
        }, "Check collision");
        //Add crosshairs to the screen
        guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
        int renderedSize = guiFont.getCharSet().getRenderedSize();
        BitmapText crosshairs = new BitmapText(guiFont);
        crosshairs.setSize(renderedSize * 1.5f);
                (cam.getWidth() / 2f) - (crosshairs.getLineWidth() / 2f), 
                (cam.getHeight() / 2f) + (crosshairs.getLineHeight() / 2f), 0);

This doesn’t happen with boxes, even if they are very thin, so probably quads are treated in a different way.

People get confused about limit.

It is not: “don’t return me anything outside the limit”

It IS: “stop doing work if this is outside the limit”

For a plane, to know if you are outside the limit, it already had to do all of the work of colliding with the plane… so it gives you the result.

Axis-oriented box collisions are a lot different (which is what JME supports for Ray collisions)… and generally as part of the process of determining which side you hit, a limit check can be made before “all the work is done”.

Edit: bottom line, if you absolutely don’t want to see results outside the limit then you have to check yourself… which is why the collision results are nice enough to give you a distance…