From f74a9bcdc7b0682c1c205e9d640fbfa5f214840b Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Thu, 24 Jul 2008 07:45:58 +0000 Subject: Implements llSetForce() and llGetForce(). These are experimental and the units may not match the Linden implementation. --- .../ScriptEngine/Common/LSL_BuiltIn_Commands.cs | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Common') diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index 2d5be27..1a60f45 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs @@ -42,6 +42,7 @@ using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; using OpenSim.Region.Environment.Modules.World.Land; using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Physics.Manager; using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase; //using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL; @@ -1578,14 +1579,40 @@ namespace OpenSim.Region.ScriptEngine.Common public void llSetForce(LSL_Types.Vector3 force, int local) { m_host.AddScriptLPS(1); - NotImplemented("llSetForce"); + //NotImplemented("llSetForce"); + + if (m_host.ParentGroup != null) + { + if (m_host.ParentGroup.RootPart != null) + { + if (local != 0) + force *= llGetRot(); + + m_host.ParentGroup.RootPart.SetForce(new PhysicsVector((float)force.x, (float)force.y, (float)force.z)); + } + } } public LSL_Types.Vector3 llGetForce() { + LSL_Types.Vector3 force = new LSL_Types.Vector3(0.0, 0.0, 0.0); + m_host.AddScriptLPS(1); - NotImplemented("llGetForce"); - return new LSL_Types.Vector3(); + //NotImplemented("llGetForce"); + //return new LSL_Types.Vector3(); + + if (m_host.ParentGroup != null) + { + if (m_host.ParentGroup.RootPart != null) + { + PhysicsVector tmpForce = m_host.ParentGroup.RootPart.GetForce(); + force.x = tmpForce.X; + force.y = tmpForce.Y; + force.z = tmpForce.Z; + } + } + + return force; } public LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range) -- cgit v1.1