Author Topic: strange ray casting behaviour  (Read 5018 times)

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
strange ray casting behaviour
« on: May 05, 2007, 04:18:59 pm »
hello,

i'm experiencing some problems with ray casting:

Code: [Select]
       
        Config.collideSectorOffset = Object3D.COLLISION_NONE;
        Config.collideOffset = Float.MAX_VALUE;

        int objectId = world.checkCollision(topCenter, DOWN, Float.MAX_VALUE);
        if (objectId == Object3D.NO_OBJECT) {
            return NO_GROUND;
        }
        Object3D object = world.getObject(objectId);
        float distance = object.calcMinDistance(topCenter, DOWN, Float.MAX_VALUE);
        assert (distance != Object3D.COLLISION_NONE);

surprisingly the assertion above fails  ??? is it a configuration issue or ? i suspected a rounding error so i tried second part Object3D.calcMinDistance from a little bit higher location but the result is the same  :-\

DOWN is a normalized vector pointing downwards: new SimpleVector(0, 1, 0);

any ideas ?
thx

r a f t

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strange ray casting behaviour
« Reply #1 on: May 05, 2007, 05:39:01 pm »
Have you tried it with a breakIfLarger-value below MAX_VALUE? The value will be added to some other values so this may lead to some overflow? Maybe it works with the other method, i.e.
Code: [Select]
float distance = object.calcMinDistance(topCenter, DOWN);

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: strange ray casting behaviour
« Reply #2 on: May 05, 2007, 05:55:18 pm »
unfortunately doesnt work either  :-\
if you wish i may send a test case

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: strange ray casting behaviour
« Reply #3 on: May 05, 2007, 06:07:09 pm »
i've visually inspected the situaution. indeed in this case object.calcMinDistance(topCenter, DOWN) returns a true value, problem is world.checkCollision(topCenter, DOWN, Float.MAX_VALUE) should return Object3D.NO_OBJECT but it doesnt

in the top view below, the small cube is placed at where the ray is casted

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strange ray casting behaviour
« Reply #4 on: May 05, 2007, 06:58:56 pm »
Have you tried World.checkCollision with another value than MAX_VALUE? I don't think that MAX_VALUE is a good idea in general. If that doesn't help, a test case would be great.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: strange ray casting behaviour
« Reply #5 on: May 05, 2007, 07:16:40 pm »
yeap, it did help, thx  :) so it's kind of summation overflow..
what about Config.collideOffset, is it also unsafe to set it to MAX_VALUE ?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: strange ray casting behaviour
« Reply #6 on: May 05, 2007, 07:29:08 pm »
I'm not sure, but i wouldn't set anything to MAX_VALUE.

Offline raft

  • quad
  • ******
  • Posts: 1993
    • View Profile
    • http://www.aptalkarga.com
Re: strange ray casting behaviour
« Reply #7 on: May 05, 2007, 07:56:13 pm »
ok, got the point