WarpPos

From Second Life Wiki
Revision as of 12:56, 17 March 2007 by Keknehv Psaltery (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The corresponding forum thread for this can be found [here].

WarpPos is simply a method by which the 10m limit on non-physical movement can be avoided, by exploiting a glitch in llSetPrimitiveParams in which multiple parameters are executed in a single server frame.

warpPos( vector destpos ) 
{   //R&D by Keknehv Psaltery, 05/25/2006
    //with a little pokeing by Strife, and a bit more
    //some more munging by Talarus Luan
    //Final cleanup by Keknehv Psaltery
    // Compute the number of jumps necessary
    integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
    // Try and avoid stack/heap collisions
    if (jumps > 100 )
        jumps = 100;    //  1km should be plenty
    list rules = [ PRIM_POSITION, destpos ];  //The start for the rules list
    integer count = 1;
    while ( ( count = count << 1 ) < jumps)
        rules = (rules=[]) + rules + rules;   //should tighten memory use.
    llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}

A few observations: Sim crossings are perilous for AVs. Depending on connection speed and whether or not you are connected to the sim (can see it on the mini-map), it may screw up your client. However, it seems like objects, by themselves, can cross great distances. I managed to send an object 4 sims away diagonally. Further testing would help us to understand these things.

The script limits the maximum distance to 1km, in order to prevent stack/heap collisions. Still, this is 100 times what llSetPos was limited to-- and you can, of course, modify it to allow larger distances, but beware.

The average time this function takes to execute is under .2 seconds, which is barely noticeable at all, and can easily be attributed to general lag. A simple optimization for an object with a known destination might be to calculate the list beforehand, and then call llSetPrimitiveParams with that list.