From c8227e1bb70817351de283fb647ec39f090fc9f1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 11:24:37 +0100 Subject: [PATCH 1/7] only rotation of root part change parts positions, so only call ResetChildPrimPhysicsPositions() if root part. Plus 'cosmetics' --- .../Shared/Api/Implementation/LSL_Api.cs | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 959d928f9c..a37c68e40d 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; + 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); - 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; + 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) From 065cda37112fecc00e3c10fe966edde2ddc46b4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 12:19:42 +0100 Subject: [PATCH 2/7] 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. --- .../Framework/Scenes/SceneObjectPart.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 8e74dc8f4b..b51ce38895 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; } From db2dcbbe2d02bee0fdaab9a3b209c98dc690b976 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 14:01:18 +0100 Subject: [PATCH 3/7] 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(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a37c68e40d..b507937fbb 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; + bool isroot = (part == part.ParentGroup.RootPart); + + // SL doesn't let scripts rotate root of physical linksets + if (isroot && part.IsPhysical) + return; + part.UpdateRotation(rot); + // Update rotation does not move the object in the physics scene if it's a linkset. - -//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; - - // 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) + // 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; From 5d329791705fa5d82d37f5c3ff03d0f4f597c2e1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 15 Jun 2012 14:31:35 +0100 Subject: [PATCH 4/7] Revert changes... This reverts commit c8227e1bb70817351de283fb647ec39f090fc9f1. --- .../Framework/Scenes/SceneObjectPart.cs | 24 +---- .../Shared/Api/Implementation/LSL_Api.cs | 89 +++++++------------ 2 files changed, 37 insertions(+), 76 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b51ce38895..8e74dc8f4b 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 b507937fbb..959d928f9c 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); - - // SL doesn't let scripts rotate root of physical linksets - if (isroot && part.IsPhysical) - return; - part.UpdateRotation(rot); - // 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) + +//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; + + // 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; + + 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; From ffc0badaf439139180bca9ed8f478ddabe7c7608 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 15 Jun 2012 15:18:57 +0200 Subject: [PATCH 5/7] Reapply the one change that was in the revert that was actually function, not form --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 959d928f9c..fe8511843d 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(); } From e2b9a5d7aa08c9f99a77d9bbf05a08566fd9cd21 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 08:54:39 +0100 Subject: [PATCH 6/7] Don't let scripts rotate root part of physical linksets like SL, Update client rotation of avatars 'linked' to child parts. (put back some 'cosmetics' from previus commit). Still let lsl api use physics engine ideia of part Physical state on this where it should be SOP ideia, so is that is clear that sync with engine is SOP responsability. --- .../Shared/Api/Implementation/LSL_Api.cs | 97 ++++++++++++------- 1 file changed, 64 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index fe8511843d..389a82b742 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; + 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); - 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; + 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; @@ -2328,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)); } @@ -2346,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); } @@ -2355,25 +2366,43 @@ 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); + bool isphys; -//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; - - // 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; - if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) + // keep using physactor ideia of isphysical + // it should be SOP ideia of that + // not much of a issue with ubitODE + if (pa != null && pa.IsPhysical) + isphys = true; + else + isphys = false; + + // SL doesn't let scripts rotate root of physical linksets + if (isroot && isphys) + return; + + part.UpdateRotation(rot); + + // Update rotation does not move the object in the physics engine if it's a non physical linkset + // so do a nasty update of parts positions if is a root part rotation + if (isroot && pa != null) // with if above implies non physical root part { part.ParentGroup.ResetChildPrimPhysicsPositions(); } + else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part + { + List sittingavas = part.ParentGroup.GetLinkedAvatars(); + if (sittingavas.Count > 0) + { + foreach (ScenePresence av in sittingavas) + { + if (isroot || part.LocalId == av.ParentID) + av.SendTerseUpdateToAllClients(); + } + } + } } /// @@ -2422,7 +2451,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) @@ -8534,6 +8564,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; From e7aceae3e0e21b9f739dbcaac055c18991887e50 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 17 Jun 2012 09:06:25 +0100 Subject: [PATCH 7/7] split ugly expression in a if making it simpler to read --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 389a82b742..d9867a8ff0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2343,10 +2343,12 @@ 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. - SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; - if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry + SceneObjectPart rootPart; + if (m_host.ParentGroup != null) // better safe than sorry { - SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); + rootPart = m_host.ParentGroup.RootPart; + if (rootPart != null) + SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); } }