Jump to content
animats

Where did this sit adjustment come from?

Recommended Posts

Posted (edited)
UpdateSitTarget(){
    SitPos=DefPos+AnimPos+AviPos;
    SitRot=llEuler2Rot(DefRot+AnimRot+AviRot);
    llSitTarget(SitPos,SitRot);
    if(agent){
        vector size = llGetAgentSize(agent);
        if(size){
            rotation localrot = ZERO_ROTATION;
            vector localpos = ZERO_VECTOR;
            if(llGetLinkNumber() > 1){
                localrot = llGetLocalRot();
                localpos = llGetLocalPos();
            }
            integer linkNum = llGetNumberOfPrims();
            do{
                if(agent == llGetLinkKey( linkNum )){
                    float fAdjust = ((((0.008906*size.z) + -0.049831)*size.z) + 0.088967)*size.z;
                    llSetLinkPrimitiveParamsFast(linkNum,
                    [PRIM_POS_LOCAL, (SitPos+<0.0, 0.0, 0.4>-(llRot2Up(SitRot)*fAdjust))*localrot+localpos,PRIM_ROT_LOCAL, SitRot * localrot]);
                    jump end;
                }
            }while( --linkNum );
        }
        else{
            llUnSit(agent);
        }
    }
    @end;
}

This is a piece of code from a chair's sit script. After an avatar sits, an adjustment is performed based on the avatar's height to put the feet on the ground. The adjustment applied is

float fAdjust = ((((0.008906*size.z) + -0.049831)*size.z) + 0.088967)*size.z;

which is a cubic curve driven by size.z. It's basically 9% of size.z plus some additional terms. This suggests that someone collected data on avatars and fit a curve to the data. Anyone know where those numbers came from, and if that formula is any good?

Edited by animats

Share this post


Link to post
Share on other sites

I don't have time now to go back through notes that I took several years ago, but you can start down your own trail by looking at the discussion on llGetAgentSize in the LSL wiki at http://wiki.secondlife.com/wiki/Talk:LlGetAgentSize .  IIRC, that's where I started when I was curious about the same thing.  I just don't recall right now where the trail went from there.

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, Mollymews said:

Strife Onizuka.  a LSL legend from back in the day

it can be seen here in his UpdateSitTarget function:  http://wiki.secondlife.com/wiki/LlSitTarget

 

In fact, Strife was summarizing and simplifying a whole long effort by a bunch of scripters to reverse-engineer where the avatar ended up for any given sit target. But Strife's original simplification wasn't a cubic equation at all. If I recall correctly, it was @Talarus Luan who arrived at that more precise estimate. Reading the history on that wiki page, you can see some of the later calculations unfold; from that discussion it appears to start with a number from Escort Defarge, but at least as I recall, it went back further, originating with Lex Neva -- as so many things did back then -- and LearJeff Innis who pulled together a tidy "Easy Sit Target Positioner" script. (I even did a little curve-fitting myself at one point.)

  • Thanks 2

Share this post


Link to post
Share on other sites
Posted (edited)
7 minutes ago, Qie Niangao said:

i see that reference in the code now that you point it out

Lex Neva woo!

edit add: i sorta remembered Lex  Neva winning an award when LL used to do that.  So I looked it up: http://wiki.secondlife.com/wiki/Linden_Lab_Innovation_Awards

edit more: With all the cuddles that the latest Linden team want to give out these days then they may be could look at giving out Hippos again. 

I nominate Rolig Loon and Whirly Fizzle and Lindal Kidd for services to the Forums, for patient perseverance  answering the same questions over and over with kindnesss and tolerance :)

 

 

Edited by Mollymews
  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...