From 61bf2bf2ddce323255d7d009274d8da5a2da54c9 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 2 Jun 2011 18:32:25 +0200 Subject: [PATCH] Make Buoyancy a prim property --- .../Framework/Scenes/SceneObjectGroup.cs | 3 ++ .../Framework/Scenes/SceneObjectPart.cs | 22 +++++--- .../Shared/Api/Implementation/LSL_Api.cs | 53 ++++++++++++------- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d3d5d0821c..74d24a6884 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -680,6 +680,9 @@ namespace OpenSim.Region.Framework.Scenes ApplyPhysics(m_scene.m_physicalPrim); + if (RootPart.PhysActor != null) + RootPart.Buoyancy = RootPart.Buoyancy; + // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled // for the same object with very different properties. The caller must schedule the update. //ScheduleGroupForFullUpdate(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4e1d6b685d..cb321aa36b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -338,6 +338,7 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_lastAcceleration; protected Vector3 m_lastAngularVelocity; protected int m_lastTerseSent; + protected float m_buoyancy = 0.0f; /// /// Stores media texture data @@ -1335,6 +1336,19 @@ namespace OpenSim.Region.Framework.Scenes set { m_collisionSoundVolume = value; } } + public float Buoyancy + { + get { return m_buoyancy; } + set + { + m_buoyancy = value; + if (PhysActor != null) + { + PhysActor.Buoyancy = value; + } + } + } + #endregion Public Properties with only Get #region Private Methods @@ -3275,14 +3289,6 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_Z = rotate; } - public void SetBuoyancy(float fvalue) - { - if (PhysActor != null) - { - PhysActor.Buoyancy = fvalue; - } - } - public void SetDieAtEdge(bool p) { if (m_parentGroup == null) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f7c44d1914..b87bf5a648 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3453,7 +3453,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (!m_host.ParentGroup.IsDeleted) { - m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); + m_host.ParentGroup.RootPart.Buoyancy = (float)buoyancy; } } } @@ -3707,27 +3707,44 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } } - else if (m_host.SitTargetAvatar == agentID) // Sitting avatar + else { - // When agent is sitting, certain permissions are implicit if requested from sitting agent - int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | - ScriptBaseClass.PERMISSION_CONTROL_CAMERA | - ScriptBaseClass.PERMISSION_TRACK_CAMERA | - ScriptBaseClass.PERMISSION_TAKE_CONTROLS; - - if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + bool sitting = false; + if (m_host.SitTargetAvatar == agentID) { - m_host.TaskInventory.LockItemsForWrite(true); - m_host.TaskInventory[invItemID].PermsGranter = agentID; - m_host.TaskInventory[invItemID].PermsMask = perm; - m_host.TaskInventory.LockItemsForWrite(false); + sitting = true; + } + else + { + foreach (SceneObjectPart p in m_host.ParentGroup.Parts) + { + if (p.SitTargetAvatar == agentID) + sitting = true; + } + } - m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(perm) }, - new DetectParams[0])); + if (sitting) + { + // When agent is sitting, certain permissions are implicit if requested from sitting agent + int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | + ScriptBaseClass.PERMISSION_CONTROL_CAMERA | + ScriptBaseClass.PERMISSION_TRACK_CAMERA | + ScriptBaseClass.PERMISSION_TAKE_CONTROLS; - return; + if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + { + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[invItemID].PermsGranter = agentID; + m_host.TaskInventory[invItemID].PermsMask = perm; + m_host.TaskInventory.LockItemsForWrite(false); + + m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams( + "run_time_permissions", new Object[] { + new LSL_Integer(perm) }, + new DetectParams[0])); + + return; + } } }