secondlife / jira-archive

2 stars 0 forks source link

[BUG-225639] manually setting localpos with numeric values that worth mathematically will not place a linked object at the mathematical expected position when using llSetLinkPrimitiveParamsFast(LINK_THIS #4390

Closed sl-service-account closed 9 months ago

sl-service-account commented 6 years ago

What just happened?

I was at http://maps.secondlife.com/secondlife/Alethia%20Island/219/163/22 yesterday and was trying to place a disk on the ground using CastRay( to get land position. llCastRay has an error here which sometimes gives zero return

https://i.gyazo.com/68f8853a767e1ac3e87c28055bc02630.jpg

I gave figures yesterday that gave:

mypos as 23.80663

floor_pos as 21.58119

groundpos as 20.58119

h as 2.860211

 

when the code below was called


// code placeholder

Move_and_resize_to_floor( float me_sz)
{

     if( _llisValidFloat((string) me_sz) == 1) mist_puddle_size = me_sz; else mist_puddle_size = 10.0;

     list ray = llCastRay(llGetPos(), llGetPos() + <5, 0, -100.0>,[RC_MAX_HITS|RC_GET_ROOT_KEY, 5]);// 
if(debug)  llOwnerSay(llDumpList2String(ray,"|")); 
     if(llList2Integer(ray, -1) < 0) {llOwnerSay("Ray Cast failed."); return;}     
     vector mypos = llGetPos();
     me_v_LocalPosition = llGetLocalPos();   
     integer i=0;
     float posv =566666;
     integer position;
     integer hasanobjectboveground = 0;
     float sizevobject;
     key floor_key = NULL_KEY;
     vector floor_pos = ZERO_VECTOR;
     lslground = ZERO_VECTOR;
     hasanobjectboveground = 0;
     mypos = llGetPos();
     // Lets clean up ray to remove any of or objects assosciated with the prim
     list obj_keys = GetObjectKeyList(LINK_SET) ;
     key lkID =  llList2Key(ray, i);
     while((llListFindList(obj_keys,[lkID]) != -1) )
       {
             ray = llDeleteSubList(ray, i, (i+2));
             lkID =  llList2Key(ray, i);
        }
        i = 0;
     lslground = ZERO_VECTOR;
     do {
            key lkID =  llList2Key(ray, i);
            if(lkID==NULL_KEY/* && lslground == ZERO_VECTOR */) {
                 lslground  =  llList2Vector(ray,i+1);
                 if(debug) llOwnerSay("Got LSL Floor");
           } else if(lkID!=NULL_KEY && (floor_pos == ZERO_VECTOR && (i<=llGetListLength(ray) - 1)))              {

if(debug) llOwnerSay("lkID " +(string)lkID+" calculation"+(string)(floor_pos == ZERO_VECTOR && hasanobjectboveground == 0)+" Got into Floor"+(string) llList2Vector(ray,i+1) + "Key "+(string)llList2Vector(ray,i));
                 hasanobjectboveground = 1;  
                 floor_key = llList2Key(ray,i);
                 floor_pos = llList2Vector(ray,i+1);

             }

           i+=2;
      } while(i<=llGetListLength(ray) - 1);

     key    ground_key ;  
     vector ground_pos ;     list box;
     float sz_from_object_on_floor=0; 

      if(hasanobjectboveground != 1) {
          ground_pos = floor_pos;
      } else { 
         ground_pos = lslground;
         floor_pos = floor_pos;
      }
      if(debug) llOwnerSay("Ground:" +(string)ground_pos + ", Floor:" +(string)floor_pos); 
  //   llOwnerSay("position " +(string)position + "m ground: " + (string)ground_pos);   
     // get inverse angle
     rotation Rootrot = llGetRootRotation();
     localrot = llGetRot();
     vector localEuler = llRot2Euler(Rootrot)*RAD_TO_DEG;
     localrot = llEuler2Rot(<0.0,90.0,90.0>*DEG_TO_RAD); 
     if(debug) llOwnerSay("Ground:" +(string)ground_pos); 
     //localpos = mypos-ground_pos;
      localpos = ground_pos-mypos;
     //localpos.x = ground_pos.z-mypos.z;
     list p = llGetLinkPrimitiveParams(LINK_ROOT,[PRIM_SIZE]);
     vector sz = llList2Vector(p,0);

     //New  trig work
     float h = llSqrt((0.5*sz.y)*(0.5*sz.y)+(0.5*sz.z)*(0.5*sz.z));
     if(debug) llOwnerSay("ofset of  myself diagonal "+(string)h);
     h += (mypos.z-floor_pos.z);

     float theta = RAD_TO_DEG * Rootrot.z; 
     if(h==previous_h && theta == previous_rot) return; 
     previous_h = h;
     previous_rot = theta;
     float distance_out  =  h/llTan(180-_llmod((theta),180,0));
     float x = 180 - _llmod((RAD_TO_DEG * Rootrot.z),180,0);
     float y  = llFabs((180-(x+90)));
     float y2 = llFabs((180-(x+y)));

      h -= llSqrt((0.5*sz.y)*(0.5*sz.y)+(0.5*sz.z)*(0.5*sz.z));
     float extra_remove = llFabs(llCos(y2));//+0.53;
if(debug) {
     llOwnerSay("h: " + (string)h +", Angle : " +(string)_llmod((RAD_TO_DEG * Rootrot.z),180,0)+ ", Cos"+(string)llFabs(llCos(y2)) + ", Sin "+(string)llFabs(llSin(y2))+", tan "+(string)llFabs(llTan(y2)));
     llOwnerSay("floor thickness "+(string)sz_from_object_on_floor+", x: " + (string)x + ", y:" + (string)y + ", y2: " + (string)y2 + ", Ground:" +(string)ground_pos + " Has Floor Flag " +(string)hasanobjectboveground + ", lslground "+(string)lslground); 
     llOwnerSay("Dist: " + (string)distance_out + ", extra " + (string)extra_remove);
    llOwnerSay("Before Addition, localpos" + (string)localpos + " My pos " + (string)mypos + "onfloor " +(string) on_floor + "Floor: " + (string)(floor_pos*DEG_TO_RAD) );   
} 
     // x is z in this prim
     localpos.z  = 0;//(h+.05);
     localpos.y = -(h - 3.32025); /*-2.71669 - .4409 - 0.07192 - 0.01174-.019); */
     localpos.x = - distance_out;if(debug) llOwnerSay("localpos" + (string)localpos + " My pos " + (string)mypos + "onfloor " +(string) on_floor + "Has object above ground: " + (string)hasanobjectboveground );  
       //localpos = _llvect_yzx(localpos);
     vector RootVector = llGetPos();     // z is x in this prim 

     if(on_floor == 1) {

             llSetLinkPrimitiveParamsFast(LINK_THIS,[
             PRIM_POS_LOCAL,localpos, 
             PRIM_SIZE, <mist_puddle_size/2,.01,mist_puddle_size>
             ]);  

           llMessageLinked(LINK_SET,-6500,"-6500|"+(string)llGetKey(),"");
           current_size= 10.0;     } else {
if(debug)            llOwnerSay("localPos: " + (string)localpos);
if(debug)            llOwnerSay("localRot: " + (string)localrot);
           mist_puddle_size=2.3;
           llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL , localpos, PRIM_ROT_LOCAL, llEuler2Rot(DEG_TO_RAD*localpos)/ llGetRootRotation(),PRIM_SIZE, <mist_puddle_size/2,0.01,mist_puddle_size>]);
         //  llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POS_LOCAL, localpos/*llGetLocalPos()*localrot*/,PRIM_SIZE, <mist_puddle_size,0.01,mist_puddle_size/2>]);
          // llSleep(3);           llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_ROT_LOCAL, localrot/ llGetRootRotation()]);
           llMessageLinked(LINK_SET,-6500,"-6500|"+(string)llGetKey(),"");
           current_size = 0.1;
           expanding_or_shrinking_flag = 3; 
           on_floor = 1;

         }    
        // get boundaries        
}

This placed the link item the script was in at z height 18.29153 and not 21.3131469 which had been calculated from cast Ray

 

localpos was assigned here manually

// x is z in this prim localpos.z = 0;//(h+.05); localpos.y = -(h ) localpos.x = - distance_out;

These are all calculated in script with h as height from mypos to ground and distance as the triangular distance out . I cannot understand why this doesnt place the item at the location z = 21.3131469 when mypos.z (23.80663) - floor_pos(21.21469) = h = 2.860211.

Then using llSetLinkPrimitiveParamsFast(LINK_THIS,[ PRIM_POS_LOCAL,localpos, PRIM_SIZE, <mist_puddle_size/2,.01,mist_puddle_size> ]); 

Should place it at localpos.z as an offset from the root which it doesn't it seems to place it at a lower location on z as 18.29153

Can anyone explain please as I am pulling my hair and having to put it in braids as this makes no sense at all.

 

 

 

 

What were you doing when it happened?

I was expecting item to be at the location given

What were you expecting to happen instead?

the item was at a different location

Other information

the item should be at the mathematical place

Original Jira Fields | Field | Value | | ------------- | ------------- | | Issue | BUG-225639 | | Summary | manually setting localpos with numeric values that worth mathematically will not place a linked object at the mathematical expected position when using llSetLinkPrimitiveParamsFast(LINK_THIS | | Type | Bug | | Priority | Unset | | Status | Closed | | Resolution | Unactionable | | Reporter | VirtualKitten (virtualkitten) | | Created at | 2018-10-16T16:04:58Z | | Updated at | 2018-11-05T19:16:40Z | ``` { 'Build Id': 'unset', 'Business Unit': ['Platform'], 'Date of First Response': '2018-11-05T13:16:40.451-0600', "Is there anything you'd like to add?": 'the item should be at the mathematical place', 'ReOpened Count': 0.0, 'Severity': 'Unset', 'System': 'SL Simulator', 'Target Viewer Version': 'viewer-development', 'What just happened?': 'I was at http://maps.secondlife.com/secondlife/Alethia%20Island/219/163/22 yesterday and was trying to place a disk on the ground using CastRay( to get land position. llCastRay has an error here which sometimes gives zero return\r\n\r\n', 'What were you doing when it happened?': 'I was expecting item to be at the location given', 'What were you expecting to happen instead?': 'the item was at a different location', 'Where': 'Firestorm 5.1.7 (55786) Jul 13 2018 20:00:04 (64bit) (Firestorm-Releasex64) with Havok support\r\nRelease Notes\r\n\r\nYou are at 219.1, 163.0, 22.1 in Alethia Island located at sim8841.agni.lindenlab.com (216.82.41.17:13004)\r\nSLURL: http://maps.secondlife.com/secondlife/Alethia%20Island/219/163/22\r\n(global coordinates 129,499.0, 261,795.0, 22.1)\r\nSecond Life Server 18.09.20.519894\r\nRelease Notes\r\n\r\nCPU: Intel(R) Core(TM)2 Quad CPU Q8300 @ 2.50GHz (2520 MHz)\r\nMemory: 4095 MB\r\nOS Version: Microsoft Windows 10 64-bit (Build 17134)\r\nGraphics Card Vendor: NVIDIA Corporation\r\nGraphics Card: GeForce GTX 660/PCIe/SSE2\r\n\r\nWindows Graphics Driver Version: 23.21.13.8813\r\nOpenGL Version: 4.6.0 NVIDIA 388.13\r\n\r\nRestrainedLove API: (disabled)\r\nlibcurl Version: libcurl/7.54.1 OpenSSL/1.0.2l zlib/1.2.8 nghttp2/1.25.0\r\nJ2C Decoder Version: KDU v7.10.4\r\nAudio Driver Version: FMOD Studio 1.10.05\r\nDullahan: 1.1.1080 / CEF: 3.3325.1750.gaabe4c4 / Chromium: 65.0.3325.146\r\nLibVLC Version: 2.2.8\r\nVoice Server Version: Vivox 4.9.0002.27586\r\n\r\nSettings mode: Firestorm\r\nViewer Skin: Firestorm (Grey)\r\nWindow size: 1600x837 px\r\nFont Used: Deja Vu (96 dpi)\r\nFont Size Adjustment: 0 pt\r\nUI Scaling: 1\r\nDraw distance: 128 m\r\nBandwidth: 500 kbit/s\r\nLOD factor: 2\r\nRender quality: High-Ultra (6/7)\r\nAdvanced Lighting Model: Yes\r\nTexture memory: 512 MB (1)\r\nVFS (cache) creation time (UTC): 2018-9-16T20:48:42 \r\nBuilt with MSVC version 1800\r\nPackets Lost: 48/20,891 (0.2%)\r\nOctober 16 2018 09:03:09 SLT', } ```
sl-service-account commented 6 years ago

Mazidox Linden commented at 2018-11-05T19:16:40Z

Hi there VirtualKitten,

 

We are unable to act on this Jira as we cannot debug LSL scripts. We would recommend visiting the LSL Scripting forum to ask questions about scripting.