From ae9a98ceb15e43dc24c485955051f554a2247401 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Fri, 14 Mar 2008 06:20:50 +0000 Subject: * Added proper handling of llSetStatus(STATUS_PHYSICS,BOOL) --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 47 ++++++++++++++++++++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 15 ++++++- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 11 ++++- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 041dc4e..47c4567 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -590,6 +590,53 @@ namespace OpenSim.Region.Environment.Scenes SetPartAsRoot(newPart); } + public void ScriptSetPhysicsStatus(bool UsePhysics) + { + if (m_scene.m_physicalPrim) + { + lock (m_parts) + { + foreach (SceneObjectPart part in m_parts.Values) + { + if (UsePhysics) + part.AddFlag(LLObject.ObjectFlags.Physics); + else + part.RemFlag(LLObject.ObjectFlags.Physics); + + part.DoPhysicsPropertyUpdate(UsePhysics, false); + IsSelected = false; + } + } + } + + } + + public void ScriptSetPhantomStatus(bool PhantomStatus) + { + lock (m_parts) + { + foreach (SceneObjectPart part in m_parts.Values) + { + if (PhantomStatus) + { + part.AddFlag(LLObject.ObjectFlags.Phantom); + if (part.PhysActor != null) + { + m_scene.PhysicsScene.RemovePrim(part.PhysActor); + } + } + else + { + part.RemFlag(LLObject.ObjectFlags.Phantom); + if ((part.ObjectFlags & (int)LLObject.ObjectFlags.Physics) != 0) + { + part.DoPhysicsPropertyUpdate(true, false); + } + } + } + } + } + public void applyImpulse(PhysicsVector impulse) { // We check if rootpart is null here because scripts don't delete if you delete the host. diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index ffb9d36..5b3ea0f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -1326,7 +1326,20 @@ namespace OpenSim.Region.Environment.Scenes // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ScheduleFullUpdate(); } - + public void ScriptSetPhysicsStatus(bool UsePhysics) + { + if (m_parentGroup != null) + { + m_parentGroup.ScriptSetPhysicsStatus(UsePhysics); + } + } + public void ScriptSetPhantomStatus(bool Phantom) + { + if (m_parentGroup != null) + { + m_parentGroup.ScriptSetPhantomStatus(Phantom); + } + } public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { if (PhysActor != null) diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index e64fb36..ab7519e 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -609,11 +609,18 @@ namespace OpenSim.Region.ScriptEngine.Common m_host.AddScriptLPS(1); if ((status & BuiltIn_Commands_BaseClass.STATUS_PHYSICS) == BuiltIn_Commands_BaseClass.STATUS_PHYSICS) { - m_host.AddFlag(LLObject.ObjectFlags.Physics); + if (value == 1) + m_host.ScriptSetPhysicsStatus(true); + else + m_host.ScriptSetPhysicsStatus(false); + } if ((status & BuiltIn_Commands_BaseClass.STATUS_PHANTOM) == BuiltIn_Commands_BaseClass.STATUS_PHANTOM) { - m_host.AddFlag(LLObject.ObjectFlags.Phantom); + if (value == 1) + m_host.ScriptSetPhantomStatus(true); + else + m_host.ScriptSetPhantomStatus(false); } if ((status & BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) == BuiltIn_Commands_BaseClass.STATUS_CAST_SHADOWS) { -- cgit v1.1