Difference between revisions of "Talk:LlGetBoundingBox"

From Second Life Wiki
Jump to navigation Jump to search
m (→‎isInPrim: recte: isInBoundingBox)
 
(4 intermediate revisions by 2 users not shown)
Line 10: Line 10:


Note to self (or anyone else) need to put info about functionality before 1.36 in history section (Don't have time now). -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 19:22, 25 February 2010 (UTC)
Note to self (or anyone else) need to put info about functionality before 1.36 in history section (Don't have time now). -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 19:22, 25 February 2010 (UTC)
== isInPrim ==
Hello Strife (and others who read this), could you add this function that I made today together with Chieron Tenk upon a request in an in-world scripter-group to the llGetBoundingBox page as an example, please:
<lsl>
//(bool) isInPrim - determines whether a given vector position in the region is within the borders of a cuboid, respecting the cuboid's rotation.
integer isInPrim(vector vPos)
{
        vector v1 = llGetPos() + llList2Vector(llGetBoundingBox(llGetKey()),0);
        vector v2 = llGetPos() + llList2Vector(llGetBoundingBox(llGetKey()),1);
        vPos = llGetPos() - vPos;
        vPos = llGetPos() + vPos / llGetRot();
        float fTemp;
        if (v1.x > v2.x)
        {
            fTemp = v2.x;
            v2.x = v1.x;
            v1.x = fTemp;
        }
        if (v1.y > v2.y)
        {
            fTemp = v2.y;
            v2.y = v1.y;
            v1.y = fTemp;
        }
        if (v1.z > v2.z)
        {
            fTemp = v2.z;
            v2.z = v1.z;
            v1.z = fTemp;
        }
        if (vPos.x < v1.x)
        {
            return FALSE;
        }
        if (vPos.y < v1.y)
        {
            return FALSE;
        }
        if (vPos.z < v1.z)
        {
            return FALSE;
        }
        if (vPos.x > v2.x)
        {
            return FALSE;
        }
        if (vPos.y > v2.y)
        {
            return FALSE;
        }
        if (vPos.z > v2.z)
        {
            return FALSE;
        }
        return TRUE;
}</lsl>
tyvm
--[[User:MartinRJ Fayray|MartinRJ Fayray]] 18:09, 15 January 2013 (PST)
:I have posted it but I've made some minor changes to it. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 20:54, 15 January 2013 (PST)
I looked at this earlier too and didn't have time to test, but I thought that min was all negative and max all positive, which would eliminate the need for swapping... If so then you could use subtractions and test < 0.0 on all six at once, rather than the extra references to min and max. also I'm pretty sure the correct localization is ''(vPos - llGetPos()) / llGetRot()'' (you want to localize to the detection position not the text position, otherwise it'll be invervted and may fail on non centered roots. should probably be secured so it gets root pos and rot too.<br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 17:02, 16 January 2013 (PST)

Latest revision as of 17:02, 16 January 2013

I did some tests for a reliable "avatar out of sim" check, trying to find a way around the usual cache time on things like llKey2Name. llGetBoundingBox reports an empty list if the avatar is out of cache (as expected and described on LSL Wiki). But surprisingly, it reports <-0.100000, -0.100000, -0.100000> <0.100000, 0.100000, 0.100000> for an avatar out of sim, but still within the usual cache period. Is this "official", reliable behaviour? --Tali Rosca 23:08, 4 February 2009 (UTC)

"The bounding box of an avatar sitting on an object includes that object."

They were talking about changing this (saw it somewhere on jira... or maybe I misread that jira). -- Strife (talk|contribs) 04:07, 26 January 2010 (UTC)

Hi, yes, I filed SVC-5276 for confirmation. Falcon changed it that way on purpose, attachments get new boxes and avatars keep the old ones. --Cerise Sorbet 04:47, 26 January 2010 (UTC)

History & SVC-1174

Note to self (or anyone else) need to put info about functionality before 1.36 in history section (Don't have time now). -- Strife (talk|contribs) 19:22, 25 February 2010 (UTC)

isInPrim

Hello Strife (and others who read this), could you add this function that I made today together with Chieron Tenk upon a request in an in-world scripter-group to the llGetBoundingBox page as an example, please:

<lsl> //(bool) isInPrim - determines whether a given vector position in the region is within the borders of a cuboid, respecting the cuboid's rotation. integer isInPrim(vector vPos) {

       vector v1 = llGetPos() + llList2Vector(llGetBoundingBox(llGetKey()),0);
       vector v2 = llGetPos() + llList2Vector(llGetBoundingBox(llGetKey()),1);
       vPos = llGetPos() - vPos;
       vPos = llGetPos() + vPos / llGetRot();
       float fTemp;
       if (v1.x > v2.x)
       {
           fTemp = v2.x;
           v2.x = v1.x;
           v1.x = fTemp;
       }
       if (v1.y > v2.y)
       {
           fTemp = v2.y;
           v2.y = v1.y;
           v1.y = fTemp;
       }
       if (v1.z > v2.z)
       {
           fTemp = v2.z;
           v2.z = v1.z;
           v1.z = fTemp;
       }
       if (vPos.x < v1.x)
       {
           return FALSE;
       }
       if (vPos.y < v1.y)
       {
           return FALSE;
       }
       if (vPos.z < v1.z)
       {
           return FALSE;
       }
       if (vPos.x > v2.x)
       {
           return FALSE;
       }
       if (vPos.y > v2.y)
       {
           return FALSE;
       }
       if (vPos.z > v2.z)
       {
           return FALSE;
       }
       return TRUE;

}</lsl> tyvm --MartinRJ Fayray 18:09, 15 January 2013 (PST)

I have posted it but I've made some minor changes to it. -- Strife (talk|contribs) 20:54, 15 January 2013 (PST)

I looked at this earlier too and didn't have time to test, but I thought that min was all negative and max all positive, which would eliminate the need for swapping... If so then you could use subtractions and test < 0.0 on all six at once, rather than the extra references to min and max. also I'm pretty sure the correct localization is (vPos - llGetPos()) / llGetRot() (you want to localize to the detection position not the text position, otherwise it'll be invervted and may fail on non centered roots. should probably be secured so it gets root pos and rot too.
-- Void (talk|contribs) 17:02, 16 January 2013 (PST)