I started noticing unexpected results from llCastRay. It seems to claim that some nearby objects are in the wrong place.
The following script demonstrates the problem. Put this sript in a small prim and wear it as a HUD on center. It should report anything up to 5 meters below your avatar. As I reported before, it fails to detect the ground unless you are in the SW corner of a mega region. But I thought it detected other things correctly, and it does not. As I walk around on things, it sometimes works, sometimes reports items being where they are not, sometimes reports nothing when you are standing on them.
I see these problems in all sub-regions of a mega, this fails in the SE corner as well.
I developed a hypothesis that it was reporting the objects as if they were not rotated. It works on objects that have a rotation of 0,0,0, or are radially symmetrical. Objects that are long and thin are "detected" by llCastRay as if they were not rotated. So it does not see them when near the ends, and sees them when flying over empty space on the sides. All the data does not match this hypothesis, there seems to be an offset as well.
At any rate, llCastRay is behaving very poorly.
After more experimenting
I got the problem to repeat with a simple prim. I made a box 2x20x0.5 meters, placed it part way in the flat ground so I could walk on and off it. Rotated it 45 degrees. When I walk around this prim, llCastRay tells me (via the script below) that I am over it when I am in a huge area around the box. It is as if llCastRay is detecting me anywhere inside a XY aligned bounding box that encloses the rotated box.
Code: Select all
default
{
state_entry()
{
llSetTimerEvent(1.0);
}
timer()
{
list hits=llCastRay(llGetPos()-<0,0,.5>,llGetPos()-<0,0,5.5>,[]);
if (llList2Integer(hits,-1)>0) //if cast ray fonund something
{
key id=llList2Key(hits,0); //get the first one
if (id==NULL_KEY)
llSetText("ground",<1,1,0>,1.0);
else
llSetText(llKey2Name(id),<0,1,0>,1.0);
}
else
llSetText("nothing",<1,0,0>,1.0);
}
}