From 9d878591c821b46704f1cd16243422e14d68e842 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 8 Jun 2012 14:29:02 +0100 Subject: *UNTESTED* added PRIM_POS_LOCAL and PRIM_ROT_LOCAL in SetPrimParams for avatars. Stopped setting position twice in normal SetPrimParams --- .../Shared/Api/Implementation/LSL_Api.cs | 52 +++++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 667aa93..d230b24 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7887,6 +7887,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } break; + case (int)ScriptBaseClass.PRIM_POS_LOCAL: + { + if (remain < 1) + return; + LSL_Vector v; + v = rules.GetVector3Item(idx++); + + SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); + if (part == null) + break; + + LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); + + v += 2 * sitOffset; + + av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); + av.SendAvatarDataToAllAgents(); + + } + break; + case (int)ScriptBaseClass.PRIM_ROTATION: { if (remain < 1) @@ -7907,6 +7928,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api av.SendAvatarDataToAllAgents(); } break; + + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + { + if (remain < 1) + return; + + LSL_Rotation r; + r = rules.GetQuaternionItem(idx++); + av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); + av.SendAvatarDataToAllAgents(); + } + break; + } } } @@ -7966,6 +8000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. + // sounds like sl bug that we need to replicate SceneObjectPart rootPart = part.ParentGroup.RootPart; SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } @@ -8335,6 +8370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { +/* if (positionChanged) { if (part.ParentGroup.RootPart == part) @@ -8352,23 +8388,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api parent.ScheduleGroupForTerseUpdate(); } } + */ } if (positionChanged) { - if (part.ParentGroup.RootPart == part) + SceneObjectGroup parentgrp = part.ParentGroup; + if (parentgrp == null) + return; + + if (parentgrp.RootPart == part) { - SceneObjectGroup parent = part.ParentGroup; + Util.FireAndForget(delegate(object x) { - parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); + parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); }); } else { part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); - SceneObjectGroup parent = part.ParentGroup; - parent.HasGroupChanged = true; - parent.ScheduleGroupForTerseUpdate(); + parentgrp.HasGroupChanged = true; + parentgrp.ScheduleGroupForTerseUpdate(); } } } -- cgit v1.1 From f0a6ec151aabbc7ee70ef3461722926c1c0c53e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 8 Jun 2012 15:27:21 +0100 Subject: *UNTESTED* let SetPrimParams for avatars parse even unsupported parameters so that if a supported one is in the middle of then it still works. --- .../Shared/Api/Implementation/LSL_Api.cs | 86 +++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d230b24..cb13855 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7843,7 +7843,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api protected void SetPrimParams(ScenePresence av, LSL_List rules) { //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. - //We only support PRIM_POSITION and PRIM_ROTATION int idx = 0; @@ -7878,7 +7877,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api v /= localRot; LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); - + v = v + 2 * sitOffset; av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); @@ -7941,6 +7940,89 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } break; + // parse rest doing nothing but number of parameters error check + case (int)ScriptBaseClass.PRIM_SIZE: + case (int)ScriptBaseClass.PRIM_MATERIAL: + case (int)ScriptBaseClass.PRIM_PHANTOM: + case (int)ScriptBaseClass.PRIM_PHYSICS: + case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + case (int)ScriptBaseClass.PRIM_NAME: + case (int)ScriptBaseClass.PRIM_DESC: + if (remain < 1) + return; + idx++; + break; + + case (int)ScriptBaseClass.PRIM_GLOW: + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + case (int)ScriptBaseClass.PRIM_TEXGEN: + if (remain < 2) + return; + idx += 2; + break; + + case (int)ScriptBaseClass.PRIM_TYPE: + if (remain < 3) + return; + code = (int)rules.GetLSLIntegerItem(idx++); + remain = rules.Length - idx; + switch (code) + { + case (int)ScriptBaseClass.PRIM_TYPE_BOX: + case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: + case (int)ScriptBaseClass.PRIM_TYPE_PRISM: + if (remain < 6) + return; + idx += 6; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: + if (remain < 5) + return; + idx += 5; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_TORUS: + case (int)ScriptBaseClass.PRIM_TYPE_TUBE: + case (int)ScriptBaseClass.PRIM_TYPE_RING: + if (remain < 11) + return; + idx += 11; + break; + + case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: + if (remain < 2) + return; + idx += 2; + break; + } + break; + + case (int)ScriptBaseClass.PRIM_COLOR: + case (int)ScriptBaseClass.PRIM_TEXT: + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + case (int)ScriptBaseClass.PRIM_OMEGA: + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) + return; + idx += 3; + break; + + case (int)ScriptBaseClass.PRIM_TEXTURE: + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: + if (remain < 5) + return; + idx += 5; + break; + + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + if (remain < 7) + return; + + idx += 7; + break; } } } -- cgit v1.1 From 22437af26af8c70c8cab3aece31cfc59595b54b4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 8 Jun 2012 15:48:46 +0100 Subject: *UNTESTED* fix PRIM_LINK_TARGET. Make it work on avatars, set any pending position change on others; don't assume m_host is in same grp that part (possible always is)... --- .../Shared/Api/Implementation/LSL_Api.cs | 44 ++++++++++++++++++---- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index cb13855..523a6ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8003,7 +8003,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXT: case (int)ScriptBaseClass.PRIM_BUMP_SHINY: case (int)ScriptBaseClass.PRIM_OMEGA: - case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) return; idx += 3; @@ -8023,6 +8022,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api idx += 7; break; + + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return; + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); + LSL_List new_rules = rules.GetSublist(idx, -1); + setLinkPrimParams((int)new_linknumber, new_rules); + return; } } } @@ -8034,6 +8041,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int idx = 0; + SceneObjectGroup parentgrp = part.ParentGroup; + bool positionChanged = false; LSL_Vector currentPosition = GetPartLocalPos(part); @@ -8073,8 +8082,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; LSL_Rotation q = rules.GetQuaternionItem(idx++); + SceneObjectPart rootPart = parentgrp.RootPart; // try to let this work as in SL... - if (part.ParentID == 0) + if (rootPart == part) { // special case: If we are root, rotate complete SOG to new rotation SetRot(part, Rot2Quaternion(q)); @@ -8083,7 +8093,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. // sounds like sl bug that we need to replicate - SceneObjectPart rootPart = part.ParentGroup.RootPart; SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); } @@ -8336,7 +8345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; string ph = rules.Data[idx++].ToString(); - m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); + parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); break; @@ -8389,7 +8398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; string temp = rules.Data[idx++].ToString(); - m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); + parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); break; @@ -8442,10 +8451,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return; + + // do a pending position change + if (positionChanged) + { + if (parentgrp == null) + return; + + if (parentgrp.RootPart == part) + { + + Util.FireAndForget(delegate(object x) + { + parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); + }); + } + else + { + part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); + parentgrp.HasGroupChanged = true; + parentgrp.ScheduleGroupForTerseUpdate(); + } + } + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); LSL_List new_rules = rules.GetSublist(idx, -1); setLinkPrimParams((int)new_linknumber, new_rules); - return; } } @@ -8475,7 +8506,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (positionChanged) { - SceneObjectGroup parentgrp = part.ParentGroup; if (parentgrp == null) return; -- cgit v1.1 From cd4994947858516f9177501499a1139f23ddd3cf Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 11 Jun 2012 22:43:35 +0100 Subject: change object drag so it applies a impulse and not a push force so it works as before my fix to impulse/forces --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8fa7880..aab6a49 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2992,10 +2992,14 @@ namespace OpenSim.Region.Framework.Scenes { if (!m_rootPart.BlockGrab) { - Vector3 llmoveforce = pos - AbsolutePosition; +/* Vector3 llmoveforce = pos - AbsolutePosition; Vector3 grabforce = llmoveforce; grabforce = (grabforce / 10) * pa.Mass; - pa.AddForce(grabforce, true); + */ + // empirically convert distance diference to a impulse + Vector3 grabforce = pos - AbsolutePosition; + grabforce = grabforce * (pa.Mass/ 10.0f); + pa.AddForce(grabforce, false); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } } -- cgit v1.1 From 24e8e5d8188dd2e8656feb5e43193e7475fa2acc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 01:26:03 +0100 Subject: *UNTESTED* extended llGet*PrimitiveParam() to support avatars. Some auxiliar code in SOP.cs --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 +++ .../Shared/Api/Implementation/LSL_Api.cs | 241 ++++++++++++++++++++- 2 files changed, 272 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a810de2..21e2878 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -519,6 +519,40 @@ namespace OpenSim.Region.Framework.Scenes } } + // returns offset position relative to root prim of object when siting + public Vector3 OffsetPositionToSOGRoot + { + get + { + if (ParentPart != null) + return ParentPart.OffsetPosition + (m_pos * ParentPart.RotationOffset); + else + return m_pos; + } + } + + public Quaternion OffsetRotationToSOGRoot + { + get + { + if (ParentPart != null) + return ParentPart.RotationOffset * Rotation; + else + return Rotation; + } + } + + public Quaternion WorldRotation + { + get + { + if (ParentPart != null) + return ParentPart.GetWorldRotation() * Rotation; + else + return Rotation; + } + } + /// /// Current velocity of the avatar. /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c3d4306..b2c21cd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8881,16 +8881,251 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); + // acording to SL wiki this must indicate a single link number or link_root or link_this. + // keep other options as before + List parts = GetLinkParts(linknumber); + List avatars = GetLinkAvatars(linknumber); LSL_List res = new LSL_List(); - foreach (var part in parts) + if (parts.Count > 0) { - LSL_List partRes = GetLinkPrimitiveParams(part, rules); - res += partRes; + foreach (var part in parts) + { + LSL_List partRes = GetLinkPrimitiveParams(part, rules); + res += partRes; + } } + if (avatars.Count > 0) + { + foreach (ScenePresence avatar in avatars) + { + LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules); + res += avaRes; + } + } + return res; + } + + public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules) + { + // avatars case + // replies as SL wiki + + LSL_List res = new LSL_List(); + int idx = 0; + while (idx < rules.Length) + { + int code = (int)rules.GetLSLIntegerItem(idx++); + int remain = rules.Length - idx; + + switch (code) + { + case (int)ScriptBaseClass.PRIM_MATERIAL: + res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); + break; + + case (int)ScriptBaseClass.PRIM_PHYSICS: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_PHANTOM: + res.Add(new LSL_Integer(0)); + break; + + case (int)ScriptBaseClass.PRIM_POSITION: + Vector3 pos = avatar.AbsolutePosition; + res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); + break; + + case (int)ScriptBaseClass.PRIM_SIZE: + // as in llGetAgentSize above + res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); + break; + + case (int)ScriptBaseClass.PRIM_ROTATION: + Quaternion rot = avatar.WorldRotation; + res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); + break; + + case (int)ScriptBaseClass.PRIM_TYPE: + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); + res.Add(new LSL_Vector(0f,1.0f,0f)); + res.Add(new LSL_Float(0.0f)); + res.Add(new LSL_Vector(0, 0, 0)); + res.Add(new LSL_Vector(1.0f,1.0f,0f)); + res.Add(new LSL_Vector(0, 0, 0)); + break; + + case (int)ScriptBaseClass.PRIM_TEXTURE: + if (remain < 1) + return res; + + int face = (int)rules.GetLSLIntegerItem(idx++); + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0.0)); + } + } + else + { + if (face >= 0 && face < 21) + { + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0.0)); + } + } + break; + + case (int)ScriptBaseClass.PRIM_COLOR: + if (remain < 1) + return res; + + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0)); + } + } + else + { + res.Add(new LSL_Vector(0,0,0)); + res.Add(new LSL_Float(0)); + } + break; + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); + } + break; + + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + int fullbright; + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); + } + break; + + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + res.Add(new LSL_Integer(0)); + res.Add(new LSL_Integer(0));// softness + res.Add(new LSL_Float(0.0f)); // gravity + res.Add(new LSL_Float(0.0f)); // friction + res.Add(new LSL_Float(0.0f)); // wind + res.Add(new LSL_Float(0.0f)); // tension + res.Add(new LSL_Vector(0f,0f,0f)); + break; + + case (int)ScriptBaseClass.PRIM_TEXGEN: + // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + } + else + { + res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); + } + break; + + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + res.Add(new LSL_Integer(0)); + res.Add(new LSL_Vector(0f,0f,0f)); + res.Add(new LSL_Float(0f)); // intensity + res.Add(new LSL_Float(0f)); // radius + res.Add(new LSL_Float(0f)); // falloff + break; + + case (int)ScriptBaseClass.PRIM_GLOW: + if (remain < 1) + return res; + face = (int)rules.GetLSLIntegerItem(idx++); + + if (face == ScriptBaseClass.ALL_SIDES) + { + for (face = 0; face < 21; face++) + { + res.Add(new LSL_Float(0f)); + } + } + else + { + res.Add(new LSL_Float(0f)); + } + break; + + case (int)ScriptBaseClass.PRIM_TEXT: + res.Add(new LSL_String("")); + res.Add(new LSL_Vector(0f,0f,0f)); + res.Add(new LSL_Float(1.0f)); + break; + case (int)ScriptBaseClass.PRIM_NAME: + res.Add(new LSL_String(avatar.Name)); + break; + case (int)ScriptBaseClass.PRIM_DESC: + res.Add(new LSL_String("")); + break; + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + Quaternion lrot = avatar.OffsetRotationToSOGRoot; + res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); + break; + case (int)ScriptBaseClass.PRIM_POS_LOCAL: + Vector3 lpos = avatar.OffsetPositionToSOGRoot; + res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); + break; + } + } return res; } -- cgit v1.1 From 5fd6f678a46de8109d7178ba788e458053e34c06 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 02:20:47 +0100 Subject: Moved auxiliar funtions of last commit from sop to lsl api since they are only used on one place each --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 34 ---------------------- .../Shared/Api/Implementation/LSL_Api.cs | 27 +++++++++++++---- 2 files changed, 22 insertions(+), 39 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 21e2878..a810de2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -519,40 +519,6 @@ namespace OpenSim.Region.Framework.Scenes } } - // returns offset position relative to root prim of object when siting - public Vector3 OffsetPositionToSOGRoot - { - get - { - if (ParentPart != null) - return ParentPart.OffsetPosition + (m_pos * ParentPart.RotationOffset); - else - return m_pos; - } - } - - public Quaternion OffsetRotationToSOGRoot - { - get - { - if (ParentPart != null) - return ParentPart.RotationOffset * Rotation; - else - return Rotation; - } - } - - public Quaternion WorldRotation - { - get - { - if (ParentPart != null) - return ParentPart.GetWorldRotation() * Rotation; - else - return Rotation; - } - } - /// /// Current velocity of the avatar. /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b2c21cd..4f6803f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8914,6 +8914,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // replies as SL wiki LSL_List res = new LSL_List(); + SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed int idx = 0; while (idx < rules.Length) { @@ -8949,7 +8950,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_ROTATION: - Quaternion rot = avatar.WorldRotation; + Quaternion rot = avatar.Rotation; + if (sitPart != null) + { + rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation + } + res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); break; @@ -9036,7 +9042,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return res; face = (int)rules.GetLSLIntegerItem(idx++); - int fullbright; if (face == ScriptBaseClass.ALL_SIDES) { for (face = 0; face < 21; face++) @@ -9110,18 +9115,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api res.Add(new LSL_Vector(0f,0f,0f)); res.Add(new LSL_Float(1.0f)); break; + case (int)ScriptBaseClass.PRIM_NAME: res.Add(new LSL_String(avatar.Name)); break; + case (int)ScriptBaseClass.PRIM_DESC: res.Add(new LSL_String("")); break; - case (int)ScriptBaseClass.PRIM_ROT_LOCAL: - Quaternion lrot = avatar.OffsetRotationToSOGRoot; + + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + Quaternion lrot = avatar.Rotation; + if (sitPart != null) + { + lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset + } res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); break; + case (int)ScriptBaseClass.PRIM_POS_LOCAL: - Vector3 lpos = avatar.OffsetPositionToSOGRoot; + Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part + if (sitPart != null) + { + lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim + } res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); break; } -- cgit v1.1 From 8b5342f613d66ac9158231494471bcc81ce9189c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 05:21:49 +0100 Subject: more changes to Get and Get primitiveparams: Let Get remove avatarheight adjust,add Get PRIM_LINK_TARGET handling, changed avatar Set positions code... --- .../Shared/Api/Implementation/LSL_Api.cs | 120 ++++++++++++++++----- 1 file changed, 94 insertions(+), 26 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 4f6803f..5760b36 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7902,11 +7902,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(200); } + // vector up using libomv (c&p from sop ) + // vector up rotated by r + private Vector3 Zrot(Quaternion r) + { + double x, y, z, m; + + m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; + if (Math.Abs(1.0 - m) > 0.000001) + { + m = 1.0 / Math.Sqrt(m); + r.X *= (float)m; + r.Y *= (float)m; + r.Z *= (float)m; + r.W *= (float)m; + } + + x = 2 * (r.X * r.Z + r.Y * r.W); + y = 2 * (-r.X * r.W + r.Y * r.Z); + z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; + + return new Vector3((float)x, (float)y, (float)z); + } + protected void SetPrimParams(ScenePresence av, LSL_List rules) { //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. int idx = 0; + SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used while (idx < rules.Length) { @@ -7916,13 +7940,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { + // a avatar is a child case (int)ScriptBaseClass.PRIM_POSITION: + case (int)ScriptBaseClass.PRIM_POS_LOCAL: { if (remain < 1) return; LSL_Vector v; v = rules.GetVector3Item(idx++); - + +/* use the sitpart SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); if (part == null) break; @@ -7937,43 +7964,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api v -= localPos; v /= localRot; +*/ + if (sitpart == null) + break; - LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); - - v = v + 2 * sitOffset; - - av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); - av.SendAvatarDataToAllAgents(); - - } - break; + Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position - case (int)ScriptBaseClass.PRIM_POS_LOCAL: - { - if (remain < 1) - return; - LSL_Vector v; - v = rules.GetVector3Item(idx++); + pos -= sitpart.OffsetPosition; // remove sit part offset - SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); - if (part == null) - break; + Quaternion rot = sitpart.RotationOffset; + pos *= Quaternion.Conjugate(rot); // removed sit part rotation - LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); - v += 2 * sitOffset; + pos += sitOffset; - av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); + av.OffsetPosition = pos; av.SendAvatarDataToAllAgents(); - } break; + case (int)ScriptBaseClass.PRIM_ROTATION: { if (remain < 1) return; - +/* LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; if (llGetLinkNumber() > 1) @@ -7986,6 +8002,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api r = rules.GetQuaternionItem(idx++); r = r * llGetRootRotation() / localRot; av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); + */ + if (sitpart == null) + break; + + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation + + Quaternion srot = sitpart.GetWorldRotation(); + rot *= Quaternion.Conjugate(srot); // removed sit part world rotation + + av.Rotation = rot; av.SendAvatarDataToAllAgents(); } break; @@ -7994,11 +8021,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (remain < 1) return; - +/* LSL_Rotation r; r = rules.GetQuaternionItem(idx++); av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); av.SendAvatarDataToAllAgents(); +*/ + if (sitpart == null) + break; + + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation + + Quaternion srot = sitpart.RotationOffset; + rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation + + av.Rotation = rot; + av.SendAvatarDataToAllAgents(); } break; @@ -8914,7 +8953,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // replies as SL wiki LSL_List res = new LSL_List(); - SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed +// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed + SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? + int idx = 0; while (idx < rules.Length) { @@ -8941,6 +8982,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: Vector3 pos = avatar.AbsolutePosition; + Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); + pos -= sitOffset; res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); break; @@ -9139,8 +9182,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim } + Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); + lpos -= lsitOffset; res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); break; + + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return res; + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); + LSL_List new_rules = rules.GetSublist(idx, -1); + + res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules); + return res; } } return res; @@ -9532,6 +9586,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api res.Add(new LSL_Float(primglow)); } break; + case (int)ScriptBaseClass.PRIM_TEXT: Color4 textColor = part.GetTextColor(); res.Add(new LSL_String(part.Text)); @@ -9540,18 +9595,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api textColor.B)); res.Add(new LSL_Float(textColor.A)); break; + case (int)ScriptBaseClass.PRIM_NAME: res.Add(new LSL_String(part.Name)); break; + case (int)ScriptBaseClass.PRIM_DESC: res.Add(new LSL_String(part.Description)); break; + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W)); break; + case (int)ScriptBaseClass.PRIM_POS_LOCAL: res.Add(new LSL_Vector(GetPartLocalPos(part))); break; + + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return res; + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); + LSL_List new_rules = rules.GetSublist(idx, -1); + LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); + res += tres; + return res; } } return res; -- cgit v1.1 From 5784b3eb31d5798f996c134f0d3433570dbee736 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 05:57:28 +0100 Subject: fix the try.. finally in SetPrimitiveParams i did mess and add one for the avatars case, so to optimize a bit 'warp' scripts. --- .../Shared/Api/Implementation/LSL_Api.cs | 344 ++++++++++----------- 1 file changed, 156 insertions(+), 188 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5760b36..ec4f62f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7932,205 +7932,193 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api int idx = 0; SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used - while (idx < rules.Length) + bool positionChanged = false; + Vector3 finalPos = Vector3.Zero; + + try { - int code = rules.GetLSLIntegerItem(idx++); + while (idx < rules.Length) + { + int code = rules.GetLSLIntegerItem(idx++); - int remain = rules.Length - idx; + int remain = rules.Length - idx; - switch (code) - { + switch (code) + { // a avatar is a child - case (int)ScriptBaseClass.PRIM_POSITION: - case (int)ScriptBaseClass.PRIM_POS_LOCAL: - { - if (remain < 1) - return; - LSL_Vector v; - v = rules.GetVector3Item(idx++); - -/* use the sitpart - SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); - if (part == null) - break; - - LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; - LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; - if (llGetLinkNumber() > 1) + case (int)ScriptBaseClass.PRIM_POSITION: + case (int)ScriptBaseClass.PRIM_POS_LOCAL: { - localRot = llGetLocalRot(); - localPos = llGetLocalPos(); - } + if (remain < 1) + return; + LSL_Vector v; + v = rules.GetVector3Item(idx++); - v -= localPos; - v /= localRot; -*/ - if (sitpart == null) - break; + if (sitpart == null) + break; - Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position + Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position - pos -= sitpart.OffsetPosition; // remove sit part offset + pos -= sitpart.OffsetPosition; // remove sit part offset - Quaternion rot = sitpart.RotationOffset; - pos *= Quaternion.Conjugate(rot); // removed sit part rotation + Quaternion rot = sitpart.RotationOffset; + pos *= Quaternion.Conjugate(rot); // removed sit part rotation - Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); + pos += sitOffset; - pos += sitOffset; + finalPos = pos; + positionChanged = true; + } + break; - av.OffsetPosition = pos; - av.SendAvatarDataToAllAgents(); - } - break; + case (int)ScriptBaseClass.PRIM_ROTATION: + { + if (remain < 1) + return; + if (sitpart == null) + break; - case (int)ScriptBaseClass.PRIM_ROTATION: - { - if (remain < 1) - return; -/* - LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; - LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; - if (llGetLinkNumber() > 1) - { - localRot = llGetLocalRot(); - localPos = llGetLocalPos(); + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation + + Quaternion srot = sitpart.GetWorldRotation(); + rot *= Quaternion.Conjugate(srot); // removed sit part world rotation + + av.Rotation = rot; + av.SendAvatarDataToAllAgents(); } + break; - LSL_Rotation r; - r = rules.GetQuaternionItem(idx++); - r = r * llGetRootRotation() / localRot; - av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); - */ - if (sitpart == null) - break; + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + { + if (remain < 1) + return; + + if (sitpart == null) + break; - LSL_Rotation r = rules.GetQuaternionItem(idx++); - Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation - - Quaternion srot = sitpart.GetWorldRotation(); - rot *= Quaternion.Conjugate(srot); // removed sit part world rotation + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation - av.Rotation = rot; - av.SendAvatarDataToAllAgents(); - } - break; + Quaternion srot = sitpart.RotationOffset; + rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation - case (int)ScriptBaseClass.PRIM_ROT_LOCAL: - { + av.Rotation = rot; + av.SendAvatarDataToAllAgents(); + } + break; + + // parse rest doing nothing but number of parameters error check + case (int)ScriptBaseClass.PRIM_SIZE: + case (int)ScriptBaseClass.PRIM_MATERIAL: + case (int)ScriptBaseClass.PRIM_PHANTOM: + case (int)ScriptBaseClass.PRIM_PHYSICS: + case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: + case (int)ScriptBaseClass.PRIM_NAME: + case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) return; -/* - LSL_Rotation r; - r = rules.GetQuaternionItem(idx++); - av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); - av.SendAvatarDataToAllAgents(); -*/ - if (sitpart == null) - break; + idx++; + break; - LSL_Rotation r = rules.GetQuaternionItem(idx++); - Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation + case (int)ScriptBaseClass.PRIM_GLOW: + case (int)ScriptBaseClass.PRIM_FULLBRIGHT: + case (int)ScriptBaseClass.PRIM_TEXGEN: + if (remain < 2) + return; + idx += 2; + break; - Quaternion srot = sitpart.RotationOffset; - rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation + case (int)ScriptBaseClass.PRIM_TYPE: + if (remain < 3) + return; + code = (int)rules.GetLSLIntegerItem(idx++); + remain = rules.Length - idx; + switch (code) + { + case (int)ScriptBaseClass.PRIM_TYPE_BOX: + case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: + case (int)ScriptBaseClass.PRIM_TYPE_PRISM: + if (remain < 6) + return; + idx += 6; + break; - av.Rotation = rot; - av.SendAvatarDataToAllAgents(); - } - break; + case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: + if (remain < 5) + return; + idx += 5; + break; - // parse rest doing nothing but number of parameters error check - case (int)ScriptBaseClass.PRIM_SIZE: - case (int)ScriptBaseClass.PRIM_MATERIAL: - case (int)ScriptBaseClass.PRIM_PHANTOM: - case (int)ScriptBaseClass.PRIM_PHYSICS: - case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: - case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: - case (int)ScriptBaseClass.PRIM_NAME: - case (int)ScriptBaseClass.PRIM_DESC: - if (remain < 1) - return; - idx++; - break; + case (int)ScriptBaseClass.PRIM_TYPE_TORUS: + case (int)ScriptBaseClass.PRIM_TYPE_TUBE: + case (int)ScriptBaseClass.PRIM_TYPE_RING: + if (remain < 11) + return; + idx += 11; + break; - case (int)ScriptBaseClass.PRIM_GLOW: - case (int)ScriptBaseClass.PRIM_FULLBRIGHT: - case (int)ScriptBaseClass.PRIM_TEXGEN: - if (remain < 2) - return; - idx += 2; - break; + case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: + if (remain < 2) + return; + idx += 2; + break; + } + break; - case (int)ScriptBaseClass.PRIM_TYPE: - if (remain < 3) - return; - code = (int)rules.GetLSLIntegerItem(idx++); - remain = rules.Length - idx; - switch (code) - { - case (int)ScriptBaseClass.PRIM_TYPE_BOX: - case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: - case (int)ScriptBaseClass.PRIM_TYPE_PRISM: - if (remain < 6) - return; - idx += 6; - break; + case (int)ScriptBaseClass.PRIM_COLOR: + case (int)ScriptBaseClass.PRIM_TEXT: + case (int)ScriptBaseClass.PRIM_BUMP_SHINY: + case (int)ScriptBaseClass.PRIM_OMEGA: + if (remain < 3) + return; + idx += 3; + break; - case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: - if (remain < 5) - return; - idx += 5; - break; + case (int)ScriptBaseClass.PRIM_TEXTURE: + case (int)ScriptBaseClass.PRIM_POINT_LIGHT: + case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: + if (remain < 5) + return; + idx += 5; + break; - case (int)ScriptBaseClass.PRIM_TYPE_TORUS: - case (int)ScriptBaseClass.PRIM_TYPE_TUBE: - case (int)ScriptBaseClass.PRIM_TYPE_RING: - if (remain < 11) - return; - idx += 11; - break; + case (int)ScriptBaseClass.PRIM_FLEXIBLE: + if (remain < 7) + return; - case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: - if (remain < 2) - return; - idx += 2; - break; - } - break; + idx += 7; + break; - case (int)ScriptBaseClass.PRIM_COLOR: - case (int)ScriptBaseClass.PRIM_TEXT: - case (int)ScriptBaseClass.PRIM_BUMP_SHINY: - case (int)ScriptBaseClass.PRIM_OMEGA: - if (remain < 3) - return; - idx += 3; - break; + case (int)ScriptBaseClass.PRIM_LINK_TARGET: + if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. + return; - case (int)ScriptBaseClass.PRIM_TEXTURE: - case (int)ScriptBaseClass.PRIM_POINT_LIGHT: - case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: - if (remain < 5) - return; - idx += 5; - break; + if (positionChanged) + { + positionChanged = false; + av.OffsetPosition = finalPos; + av.SendAvatarDataToAllAgents(); + } - case (int)ScriptBaseClass.PRIM_FLEXIBLE: - if (remain < 7) + LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); + LSL_List new_rules = rules.GetSublist(idx, -1); + setLinkPrimParams((int)new_linknumber, new_rules); return; + } + } + } - idx += 7; - break; - - case (int)ScriptBaseClass.PRIM_LINK_TARGET: - if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. - return; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); - return; + finally + { + if (positionChanged) + { + av.OffsetPosition = finalPos; + av.SendAvatarDataToAllAgents(); + positionChanged = false; } } } @@ -8166,8 +8154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; v=rules.GetVector3Item(idx++); - positionChanged = true; currentPosition = GetSetPosTarget(part, v, currentPosition); + positionChanged = true; break; case (int)ScriptBaseClass.PRIM_SIZE: @@ -8549,13 +8537,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Float gain = rules.GetLSLFloatItem(idx++); TargetOmega(part, axis, (double)spinrate, (double)gain); break; + case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. return; - // do a pending position change + // do a pending position change before jumping to other part/avatar if (positionChanged) { + positionChanged = false; if (parentgrp == null) return; @@ -8584,7 +8574,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { -/* if (positionChanged) { if (part.ParentGroup.RootPart == part) @@ -8602,27 +8591,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api parent.ScheduleGroupForTerseUpdate(); } } - */ - } - - if (positionChanged) - { - if (parentgrp == null) - return; - - if (parentgrp.RootPart == part) - { - - Util.FireAndForget(delegate(object x) { - parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); - }); - } - else - { - part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); - parentgrp.HasGroupChanged = true; - parentgrp.ScheduleGroupForTerseUpdate(); - } } } -- cgit v1.1 From f51ef99bd5f9cc1834ec402ca68bc70e4570bc76 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jun 2012 08:05:40 +0100 Subject: try to replicate SL bug of PRIM_ROTATION also for avas, est a fix to other cases --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ec4f62f..31ce2c4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7983,9 +7983,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation r = rules.GetQuaternionItem(idx++); Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation - Quaternion srot = sitpart.GetWorldRotation(); - rot *= Quaternion.Conjugate(srot); // removed sit part world rotation +// need to replicate SL bug + SceneObjectGroup sitgrp = sitpart.ParentGroup; + if (sitgrp != null && sitgrp.RootPart != sitpart) + { + rot *= sitgrp.RootPart.RotationOffset; + } + + Quaternion srot = sitpart.GetWorldRotation(); + rot = Quaternion.Conjugate(srot) * rot; // removed sit part world rotation av.Rotation = rot; av.SendAvatarDataToAllAgents(); } @@ -8003,7 +8010,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation Quaternion srot = sitpart.RotationOffset; - rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation + rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation av.Rotation = rot; av.SendAvatarDataToAllAgents(); -- cgit v1.1 From ff450d29da9d8a551fc244f23f5da4645c26dc91 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 13 Jun 2012 01:59:54 +0200 Subject: Add detecting non-physical phantoms back into raycast --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 065d3df..22d62f7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -12139,9 +12139,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api results.Add(r); } - // bug: will not detect phantom unless they are physical - // don't use ObjectIntersection because its also bad - + // TODO: Replace this with a better solution. ObjectIntersection can only + // detect nonphysical phantoms. They are detected by virtue of being + // nonphysical (e.g. no PhysActor) so will not conflict with detecting + // physicsl phantoms as done by the physics scene + // We don't want anything else but phantoms here. + if (detectPhantom) + { + ContactResult[] objectHits = ObjectIntersection(rayStart, rayEnd, false, false, true); + foreach (ContactResult r in objectHits) + results.Add(r); + } } else { -- cgit v1.1 From b4ab9a735007604caba2253077434299b4f81b65 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 01:26:15 +0100 Subject: *TEST this will affect inworld sittargets by +-0.1m, so may be very BAD *. Changed the sign of the sitoffset dependent on avatar size in SP.cs. Removed that offset correction from SET/GET..primitiveParams in LSL api. If the sign needs to be the previus one, then all references to avatar positions on LSL api need to be fixed with that correction, not only SET/GETprimitiveParams. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- .../Shared/Api/Implementation/LSL_Api.cs | 26 ++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a810de2..059d4c2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2383,7 +2383,8 @@ namespace OpenSim.Region.Framework.Scenes Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; - m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; +// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 31ce2c4..891d4d6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7964,8 +7964,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion rot = sitpart.RotationOffset; pos *= Quaternion.Conjugate(rot); // removed sit part rotation - Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); - pos += sitOffset; +// Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); +// pos += sitOffset; finalPos = pos; positionChanged = true; @@ -7984,11 +7984,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation // need to replicate SL bug - SceneObjectGroup sitgrp = sitpart.ParentGroup; if (sitgrp != null && sitgrp.RootPart != sitpart) { - rot *= sitgrp.RootPart.RotationOffset; + rot = sitgrp.RootPart.RotationOffset * rot; } Quaternion srot = sitpart.GetWorldRotation(); @@ -8956,9 +8955,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_POSITION: - Vector3 pos = avatar.AbsolutePosition; - Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); - pos -= sitOffset; + + // can't use Abs pos to extract offset... +// Vector3 pos = avatar.AbsolutePosition; + Vector3 pos = avatar.OffsetPosition; + +// Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); +// pos -= sitOffset; + + if( sitPart != null) + pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); + res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); break; @@ -9153,12 +9160,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POS_LOCAL: Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part +// Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); +// lpos -= lsitOffset; + if (sitPart != null) { lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim } - Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); - lpos -= lsitOffset; res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); break; -- cgit v1.1 From 4027c8e9c9999f1b2fbb9ee921aa02525d569318 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 01:51:22 +0100 Subject: Fixed llGetObjectDetails(), OBJECT_ROT for sitting avatars case, plus 'cosmetics' and added some parts costs information. --- .../Shared/Api/Implementation/LSL_Api.cs | 32 ++++++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 891d4d6..9772c5a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -11800,6 +11800,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List ret = new LSL_List(); UUID key = new UUID(); + + if (UUID.TryParse(id, out key)) { ScenePresence av = World.GetScenePresence(key); @@ -11817,13 +11819,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_String("")); break; case ScriptBaseClass.OBJECT_POS: - ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); + Vector3 avpos = av.AbsolutePosition; + ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); break; case ScriptBaseClass.OBJECT_ROT: - ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); + Quaternion avrot = av.Rotation; + if(av.ParentID != 0 && av.ParentPart != null) + { + avrot = av.ParentPart.GetWorldRotation() * avrot; + } + ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W)); break; case ScriptBaseClass.OBJECT_VELOCITY: - ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); + Vector3 avvel = av.Velocity; + ret.Add(new LSL_Vector((double)avvel.X, (double)avvel.Y, (double)avvel.Z)); break; case ScriptBaseClass.OBJECT_OWNER: ret.Add(new LSL_String(id)); @@ -11879,17 +11888,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.OBJECT_NAME: ret.Add(new LSL_String(obj.Name)); break; - case ScriptBaseClass.OBJECT_DESC: + case ScriptBaseClass.OBJECT_DESC: ret.Add(new LSL_String(obj.Description)); break; case ScriptBaseClass.OBJECT_POS: - ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); + Vector3 opos = obj.AbsolutePosition; + ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); break; case ScriptBaseClass.OBJECT_ROT: - ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); + Quaternion orot = obj.RotationOffset; + ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); break; case ScriptBaseClass.OBJECT_VELOCITY: - ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); + Vector3 ovel = obj.Velocity; + ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z)); break; case ScriptBaseClass.OBJECT_OWNER: ret.Add(new LSL_String(obj.OwnerID.ToString())); @@ -11927,17 +11939,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // The value returned in SL for normal prims is prim count ret.Add(new LSL_Integer(0)); break; + + // costs below may need to be diferent for root parts, need to check case ScriptBaseClass.OBJECT_SERVER_COST: // The value returned in SL for normal prims is prim count ret.Add(new LSL_Float(0)); break; case ScriptBaseClass.OBJECT_STREAMING_COST: // The value returned in SL for normal prims is prim count * 0.06 - ret.Add(new LSL_Float(0)); + ret.Add(new LSL_Float(obj.StreamingCost)); break; case ScriptBaseClass.OBJECT_PHYSICS_COST: // The value returned in SL for normal prims is prim count - ret.Add(new LSL_Float(0)); + ret.Add(new LSL_Float(obj.PhysicsCost)); break; default: // Invalid or unhandled constant. -- cgit v1.1 From b30c23eba42f3df4e82a509de78876b679aad3e6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 02:50:39 +0100 Subject: convert a LSL rotation of <0,0,0,0> to <0,0,0,1> and not <0,0,1,0> in SitTarget. Something seems to be doing that before this gets called, but just in case... --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9772c5a..089b401 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7099,7 +7099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // LSL quaternions can normalize to 0, normal Quaternions can't. if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) - rot.z = 1; // ZERO_ROTATION = 0,0,0,1 + rot.s = 1; // ZERO_ROTATION = 0,0,0,1 part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); part.SitTargetOrientation = Rot2Quaternion(rot); -- cgit v1.1 From 7bd274b3d34b5f7cbdc4e4d9e9f6915392b004b8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 13 Jun 2012 04:59:09 +0100 Subject: Changed t adding the avatar dependent sit offset and not subtracting, so not to break inworld contents. SL ported scripts will show a sit error around 0.1m. Added respective compensation in LSL api to maintain coerence. Fixed several bugs still on SET/GET[link]PrimitiveParams[fast] and llGetObjectDetails() --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +- .../Shared/Api/Implementation/LSL_Api.cs | 67 ++++++++++++++-------- 2 files changed, 46 insertions(+), 27 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 059d4c2..87b4d9f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2383,8 +2383,10 @@ namespace OpenSim.Region.Framework.Scenes Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; -// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; + + m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; + +// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; part.ParentGroup.AddAvatar(UUID); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 089b401..fafeba2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7959,13 +7959,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position - pos -= sitpart.OffsetPosition; // remove sit part offset - - Quaternion rot = sitpart.RotationOffset; - pos *= Quaternion.Conjugate(rot); // removed sit part rotation - -// Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); -// pos += sitOffset; + if (sitpart != sitpart.ParentGroup.RootPart) + { + pos -= sitpart.OffsetPosition; // remove sit part offset + Quaternion rot = sitpart.RotationOffset; + pos *= Quaternion.Conjugate(rot); // removed sit part rotation + } + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f); + pos += sitOffset; finalPos = pos; positionChanged = true; @@ -7990,8 +7991,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rot = sitgrp.RootPart.RotationOffset * rot; } - Quaternion srot = sitpart.GetWorldRotation(); - rot = Quaternion.Conjugate(srot) * rot; // removed sit part world rotation + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation av.Rotation = rot; av.SendAvatarDataToAllAgents(); } @@ -8007,10 +8008,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_Rotation r = rules.GetQuaternionItem(idx++); Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation - - Quaternion srot = sitpart.RotationOffset; - rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation - + if (sitpart != sitpart.ParentGroup.RootPart) + { + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation + } av.Rotation = rot; av.SendAvatarDataToAllAgents(); } @@ -8956,12 +8958,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: - // can't use Abs pos to extract offset... -// Vector3 pos = avatar.AbsolutePosition; Vector3 pos = avatar.OffsetPosition; -// Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); -// pos -= sitOffset; + Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); + pos -= sitOffset; if( sitPart != null) pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); @@ -9151,7 +9151,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROT_LOCAL: Quaternion lrot = avatar.Rotation; - if (sitPart != null) + + if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) { lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset } @@ -9160,10 +9161,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POS_LOCAL: Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part -// Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); -// lpos -= lsitOffset; + Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); + lpos -= lsitOffset; - if (sitPart != null) + if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) { lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim } @@ -11819,12 +11820,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_String("")); break; case ScriptBaseClass.OBJECT_POS: - Vector3 avpos = av.AbsolutePosition; + Vector3 avpos; + + if (av.ParentID != 0 && av.ParentPart != null) + { + avpos = av.OffsetPosition; + + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f); + avpos -= sitOffset; + + avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation(); + } + else + avpos = av.AbsolutePosition; + ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z)); break; case ScriptBaseClass.OBJECT_ROT: Quaternion avrot = av.Rotation; - if(av.ParentID != 0 && av.ParentPart != null) + if (av.ParentID != 0 && av.ParentPart != null) { avrot = av.ParentPart.GetWorldRotation() * avrot; } @@ -11896,8 +11910,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); break; case ScriptBaseClass.OBJECT_ROT: - Quaternion orot = obj.RotationOffset; - ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); +// Quaternion orot = obj.RotationOffset; +// ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); + + LSL_Rotation objrot = GetPartRot(obj); + ret.Add(objrot); break; case ScriptBaseClass.OBJECT_VELOCITY: Vector3 ovel = obj.Velocity; -- cgit v1.1 From c8227e1bb70817351de283fb647ec39f090fc9f1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 11:24:37 +0100 Subject: only rotation of root part change parts positions, so only call ResetChildPrimPhysicsPositions() if root part. Plus 'cosmetics' --- .../Shared/Api/Implementation/LSL_Api.cs | 52 +++++++++++++--------- 1 file changed, 31 insertions(+), 21 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 959d928..a37c68e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -660,18 +660,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); double x,y,z,s; - - double c1 = Math.Cos(v.x * 0.5); - double c2 = Math.Cos(v.y * 0.5); - double c3 = Math.Cos(v.z * 0.5); - double s1 = Math.Sin(v.x * 0.5); - double s2 = Math.Sin(v.y * 0.5); - double s3 = Math.Sin(v.z * 0.5); - - x = s1 * c2 * c3 + c1 * s2 * s3; - y = c1 * s2 * c3 - s1 * c2 * s3; - z = s1 * s2 * c3 + c1 * c2 * s3; - s = c1 * c2 * c3 - s1 * s2 * s3; + v.x *= 0.5; + v.y *= 0.5; + v.z *= 0.5; + double c1 = Math.Cos(v.x); + double c2 = Math.Cos(v.y); + double c1c2 = c1 * c2; + double s1 = Math.Sin(v.x); + double s2 = Math.Sin(v.y); + double s1s2 = s1 * s2; + double c1s2 = c1 * s2; + double s1c2 = s1 * c2; + double c3 = Math.Cos(v.z); + double s3 = Math.Sin(v.z); + + x = s1c2 * c3 + c1s2 * s3; + y = c1s2 * c3 - s1c2 * s3; + z = s1s2 * c3 + c1c2 * s3; + s = c1c2 * c3 - s1s2 * s3; return new LSL_Rotation(x, y, z, s); } @@ -1911,11 +1917,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntry tex = part.Shape.Textures; Color4 texcolor; LSL_Vector rgb = new LSL_Vector(); + int nsides = GetNumberOfSides(part); + if (face == ScriptBaseClass.ALL_SIDES) { int i; - - for (i = 0 ; i < GetNumberOfSides(part); i++) + for (i = 0; i < nsides; i++) { texcolor = tex.GetFace((uint)i).RGBA; rgb.x += texcolor.R; @@ -1923,13 +1930,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rgb.z += texcolor.B; } - rgb.x /= (float)GetNumberOfSides(part); - rgb.y /= (float)GetNumberOfSides(part); - rgb.z /= (float)GetNumberOfSides(part); + float invnsides = 1.0f / (float)nsides; + + rgb.x *= invnsides; + rgb.y *= invnsides; + rgb.z *= invnsides; return rgb; } - if (face >= 0 && face < GetNumberOfSides(part)) + if (face >= 0 && face < nsides) { texcolor = tex.GetFace((uint)face).RGBA; rgb.x = texcolor.R; @@ -2369,8 +2378,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // without the absoluteposition = absoluteposition happening, the doors do not move in the physics // scene PhysicsActor pa = part.PhysActor; - - if (pa != null && !pa.IsPhysical) + // only root part rot changes positions + if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) { part.ParentGroup.ResetChildPrimPhysicsPositions(); } @@ -2422,7 +2431,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetLocalRot() { m_host.AddScriptLPS(1); - return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); + Quaternion rot = m_host.RotationOffset; + return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); } public void llSetForce(LSL_Vector force, int local) -- cgit v1.1 From 065cda37112fecc00e3c10fe966edde2ddc46b4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 12:19:42 +0100 Subject: Add sop IsPhysical and IsPhantom to be used gradually in core in place of asking physics engines all the time. Some engines delays may make them give wrong answers. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e74dc8..b51ce38 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -611,7 +611,10 @@ namespace OpenSim.Region.Framework.Scenes public bool IsSelected { - get { return m_isSelected; } + get + { + return m_isSelected; + } set { m_isSelected = value; @@ -619,8 +622,23 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.PartSelectChanged(value); } } - - + + public bool IsPhysical + { + get + { + return ((Flags & PrimFlags.Physics) != 0); + } + } + + public bool IsPhantom + { + get + { + return ((Flags & PrimFlags.Phantom) != 0); + } + } + public Dictionary CollisionFilter { get { return m_CollisionFilter; } -- cgit v1.1 From db2dcbbe2d02bee0fdaab9a3b209c98dc690b976 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 14:01:18 +0100 Subject: SL doesn't let scripts rotate root part of physical linksets also fix sitting avatars rotations broken in previus commit, forcing send of updates. --- .../Shared/Api/Implementation/LSL_Api.cs | 43 ++++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a37c68e..b507937 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2337,13 +2337,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // (root prim). ParentID may be nonzero in attachments and // using it would cause attachments and HUDs to rotate // to the wrong positions. + SetRot(m_host, Rot2Quaternion(rot)); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart = m_host.ParentGroup.RootPart; - if (rootPart != null) // better safe than sorry + SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; + if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry { SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } @@ -2355,6 +2356,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLocalRot(LSL_Rotation rot) { m_host.AddScriptLPS(1); + SetRot(m_host, Rot2Quaternion(rot)); ScriptSleep(200); } @@ -2364,25 +2366,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; - part.UpdateRotation(rot); - // Update rotation does not move the object in the physics scene if it's a linkset. + bool isroot = (part == part.ParentGroup.RootPart); -//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type -// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; + // SL doesn't let scripts rotate root of physical linksets + if (isroot && part.IsPhysical) + return; + + part.UpdateRotation(rot); - // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line - // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt - // It's perfectly okay when the object is not an active physical body though. - // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against - // but only if the object is not physial and active. This is important for rotating doors. - // without the absoluteposition = absoluteposition happening, the doors do not move in the physics - // scene - PhysicsActor pa = part.PhysActor; - // only root part rot changes positions - if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) + // Update rotation does not move the object in the physics scene if it's a linkset. + // so do a nasty update + // but only root part rotation changes positions and only needed if we have physics actor + if (isroot && part.PhysActor != null) { part.ParentGroup.ResetChildPrimPhysicsPositions(); } + else // fix sitting avatars + { + List sittingavas = part.ParentGroup.GetLinkedAvatars(); + if (sittingavas.Count > 0) + { + foreach (ScenePresence av in sittingavas) + { + if (isroot || part.LocalId == av.ParentID) + av.SendAvatarDataToAllAgents(); + } + } + } } /// @@ -8544,6 +8554,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return; + LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; -- cgit v1.1 From 5d329791705fa5d82d37f5c3ff03d0f4f597c2e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 14:31:35 +0100 Subject: Revert changes... This reverts commit c8227e1bb70817351de283fb647ec39f090fc9f1. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 24 +----- .../Shared/Api/Implementation/LSL_Api.cs | 89 +++++++++------------- 2 files changed, 37 insertions(+), 76 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b51ce38..8e74dc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -611,10 +611,7 @@ namespace OpenSim.Region.Framework.Scenes public bool IsSelected { - get - { - return m_isSelected; - } + get { return m_isSelected; } set { m_isSelected = value; @@ -622,23 +619,8 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.PartSelectChanged(value); } } - - public bool IsPhysical - { - get - { - return ((Flags & PrimFlags.Physics) != 0); - } - } - - public bool IsPhantom - { - get - { - return ((Flags & PrimFlags.Phantom) != 0); - } - } - + + public Dictionary CollisionFilter { get { return m_CollisionFilter; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b507937..959d928 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -660,24 +660,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); double x,y,z,s; - v.x *= 0.5; - v.y *= 0.5; - v.z *= 0.5; - double c1 = Math.Cos(v.x); - double c2 = Math.Cos(v.y); - double c1c2 = c1 * c2; - double s1 = Math.Sin(v.x); - double s2 = Math.Sin(v.y); - double s1s2 = s1 * s2; - double c1s2 = c1 * s2; - double s1c2 = s1 * c2; - double c3 = Math.Cos(v.z); - double s3 = Math.Sin(v.z); - - x = s1c2 * c3 + c1s2 * s3; - y = c1s2 * c3 - s1c2 * s3; - z = s1s2 * c3 + c1c2 * s3; - s = c1c2 * c3 - s1s2 * s3; + + double c1 = Math.Cos(v.x * 0.5); + double c2 = Math.Cos(v.y * 0.5); + double c3 = Math.Cos(v.z * 0.5); + double s1 = Math.Sin(v.x * 0.5); + double s2 = Math.Sin(v.y * 0.5); + double s3 = Math.Sin(v.z * 0.5); + + x = s1 * c2 * c3 + c1 * s2 * s3; + y = c1 * s2 * c3 - s1 * c2 * s3; + z = s1 * s2 * c3 + c1 * c2 * s3; + s = c1 * c2 * c3 - s1 * s2 * s3; return new LSL_Rotation(x, y, z, s); } @@ -1917,12 +1911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Primitive.TextureEntry tex = part.Shape.Textures; Color4 texcolor; LSL_Vector rgb = new LSL_Vector(); - int nsides = GetNumberOfSides(part); - if (face == ScriptBaseClass.ALL_SIDES) { int i; - for (i = 0; i < nsides; i++) + + for (i = 0 ; i < GetNumberOfSides(part); i++) { texcolor = tex.GetFace((uint)i).RGBA; rgb.x += texcolor.R; @@ -1930,15 +1923,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api rgb.z += texcolor.B; } - float invnsides = 1.0f / (float)nsides; - - rgb.x *= invnsides; - rgb.y *= invnsides; - rgb.z *= invnsides; + rgb.x /= (float)GetNumberOfSides(part); + rgb.y /= (float)GetNumberOfSides(part); + rgb.z /= (float)GetNumberOfSides(part); return rgb; } - if (face >= 0 && face < nsides) + if (face >= 0 && face < GetNumberOfSides(part)) { texcolor = tex.GetFace((uint)face).RGBA; rgb.x = texcolor.R; @@ -2337,14 +2328,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // (root prim). ParentID may be nonzero in attachments and // using it would cause attachments and HUDs to rotate // to the wrong positions. - SetRot(m_host, Rot2Quaternion(rot)); } else { // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. - SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; - if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry + SceneObjectPart rootPart = m_host.ParentGroup.RootPart; + if (rootPart != null) // better safe than sorry { SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } @@ -2356,7 +2346,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetLocalRot(LSL_Rotation rot) { m_host.AddScriptLPS(1); - SetRot(m_host, Rot2Quaternion(rot)); ScriptSleep(200); } @@ -2366,33 +2355,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return; - bool isroot = (part == part.ParentGroup.RootPart); + part.UpdateRotation(rot); + // Update rotation does not move the object in the physics scene if it's a linkset. - // SL doesn't let scripts rotate root of physical linksets - if (isroot && part.IsPhysical) - return; +//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type +// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; - part.UpdateRotation(rot); + // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line + // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt + // It's perfectly okay when the object is not an active physical body though. + // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against + // but only if the object is not physial and active. This is important for rotating doors. + // without the absoluteposition = absoluteposition happening, the doors do not move in the physics + // scene + PhysicsActor pa = part.PhysActor; - // Update rotation does not move the object in the physics scene if it's a linkset. - // so do a nasty update - // but only root part rotation changes positions and only needed if we have physics actor - if (isroot && part.PhysActor != null) + if (pa != null && !pa.IsPhysical) { part.ParentGroup.ResetChildPrimPhysicsPositions(); } - else // fix sitting avatars - { - List sittingavas = part.ParentGroup.GetLinkedAvatars(); - if (sittingavas.Count > 0) - { - foreach (ScenePresence av in sittingavas) - { - if (isroot || part.LocalId == av.ParentID) - av.SendAvatarDataToAllAgents(); - } - } - } } /// @@ -2441,8 +2422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_Rotation llGetLocalRot() { m_host.AddScriptLPS(1); - Quaternion rot = m_host.RotationOffset; - return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); + return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); } public void llSetForce(LSL_Vector force, int local) @@ -8554,7 +8534,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return; - LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; -- cgit v1.1 From ffc0badaf439139180bca9ed8f478ddabe7c7608 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jun 2012 15:18:57 +0200 Subject: Reapply the one change that was in the revert that was actually function, not form --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 959d928..fe85118 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2370,7 +2370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // scene PhysicsActor pa = part.PhysActor; - if (pa != null && !pa.IsPhysical) + if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) { part.ParentGroup.ResetChildPrimPhysicsPositions(); } -- cgit v1.1