[Opensim-dev] TimerEvent to slow, do/while faster.

Mike Higgins mike at kayaker.net
Sat Jul 21 06:59:51 UTC 2012


     So I finally got around to playing with not_at_target. As R.Gunther 
noted, timer is too slow and not_at_target is too fast.
I tried putting a sleep(0.1) in at the start of not_at_target, but the 
motion was jerky. I tried putting it in at the end, still very uneven.

Then I tried the scheme in the following code. Where it says "move your 
critter" I have 100+ lines to make the decision of where to move next, 
with vector and rotation calculations.

     What worked for me was accumulating llGetAndResetTime() until 
enough time has passed for the next move. With expected delays, checking 
for 0.05 seconds or more typically takes around twice that long, which 
is a respectable 0.1 or 10 moves a second. The movement of a single 
critter was quite smooth, so I released 10 of them. They still moved 
reasonably well! I feared that this much script activity would lag the 
sim, but my FPS barely budged. (I have a script that drops the FPS from 
56 to 30 when just one of them is running. And it is not my fault! I 
submitted it as a bug. Mantis # 0006080). Top scripts shows this 
not_at_target script up at the top, so this is not the perfect solution 
yet. But the best I've seen so far!

     I left them running overnight and by morning they had all stopped 
moving. I wondered if my llTarget call had timed out, so I put another 
call to llTarget inside not_at_target to refresh it every time. Same 
problem, they all stopped moving by the next morning. I have scripts 
with timers that have been running for months and survived server SIM 
restarts. So I put a call to llTarget inside a timer to wake them back 
up when the not_at_target stops getting calls. I just started them 
ticking, I will find out tomorrow if this keeps them going. I should 
probably report the failure of not_at_target as a bug in Open Simulator!

//not_at_target mover
float step=0.05;     //how often to move in seconds (typically takes 
twice this long)
float time=0.0;     //global to count time passed since last move

default
{
     state_entry()
     {
         llGetAndResetTime();
         llTarget(<300,300,0>,1.0);
         llSetTimerEvent(30.0);      //use timer to refresh llTarget
     } //state_entry

     timer()
     {
         llTarget(<300,300,0>,1.0);  //refresh this every 30 seconds
     } //timer

     not_at_target()
     {
         time+=llGetAndResetTime();
         if (time<step) return;      //ignore system if calls me too soon
         time=0.0;
//move your critter here. I use 
llSetLinkPrimitiveParamsFast(LINK_THIS,[...]) at the end
     } //not_at_timer

}

On 7/17/12 4:45 PM, R.Gunther wrote:
> On 2012-07-18 01:31, Justin Clark-Casey wrote:
>> If you want to increase timer resolution the current thing to do 
>> would be to change
>>
>> cmdHandlerThreadCycleSleepms = 100;
>> Intressting, then i get the question why it seems the event " 
>> not_at_target" seems to have o restriction.
> with that function i always get some sort if filled query. 
> not_at_target can fire at the same speed as do/while
> It looks like its getting faster called then processed. i think 
> "timerevent" is right now to slow and "not_at_target"
> is way to fast and seems to require lots of lsl time.
>
> The whole event triggering is sometimes tricky.
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-dev/attachments/20120720/9129e20c/attachment-0001.html>


More information about the Opensim-dev mailing list