From 7adaede14ad9f614e14f179d7c6d90bafbe32b45 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 22 Jan 2020 18:23:35 +0000 Subject: [PATCH] mantis 8634: add osSetSitActiveRange(float range) , osSetStandTarget(vector feetAproxPosition) and respective get functions. range <0 disables sits on the prim, = 0 uses region default,feetAproxPosition is in prim local frame. <0,0,0> disables it. Still no persistance. feedback required! --- .../Framework/Scenes/SceneObjectPart.cs | 3 + .../Region/Framework/Scenes/ScenePresence.cs | 67 +++++++++++++++---- .../Shared/Api/Implementation/OSSL_Api.cs | 23 +++++++ .../Shared/Api/Interface/IOSSL_Api.cs | 31 +++++---- .../Shared/Api/Runtime/LSL_Constants.cs | 2 +- .../Shared/Api/Runtime/OSSL_Stub.cs | 21 ++++++ 6 files changed, 119 insertions(+), 28 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 1942dfe5fc..ce7f8a02aa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1257,6 +1257,9 @@ namespace OpenSim.Region.Framework.Scenes set { m_sitTargetOrientation = value; } } + public float SitActiveRange { get; set;} + public Vector3 StandOffset { get; set;} + public bool Stopped { get { diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index dc6f7fdb0a..2e7fb38049 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3262,21 +3262,52 @@ namespace OpenSim.Region.Framework.Scenes standRotation = standRotation * m_bodyRot; m_bodyRot = standRotation; - Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W); - float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; - if (t > 0) + Quaternion standRotationZ; + Vector3 adjustmentForSitPose = part.StandOffset; + if (adjustmentForSitPose.X == 0 && + adjustmentForSitPose.Y == 0 && + adjustmentForSitPose.Z == 0) { - t = 1.0f / (float)Math.Sqrt(t); - standRotationZ.W *= t; - standRotationZ.Z *= t; + standRotationZ = new Quaternion(0, 0, standRotation.Z, standRotation.W); + float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; + if (t > 0) + { + t = 1.0f / (float)Math.Sqrt(t); + standRotationZ.W *= t; + standRotationZ.Z *= t; + } + else + { + standRotationZ.W = 1.0f; + standRotationZ.Z = 0f; + } + adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ; } else { - standRotationZ.W = 1.0f; - standRotationZ.Z = 0f; - } + sitWorldPosition = part.GetWorldPosition(); - Vector3 adjustmentForSitPose = new Vector3(0.65f, 0, m_sitAvatarHeight * 0.5f + .1f) * standRotationZ; + standRotation = part.GetWorldRotation(); + standRotationZ = new Quaternion(0, 0, standRotation.Z, standRotation.W); + float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; + if (t > 0) + { + t = 1.0f / (float)Math.Sqrt(t); + standRotationZ.W *= t; + standRotationZ.Z *= t; + } + else + { + standRotationZ.W = 1.0f; + standRotationZ.Z = 0f; + } + adjustmentForSitPose *= standRotationZ; + + if (Appearance != null && Appearance.AvatarHeight > 0) + adjustmentForSitPose.Z += 0.5f * Appearance.AvatarHeight + .1f; + else + adjustmentForSitPose.Z += .9f; + } m_pos = sitWorldPosition + adjustmentForSitPose; } @@ -3325,7 +3356,7 @@ namespace OpenSim.Region.Framework.Scenes //look for prims with explicit sit targets that are available foreach (SceneObjectPart part in partArray) { - if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) + if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero && part.SitActiveRange > 0) { //switch the target to this prim return part; @@ -3346,6 +3377,17 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; + float range = part.SitActiveRange; + if (range < 0) + return; + + Vector3 pos = part.AbsolutePosition + offset; + if (range > 1e-5f) + { + if (Vector3.DistanceSquared(AbsolutePosition, pos) > range * range) + return; + } + if (PhysicsActor != null) m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; @@ -3359,9 +3401,6 @@ namespace OpenSim.Region.Framework.Scenes if (PhysicsSit(part,offset)) // physics engine return; - Vector3 pos = part.AbsolutePosition + offset; - if (Vector3.DistanceSquared(AbsolutePosition, pos) > 100) - return; AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index eb7049e4de..ae023b139b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -5674,5 +5674,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return 3; return 0; } + + public void osSetSitActiveRange(LSL_Float v) + { + if (v > 128f) + v = 128f; + m_host.SitActiveRange = (float)v; + } + + public LSL_Float osGetSitActiveRange() + { + return m_host.SitActiveRange; + } + + public void osSetStandTarget(LSL_Vector v) + { + // todo add limits ? + m_host.StandOffset = v; + } + + public LSL_Vector osGetStandTarget() + { + return m_host.StandOffset; + } } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 2bb71e9518..977c51b09c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -380,33 +380,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List osGetRegionStats(); vector osGetRegionSize(); - int osGetSimulatorMemory(); - int osGetSimulatorMemoryKB(); + int osGetSimulatorMemory(); + int osGetSimulatorMemoryKB(); void osKickAvatar(string FirstName, string SurName, string alert); void osKickAvatar(LSL_Key agentId, string alert); void osSetSpeed(string UUID, LSL_Float SpeedModifier); void osSetOwnerSpeed(LSL_Float SpeedModifier); - LSL_Float osGetHealth(key agentId); + LSL_Float osGetHealth(key agentId); void osCauseHealing(key agentId, LSL_Float healing); void osSetHealth(key agentId, LSL_Float health); void osSetHealRate(key agentId, LSL_Float health); - LSL_Float osGetHealRate(key agentId); + LSL_Float osGetHealRate(key agentId); void osCauseDamage(key avatar, LSL_Float damage); void osForceOtherSit(string avatar); void osForceOtherSit(string avatar, string target); - LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules); + LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules); void osSetPrimitiveParams(LSL_Key prim, LSL_List rules); void osSetProjectionParams(LSL_Integer projection, LSL_Key texture, LSL_Float fov, LSL_Float focus, LSL_Float amb); void osSetProjectionParams(LSL_Key prim, LSL_Integer projection, LSL_Key texture, LSL_Float fov, LSL_Float focus, LSL_Float amb); void osSetProjectionParams(LSL_Integer linknumber, LSL_Integer projection, LSL_Key texture, LSL_Float fov, LSL_Float focus, LSL_Float amb); - LSL_List osGetAvatarList(); - LSL_List osGetNPCList(); + LSL_List osGetAvatarList(); + LSL_List osGetNPCList(); - LSL_String osUnixTimeToTimestamp(LSL_Integer time); + LSL_String osUnixTimeToTimestamp(LSL_Integer time); - LSL_Integer osInviteToGroup(LSL_Key agentId); - LSL_Integer osEjectFromGroup(LSL_Key agentId); + LSL_Integer osInviteToGroup(LSL_Key agentId); + LSL_Integer osEjectFromGroup(LSL_Key agentId); void osSetTerrainTexture(int level, LSL_Key texture); void osSetTerrainTextureHeight(int corner, double low, double high); @@ -416,7 +416,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// /// 1 if thing is a valid UUID, 0 otherwise - LSL_Integer osIsUUID(string thing); + LSL_Integer osIsUUID(string thing); /// /// Wraps to Math.Min() @@ -424,7 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// /// - LSL_Float osMin(double a, double b); + LSL_Float osMin(double a, double b); /// /// Wraps to Math.max() @@ -432,7 +432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces /// /// /// - LSL_Float osMax(double a, double b); + LSL_Float osMax(double a, double b); /// /// Get the key of the object that rezzed this object. @@ -559,5 +559,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void osResetAllScripts(LSL_Integer AllLinkset); LSL_Integer osIsNotValidNumber(LSL_Float v); + + void osSetSitActiveRange(LSL_Float v); + LSL_Float osGetSitActiveRange(); + void osSetStandTarget(vector v); + vector osGetStandTarget(); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index da2c560f6f..806449c928 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public partial class ScriptBaseClass { // SCRIPTS CONSTANTS - public static readonly LSLInteger OS_APIVERSION = 10; + public static readonly LSLInteger OS_APIVERSION = 11; public static readonly LSLInteger TRUE = 1; public static readonly LSLInteger FALSE = 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 9745403429..f61f0aa93c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -1421,5 +1421,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osIsNotValidNumber(v); } + + public void osSetSitActiveRange(LSL_Float v) + { + m_OSSL_Functions.osSetSitActiveRange(v); + } + + public LSL_Float osGetSitActiveRange() + { + return m_OSSL_Functions.osGetSitActiveRange(); + } + + public void osSetStandTarget(vector v) + { + m_OSSL_Functions.osSetStandTarget(v); + } + + public vector osGetStandTarget() + + { + return m_OSSL_Functions.osGetStandTarget(); + } } }