From 838818270785c58d7b2df221b8b94397aa3cdb04 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 13 Mar 2012 22:20:12 +0100 Subject: Implement llSetPrimitiveParams for physics shape and material. Add llSetPhysicsMaterial support. --- .../Shared/Api/Implementation/LSL_Api.cs | 60 ++++++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../Shared/Api/Runtime/LSL_Constants.cs | 11 ++++ .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++ 4 files changed, 77 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 958527a..fd4c7ad 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7632,6 +7632,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } + private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, + float material_density, float material_friction, + float material_restitution, float material_gravity_modifier) + { + ExtraPhysicsData physdata = new ExtraPhysicsData(); + physdata.PhysShapeType = (PhysShapeType)part.PhysicsShapeType; + physdata.Density = part.Density; + physdata.Friction = part.Friction; + physdata.Bounce = part.Bounciness; + physdata.GravitationModifier = part.GravityModifier; + + if ((material_bits & (int)ScriptBaseClass.DENSITY) != 0) + physdata.Density = material_density; + if ((material_bits & (int)ScriptBaseClass.FRICTION) != 0) + physdata.Friction = material_friction; + if ((material_bits & (int)ScriptBaseClass.RESTITUTION) != 0) + physdata.Bounce = material_restitution; + if ((material_bits & (int)ScriptBaseClass.GRAVITY_MULTIPLIER) != 0) + physdata.GravitationModifier = material_gravity_modifier; + + part.UpdateExtraPhysics(physdata); + } + + public void llSetPhysicsMaterial(int material_bits, + float material_gravity_modifier, float material_restitution, + float material_friction, float material_density) + { + SetPhysicsMaterial(m_host, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); + } + public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) { llSetLinkPrimitiveParamsFast(linknumber, rules); @@ -8043,6 +8073,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.ScriptSetPhysicsStatus(physics); break; + case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: + if (remain < 1) + return; + + int shape_type = rules.GetLSLIntegerItem(idx++); + + ExtraPhysicsData physdata = new ExtraPhysicsData(); + physdata.Density = part.Density; + physdata.Bounce = part.Bounciness; + physdata.GravitationModifier = part.GravityModifier; + physdata.PhysShapeType = (PhysShapeType)shape_type; + + part.UpdateExtraPhysics(physdata); + + break; + + case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: + if (remain < 5) + return; + + int material_bits = rules.GetLSLIntegerItem(idx++); + float material_density = (float)rules.GetLSLFloatItem(idx++); + float material_friction = (float)rules.GetLSLFloatItem(idx++); + float material_restitution = (float)rules.GetLSLFloatItem(idx++); + float material_gravity_modifier = (float)rules.GetLSLFloatItem(idx++); + + SetPhysicsMaterial(part, material_bits, material_density, material_friction, material_restitution, material_gravity_modifier); + + break; + case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) return; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 8d97a7c..b976dc3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -417,6 +417,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_String llXorBase64Strings(string str1, string str2); LSL_String llXorBase64StringsCorrect(string str1, string str2); LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); + void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index ba75253..4ce3cf1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -570,6 +570,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_MEDIA_PERM_OWNER = 1; public const int PRIM_MEDIA_PERM_GROUP = 2; public const int PRIM_MEDIA_PERM_ANYONE = 4; + + public const int PRIM_PHYSICS_SHAPE_TYPE = 30; + public const int PRIM_PHYSICS_SHAPE_PRIM = 0; + public const int PRIM_PHYSICS_SHAPE_CONVEX = 2; + public const int PRIM_PHYSICS_SHAPE_NONE = 1; + + public const int PRIM_PHYSICS_MATERIAL = 31; + public const int DENSITY = 1; + public const int FRICTION = 2; + public const int RESTITUTION = 4; + public const int GRAVITY_MULTIPLIER = 8; // extra constants for llSetPrimMediaParams public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index a8d1ddb..bf58d13 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1949,5 +1949,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { m_LSL_Functions.llSetKeyframedMotion(frames, options); } + + public void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density) + { + m_LSL_Functions.llSetPhysicsMaterial(material_bits, material_gravity_modifier, material_restitution, material_friction, material_density); + } } } -- cgit v1.1