From 72f7009b1067771b8854722ccfc6a6e1a847ac71 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 12 Jan 2021 15:38:10 +0000 Subject: [PATCH] add os[Link]ParticleSystem with expire option. If expire true and system MaxAge > 0, the system will be be (lazy) removed from the prim after that MaxAge --- .../Region/Framework/Scenes/SceneObjectPart.cs | 17 +++++++++++++++-- .../Shared/Api/Interface/IOSSL_Api.cs | 9 ++++++--- .../Shared/Api/Runtime/OSSL_Stub.cs | 10 ++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 0e829a1b85..436be594c6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -325,6 +325,7 @@ namespace OpenSim.Region.Framework.Scenes protected SceneObjectGroup m_parentGroup; protected byte[] m_particleSystem = Utils.EmptyBytes; + protected double m_particleSystemExpire = -1; protected ulong m_regionHandle; protected Quaternion m_rotationOffset = Quaternion.Identity; protected PrimitiveBaseShape m_shape; @@ -735,7 +736,15 @@ namespace OpenSim.Region.Framework.Scenes public Byte[] ParticleSystem { - get { return m_particleSystem; } + get + { + if(m_particleSystemExpire > 0 && Util.GetTimeStamp() > m_particleSystemExpire) + { + m_particleSystemExpire = -1; + m_particleSystem = new byte[0]; + } + return m_particleSystem; + } set { m_particleSystem = value; } } @@ -1940,8 +1949,12 @@ namespace OpenSim.Region.Framework.Scenes // m_log.Debug("Aprev: " + prevflag.ToString() + " curr: " + Flags.ToString()); } - public void AddNewParticleSystem(Primitive.ParticleSystem pSystem) + public void AddNewParticleSystem(Primitive.ParticleSystem pSystem, bool expire) { + if(expire && pSystem.MaxAge > 0.0001) + m_particleSystemExpire = Util.GetTimeStamp() + pSystem.MaxAge + 0.1; + else + m_particleSystemExpire = -1; m_particleSystem = pSystem.GetBytes(); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 3534508b95..24ab2bbad7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -576,15 +576,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces vector osGetLinkStandTarget(LSL_Integer linkNumber); LSL_Integer osClearObjectAnimations(); - LSL_Float osGetApparentTime(); + LSL_Float osGetApparentTime(); LSL_String osGetApparentTimeString(LSL_Integer format24); - LSL_Float osGetApparentRegionTime(); + LSL_Float osGetApparentRegionTime(); LSL_String osGetApparentRegionTimeString(LSL_Integer format24); LSL_Integer osReplaceAgentEnvironment(LSL_Key agentkey, LSL_Integer transition, LSL_String daycycle); LSL_Integer osReplaceParcelEnvironment(LSL_Integer transition, LSL_String daycycle); LSL_Integer osReplaceRegionEnvironment(LSL_Integer transition, LSL_String daycycle, - LSL_Float daylen, LSL_Float dayoffset, LSL_Float altitude1, LSL_Float altitude2, LSL_Float altitude3); + LSL_Float daylen, LSL_Float dayoffset, LSL_Float altitude1, LSL_Float altitude2, LSL_Float altitude3); LSL_Integer osResetEnvironment(LSL_Integer parcelOrRegion, LSL_Integer transition); + + void osParticleSystem(LSL_List rules, LSL_Integer expire); + void osLinkParticleSystem(LSL_Integer linknumber, LSL_List rules, LSL_Integer expire); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 088e890143..8de63b9c0d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1533,5 +1533,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osResetEnvironment(parcelOrRegion, transition); } + + public void osParticleSystem(LSL_List rules, LSL_Integer expire) + { + m_OSSL_Functions.osParticleSystem(rules, expire); + } + + public void osLinkParticleSystem(LSL_Integer linknumber, LSL_List rules, LSL_Integer expire) + { + m_OSSL_Functions.osLinkParticleSystem(linknumber, rules, expire); + } } }