Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

WarpPos -- llSetPos without the limits

Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2006 15:28
Recently I have discovered a method by which the 10m limit on non-physical movement, which limits speed to about 50m/s, may be avoided.

llSetPrimitiveParams, it would seem, executes each rule in the list as it comes across it. This allows you to set up a list in the form of [PRIM_POSITION,pos,PRIM_POSITION,pos, ... ,PRIM_POSITION,pos] which, when run by the server, basically causes many llSetPos calls in a very short amount of time. As far as I can tell, this is done in one frame on the server-- so there are no intermediate steps in the journey.

Here's my code. It's completely public domain. Look at it, modify it, sell it in an item, whatever. But I'll be annoyed if you scam noobs into buying it.
CODE

warpPos( vector d ) //R&D by Keknehv Psaltery, ~05/25/2006
{
if ( d.z > 768 ) //Otherwise we'll get stuck hitting the ceiling
d.z = 768;
//The number of jumps necessary
integer s = (integer)(llVecMag(d-llGetPos())/10)+1;
//Try and avoid stack/heap collisions
if ( s > 100 )
s = 100; // 1km should be plenty
//Solve '2^n=s'
integer e = (integer)( llLog( s ) / llLog( 2 ) );
list rules = [ PRIM_POSITION, d ]; //The start for the rules list
integer i;
for ( i = 0 ; i < e ; ++i ) //Start expanding the list
rules += rules;
integer r = s - (integer)llPow( 2, e );
if ( r > 0 ) //Finish it up
rules += llList2List( rules, 0, r * 2 + 1 );
llSetPrimitiveParams( rules );
}


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-- be happy! And you can, of course, modify it to allow larger distances, but beware.

The average time this function takes to execute is .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 simply call llSetPrimitiveParams with that list.

Strife Onizuka and several others took this code, smashed it, and made it faster and less memory-intensive.
UPDATE: 2007.03.18 -- added failsafe
CODE

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) );
while ( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
llSetPos(destpos);
if ( llVecDist( llGetPos(), destpos ) > .001 ) //Failsafe
while ( --jumps )
llSetPos( destpos );
}


Also, I asked a Linden about this. Here was his response [deleted unnecessary bits]
CODE

llSetPos has a 10 m limit because of how sim-sim transfers work - basically, a sim knows about objects in it's neighboring sims for a 10 m border
so if you move an object from one sim to another, it is eaiser when both sims know about it
so we have a 10 m limit
this is also the reason behidn why prims can't get any bigger than 10m
[asking what their response would be to something like WarpPos]
no, 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

Can you post Linden names on the forums? I'm not sure, so I removed them.

Well, that's all. Have fun!
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
05-27-2006 16:18
/54/8d/109523/1.html
_____________________
i've got nothing. ;)