## 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 14:41
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) );    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 borderso if you move an object from one sim to another, it is eaiser when both sims know about itso we have a 10 m limitthis 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!
_____________________
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
05-26-2006 14:58
That, is a spectacularly awsome find, and you should go down in sl history for this. I would suggest you modify the wiki under llSetPos and llSetPrimitiveParams with a note about this. Also, Whenever an arbitrary limit in SL is broken there is an outcry about how bad it is for the software, usually server side. In this case I think that it's possibly a boon for server and client workload as it requires fewer script loops and position updates to move something a long distances. Also as the position is updated all at once I think, but don't know, that it might be possible to actually jump an object over a region or regions. which of course saves load on those jumped servers. It's a possibility depending on how position updates are handled and determining what region should take handoff of the object.

I hope the Lindens take a serious look at whether or not it's causing a problem before they disable it on general principal. For instance given this method for rapid transit of objects, it might actually be possible to update the objects in a list of vendors in specific regions using the reverse engineered SL protocol that has also been posted to create an offline pathfinding algorithm maybe based on the recently open sourced roam code, and accessible via the new llHttpRequest call . Convergence is a wonderful thing!
_____________________
Rickard Roentgen
Renaissance Punk
Join date: 4 Apr 2004
Posts: 1,869
05-26-2006 15:03
also a note, if it is unreliable across borders, then a simple fix is to jump across a single sim at a time, short jump across the border, etc and so forth. Short jumps work fine for even avatars, I use them to jump from 1 meter inside a sim to 1 meter inside another in my vehicles to prevent falling out of the sky. speaking of which I need to update my vehicles with this, because of script speed and vehicle max velocity it's sometimes possible to detect an imminent border crossing (one that will happen before the script can tick again) when I'm farther than 10 meters from the border. Currently I have to loop multiple setpos in this case which slows down the transition and in general is inelegant. It would be nice to be able to jump the occasional 25 or so meters to the border in one jump.
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2006 15:05
From: Rickard Roentgen
I would suggest you modify the wiki under llSetPos and llSetPrimitiveParams with a note about this.

Yes, I did.

Oh, by the way, here's my [ugly] code that I used to test it. Say your destination on channel 2, and it will go there.

CODE
`vector home; 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 );}default{    state_entry()    {        llListen( 2, "", llGetOwner(), "" );    }    listen( integer chan, string name, key id, string msg )    {        if ( msg == "home" )        {            home = llGetPos();            return;        } else if ( msg == "gohome" )        {            warpPos( home );            return;        }        list parsed = llParseString2List( llToLower(msg), [" ",",","<",">"], [] );        if ( llGetListLength( parsed ) < 3 )            return;        warpPos ( <   llList2Float( parsed, 0 ),                        llList2Float( parsed, 1 ),                        llList2Float( parsed, 2 ) > );    }}`
_____________________
Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
05-26-2006 15:12
Goodness. I don't even know where to begin on how beautiful this is!
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
05-26-2006 15:13
Yes, definitely, a cracking find there.
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
05-26-2006 15:39
Wow, awesome.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
05-26-2006 15:41
Fabulous little hack, Keknehv. Thanks for discovering this; it'll make a few projects I've got in mind easier, and a few others I'd mothballed possible.
_____________________
Come visit the In Effect main store and cafĂ©
Drawbridge (160, 81)
Particle effects, fashion, accessories, and coffee!
On the Web at SL Exchange and SL Boutique
Kex Godel
Master Slacker
Join date: 14 Nov 2003
Posts: 869
05-26-2006 15:52
Great work; awesome find! =D
_____________________
Don't follow advice you get from signatures. =)
Join date: 23 Sep 2003
Posts: 2,708
05-26-2006 16:32
Huzzah! Awesome work.
_____________________
"Don't anticipate outcome," the man said. "Await the unfolding of events. Remain in the moment." - Konrad
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2006 17:02
Thanks for the replies everyone!

Now I just need to figure out a way to do this every week... hmmm...
_____________________
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
05-26-2006 18:58
Would this, or would this in the past, before the new restrictions, have enabled the rapid spread of grid crashing scripting objects?
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Logan Bauer
Join date: 13 Jun 2004
Posts: 2,237
05-26-2006 20:59
O_O

Keknehv, this is amazing, reopens a lot of doors I'd though closed and unlocks some that were waiting for llTeleportAgent(). Thank you!
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
05-26-2006 21:15
Would this, or would this in the past, before the new restrictions, have enabled the rapid spread of grid crashing scripting objects?
Not sure. I doubt it. With an llSetPos loop we could already have objects moving around the grid at 50m/s, which is pretty fast. If you can cross a sim in 5 seconds, the grid isn't really that big, and if someone were using just that to send nasties all over the place, it wouldn't be hard I imagine to get stuff all over the grid causing trouble before anyone would notice. So this trick doesn't seem to me to give much more than was available before, if one is trying to crash the grid.
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
05-26-2006 22:59
50m per second = 180kph or 112mph wich is decently quick, quick enugh to spawn some mindless, choped up wiki code bs sim crasher

so do you bog a system, that already doesnt perform (for most liget uses) , or add in patches to deal with it (for greif uses) ... with this workaround & the lower server cost & the much faster update, it seems to make since in the progress of lsl (to me)

btw cool stuff OP
Alan Palmerstone
Payment Info Used
Join date: 4 Jun 2004
Posts: 659
05-27-2006 00:13
This is great - I have been playing with it for a couple of hours now.

I was getting some errors saying the rules list didn't have arg#1 for PRIM_POSITION and it was throwing off the jumps. I would come up short by several jumps in some cases. I increased the +1 in the # of jumps line to compensate, but that did not always take care of it.

Since my destinations are known, I just hardcoded the list and it is working.

Thank you very much for finding and sharing this.
_____________________
Visit Parrot Island - relax on the beach, snuggle at the waterfall, ride the jetskis, make a movie and buy a pool!
Moopf Murray
Moopfmerising
Join date: 7 Jan 2004
Posts: 2,448
05-27-2006 00:47
Well this is simply fandabbydozy! Thanks for sharing it Keknehv, I can see a lot of uses for this already.
_____________________
Champie Jack
Registered User
Join date: 6 Dec 2003
Posts: 1,156
05-27-2006 00:52
I was having fun with the script when I got crazy and tried to make 8 prims all move to a new position on the other side of the sim when I unlinked the set (what was I thinking?).

Anyway, they all showed up where they were supposed to, but then I tried to send them all "home." i must have messed up somewhere because only 2 made it back "home."

Needless to say, Europa has been acting funky ever since. I found 3 of the stray prims, but I can't find the other 3. Time Dilation has been wacky, but now it's more stable (between 0.90 and 1.00). Before I found any of the stray prims, TIME Dialtion was all over the place, as low as 0.15.

Anyway, thanks for the script! I hope I can clean up europa and add some safe-guards.

I apologize to anyone who has been disturbed by my actions in Europa. I recommend that anyone who has land in the surrounding sims should delete any objects owned by me. Thanks

Champie
Zodiakos Absolute
With a a dash of lemon.
Join date: 6 Jun 2005
Posts: 282
05-27-2006 04:17
Oh...my...goodness. I already know what I'm going to use this for. XD
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-27-2006 06:12
From: Alan Palmerstone
I was getting some errors saying the rules list didn't have arg#1 for PRIM_POSITION and it was throwing off the jumps. I would come up short by several jumps in some cases. I increased the +1 in the # of jumps line to compensate, but that did not always take care of it.

Woops, that was because the demonstration that I posted wasn't quite the newest version. Sorry about that, it's fixed now.

About going home... that's really just a feature I added when testing so I could go back to my original place. So if it's not working, you should probably just double check the code.
_____________________
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-27-2006 06:17
Would this, or would this in the past, before the new restrictions, have enabled the rapid spread of grid crashing scripting objects?

Yes, as Seifert said, the same capability was there before, it's just faster now. The spread was already rapid-- the main problem with grid crashing objects is not deployment time, but payload. If they are deployed and passive, most likely no one is going to notice them until they activate.
_____________________
Vick Vargas
Registered User
Join date: 14 Feb 2006
Posts: 13
05-27-2006 07:11
I am fairly new to LSL but am really starting to get into it.

I was wondering if someone could explain the implementation / uses of this code?
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-27-2006 07:51
Well, it was bound to happen sooner or later...
Okay, the main use is instantaneous prim movement inside a sim.

Implementation:
The code is just expanding the list [PRIM_POSITION,pos] to as large as it needs to be to reach the destination. Here, I'll go step by step through the code.

CODE
`    if ( d.z > 768 )      //Otherwise we'll get stuck hitting the ceiling        d.z = 768;`
This makes sure that we don't try and go above 768m, because any calls to go above 768 get silently ignored.
CODE
`    integer s = (integer)(llVecMag(d-llGetPos())/10);`

Right here, we calculate how many 10 meter jumps it is to the destination, so we can know how big the list will need to be.
CODE
`integer e = (integer)( llLog( s ) / llLog( 2 ) );`

This finds out how many times we do rules+=rules (~squaring a list). Go back to Algebra if it doesn't make sense.
CODE
`    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;`
This makes the list get pretty close to the target size. So, if we need 40 jumps, at this point, the list will be 32 jumps.
CODE
`integer r = s - (integer)llPow( 2, e );    if ( r > 0 )                    //Finish it up        rules += llList2List( rules, 0, r * 2 + 1 );`

This calculates how many more we need to finish the list, and adds them onto it.
CODE
`    llSetPrimitiveParams( rules );`
And this, at last, sends the fully-formed rules list to the sim for execution.

In hindsight, when s is initially set, it should use llCeil or equivalent, so 45/10 will get 5 jumps instead of 4. I'll edit my posts to reflect this.
_____________________
Alan Palmerstone
Payment Info Used
Join date: 4 Jun 2004
Posts: 659
05-27-2006 10:12
From: Keknehv Psaltery
Woops, that was because the demonstration that I posted wasn't quite the newest version. Sorry about that, it's fixed now.

About going home... that's really just a feature I added when testing so I could go back to my original place. So if it's not working, you should probably just double check the code.

The change in your first script did the trick. I am not hardcoding the list anymore and it works just fine.
_____________________
Visit Parrot Island - relax on the beach, snuggle at the waterfall, ride the jetskis, make a movie and buy a pool!
Cubeos Boffin
Registered User
Join date: 18 Sep 2004
Posts: 15
05-27-2006 10:42
Great hack. Works really nicely, and I can think of many uses already.