Difference between revisions of "WarpPos"

From Second Life Wiki
Jump to navigation Jump to search
m (updated from llSetPrimitiveParams([___]); to llSetLinkPrimitiveParamsFast(LINK_ROOT, [___]); to make warping faster (no 200 milisecond delay))
(Replaced <source> with <syntaxhighlight> and 'promoted' the note to a notice box to be more visible)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
WarpPos is a method by which the 10m limit on non-physical movement can be avoided, by exploiting a misfeature in [[llSetPrimitiveParams]] in which multiple parameters of the same flag type are executed in a single server frame.
WarpPos is a method by which the 10m limit on non-physical movement can be avoided, by exploiting a misfeature in [[llSetPrimitiveParams]] in which multiple parameters of the same flag type are executed in a single server frame.
<lsl>
warpPos( vector destinationRootPosition )
{
    //R&D by Keknehv Psaltery, 05/25/2006
    //with a little poking by Strife, and a bit more
    //some more munging by Talarus Luan
    //Final cleanup by Keknehv Psaltery
    //Changed jump value to 411 (4096 ceiling) by Jesse Barnett
    // Compute the number of jumps necessary


    vector currentRootPosition = llGetRootPosition();
{{notice|{{strong|{{bigger|Note that [[llSetRegionPos]] now offers similar functionality.}}}}
You should probably use it instead of this workaround.}}


    integer jumps = (integer)(llVecDist(destinationRootPosition, currentRootPosition) / 10.0) + 1;
<syntaxhighlight lang="lsl2">
warpPos( vector destpos )
{  //R&D by Keknehv Psaltery, 05/25/2006
    //with a little poking by Strife, and a bit more
    //some more munging by Talarus Luan
    //Final cleanup by Keknehv Psaltery
    //Changed jump value to 411 (4096 ceiling) by Jesse Barnett
    // Compute the number of jumps necessary
    integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
    // Try and avoid stack/heap collisions
    if (jumps > 411)
        jumps = 411;
    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) );
    if ( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
        while ( --jumps )
            llSetPos( destpos );
}
</syntaxhighlight>


    // Try and avoid stack/heap collisions
{{Box|1=Quote: [http://forums-archive.secondlife.com/54/8d/109523/1.html warpPos -- [[llSetPos]] without the limits] ~~ {{User|Keknehv Psaltery}}|2=
    if (jumps > 411)
        jumps = 411;
 
    // The start for the rules list
    list rules = [ PRIM_POSITION, destinationRootPosition ];
 
    integer count = 1;
 
    while ( ( count = count << 1 ) < jumps)
        rules = (rules=[]) + rules + rules;// should tighten memory use.
 
    llSetLinkPrimitiveParamsFast(LINK_ROOT,
        rules + llList2List( rules, (count - jumps) << 1, count) );
 
    //Failsafe
    currentRootPosition = llGetRootPosition();
    if ( llVecDist( currentRootPosition, destinationRootPosition ) > .001 )
        while ( --jumps )
            llSetLinkPrimitiveParamsFast(LINK_ROOT, [PRIM_POSITION, destinationRootPosition] );
}
</lsl>
 
{{Box|1=Quote: [http://forums-archive.secondlife.com/54/8d/109523/1.html warpPos -- llSetPos without the limits] ~~ {{User|Keknehv Psaltery}}|2=
A few observations:<br/>
A few observations:<br/>
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.<br/>
[[Region|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.<br/>
...<br/>
...<br/>
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.<br/>
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.<br/>
...<br/>
...<br/>
a Linden ... response ... go ahead and find a workaround - I'd love to see it, I'm sure it is usefull, but it might not work very well across sim borders
a Linden ... response ... go ahead and find a workaround - I'd love to see it, I'm sure it is useful, but it might not work very well across sim borders
}}
}}

Latest revision as of 16:59, 1 October 2022

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

 warpPos( vector destpos ) 
 {   //R&D by Keknehv Psaltery, 05/25/2006
     //with a little poking by Strife, and a bit more
     //some more munging by Talarus Luan
     //Final cleanup by Keknehv Psaltery
     //Changed jump value to 411 (4096 ceiling) by Jesse Barnett
     // Compute the number of jumps necessary
     integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
     // Try and avoid stack/heap collisions
     if (jumps > 411)
         jumps = 411;
     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) );
     if ( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
         while ( --jumps ) 
             llSetPos( destpos );
 }

Quote: warpPos -- llSetPos without the limits ~~ Keknehv Psaltery

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 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.
...
a Linden ... response ... go ahead and find a workaround - I'd love to see it, I'm sure it is useful, but it might not work very well across sim borders