llCastRay sort of working in mega regions

Provide feedback, criticism or praise about Kitely, or suggest new features
Post Reply
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

llCastRay sort of working in mega regions

Post by Kayaker Magic »

I needed llCastRay today, and I found one feature that doesn't work quite right.
llCastRay works perfectly in the SW corner of a mega region. (Well, I didn't try EVERYTHING there may be other issues). It can find prims everywhere else, but it cannot detect the ground when you are casting outside the SW sub-region in a mega.


Here's a script that I used to diagnose the problem: Put this in a prim, move it around 4m off the ground, it will detect the ground (UUID all zeros). Move it outside the SW sub-region and try again, it finds nothing.
Move it over a prim, it tells the UUID and location of the prim. This works everywhere!

Code: Select all

default
{
    state_entry()
    {
        llSetTimerEvent(1.0);
    }
    timer()
    {
        list hits=llCastRay(llGetPos()-<0,0,.5>,llGetPos()-<0,0,5.5>,[]);
        llOwnerSay(llList2CSV(hits));
    }
}
These users thanked the author Kayaker Magic for the post:
Dundridge Dreadlow
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

More problems with llCastRay

Post by Kayaker Magic »

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);
    }
}

Post Reply