Collision detection - strange things going on with collision detection only with the mac testing

Hey everybody,

testinig my application on win7 and linux >> works fine.

Now I had the possibiliy to check it on Mac.
The test run on:

MAC OS: Yosomite
CPU: 2x2.8GHz Quadcore
GPU: NVidia 8800GT 512MB
Display: 27Zoll FULLHD 1920x1080 Monitor
Java: 8u25

The collision detection on windows and linux works fine, but here it sucks :confused:
Clicking on Screen and check the collision on my sceneModel and return the collision point.
For this collision point I create later a sphere on model.

Here is the code of my collisions method:

    private Vector3f getCollisionPoint() {
       Vector3f v = new Vector3f();
       CollisionResults results = new CollisionResults();
       // Convert screen click to 3d position
       Vector2f click2d = inputManager.getCursorPosition();
       mx = inputManager.getCursorPosition().getX();
       my = inputManager.getCursorPosition().getY();

       Vector3f click3d = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
       Vector3f dir = cam.getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();

       // Aim the ray from the clicked spot forwards.
       Ray ray = new Ray(click3d, dir);
       // Collect intersections between ray and all nodes in results markerList.
       sceneModel.collideWith(ray, results);
       // (Print the results so we see what is going on:)
       for (int i = 0; i < results.size(); i++) {
           // (For each "hit", we know distance, impact point, geometry.)
           float dist = results.getCollision(i).getDistance();
           Vector3f pt = results.getCollision(i).getContactPoint();
           System.out.println("Distanz: " + dist + "PT: " + pt);
           String target = results.getCollision(i).getGeometry().getName();
           System.out.println("Selection #" + i + ": " + target + " at " + pt + ", " + dist + " WU away.");
       if (results.size() > 0) {
           // The closest collision point is what was truly hit:
           CollisionResult closest = results.getClosestCollision();
           v = sceneNode.worldToLocal(closest.getContactPoint(), v);
           hit = true;
       } else {
           hit = false;
       return v;

On Mac:
If I set this sphere at this point in scene it appears (with offset) above the cursor.

This offset will be become smaler with “zoom in” by the default flyCam use.
I have no idea why I find this this behavior only on mac?

Is there some os spezific thing I have to check? Or can I try something to get the problem delimit?
On windodws 7 and linux it works fine without strange behaviors.

Has anyone an idea?

For advice I would be very grateful.

EsKay :3

Mabey @zzuegg ? Seem so you had a similar problem earlier …
Do you had found the reason or a solution? :}

Hm add a syso each update for the mouse position.

check if 0,0 is att all reachable, if not you have a offset for sure.

Also check if Mouse.get* restrns the same stuff, (aka is the problem a jme one or a lwjgl one)

Thanks @Empire_Phoenix

EDIT: now I think I get what you mean :smile:
You mean I should testing with syso (System.out.println statement) the mouse position an screen >> e.c. clicking on edges and some where else. If I can’t reach the (0,0) position I have an offset ^^

I will check this but I don’t have an mac at home so I can’t test the sourcecode with debug output on a mac.
A friend can only test the build version of my app at work :confused:
Maybe I should implement some log file report.

Yeps thats what i mean.

syso + autocomplete makes a system.out.println in eclipse, guess i treid to autocomplete here XD

1 Like