From 7809eb5ba058f72bee5f82011922a52a4665cd3c Mon Sep 17 00:00:00 2001 From: lickx Date: Sun, 22 May 2022 08:31:17 +0200 Subject: [PATCH] Support PRIM_PROJECTOR Signed-off-by: UbitUmarov --- .../Shared/Api/Implementation/LSL_Api.cs | 63 +++++++++++++++++++ .../Shared/Api/Runtime/LSL_Constants.cs | 1 + 2 files changed, 64 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3f252070cf..31a461b72a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10509,6 +10509,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return rules.GetSublist(idx, -1); + case ScriptBaseClass.PRIM_PROJECTOR: + if (remain < 4) + return new LSL_List(); + + string stexname = rules.Data[idx++].ToString(); + UUID stexID = UUID.Zero; + if(!string.IsNullOrEmpty(stexname)) + { + stexID = ScriptUtils.GetAssetIdFromItemName(m_host, stexname, (int)AssetType.Texture); + if (stexID.IsZero()) + { + if (!UUID.TryParse(stexname, out stexID)) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_PROJECTOR: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + } + } + + LSL_Float fov; + try + { + fov = rules.GetLSLFloatItem(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_PROJECTOR: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + + LSL_Float focus; + try + { + focus = rules.GetLSLFloatItem(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_PROJECTOR: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + + LSL_Float amb; + try + { + amb = rules.GetLSLFloatItem(idx++); + } + catch(InvalidCastException) + { + Error(originFunc, string.Format("Error running rule #{0} -> PRIM_PROJECTOR: arg #{1} - must be float", rulesParsed, idx - idxStart - 1)); + return new LSL_List(); + } + + bool projection = !stexID.IsZero(); + part.Shape.ProjectionEntry = projection; + part.Shape.ProjectionTextureUUID = stexID; + part.Shape.ProjectionFOV = Util.Clamp((float)fov, 0, 3.0f); + part.Shape.ProjectionFocus = Util.Clamp((float)focus, 0, 20.0f); + part.Shape.ProjectionAmbiance = Util.Clamp((float)amb, 0, 1.0f); + + part.ParentGroup.HasGroupChanged = true; + part.ScheduleFullUpdate(); + break; + default: Error(originFunc, string.Format("Error running rule #{0}: arg #{1} - unsupported parameter", rulesParsed, idx - idxStart)); return new LSL_List(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 22217988e5..32b7e7b029 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -455,6 +455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase //ApiDesc not supported public const int PRIM_SCRIPTED_SIT_ONLY = 40; // experiences related. unsupported public const int PRIM_SIT_TARGET = 41; + public const int PRIM_PROJECTOR = 42; // parameters