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!

master
UbitUmarov 2020-01-22 18:23:35 +00:00
parent 8db60ba3aa
commit 7adaede14a
6 changed files with 119 additions and 28 deletions

View File

@ -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 {

View File

@ -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);
}

View File

@ -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;
}
}
}

View File

@ -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
/// </summary>
/// <param name="thing"></param>
/// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
LSL_Integer osIsUUID(string thing);
LSL_Integer osIsUUID(string thing);
/// <summary>
/// Wraps to Math.Min()
@ -424,7 +424,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
LSL_Float osMin(double a, double b);
LSL_Float osMin(double a, double b);
/// <summary>
/// Wraps to Math.max()
@ -432,7 +432,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
LSL_Float osMax(double a, double b);
LSL_Float osMax(double a, double b);
/// <summary>
/// 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();
}
}

View File

@ -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;

View File

@ -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();
}
}
}