diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f7af6aff3f..b19008fd9d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -5340,6 +5340,19 @@ namespace OpenSim.Region.Framework.Scenes return null; } + public void SetBuoyancy(float fvalue) + { + if(IsAttachment) + { + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); + PhysicsActor pa = avatar?.PhysicsActor; + if( pa is not null ) + pa.Buoyancy = fvalue; + } + else + RootPart.Buoyancy = fvalue; + } + public override string ToString() { return $"{Name} {UUID} ({AbsolutePosition})"; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b27d0ede22..3eccf5bbe7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1602,14 +1602,24 @@ namespace OpenSim.Region.Framework.Scenes } set { - if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) + if (ParentGroup != null) { - ParentGroup.RootPart.Buoyancy = value; - return; + if (ParentGroup.RootPart != null && ParentGroup.RootPart != this) + { + ParentGroup.RootPart.Buoyancy = value; + return; + } + if (ParentGroup.IsAttachment) + { + ScenePresence avatar = m_scene.GetScenePresence(ParentGroup.AttachedAvatar); + PhysicsActor pa = avatar?.PhysicsActor; + if (pa != null) + pa.Buoyancy = value; + } + else if (PhysActor != null) + PhysActor.Buoyancy = value; } m_buoyancy = value; - if (PhysActor != null) - PhysActor.Buoyancy = value; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d1cda84db8..574035a78c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4291,10 +4291,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetBuoyancy(double buoyancy) { - if (!m_host.ParentGroup.IsDeleted) { - m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); + m_host.ParentGroup.SetBuoyancy((float)buoyancy); } }